Exemplo n.º 1
0
        public static RadObjectType FromSystemType(Type systemType)
        {
            RadObjectType type1;

            if (systemType == null)
            {
                throw new ArgumentNullException("systemType");
            }
            if (!typeof(RadObject).IsAssignableFrom(systemType))
            {
                throw new ArgumentException("DTypeNotSupportForSystemType");
            }
            Queue queue1 = null;

            lock (RadObjectType._lock)
            {
                type1 = RadObjectType.FromSystemTypeRecursive(systemType, ref queue1);
                goto Label_0071;
            }
Label_0061:
            RuntimeHelpers.RunClassConstructor((RuntimeTypeHandle)queue1.Dequeue());
Label_0071:
            if ((queue1 == null) || (queue1.Count <= 0))
            {
                return(type1);
            }
            goto Label_0061;
        }
Exemplo n.º 2
0
        internal RadPropertyMetadata GetMetadata(RadObjectType type, out bool found)
        {
            RadPropertyMetadata metadata = this.GetMetadata(type);

            found = metadata != this._defaultMetadata;
            return(metadata);
        }
Exemplo n.º 3
0
 private void SetupOverrideMetadata(Type forType, RadPropertyMetadata typeMetadata, out RadObjectType dType, out RadPropertyMetadata baseMetadata)
 {
     if (forType == null)
     {
         throw new ArgumentNullException("forType");
     }
     if (typeMetadata == null)
     {
         throw new ArgumentNullException("typeMetadata");
     }
     if (typeMetadata.Sealed)
     {
         throw new ArgumentException(string.Format("TypeMetadataAlreadyInUse", new object[0]));
     }
     if (!typeof(RadObject).IsAssignableFrom(forType))
     {
         object[] objArray1 = new object[] { forType.Name };
         throw new ArgumentException(string.Format("TypeMustBeRadObjectDerived {0}", objArray1));
     }
     if (typeMetadata.IsDefaultValueModified)
     {
         RadProperty.ValidateMetadataDefaultValue(typeMetadata, this.PropertyType, this.ValidateValueCallback);
     }
     dType        = RadObjectType.FromSystemType(forType);
     baseMetadata = this.GetMetadata(dType.BaseType);
     if (!baseMetadata.GetType().IsAssignableFrom(typeMetadata.GetType()))
     {
         throw new ArgumentException(string.Format("OverridingMetadataDoesNotMatchBaseMetadataType", new object[0]));
     }
 }
Exemplo n.º 4
0
 static RadObject()
 {
     RadType = RadObjectType.FromSystemType(typeof(RadObject));
     PropertyChangedEventKey     = new object();
     RadPropertyChangedEventKey  = new object();
     RadPropertyChangingEventKey = new object();
 }
Exemplo n.º 5
0
 public bool IsSubclassOf(RadObjectType radObjectType)
 {
     if (radObjectType != null)
     {
         for (RadObjectType baseDtype = this._baseDType; baseDtype != null; baseDtype = baseDtype._baseDType)
         {
             if (baseDtype.Id == radObjectType.Id)
             {
                 return(true);
             }
         }
     }
     return(false);
 }
Exemplo n.º 6
0
        internal RadPropertyValue(RadObject owner, RadProperty property)
        {
            this.owner    = owner;
            this.property = property;
            bool found;

            this.metadata = property.GetMetadata(this.owner.RadObjectType, out found);
            if (!found)
            {
                RadObjectType radObjectType = RadObjectType.FromSystemType(property.OwnerType);
                this.metadata = property.GetMetadata(radObjectType);
            }
            this.valueSource = ValueSource.Unknown;
        }
Exemplo n.º 7
0
 public bool IsSubclassOf(RadObjectType radObjectType)
 {
     if (radObjectType != null)
     {
         for (RadObjectType type1 = this._baseDType; type1 != null; type1 = type1._baseDType)
         {
             if (type1.Id == radObjectType.Id)
             {
                 return(true);
             }
         }
     }
     return(false);
 }
Exemplo n.º 8
0
 public RadPropertyMetadata GetMetadata(RadObjectType radObjectType)
 {
     if (radObjectType != null)
     {
         int    num2;
         object obj1;
         int    num1 = this._metadataMap.Count - 1;
         if (num1 < 0)
         {
             return(this._defaultMetadata);
         }
         if (num1 == 0)
         {
             this._metadataMap.GetKeyValuePair(num1, out num2, out obj1);
             while (radObjectType.Id > num2)
             {
                 radObjectType = radObjectType.BaseType;
             }
             if (num2 == radObjectType.Id)
             {
                 return((RadPropertyMetadata)obj1);
             }
         }
         else
         if (radObjectType.Id != 0)
         {
             do
             {
                 this._metadataMap.GetKeyValuePair(num1, out num2, out obj1);
                 num1--;
                 while ((radObjectType.Id < num2) && (num1 >= 0))
                 {
                     this._metadataMap.GetKeyValuePair(num1, out num2, out obj1);
                     num1--;
                 }
                 while (radObjectType.Id > num2)
                 {
                     radObjectType = radObjectType.BaseType;
                 }
                 if (num2 == radObjectType.Id)
                 {
                     return((RadPropertyMetadata)obj1);
                 }
             }while (num1 >= 0);
         }
     }
     return(this._defaultMetadata);
 }
