Beispiel #1
0
        public virtual void SetValue(ParameterProperty property, object value)
        {
            if (!property.IsValidValue(value))
            {
                throw new ArgumentException("值类型不匹配");
            }
            Type   type = GetType();
            string key  = property.CreateKey(type);

            m_DicValue[key] = value;
        }
        public static void SetValue(ParameterProperty property, Type ownerType, object value)
        {
            string key = property.CreateKey(ownerType);
            object data;

            if (m_DicDefault.TryGetValue(key, out data))
            {
                m_DicDefault[key] = value;
            }
            else
            {
                throw new Exception("属性没有进行注册");
            }
        }
Beispiel #3
0
        public virtual object GetValue(ParameterProperty property)
        {
            Type   type = GetType();
            string key  = property.CreateKey(type);
            object data;

            if (m_DicValue.TryGetValue(key, out data))
            {
                return(data);
            }
            if (!ParameterProperty.GetValue(property, type, out data))
            {
                //throw new Exception("属性没有进行注册");
            }
            return(data);
        }
 public static bool GetValue(ParameterProperty property, Type ownerType, out object value)
 {
     value = null;
     if (ownerType.FullName == property.OwerType.FullName)
     {
         string key = property.CreateKey(ownerType);
         return(m_DicDefault.TryGetValue(key, out value));
     }
     else
     {
         string key = property.CreateKey(ownerType);
         if (!m_DicDefault.TryGetValue(key, out value))
         {
             key = property.CreateKey();
             return(m_DicDefault.TryGetValue(key, out value));
         }
     }
     return(true);
 }
        public static ParameterProperty Register(Type ownertype, string name, Type valueType, object defaultValue)
        {
            ParameterProperty property = new ParameterProperty();

            property.Name      = name;
            property.OwerType  = ownertype;
            property.ValueType = valueType;
            if (property.CheckedKey())
            {
                throw new ArgumentException("该名称属性已经被注册");
            }
            if (!property.IsValidValue(defaultValue))
            {
                throw new ArgumentException("默认值类型不匹配");
            }
            string key = property.CreateKey(ownertype);

            m_DicDefault[key] = defaultValue;
            return(property);
        }