public ServerHandler(string url, string SessionID, IRegistryCore registry) :
            base("POST", url)
        {
            m_SessionID   = SessionID;
            m_registry    = registry;
            m_capsService = m_registry.RequestModuleInterface <ICapsService>();
            m_urlModule   = m_registry.RequestModuleInterface <IGridRegistrationService>();
            if (m_methods == null)
            {
                m_methods = new Dictionary <string, List <MethodImplementation> >();
                List <string> alreadyRunPlugins = new List <string>();
                foreach (ConnectorBase plugin in ConnectorRegistry.Connectors)
                {
                    if (alreadyRunPlugins.Contains(plugin.PluginName))
                    {
                        continue;
                    }
                    alreadyRunPlugins.Add(plugin.PluginName);
                    foreach (MethodInfo method in plugin.GetType().GetMethods())
                    {
                        CanBeReflected reflection = (CanBeReflected)Attribute.GetCustomAttribute(method, typeof(CanBeReflected));
                        if (reflection != null)
                        {
                            string methodName = reflection.RenamedMethod == "" ? method.Name : reflection.RenamedMethod;
                            List <MethodImplementation> methods = new List <MethodImplementation>();
                            MethodImplementation        imp     = new MethodImplementation()
                            {
                                Method = method, Reference = plugin, Attribute = reflection
                            };
                            if (!m_methods.TryGetValue(methodName, out methods))
                            {
                                m_methods.Add(methodName, (methods = new List <MethodImplementation>()));
                            }

                            methods.Add(imp);
                        }
                    }
                }
            }
        }
        private bool GetMethodInfo(string method, int parameters, out MethodImplementation methodInfo)
        {
            List <MethodImplementation> methods = new List <MethodImplementation>();

            if (m_methods.TryGetValue(method, out methods))
            {
                if (methods.Count == 1)
                {
                    methodInfo = methods[0];
                    return(true);
                }
                foreach (MethodImplementation m in methods)
                {
                    if (m.Method.GetParameters().Length == parameters)
                    {
                        methodInfo = m;
                        return(true);
                    }
                }
            }
            MainConsole.Instance.Warn("COULD NOT FIND METHOD: " + method);
            methodInfo = null;
            return(false);
        }
Ejemplo n.º 3
0
        public ServerHandler(string url, string SessionID, IRegistryCore registry) :
            base("POST", url)
        {
            m_SessionID = SessionID;
            m_registry = registry;
            m_capsService = m_registry.RequestModuleInterface<ICapsService>();
            m_urlModule = m_registry.RequestModuleInterface<IGridRegistrationService>();
            if (m_methods == null)
            {
                m_methods = new Dictionary<string, List<MethodImplementation>>();
                List<string> alreadyRunPlugins = new List<string>();
                foreach (ConnectorBase plugin in ConnectorRegistry.Connectors)
                {
                    if (alreadyRunPlugins.Contains(plugin.PluginName))
                        continue;
                    alreadyRunPlugins.Add(plugin.PluginName);
                    foreach (MethodInfo method in plugin.GetType().GetMethods())
                    {
                        CanBeReflected reflection = (CanBeReflected)Attribute.GetCustomAttribute(method, typeof(CanBeReflected));
                        if (reflection != null)
                        {
                            string methodName = reflection.RenamedMethod == "" ? method.Name : reflection.RenamedMethod;
                            List<MethodImplementation> methods = new List<MethodImplementation>();
                            MethodImplementation imp = new MethodImplementation() { Method = method, Reference = plugin, Attribute = reflection };
                            if (!m_methods.TryGetValue(methodName, out methods))
                                m_methods.Add(methodName, (methods = new List<MethodImplementation>()));

                            methods.Add(imp);
                        }
                    }
                }
            }
        }
Ejemplo n.º 4
0
 private bool GetMethodInfo(string method, int parameters, out MethodImplementation methodInfo)
 {
     List<MethodImplementation> methods = new List<MethodImplementation>();
     if (m_methods.TryGetValue(method, out methods))
     {
         if (methods.Count == 1)
         {
             methodInfo = methods[0];
             return true;
         }
         foreach (MethodImplementation m in methods)
         {
             if (m.Method.GetParameters().Length == parameters)
             {
                 methodInfo = m;
                 return true;
             }
         }
     }
     MainConsole.Instance.Warn("COULD NOT FIND METHOD: " + method);
     methodInfo = null;
     return false;
 }
Ejemplo n.º 5
0
        public NewServerHandler(string url, IRegistryCore registry, ConnectorBase conn) :
            base("POST", url)
        {
            m_registry = registry;
            if (m_methods == null)
            {
                m_methods = new Dictionary<string, List<MethodImplementation>>();
                List<string> alreadyRunPlugins = new List<string>();
                List<ConnectorBase> connectors = conn == null ? ConnectorRegistry.Connectors : new List<ConnectorBase>() { conn };
                foreach (ConnectorBase plugin in connectors)
                {
                    if (alreadyRunPlugins.Contains(plugin.PluginName))
                        continue;
                    alreadyRunPlugins.Add(plugin.PluginName);
                    foreach (MethodInfo method in plugin.GetType().GetMethods())
                    {
                        CanBeReflected reflection = (CanBeReflected)Attribute.GetCustomAttribute(method, typeof(CanBeReflected));
                        if (reflection != null)
                        {
                            string methodName = reflection.RenamedMethod == "" ? method.Name : reflection.RenamedMethod;
                            List<MethodImplementation> methods = new List<MethodImplementation>();
                            MethodImplementation imp = new MethodImplementation() { Method = method, Reference = plugin, Attribute = reflection };
                            if (!m_methods.TryGetValue(methodName, out methods))
                                m_methods.Add(methodName, (methods = new List<MethodImplementation>()));

                            methods.Add(imp);
                        }
                    }
                }
            }
        }