Appcelerator.ServiceManager.RegisterServicesFromAssembly C# (CSharp) Method

RegisterServicesFromAssembly() private method

private RegisterServicesFromAssembly ( Assembly assy ) : void
assy System.Reflection.Assembly
return void
        private void RegisterServicesFromAssembly(Assembly assy)
        {
            Type[] types = assy.GetTypes();

            foreach (Type type in types)
            {
                MethodInfo[] methodInfos = type.GetMethods();

                foreach (MethodInfo method in methodInfos)
                {
                    ServiceAttribute attr = (ServiceAttribute)Attribute.GetCustomAttribute(method, typeof(ServiceAttribute));

                    if (attr != null)
                    {
                        Service service = new Service(attr.Request, attr.Response, method);
                        Logger.Instance.Debug("Registering request: " + attr.Request + " to service handler: " + method.Name + " with response: " + attr.Response);
                        try
                        {
                            this.RequestToServiceMap.Add(attr.Request, new List<Service>());
                            this.RequestToServiceMap[attr.Request].Add(service);
                        }
                        catch (ArgumentException)
                        {
                            // There's already another list of handlers for this request, so add the new service to that list
                            this.RequestToServiceMap[attr.Request].Add(service);
                        }
                    }
                }
            }
        }