Example #1
0
        private static RadProperty RegisterCommon(string name, Type propertyType, Type ownerType, AttachedPropertyUsage usage, RadPropertyMetadata defaultMetadata, ValidateValueCallback validateValueCallback)
        {
            RadProperty.FromNameKey key1 = new RadProperty.FromNameKey(name, ownerType);
            lock (RadProperty.Synchronized)
            {
                if (RadProperty.PropertyFromName.Contains(key1))
                {
                    object[] objArray1 = new object[] { name, ownerType.Name };
                    throw new ArgumentException(string.Format("Property already registered", objArray1));
                }
            }
            if (defaultMetadata == null)
            {
                defaultMetadata = RadProperty.AutoGeneratePropertyMetadata(propertyType, validateValueCallback, name, ownerType);
            }
            else
            {
                if (!defaultMetadata.DefaultValueWasSet())
                {
                    defaultMetadata.DefaultValue = RadProperty.AutoGenerateDefaultValue(propertyType);
                }
                //TODO:
                //RadProperty.ValidateMetadataDefaultValue(defaultMetadata, propertyType, validateValueCallback);
            }
            defaultMetadata.SetAttachedPropertyUsage(usage);
            RadProperty property1 = new RadProperty(name, propertyType, ownerType, defaultMetadata, validateValueCallback);

            defaultMetadata.Seal(property1, null);
            lock (RadProperty.Synchronized)
            {
                RadProperty.PropertyFromName[key1] = property1;
            }

            return(property1);
        }
Example #2
0
        public static RadProperty Register(string name, Type propertyType, Type ownerType, RadPropertyMetadata typeMetadata, ValidateValueCallback validateValueCallback)
        {
            //RadProperty.RegisterParameterValidation(name, propertyType, ownerType);
            RadPropertyMetadata metadata1 = null;

            if ((typeMetadata != null) && typeMetadata.DefaultValueWasSet())
            {
                metadata1 = new RadPropertyMetadata(typeMetadata.DefaultValue);
            }
            RadProperty property1 = RadProperty.RegisterCommon(name, propertyType, ownerType, AttachedPropertyUsage.Self, metadata1, validateValueCallback);

            if (typeMetadata != null)
            {
                property1.OverrideMetadata(ownerType, typeMetadata);
            }
            return(property1);
        }
Example #3
0
        public static RadProperty Register(
            string name,
            Type propertyType,
            Type ownerType,
            RadPropertyMetadata typeMetadata,
            ValidateValueCallback validateValueCallback)
        {
            RadPropertyMetadata defaultMetadata = (RadPropertyMetadata)null;

            if (typeMetadata != null && typeMetadata.DefaultValueWasSet())
            {
                defaultMetadata = new RadPropertyMetadata(typeMetadata.DefaultValue);
            }
            RadProperty radProperty = RadProperty.RegisterCommon(name, propertyType, ownerType, AttachedPropertyUsage.Self, defaultMetadata, validateValueCallback);

            if (typeMetadata != null)
            {
                radProperty.OverrideMetadata(ownerType, typeMetadata);
            }
            return(radProperty);
        }
Example #4
0
        private static RadProperty RegisterCommon(
            string name,
            Type propertyType,
            Type ownerType,
            AttachedPropertyUsage usage,
            RadPropertyMetadata defaultMetadata,
            ValidateValueCallback validateValueCallback)
        {
            RadProperty.FromNameKey fromNameKey = new RadProperty.FromNameKey(name, ownerType);
            lock (RadProperty.Synchronized)
            {
                if (RadProperty.PropertyFromName.Contains((object)fromNameKey))
                {
                    throw new ArgumentException(string.Format("Property already registered", new object[2]
                    {
                        (object)name,
                        (object)ownerType.Name
                    }));
                }
            }
            if (defaultMetadata == null)
            {
                defaultMetadata = RadProperty.AutoGeneratePropertyMetadata(propertyType, validateValueCallback, name, ownerType);
            }
            else if (!defaultMetadata.DefaultValueWasSet())
            {
                defaultMetadata.DefaultValue = RadProperty.AutoGenerateDefaultValue(propertyType);
            }
            defaultMetadata.SetAttachedPropertyUsage(usage);
            RadProperty dp = new RadProperty(name, propertyType, ownerType, defaultMetadata, validateValueCallback);

            defaultMetadata.Seal(dp, (Type)null);
            lock (RadProperty.Synchronized)
                RadProperty.PropertyFromName[(object)fromNameKey] = (object)dp;
            return(dp);
        }