Beispiel #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);
        }
Beispiel #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);
 }
Beispiel #3
0
 public bool Equals(RadProperty.FromNameKey key)
 {
     if (this._name.Equals(key._name))
     {
         return((object)this._ownerType == (object)key._ownerType);
     }
     return(false);
 }
Beispiel #4
0
 public static RadProperty FindSafe(Type objectType, string propertyName)
 {
     RadProperty.FromNameKey fromNameKey = new RadProperty.FromNameKey(propertyName, objectType);
     lock (RadProperty.Synchronized)
     {
         if (RadProperty.PropertyFromName.Contains((object)fromNameKey))
         {
             return((RadProperty)RadProperty.PropertyFromName[(object)fromNameKey]);
         }
         return((RadProperty)null);
     }
 }
Beispiel #5
0
 public static RadProperty FindSafe(Type objectType, string propertyName)
 {
     RadProperty.FromNameKey key1 = new RadProperty.FromNameKey(propertyName, objectType);
     lock (RadProperty.Synchronized)
     {
         if (RadProperty.PropertyFromName.Contains(key1))
         {
             return((RadProperty)RadProperty.PropertyFromName[key1]);
         }
         else
         {
             return(null);
         }
     }
 }
Beispiel #6
0
        public static RadProperty FindSafe(string className, string propertyName)
        {
            Type typeByName = RadTypeResolver.Instance.GetTypeByName(className, false);

            if ((object)typeByName == null)
            {
                return((RadProperty)null);
            }
            RadProperty.FromNameKey fromNameKey = new RadProperty.FromNameKey(propertyName, typeByName);
            lock (RadProperty.Synchronized)
            {
                if (RadProperty.PropertyFromName.Contains((object)fromNameKey))
                {
                    return((RadProperty)RadProperty.PropertyFromName[(object)fromNameKey]);
                }
                return((RadProperty)null);
            }
        }
Beispiel #7
0
        public static RadProperty FindSafe(string className, string propertyName)
        {
            Type objectType = RadTypeResolver.Instance.GetTypeByName(className, false);

            if (objectType == null)
            {
                return(null);
            }

            RadProperty.FromNameKey key1 = new RadProperty.FromNameKey(propertyName, objectType);
            lock (RadProperty.Synchronized)
            {
                if (RadProperty.PropertyFromName.Contains(key1))
                {
                    return((RadProperty)RadProperty.PropertyFromName[key1]);
                }
                else
                {
                    return(null);
                }
            }
        }
Beispiel #8
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);
 }
Beispiel #9
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);
        }