Exemplo n.º 9
0
 public bool IsInstanceOfType(RadObject radObject)
 {
     if (radObject != null)
     {
         RadObjectType type1 = radObject.RadObjectType;
         do
         {
             if (type1.Id == this.Id)
             {
                 return(true);
             }
             type1 = type1._baseDType;
         }while (type1 != null);
     }
     return(false);
 }
Exemplo n.º 10
0
 public RadPropertyMetadata GetMetadata(RadObjectType radObjectType)
 {
     if (radObjectType != null)
     {
         int index = this._metadataMap.Count - 1;
         if (index < 0)
         {
             return(this._defaultMetadata);
         }
         if (index == 0)
         {
             int    key;
             object obj;
             this._metadataMap.GetKeyValuePair(index, out key, out obj);
             while (radObjectType.Id > key)
             {
                 radObjectType = radObjectType.BaseType;
             }
             if (key == radObjectType.Id)
             {
                 return((RadPropertyMetadata)obj);
             }
         }
         else if (radObjectType.Id != 0)
         {
             do
             {
                 int    key;
                 object obj;
                 this._metadataMap.GetKeyValuePair(index, out key, out obj);
                 for (--index; radObjectType.Id < key && index >= 0; --index)
                 {
                     this._metadataMap.GetKeyValuePair(index, out key, out obj);
                 }
                 while (radObjectType.Id > key)
                 {
                     radObjectType = radObjectType.BaseType;
                 }
                 if (key == radObjectType.Id)
                 {
                     return((RadPropertyMetadata)obj);
                 }
             }while (index >= 0);
         }
     }
     return(this._defaultMetadata);
 }
Exemplo n.º 11
0
        public bool IsInstanceOfType(RadObject radObject)
        {
            if (radObject != null)
            {
                RadObjectType radObjectType = radObject.RadObjectType;
                while (radObjectType.Id != this.Id)
                {
                    radObjectType = radObjectType._baseDType;
                    if (radObjectType == null)
                    {
                        goto label_5;
                    }
                }
                return(true);
            }
label_5:
            return(false);
        }
Exemplo n.º 12
0
        internal RadPropertyValue(RadObject owner, RadProperty property)
        {
            this.owner    = owner;
            this.property = property;
            //check which metadata to cache
            //there are two options:
            //1. Property is declared by owner's class hierarchy.
            //   In this case we retrieve the metadata for the owner itself.
            //2. Property is NOT declared by owner's class hierarchy.
            //   In this case if we request metadata for our owner, we will get the default one,
            //   so we need to reflect this by getting the metadata for the declaring type.
            bool metadataFound;

            this.metadata = property.GetMetadata(this.owner.RadObjectType, out metadataFound);
            if (!metadataFound)
            {
                RadObjectType declaringType = RadObjectType.FromSystemType(property.OwnerType);
                this.metadata = property.GetMetadata(declaringType);
            }
            this.valueSource = ValueSource.Unknown;
        }
Exemplo n.º 13
0
        public static RadObjectType FromSystemType(Type systemType)
        {
            if ((object)systemType == null)
            {
                throw new ArgumentNullException(nameof(systemType));
            }
            if (!typeof(RadObject).IsAssignableFrom(systemType))
            {
                throw new ArgumentException("DTypeNotSupportForSystemType");
            }
            Queue         encounteredTypes = (Queue)null;
            RadObjectType radObjectType;

            lock (RadObjectType._lock)
                radObjectType = RadObjectType.FromSystemTypeRecursive(systemType, ref encounteredTypes);
            while (encounteredTypes != null && encounteredTypes.Count > 0)
            {
                RuntimeHelpers.RunClassConstructor((RuntimeTypeHandle)encounteredTypes.Dequeue());
            }
            return(radObjectType);
        }
Exemplo n.º 14
0
        private static RadObjectType FromSystemTypeRecursive(Type systemType, ref Queue encounteredTypes)
        {
            RadObjectType type1 = (RadObjectType)RadObjectType.DTypeFromCLRType[systemType];

            if (type1 == null)
            {
                if (encounteredTypes == null)
                {
                    encounteredTypes = new Queue(10);
                }
                type1             = new RadObjectType();
                type1._systemType = systemType;
                RadObjectType.DTypeFromCLRType[systemType] = type1;
                if (systemType != typeof(RadObject))
                {
                    type1._baseDType = RadObjectType.FromSystemTypeRecursive(systemType.BaseType, ref encounteredTypes);
                }
                type1._id = RadObjectType.DTypeCount++;
                encounteredTypes.Enqueue(systemType.TypeHandle);
            }
            return(type1);
        }
