示例#1
0
        private void LoadApiClientRegistrations(AutofacContainerBuilder builder, List <Assembly> assemblies)
        {
            var registrations = new ApiClientRegistrations();

            foreach (var assembly in assemblies)
            {
                foreach (var type in assembly.GetTypes())
                {
                    var api = (EnableApiAttribute)type.GetCustomAttribute(typeof(EnableApiAttribute));

                    if (api == null)
                    {
                        continue;
                    }
                    registrations.Add(new ApiClientRegistration {
                        Route = api.Route, Type = type
                    });
                }
            }

            builder.RegisterInstance(registrations);
        }