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.
상속: NodeMemberInfo
예제 #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);
        }
예제 #2
0
파일: Node.cs 프로젝트: layshua/Alexandria
        /// <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);
        }
예제 #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));
        }
예제 #4
0
파일: Node.cs 프로젝트: layshua/Alexandria
 /// <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;
 }
예제 #5
0
파일: Node.cs 프로젝트: layshua/Alexandria
 /// <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));
 }