public static void AddServiceActor(IServiceCollection services, List <Type> actorTypes, params string[] categories)
        {
            actorTypes.ForEach(
                t =>
            {
                if (categories == null || categories.Length == 0)
                {
                    services.AddSingleton(serviceType, t);
                }
                else
                {
                    RpcServiceAttribute attr = null;
                    foreach (var interfaceType in t.GetInterfaces())
                    {
                        attr = interfaceType.GetCustomAttribute <RpcServiceAttribute>();
                        if (attr != null)
                        {
                            break;
                        }
                    }

                    if (attr == null)
                    {
                        return;
                    }

                    if (EnumerableExtensions.IndexOf(categories, attr.GroupName) >= 0)
                    {
                        services.AddSingleton(serviceType, t);
                    }
                }
            });
        }
Exemple #2
0
        public static void AddServiceActor(IServiceCollection services, List <Type> actorTypes, params string[] categories)
        {
            actorTypes.ForEach(
                t =>
            {
                var tAttr = t.GetCustomAttribute(typeof(RpcServiceAttribute), false);
                if (tAttr == null)
                {
                    return;
                }

                var rpcOption = tAttr as RpcServiceAttribute;
                if (categories == null || EnumerableExtensions.IndexOf(categories, rpcOption.GroupName) >= 0)
                {
                    services.AddSingleton(serviceType, t);
                }
            });
        }