Esempio n. 1
0
        public static ExtendProperty RegisterProperty(string propertyName, Type propertyType, Type ownerType, object defaultValue, MetaData metaData)
        {
            var property = new ExtendProperty(propertyName, propertyType, ownerType);

            property.OverrideDefaultValue(ownerType, defaultValue);
            property.MetaData = metaData;
            ExtendPropertysProvider.Set(property.GetHashCode(), property);

            return(property);
        }
Esempio n. 2
0
        public bool ClearValue(ExtendProperty property)
        {
            bool result       = false;
            int  propertyHash = property.GetHashCode();
            int  key          = this.GetHashCode() ^ propertyHash;

            if (propertyValues.Keys.Any(k => k == key))
            {
                object outObj = null;
                propertyValues.TryRemove(key, out outObj);
                result = true;
            }
            return(result);
        }
Esempio n. 3
0
        public object GetValue(ExtendProperty property)
        {
            int propertyHash = property.GetHashCode();
            int key          = this.GetHashCode() ^ propertyHash;

            object result = null;

            if (!propertyValues.TryGetValue(key, out result))
            {
                result = property.GetDefaultValue(this.OwnerType);
                if (result == null)
                {
                    result = property.DefaultValue;
                }
            }

            return(result);
        }
Esempio n. 4
0
        public virtual void SetValue(ExtendProperty property, object value)
        {
            var changingItemArgs =
                new ExtendPropertyValueChangingArgs()
            {
                Value        = value,
                Item         = GetOwner(),
                PropertyType = property.PropertyType,
                PropertyName = property.PropertyName,
                Cancel       = false
            };

            property.OnValueChanging(changingItemArgs);

            if (!changingItemArgs.Cancel)
            {
                var changedItemArgs = new ExtendPropertyValueChangedArgs();

                int propertyHash = property.GetHashCode();
                int key          = this.GetHashCode() ^ propertyHash;

                if (propertyValues.Keys.Any(k => k == key))
                {
                    changedItemArgs.OldValue = propertyValues[key];
                    propertyValues[key]      = value;
                }
                else
                {
                    changedItemArgs.OldValue = null;
                    propertyValues.TryAdd(key, value);
                }

                changedItemArgs.Item         = GetOwner();
                changedItemArgs.PropertyType = property.PropertyType;
                changedItemArgs.PropertyName = property.PropertyName;
                changedItemArgs.NewValue     = value;
                changedItemArgs.PropertyInfo = property;

                property.OnValueChanged(changedItemArgs);
                OnPropertyChanged(property);
                //OnChildrenPropertyChanged(changedItemArgs);
            }
        }
Esempio n. 5
0
        public static ExtendProperty RegisterProperty(string propertyName, Type propertyType, Type ownerType,object defaultValue,MetaData metaData)
        {
            var property = new ExtendProperty(propertyName, propertyType, ownerType);
            property.OverrideDefaultValue(ownerType, defaultValue);
            property.MetaData = metaData;
            ExtendPropertysProvider.Set(property.GetHashCode(), property);

            return property;
        }