Exemplo n.º 15
0
 private void ProcessOverrideMetadata(
     Type forType,
     RadPropertyMetadata typeMetadata,
     RadObjectType dType,
     RadPropertyMetadata baseMetadata)
 {
     lock (RadProperty.Synchronized)
     {
         if (RadProperty.UnsetValue == this._metadataMap[dType.Id])
         {
             this._metadataMap[dType.Id] = (object)typeMetadata;
         }
         else
         {
             throw new ArgumentException(string.Format("TypeMetadataAlreadyRegistered {0}", new object[1]
             {
                 (object)forType.Name
             }));
         }
     }
     typeMetadata.InvokeMerge(baseMetadata, this);
     typeMetadata.Seal(this, forType);
 }
Exemplo n.º 16
0
        private static RadObjectType FromSystemTypeRecursive(
            Type systemType,
            ref Queue encounteredTypes)
        {
            RadObjectType radObjectType = (RadObjectType)RadObjectType.DTypeFromCLRType[(object)systemType];

            if (radObjectType == null)
            {
                if (encounteredTypes == null)
                {
                    encounteredTypes = new Queue(10);
                }
                radObjectType             = new RadObjectType();
                radObjectType._systemType = systemType;
                RadObjectType.DTypeFromCLRType[(object)systemType] = (object)radObjectType;
                if ((object)systemType != (object)typeof(RadObject))
                {
                    radObjectType._baseDType = RadObjectType.FromSystemTypeRecursive(systemType.BaseType, ref encounteredTypes);
                }
                radObjectType._id = RadObjectType.DTypeCount++;
                encounteredTypes.Enqueue((object)systemType.TypeHandle);
            }
            return(radObjectType);
        }
Exemplo n.º 17
0
        void FillReflectionTree(Type assignableFrom)
        {
            Assembly[] assemblies    = AppDomain.CurrentDomain.GetAssemblies();
            ArrayList  AssemblyNodes = new ArrayList();

            foreach (Assembly assembly in assemblies)
            {
                SortedList namespaces = new SortedList();
                Type[]     assemblyTypes;
                try
                {
                    assemblyTypes = assembly.GetTypes();
                }
                catch
                {
                    continue;
                }

                foreach (Type type in assemblyTypes)
                {
                    if (type.IsPublic && type.IsClass && assignableFrom.IsAssignableFrom(type))
                    {
                        ArrayList list;// = null;

                        string namespaceName = type.Namespace;
                        if (namespaceName == null)
                        {
                            namespaceName = string.Empty;
                        }

                        if (namespaces.Contains(namespaceName))
                        {
                            list = (ArrayList)namespaces[namespaceName];
                        }
                        else
                        {
                            list = new ArrayList();
                            if (list.Count > 0)
                            {
                            }
                            namespaces.Add(namespaceName, list);
                        }

                        list.Add(type);
                    }
                }

                try
                {
                    if (namespaces.Count > 0)
                    {
                        TreeNode assemblyNode = new TreeNode(assembly.GetName().Name);
                        AssemblyNodes.Add(assemblyNode);

                        foreach (DictionaryEntry de in namespaces)
                        {
                            ArrayList list          = (ArrayList)de.Value;
                            TreeNode  namespaceNode = new TreeNode((string)de.Key);
                            assemblyNode.Nodes.Add(namespaceNode);

                            ArrayList TypeNodes = new ArrayList();

                            foreach (Type type in list)
                            {
                                TreeNode typeNode = new TreeNode(type.Name);
                                typeNode.Tag = type;

                                if (includeProperties)
                                {
                                    ArrayList     PropertyNodes = new ArrayList();
                                    RadObjectType radObjectType = RadObjectType.FromSystemType(type);

                                    foreach (RadProperty property in radObjectType.GetRadProperties())
                                    {
                                        TreeNode node = new TreeNode(property.Name);
                                        node.Tag = property;
                                        PropertyNodes.Add(node);

                                        if (value != null && value.Equals(type.FullName + "." + property.Name))
                                        {
                                            treeView1.SelectedNode = node;
                                            node.EnsureVisible();
                                        }
                                    }

                                    PropertyNodes.Sort(new TreeNodesComparer());
                                    foreach (TreeNode t in PropertyNodes)
                                    {
                                        typeNode.Nodes.Add(t);
                                    }
                                }
                                else if (value != null && value.Equals(type.FullName))
                                {
                                    treeView1.SelectedNode = typeNode;
                                    typeNode.EnsureVisible();
                                }

                                if (!includeProperties || typeNode.Nodes.Count > 0)
                                {
                                    TypeNodes.Add(typeNode);
                                }
                            }

                            TypeNodes.Sort(new TreeNodesComparer());
                            foreach (TreeNode t in TypeNodes)
                            {
                                namespaceNode.Nodes.Add(t);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            }

            AssemblyNodes.Sort(new TreeNodesComparer());
            foreach (TreeNode t in AssemblyNodes)
            {
                treeView1.Nodes.Add(t);
            }
        }
Exemplo n.º 18
0
 public RadObject()
 {
     this.propertyValues = new RadPropertyValueCollection(this);
     this.radType        = RadObjectType.FromSystemType(this.GetType());
 }