コード例 #1
0
        private static IEnumerable <Type> GetDefaultExposedServices(IServiceCollection services, Type type)
        {
            var serviceTypes = new List <Type>();

            serviceTypes.Add(type);

            foreach (var interfaceType in type.GetTypeInfo().GetInterfaces())
            {
                var interfaceName = interfaceType.Name;

                if (interfaceName.StartsWith("I"))
                {
                    interfaceName = interfaceName.Right(interfaceName.Length - 1);
                }

                if (type.Name.EndsWith(interfaceName))
                {
                    serviceTypes.Add(interfaceType);
                }
            }

            var exposeActions = services.GetExposingActionList();

            if (exposeActions.Any())
            {
                var args = new OnServiceExposingContext(type, serviceTypes);
                foreach (var action in services.GetExposingActionList())
                {
                    action(args);
                }
            }

            return(serviceTypes);
        }
コード例 #2
0
        protected virtual void TriggerServiceExposing(IServiceCollection services, Type type, List <Type> serviceTypes)
        {
            var exposeActions = services.GetExposingActionList();

            if (exposeActions.Any())
            {
                var args = new OnServiceExposingContext(type, serviceTypes);
                foreach (var action in exposeActions)
                {
                    action(args);
                }
            }
        }