/// <summary>Get a property of the type, or throw an exception.</summary> /// <param name="name"></param> /// <returns></returns> /// <exception cref="ArgumentException">This <see cref="NodeType"/> does not have an instance public or private property named <paramref name="name"/>.</exception> public NodeTypeProperty GetProperty(string name) { NodeTypeProperty property; if (propertiesByName.TryGetValue(name, out property)) return property; PropertyInfo info = type.GetProperty(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (info == null) throw new ArgumentException("Type " + Name + " does not have a property named " + name + "."); return propertiesByName[name] = new NodeTypeProperty(this, info); }
/// <summary>Get the value of a property.</summary> /// <param name="property"></param> /// <returns></returns> protected object GetValue(NodeTypeProperty property) { object value; if (assignedProperties.TryGetValue(property, out value)) { return(value); } if (prototype != null) { return(prototype.GetValue(property)); } return(property.DefaultValue); }
/// <summary>Get a property of the type, or throw an exception.</summary> /// <param name="name"></param> /// <returns></returns> /// <exception cref="ArgumentException">This <see cref="NodeType"/> does not have an instance public or private property named <paramref name="name"/>.</exception> public NodeTypeProperty GetProperty(string name) { NodeTypeProperty property; if (propertiesByName.TryGetValue(name, out property)) { return(property); } PropertyInfo info = type.GetProperty(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (info == null) { throw new ArgumentException("Type " + Name + " does not have a property named " + name + "."); } return(propertiesByName[name] = new NodeTypeProperty(this, info)); }
/// <summary>Set the value of a property.</summary> /// <param name="property"></param> /// <param name="value"></param> protected void SetValue(NodeTypeProperty property, object value) { assignedProperties[property] = value; }
/// <summary>Get the value of a property.</summary> /// <typeparam name="T"></typeparam> /// <param name="property"></param> /// <returns></returns> protected T GetValue <T>(NodeTypeProperty property) { return((T)GetValue(property)); }