예제 #1
0
 static RadObject()
 {
     RadType = RadObjectType.FromSystemType(typeof(RadObject));
     PropertyChangedEventKey     = new object();
     RadPropertyChangedEventKey  = new object();
     RadPropertyChangingEventKey = new object();
 }
예제 #2
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]));
     }
 }
예제 #3
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;
        }
예제 #4
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;
        }
예제 #5
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);
            }
        }
예제 #6
0
 public RadObject()
 {
     this.propertyValues = new RadPropertyValueCollection(this);
     this.radType        = RadObjectType.FromSystemType(this.GetType());
 }