Пример #1
0
        static ScriptManager()
        {
            var assembly = Assembly.GetExecutingAssembly();

            if (assembly == null)
            {
                return;
            }
            foreach (var type in assembly.GetTypes())
            {
                ScriptAttribute attribute = null;

                foreach (ScriptAttribute attr in type.GetCustomAttributes(typeof(ScriptAttribute), false))
                {
                    attribute = attr;
                    break;
                }

                if (attribute == null)
                {
                    continue;
                }

                scripts.Add(attribute.Name, type);
            }
        }
Пример #2
0
        public static void LoadFromAssembly(Assembly assembly)
        {
            foreach (var type in assembly.GetTypes())
            {
                ScriptAttribute attribute = null;

                foreach (ScriptAttribute attr in type.GetCustomAttributes(typeof(ScriptAttribute), false))
                {
                    attribute = attr;
                    break;
                }

                if (attribute == null)
                {
                    continue;
                }

                Scripts.Add(attribute.Name, type);
            }
        }