Exemplo n.º 1
0
        public static Dictionary <string, Tuple <Type, object> >[] GetSchema(IRequestifyPlugin plugin)
        {
            /*
             * Array schema
             * [0] = Config
             * [1] = Commands
             */
            Dictionary <string, Tuple <Type, object> >[] rett = new Dictionary <string, Tuple <Type, object> > [2];
            var assembly = Instance.Plugins.GetAssembly(plugin);
            Dictionary <string, Tuple <Type, object> > ret = new Dictionary <string, Tuple <Type, object> >();
            var assamblies     = RequestifyTF2.Managers.PluginManager.GetTypesFromInterface(assembly, "IRequestifyConfiguration");
            var asssFieldInfos = assamblies[0].GetFields()
                                 .ToList();

            foreach (var v in asssFieldInfos)
            {
                object val = null;
                if (v.CustomAttributes.Any())
                {
                    foreach (var s in v.CustomAttributes)
                    {
                        if (s.AttributeType == typeof(DefaultValueAttribute))
                        {
                            if (s.ConstructorArguments[0].ArgumentType == v.FieldType)
                            {
                                val = s.ConstructorArguments[0].Value;
                            }
                        }
                    }
                }
                ret.Add(v.Name, new Tuple <Type, object>(v.FieldType, val));
            }

            rett[0] = ret;
            var cmnds = Instance.Commands.RegisteredCommand.Where(n => n.Father == assembly);
            var ret2  = new Dictionary <string, Tuple <Type, object> >();

            foreach (var command in cmnds)
            {
                ret2.Add(command.Name, new Tuple <Type, object>(typeof(bool), true));
            }

            rett[1] = ret2;
            return(rett);
        }
Exemplo n.º 2
0
 public Plugin(IRequestifyPlugin Plugin, Status status)
 {
     plugin = Plugin;
     Status = status;
 }
Exemplo n.º 3
0
 public Assembly GetAssembly(IRequestifyPlugin plugin)
 {
     return(plugin.GetType().Assembly);
 }
Exemplo n.º 4
0
 // Constructor.
 public PluginLoadedArgs(IRequestifyPlugin plugin)
 {
     Plugin = plugin;
 }
Exemplo n.º 5
0
            internal static void Invoke(IRequestifyPlugin Plugin)
            {
                var e = new PluginLoadedArgs(Plugin);

                OnPluginLoad(e);
            }
Exemplo n.º 6
0
 public static void LogError(IRequestifyPlugin plugin, string message)
 {
     Write(Status.Error, $"{plugin.Name} => {message}");
 }