Ejemplo n.º 1
0
        /// <summary>
        /// Fetches every CanvasType Declaration in the script assemblies to provide the framework with custom canvas types
        /// </summary>
        public static void FetchCanvasTypes()
        {
            CanvasTypes = new Dictionary <Type, NodeCanvasTypeData>();
            foreach (Type type in ReflectionUtility.getSubTypes(typeof(NodeCanvas), typeof(NodeCanvasTypeAttribute)))
            {
                object[] nodeAttributes      = type.GetCustomAttributes(typeof(NodeCanvasTypeAttribute), false);
                NodeCanvasTypeAttribute attr = nodeAttributes[0] as NodeCanvasTypeAttribute;
                CanvasTypes.Add(type, new NodeCanvasTypeData()
                {
                    CanvasType = type, DisplayString = attr.Name
                });
            }

            //下面是能显示在ToolBar的Create Canvas多选框中的Canvas类型收集
            OnlyInToolBarCanvasTypes = new Dictionary <Type, NodeCanvasTypeData>();
            foreach (var type in ReflectionUtility.getSubTypes(typeof(NodeCanvas), typeof(NodeCanvasTypeAttribute)))
            {
                object[] OnlyInToolBarCanvasTypesAttributes = type.GetCustomAttributes(typeof(CannotShowInToolBarCanvasTypeAttribute), false);
                object[] nodeAttributes = type.GetCustomAttributes(typeof(NodeCanvasTypeAttribute), false);
                if (OnlyInToolBarCanvasTypesAttributes.Length == 0)
                {
                    NodeCanvasTypeAttribute attr = nodeAttributes[0] as NodeCanvasTypeAttribute;
                    OnlyInToolBarCanvasTypes.Add(type, new NodeCanvasTypeData()
                    {
                        CanvasType = type, DisplayString = attr.Name
                    });
                }
            }
        }
Ejemplo n.º 2
0
        public static void GetAllCanvasTypes()
        {
            TypeOfCanvases = new Dictionary <Type, NodeCanvasTypeData>();

            IEnumerable <Assembly> scriptAssemblies =
                AppDomain.CurrentDomain.GetAssemblies()
                .Where((Assembly assembly) => assembly.FullName.Contains("Assembly"));

            foreach (Assembly assembly in scriptAssemblies)
            {
                foreach (
                    Type type in
                    assembly.GetTypes()
                    .Where(
                        T =>
                        T.IsClass && !T.IsAbstract &&
                        T.GetCustomAttributes(typeof(NodeCanvasTypeAttribute), false).Length > 0))
                {
                    object[] nodeAttributes      = type.GetCustomAttributes(typeof(NodeCanvasTypeAttribute), false);
                    NodeCanvasTypeAttribute attr = nodeAttributes[0] as NodeCanvasTypeAttribute;
                    TypeOfCanvases.Add(type, new NodeCanvasTypeData()
                    {
                        CanvasType = type, DisplayString = attr.Name
                    });
                }
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Fetches every CanvasType Declaration in the script assemblies to provide the framework with custom canvas types
 /// </summary>
 public static void FetchCanvasTypes()
 {
     CanvasTypes = new Dictionary <Type, NodeCanvasTypeData>();
     foreach (Type type in ReflectionUtility.getSubTypes(typeof(NodeCanvas), typeof(NodeCanvasTypeAttribute)))
     {
         object[] nodeAttributes      = type.GetCustomAttributes(typeof(NodeCanvasTypeAttribute), false);
         NodeCanvasTypeAttribute attr = nodeAttributes[0] as NodeCanvasTypeAttribute;
         CanvasTypes.Add(type, new NodeCanvasTypeData()
         {
             CanvasType = type, DisplayString = attr.Name
         });
     }
 }
        public static void GetAllCanvasTypes()
        {
            TypeOfCanvases = new Dictionary <Type, NodeCanvasTypeData>();
            IEnumerable <Assembly> enumerable = from assembly in AppDomain.CurrentDomain.GetAssemblies()
                                                where assembly.FullName.Contains("Assembly")
                                                select assembly;

            foreach (Assembly item in enumerable)
            {
                foreach (Type item2 in from T in item.GetTypes()
                         where T.IsClass && !T.IsAbstract && T.GetCustomAttributes(typeof(NodeCanvasTypeAttribute), false).Length > 0
                         select T)
                {
                    object[] customAttributes = item2.GetCustomAttributes(typeof(NodeCanvasTypeAttribute), false);
                    NodeCanvasTypeAttribute nodeCanvasTypeAttribute = customAttributes[0] as NodeCanvasTypeAttribute;
                    TypeOfCanvases.Add(item2, new NodeCanvasTypeData
                    {
                        CanvasType    = item2,
                        DisplayString = nodeCanvasTypeAttribute.Name
                    });
                }
            }
        }