请教,怎么将这段C#代码转换为C++实现
请问,如何将这段C#代码转换为C++实现?
//-- DependencyProperty --//
public class DependencyProperty
{
internal static Dictionary<object, DependencyProperty> RegisteredDps = new Dictionary<object, DependencyProperty>();
internal string Name;
internal object Value;
internal object HashCode;
private DependencyProperty(string name, Type propertyName, Type ownerType, object defaultValue)
{
this.Name = name;
this.Value = defaultValue;
this.HashCode = name.GetHashCode() ^ ownerType.GetHashCode();
}
public static DependencyProperty Register(string name, Type propertyType, Type ownerType, object defaultValue)
{
DependencyProperty dp = new DependencyProperty(name, propertyType, ownerType, defaultValue);
RegisteredDps.Add(dp.HashCode, dp);
return dp;
}
}
//-- DependencyObject --//
public class DependencyObject
{
private string _unUsedField;
public static readonly DependencyProperty NameProperty = DependencyProperty.Register("Name", typeof(string), typeof(DependencyObject), string.Empty);
public object GetValue(DependencyProperty dp)
{
return DependencyProperty.RegisteredDps[dp.HashCode].Value;
}
public void SetValue(DependencyProperty dp, object value)
{
DependencyProperty.RegisteredDps[dp.HashCode].Value = value;
}
public string Name
{
get
{
return (string)GetValue(NameProperty);
}