Exemplo n.º 1
0
 private static void Registers()
 {
     if (!msInitialized)
     {
         msInitialized = true;
         GlobalReflectionCache.LoadAssemblies();
         NameToTypeUtility.Initialize();
         var allModules = GlobalReflectionCache.FindTypes <ModuleAttribute>(false);
         if (allModules != null)
         {
             allModules.Sort(EngineComparers.defaultModuleAttributeComparer);
             foreach (var m in allModules)
             {
                 //DebugUtility.Log(LoggerTags.Engine, "Module {0} Loaded.", m);
                 ModuleAttribute attr = m.GetCustomAttribute <ModuleAttribute>(true);
                 if (!string.IsNullOrEmpty(attr.entryPoint))
                 {
                     var entry = m.GetMethod(attr.entryPoint, System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic);
                     if (entry != null)
                     {
                         //DebugUtility.Log(LoggerTags.Engine, "Module {0} Entry.", m);
                         entry.Invoke(null, null);
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 2
0
        public int Compare(Type x, Type y)
        {
            ModuleAttribute xAttr = x.GetCustomAttribute <ModuleAttribute>(true);
            ModuleAttribute yAttr = y.GetCustomAttribute <ModuleAttribute>(true);

            if (xAttr == null)
            {
                return(-1);
            }

            if (yAttr == null)
            {
                return(1);
            }

            if (xAttr.engine && !yAttr.engine)
            {
                return(-1);
            }

            if (!xAttr.engine && yAttr.engine)
            {
                return(1);
            }

            return(xAttr.order.CompareTo(yAttr.order));
        }