Esempio n. 1
0
        public List <ServiceRegistryContainerRegistrationResult> RegisterServiceRegistryContainer(Type type)
        {
            List <ServiceRegistryContainerRegistrationResult> results = new List <ServiceRegistryContainerRegistrationResult>();

            foreach (MethodInfo method in type.GetMethods().Where(m => m.HasCustomAttributeOfType <ServiceRegistryLoaderAttribute>()))
            {
                try
                {
                    ServiceRegistryLoaderAttribute loaderAttr = method.GetCustomAttributeOfType <ServiceRegistryLoaderAttribute>();
                    if (loaderAttr.ProcessModes.Contains(Net.ProcessMode.Current.Mode))
                    {
                        string          registryName = loaderAttr.RegistryName ?? $"{type.Namespace}.{type.Name}.{method.Name}";
                        string          description  = loaderAttr.Description ?? registryName;
                        ServiceRegistry registry     = RegisterServiceRegistryLoader(registryName, method, true, description);
                        results.Add(new ServiceRegistryContainerRegistrationResult(registryName, registry, type, method, loaderAttr));
                    }
                }
                catch (Exception ex)
                {
                    results.Add(new ServiceRegistryContainerRegistrationResult(ex)
                    {
                        MethodInfo = method
                    });
                }
            }
            return(results);
        }
 public RegisterServiceRegistryContainerResult(string name, CoreServices.ServiceRegistry registry, Type type, MethodInfo method, ServiceRegistryLoaderAttribute attr)
 {
     Success         = true;
     Type            = type;
     MethodInfo      = method;
     Attribute       = attr;
     ServiceRegistry = registry;
     Name            = name;
 }