コード例 #1
0
ファイル: Tweak.cs プロジェクト: AwokeinanEnigma/CloudFrame
 /// <summary>Use Reflection to set the name from the HarbTweak attribute to prevent having to declare it twice</summary>
 /// <param name="config">A reference to the Config of the calling plugin</param>
 /// <param name="name">The name of this tweak, should be identical to the HarbTweak attribute name.</param>
 /// <param name="defaultEnabled">If this tweak is enabled by default.</param>
 /// <param name="description">If this tweak is enabled by default.</param>
 public AContentModule(ConfigFile config, string name, bool defaultEnabled, string description)
 {
     Config  = config;
     Name    = name;
     Enabled = AddConfig("Enabled", defaultEnabled, description);
     Enabled.SettingChanged += Enabled_SettingChanged;
     MakeConfig();
     if (Enabled.Value)
     {
         TweakLogger.Log($"Loaded AContentModule: {Name}.");
     }
     else
     {
         TweakLogger.Log($"Prepared AContentModule: {Name}.");
     }
 }
コード例 #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);
     }
 }