Properties can use the DisplayNameAttribute to define Properties can use the DefaultValueAttribute to define the initial value for a property if none has been assigned, as well as to determine whether the property value has truly been changed for presentation purposes.
Inheritance: NodeMemberInfo
Esempio n. 1
0
        /// <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);
        }
Esempio n. 2
0
        /// <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);
        }
Esempio n. 3
0
        /// <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));
        }
Esempio n. 4
0
 /// <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;
 }
Esempio n. 5
0
 /// <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));
 }