public static IEnumerable <string> GetDataContractName(this IServiceBuilder builder)
        {
            var namespaces = new List <string>();
            var assemblies = builder.GetInterfaceService()
                             .Select(p => p.Assembly)
                             .Union(GetSystemModules())
                             .Distinct()
                             .ToList();

            var referenceAssemblies = builder.GetInterfaceService();

            referenceAssemblies.ForEach(p =>
            {
                namespaces.AddRange(p.Assembly.GetTypes().Where(t => t.GetCustomAttribute <DataContractAttribute>() != null).Select(n => n.Namespace));
            });
            return(namespaces.Distinct());
        }
Esempio n. 2
0
        public static IServiceBuilder AddClientProxy(this IServiceBuilder builder)
        {
            var services = builder.Services;

            services.RegisterType <ServiceProxyGenerater>().As <IServiceProxyGenerater>().SingleInstance();
            services.RegisterType <ServiceProxyProvider>().As <IServiceProxyProvider>().SingleInstance();
            builder.Services.Register(provider => new ServiceProxyFactory(
                                          provider.Resolve <IRemoteInvokeService>(),
                                          provider.Resolve <ITypeConvertibleService>(),
                                          provider.Resolve <IServiceProvider>(),
                                          builder.GetInterfaceService()
                                          )).As <IServiceProxyFactory>().SingleInstance();
            return(builder);
        }
Esempio n. 3
0
        /// <summary>
        /// 添加客户端代理
        /// </summary>
        /// <param name="builder">服务构建者</param>
        /// <returns>服务构建者。</returns>
        public static IServiceBuilder AddClientProxy(this IServiceBuilder builder)
        {
            var containerBuilder = builder.ContainerBuilder;

            containerBuilder.RegisterType <ServiceProxyGenerater>().As <IServiceProxyGenerater>().SingleInstance();
            containerBuilder.RegisterType <ServiceProxyProvider>().As <IServiceProxyProvider>().SingleInstance();
            builder.ContainerBuilder.Register(provider => new ServiceProxyFactory(
                                                  provider.Resolve <IRemoteInvokeService>(),
                                                  provider.Resolve <ITypeConvertibleService>(),
                                                  provider.Resolve <IServiceProvider>(),
                                                  provider.Resolve <IServiceRouteProvider>(),
                                                  builder.GetInterfaceService(),
                                                  builder.GetDataContractName()
                                                  )).As <IServiceProxyFactory>().SingleInstance();
            return(builder);
        }