Exemple #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);
        }
Exemple #2
0
 public RadProperty AddOwner(Type ownerType, RadPropertyMetadata typeMetadata)
 {
     if (ownerType == null)
     {
         throw new ArgumentNullException("ownerType");
     }
     if (this._defaultMetadata.ReadOnly && (this._defaultMetadata.AttachedPropertyUsage != AttachedPropertyUsage.Self))
     {
         object[] objArray1 = new object[] { this.Name };
         throw new InvalidOperationException(string.Format("Cannot Add Owner For Attached ReadOnly Property: {0}", objArray1));
     }
     RadProperty.FromNameKey key1 = new RadProperty.FromNameKey(this.Name, ownerType);
     lock (RadProperty.Synchronized)
     {
         if (RadProperty.PropertyFromName.Contains(key1))
         {
             object[] objArray2 = new object[] { this.Name, ownerType.Name };
             throw new ArgumentException(string.Format("Property Already Registered {0}, {1}", objArray2));
         }
     }
     if ((typeMetadata == null) && (this._defaultMetadata.AttachedPropertyUsage != AttachedPropertyUsage.Self))
     {
         typeMetadata = this._defaultMetadata.Copy(this);
     }
     if (typeMetadata != null)
     {
         typeMetadata.SetAttachedPropertyUsage(AttachedPropertyUsage.Self);
         this.OverrideMetadata(ownerType, typeMetadata);
     }
     lock (RadProperty.Synchronized)
     {
         RadProperty.PropertyFromName[key1] = this;
     }
     return(this);
 }
Exemple #3
0
 public RadProperty AddOwner(Type ownerType, RadPropertyMetadata typeMetadata)
 {
     if ((object)ownerType == null)
     {
         throw new ArgumentNullException(nameof(ownerType));
     }
     if (this._defaultMetadata.ReadOnly && this._defaultMetadata.AttachedPropertyUsage != AttachedPropertyUsage.Self)
     {
         throw new InvalidOperationException(string.Format("Cannot Add Owner For Attached ReadOnly Property: {0}", new object[1]
         {
             (object)this.Name
         }));
     }
     RadProperty.FromNameKey fromNameKey = new RadProperty.FromNameKey(this.Name, ownerType);
     lock (RadProperty.Synchronized)
     {
         if (RadProperty.PropertyFromName.Contains((object)fromNameKey))
         {
             throw new ArgumentException(string.Format("Property Already Registered {0}, {1}", new object[2]
             {
                 (object)this.Name,
                 (object)ownerType.Name
             }));
         }
     }
     if (typeMetadata == null && this._defaultMetadata.AttachedPropertyUsage != AttachedPropertyUsage.Self)
     {
         typeMetadata = this._defaultMetadata.Copy(this);
     }
     if (typeMetadata != null)
     {
         typeMetadata.SetAttachedPropertyUsage(AttachedPropertyUsage.Self);
         this.OverrideMetadata(ownerType, typeMetadata);
     }
     lock (RadProperty.Synchronized)
         RadProperty.PropertyFromName[(object)fromNameKey] = (object)this;
     return(this);
 }
Exemple #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);
        }