Ejemplo n.º 1
0
 private void LateEnableAContentModules()
 {
     while (startTweaks.Count > 0)
     {
         Type tweak = startTweaks.Dequeue();
         AContentModuleAttribute attribute = (AContentModuleAttribute)tweak.GetCustomAttributes(typeof(AContentModuleAttribute), false).FirstOrDefault();
         EnableAContentModule(tweak, attribute);
     }
 }
Ejemplo n.º 2
0
 private void EnableAContentModule(Type type, AContentModuleAttribute customAttr)
 {
     //constuctorArgumentArray[0] is set in the constructor of this class.
     constuctorArgumentArray[1] = customAttr.Name;
     constuctorArgumentArray[2] = customAttr.DefaultEnabled;
     constuctorArgumentArray[3] = customAttr.Description;
     try
     {
         var            ctor           = type.GetConstructor(constructorParameters);
         AContentModule aContentModule = (AContentModule)ctor.Invoke(constuctorArgumentArray);
         aContentModule.ReloadContent();
     }
     catch
     {
         TweakLogger.Log($"Couldn't load AContentModule: {constuctorArgumentArray[1]}", 0);
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// This is a seperate function to encourage people to not have giant Awake()'s.
        /// </summary>
        private void FindAndEnableAllAContentModules()
        {
            var types = Assembly.GetExecutingAssembly().GetTypes();

            foreach (Type type in types)
            {
                AContentModuleAttribute customAttr = (AContentModuleAttribute)type.GetCustomAttributes(typeof(AContentModuleAttribute), false).FirstOrDefault();
                if (customAttr != null)
                {
                    if (customAttr.target == AContentStartupTarget.Start)
                    {
                        startTweaks.Enqueue(type);
                    }
                    else
                    {
                        EnableAContentModule(type, customAttr);
                    }
                }
            }
        }