示例#1
0
 public CollectionCodec(Type type, Type elementType, ICodecContainer codecContainer)
     : base(type, elementType, codecContainer)
 {
     collectionConstructor = type.GetConstructor(Type.EmptyTypes);
     getCountMethod = typeof(ICollection<>).MakeGenericType(elementType).GetMethod("get_Count");
     addMethod = typeof(ICollection<>).MakeGenericType(elementType).GetMethod("Add");
 }
示例#2
0
 public GenericHandler(ICodecContainer codecContainer, IRawHandlerFactory delegateFactory, IReadOnlyList<ServiceDescription> serviceDescriptionChain, MethodDescription methodDescription, ServicePath servicePath)
 {
     rawHandlers = new ConcurrentDictionary<TypesKey, IHandler>();
     createRawHandler = delegateFactory.CreateGenericClass(serviceDescriptionChain, methodDescription, servicePath);
     genericParameterCount = methodDescription.GenericParameters.Count;
     typeCodec = codecContainer.GetManualCodecFor<Type>();
 }
 public ICodecContainer GetCodecContainer()
 {
     return codecContainer ?? (codecContainer =
                               overrides.CodecContainer != null
                                   ? overrides.CodecContainer(this)
                                   : new CodecContainer());
 }
 public void Setup()
 {
     serviceDescriptionBuilder = new ServiceDescriptionBuilder(new MethodDescriptionBuilder());
     codecContainer            = new CodecContainer();
     methodCallProcessor       = Substitute.For <IOutgoingMethodCallProcessor>();
     factory = new ServiceProxyClassFactory(serviceDescriptionBuilder, codecContainer);
 }
示例#5
0
 public CollectionCodec(Type type, Type elementType, ICodecContainer codecContainer)
     : base(type, elementType, codecContainer)
 {
     collectionConstructor = type.GetConstructor(Type.EmptyTypes);
     getCountMethod        = typeof(ICollection <>).MakeGenericType(elementType).GetMethod("get_Count");
     addMethod             = typeof(ICollection <>).MakeGenericType(elementType).GetMethod("Add");
 }
示例#6
0
 public RawHandlerFactory(ICodecContainer codecContainer)
 {
     this.codecContainer = codecContainer;
     var appDomain = AppDomain.CurrentDomain;
     var assemblyBuilder = appDomain.DefineDynamicAssembly(new AssemblyName("SharpRpcHandlers"), AssemblyBuilderAccess.Run);
     moduleBuilder = assemblyBuilder.DefineDynamicModule("SharpRpcHandlerModule");
 }
示例#7
0
 public ICodecContainer GetCodecContainer()
 {
     return(codecContainer ?? (codecContainer =
                                   overrides.CodecContainer != null
                                   ? overrides.CodecContainer(this)
                                   : new CodecContainer()));
 }
示例#8
0
 public GenericHandler(ICodecContainer codecContainer, IRawHandlerFactory delegateFactory, IReadOnlyList <ServiceDescription> serviceDescriptionChain, MethodDescription methodDescription, ServicePath servicePath)
 {
     rawHandlers           = new ConcurrentDictionary <TypesKey, IHandler>();
     createRawHandler      = delegateFactory.CreateGenericClass(serviceDescriptionChain, methodDescription, servicePath);
     genericParameterCount = methodDescription.GenericParameters.Count;
     typeCodec             = codecContainer.GetManualCodecFor <Type>();
 }
 public void Setup()
 {
     serviceDescriptionBuilder = new ServiceDescriptionBuilder(new MethodDescriptionBuilder());
     codecContainer            = new CodecContainer();
     requestProcessor          = Substitute.For <IOutgoingRequestProcessor>();
     factory = new ProxyFactory(serviceDescriptionBuilder, codecContainer);
 }
示例#10
0
 public NewExpressionSubcodec(ExpressionCodec commonCodec, ICodecContainer codecContainer)
     : base(commonCodec, codecContainer)
 {
     constructorInfoCodec = codecContainer.GetManualCodecFor <ConstructorInfo>();
     expressionArrayCodec = codecContainer.GetManualCodecFor <Expression[]>();
     memberInfoArrayCodec = codecContainer.GetManualCodecFor <MemberInfo[]>();
 }
 public IncomingRequestProcessor(ILogger logger, IServiceImplementationContainer serviceImplementationContainer,
                                 IHandlerContainer handlerContainer, ICodecContainer codecContainer)
 {
     this.logger = logger;
     this.serviceImplementationContainer = serviceImplementationContainer;
     this.handlerContainer = handlerContainer;
     exceptionCodec        = codecContainer.GetManualCodecFor <Exception>();
 }
示例#12
0
 public ManualCodec(ICodecContainer codecContainer, IEmittingCodec emittingCodec) : base(typeof(T), emittingCodec)
 {
     this.codecContainer   = codecContainer;
     calculateSizeDelegate = (CalculateSizeDelegate)CalculateSizeMethod.CreateDelegate(typeof(CalculateSizeDelegate));
     encodeDelegate        = (EncodeDelegate)EncodeMethod.CreateDelegate(typeof(EncodeDelegate));
     decodeDelegate        = (DecodeDelegate)DecodeMethod.CreateDelegate(typeof(DecodeDelegate));
     decodeFastDelegate    = (DecodeDelegate)DecodeFastMethod.CreateDelegate(typeof(DecodeDelegate));
 }
示例#13
0
        public RawHandlerFactory(ICodecContainer codecContainer)
        {
            this.codecContainer = codecContainer;
            var appDomain       = AppDomain.CurrentDomain;
            var assemblyBuilder = appDomain.DefineDynamicAssembly(new AssemblyName("SharpRpcHandlers"), AssemblyBuilderAccess.Run);

            moduleBuilder = assemblyBuilder.DefineDynamicModule("SharpRpcHandlerModule");
        }
 public IncomingRequestProcessor(ILogger logger, IServiceImplementationContainer serviceImplementationContainer, 
     IHandlerContainer handlerContainer, ICodecContainer codecContainer)
 {
     this.logger = logger;
     this.serviceImplementationContainer = serviceImplementationContainer;
     this.handlerContainer = handlerContainer;
     exceptionCodec = codecContainer.GetManualCodecFor<Exception>();
 }
示例#15
0
 public MemberInfoCodec(ICodecContainer codecContainer)
 {
     memberTypesCodec     = codecContainer.GetManualCodecFor <MemberTypes>();
     constructorInfoCodec = codecContainer.GetManualCodecFor <ConstructorInfo>();
     eventInfoCodec       = codecContainer.GetManualCodecFor <EventInfo>();
     fieldInfoCodec       = codecContainer.GetManualCodecFor <FieldInfo>();
     methodInfoCodec      = codecContainer.GetManualCodecFor <MethodInfo>();
     propertyInfoCodec    = codecContainer.GetManualCodecFor <PropertyInfo>();
 }
示例#16
0
        public ProxyFactory(IServiceDescriptionBuilder serviceDescriptionBuilder, ICodecContainer codecContainer)
        {
            this.serviceDescriptionBuilder = serviceDescriptionBuilder;
            this.codecContainer            = codecContainer;
            var appDomain       = AppDomain.CurrentDomain;
            var assemblyBuilder = appDomain.DefineDynamicAssembly(new AssemblyName("SharpRpcServiceProxies"), AssemblyBuilderAccess.Run);

            moduleBuilder = assemblyBuilder.DefineDynamicModule("SharpRpcServiceProxyModule");
        }
 public IncomingRequestProcessor(IRpcClientServer clientServer, IServiceImplementationContainer serviceImplementationContainer, 
     IServiceMethodHandlerContainer serviceMethodHandlerContainer, ICodecContainer codecContainer)
 {
     this.clientServer = clientServer;
     this.logger = clientServer.Logger;
     this.serviceImplementationContainer = serviceImplementationContainer;
     this.serviceMethodHandlerContainer = serviceMethodHandlerContainer;
     exceptionCodec = codecContainer.GetManualCodecFor<Exception>();
 }
        public void Setup()
        {
            var serviceDescriptionBuilder = new ServiceDescriptionBuilder(new MethodDescriptionBuilder());

            codecContainer           = new CodecContainer();
            factory                  = new RawHandlerFactory(codecContainer);
            service                  = Substitute.For <IGlobalService>();
            globalServiceDescription = serviceDescriptionBuilder.Build(typeof(IGlobalService));
        }
示例#19
0
 public CollectionCodec(Type type, Type elementType, ICodecContainer codecContainer)
     : base(type, elementType, codecContainer)
 {
     collectionConstructor = type.GetConstructor(Type.EmptyTypes);
     getCountMethod        = typeof(ICollection <>).MakeGenericType(elementType).GetMethod("get_Count");
     addMethod             = typeof(ICollection <>).MakeGenericType(elementType).GetMethod("Add");
     getEnumeratorMethod   = typeof(IEnumerable <>).MakeGenericType(elementType).GetMethod("GetEnumerator");
     moveNextMethod        = typeof(IEnumerator).GetMethod("MoveNext");
     getCurrentMethod      = typeof(IEnumerator <>).MakeGenericType(elementType).GetMethod("get_Current");
 }
示例#20
0
        public void Setup()
        {
            codecContainer = new CodecContainer();
            factory        = new ServiceMethodHandlerFactory(codecContainer);
            service        = Substitute.For <IGlobalService>();
            var serviceDescriptionBuilder = new ServiceDescriptionBuilder(new MethodDescriptionBuilder());
            var globalServiceDescription  = serviceDescriptionBuilder.Build(typeof(IGlobalService));

            globalServiceImplementationInfo =
                new ServiceImplementationInfo(globalServiceDescription, service);
        }
 public DirectDataContractCodec(Type type, ICodecContainer codecContainer, bool doNotCalculateMaxSize = false)
 {
     this.type = type;
     memberInfos = type.EnumerateDataMembers()
         .Select(x => new DataMemberInfo
             {
                 Codec = codecContainer.GetEmittingCodecFor(x.PropertyType),
                 Property = x
             })
         .OrderBy(x => x.Codec.FixedSize.HasValue ? 0 : x.Codec.MaxSize.HasValue ? 1 : 2)
         .ThenBy(x => x.Property.Name)
         .ToArray();
     numFixedProperties = memberInfos.IndexOfFirst(x => !x.Codec.FixedSize.HasValue, memberInfos.Length);
     fixedPartOfSize = sizeof(int) + memberInfos.Take(numFixedProperties).Sum(x => x.Codec.FixedSize.Value);
     maxSize = doNotCalculateMaxSize
         ? null
         : memberInfos.All(x => x.Codec.MaxSize.HasValue) ? memberInfos.Sum(x => x.Codec.MaxSize) : null;
 }
示例#22
0
 public StructuralCodecBase(Type type, ICodecContainer codecContainer, bool doNotCalculateMaxSize = false)
 {
     this.type   = type;
     memberInfos = EnumerateMembers(type)
                   .Select(x => new DataMemberInfo
     {
         Codec  = codecContainer.GetEmittingCodecFor(GetMemberType(x)),
         Member = x
     })
                   .OrderBy(x => x.Codec.FixedSize.HasValue ? 0 : x.Codec.MaxSize.HasValue ? 1 : 2)
                   .ThenBy(x => x.Member.Name)
                   .ToArray();
     numFixedProperties = memberInfos.IndexOfFirst(x => !x.Codec.FixedSize.HasValue, memberInfos.Length);
     fixedPartOfSize    = memberInfos.Take(numFixedProperties).Sum(x => x.Codec.FixedSize.Value);
     if (CanBeNull)
     {
         fixedPartOfSize += sizeof(int);
     }
     maxSize = doNotCalculateMaxSize
         ? null
         : memberInfos.All(x => x.Codec.MaxSize.HasValue) ? memberInfos.Sum(x => x.Codec.MaxSize) : null;
 }
示例#23
0
        public ExpressionCodec(ICodecContainer codecContainer)
        {
            expressionTypeCodec = codecContainer.GetManualCodecFor <ExpressionType>();

            binarySubcodec      = new BinaryExpressionSubcodec(this, codecContainer);
            blockSubcodec       = new BlockExpressionSubcodec(this, codecContainer);
            conditionalSubcodec = new ConditionalExpressionSubcodec(this, codecContainer);
            constantSubcodec    = new ConstantExpressionSubcodec(this, codecContainer);
            invocationSubcodec  = new InvocationExpressionSubcodec(this, codecContainer);
            lambdaSubcodec      = new LambdaExpressionSubcodec(this, codecContainer);
            listInitSubcodec    = new ListInitExpressionSubcodec(this, codecContainer);
            memberSubcodec      = new MemberExpressionSubcodec(this, codecContainer);
            var memberBindingCollectionCodec = new MemberBindingCollectionCodec(this, codecContainer);

            memberInitSubcodec     = new MemberInitExpressionSubcodec(this, memberBindingCollectionCodec, codecContainer);
            methodCallSubcodec     = new MethodCallExpressionSubcodec(this, codecContainer);
            newArrayBoundsSubcodec = new NewArrayBoundsExpressionSubcodec(this, codecContainer);
            newArrayInitSubcodec   = new NewArrayInitExpressionSubcodec(this, codecContainer);
            newSubcodec            = new NewExpressionSubcodec(this, codecContainer);
            parameterSubcodec      = new ParameterExpressionSubcodec(this, codecContainer);
            typeEqualSubcodec      = new TypeEqualExpressionSubcodec(this, codecContainer);
            typeIsSubcodec         = new TypeIsExpressionSubcodec(this, codecContainer);
            unarySubcodec          = new UnaryExpressionSubcodec(this, codecContainer);
        }
示例#24
0
 public ExceptionCodec(ICodecContainer codecContainer)
 {
     stringCodec     = codecContainer.GetManualCodecFor <string>();
     createException = CreateExceptionCreator();
 }
示例#25
0
 public MethodInfoCodec(ICodecContainer codecContainer)
     : base(codecContainer)
 {
 }
 public ReferenceStructArrayCodec(Type elementType, ICodecContainer codecContainer)
     : base(elementType, codecContainer)
 {
 }
示例#27
0
 public MemberBindingCodec(MemberBindingCollectionCodec memberBindingCollectionCodec, ExpressionCodec expressionCodec, ICodecContainer codecContainer)
 {
     memberBindingTypeCodec   = codecContainer.GetManualCodecFor <MemberBindingType>();
     memberAssignmentCodec    = new MemberAssignmentCodec(expressionCodec, codecContainer);
     memberListBindingCodec   = new MemberListBindingCodec(codecContainer);
     memberMemberBindingCodec = new MemberMemberBindingCodec(memberBindingCollectionCodec, codecContainer);
 }
示例#28
0
 public ReferenceArrayCodec(Type type, ICodecContainer codecContainer)
 {
     this.type = type;
     elementCodec = codecContainer.GetEmittingCodecFor(type);
     isStruct = type.IsValueType;
 }
 public NewArrayInitExpressionSubcodec(ExpressionCodec commonCodec, ICodecContainer codecContainer)
     : base(commonCodec, codecContainer)
 {
     typeCodec            = codecContainer.GetManualCodecFor <Type>();
     expressionArrayCodec = codecContainer.GetManualCodecFor <Expression[]>();
 }
示例#30
0
 public EventInfoCodec(ICodecContainer codecContainer) : base(codecContainer)
 {
 }
示例#31
0
 public DataContractCodec(Type type, ICodecContainer codecContainer, bool doNotCalculateMaxSize = false)
     : base(type, codecContainer, doNotCalculateMaxSize)
 {
 }
 public MemberBindingCollectionCodec(ExpressionCodec expressionCodec, ICodecContainer codecContainer)
 {
     memberBindingCodec = new MemberBindingCodec(this, expressionCodec, codecContainer);
     intCodec = codecContainer.GetManualCodecFor<int>();
 }
示例#33
0
 public ClassArrayCodec(Type elementType, ICodecContainer codecContainer)
     : base(elementType, codecContainer)
 {
 }
 public ServiceMethodHandlerFactory(ICodecContainer codecContainer)
 {
     this.codecContainer = codecContainer;
 }
 public void Setup()
 {
     codecContainer = new CodecContainer();
     factory = new ServiceMethodHandlerFactory(codecContainer);
     service = Substitute.For<IGlobalServiceImplementation>();
     var serviceDescriptionBuilder = new ServiceDescriptionBuilder(new MethodDescriptionBuilder());
     var globalServiceDescription =  serviceDescriptionBuilder.Build(typeof(IGlobalService));
     globalServiceImplementationInfo =
         new ServiceImplementationInfo(typeof(IGlobalService), globalServiceDescription, service);
 }
 public IndirectDataContractCodec(Type type, ICodecContainer codecContainer)
     : base(type, new DirectDataContractCodec(type, codecContainer))
 {
 }
 public void Setup()
 {
     serviceDescriptionBuilder = new ServiceDescriptionBuilder(new MethodDescriptionBuilder());
     codecContainer = new CodecContainer();
     methodCallProcessor = Substitute.For<IOutgoingMethodCallProcessor>();
     factory = new ServiceProxyClassFactory(serviceDescriptionBuilder, codecContainer);
 }
 protected ReferenceArrayCodecBase(Type elementType, ICodecContainer codecContainer)
     : base(elementType.MakeArrayType(), elementType, codecContainer)
 {
 }
 public ParameterExpressionSubcodec(ExpressionCodec commonCodec, ICodecContainer codecContainer) : base(commonCodec, codecContainer)
 {
     typeCodec   = codecContainer.GetManualCodecFor <Type>();
     stringCodec = codecContainer.GetManualCodecFor <string>();
 }
示例#40
0
 protected ReferenceArrayCodecBase(Type elementType, ICodecContainer codecContainer)
     : base(elementType.MakeArrayType(), elementType, codecContainer)
 {
 }
 public OutgoingRequestProcessor(IReadOnlyDictionary<string, IServiceTopology> topology, IRequestSenderContainer requestSenderContainer, ICodecContainer codecContainer)
 {
     this.topology = topology;
     this.requestSenderContainer = requestSenderContainer;
     exceptionCodec = codecContainer.GetManualCodecFor<Exception>();
 }
示例#42
0
 protected ExpressionSubcodecBase(ExpressionCodec commonCodec, ICodecContainer codecContainer)
 {
     CommonCodec         = commonCodec;
     CodecContainer      = codecContainer;
     ExpressionTypeCodec = codecContainer.GetManualCodecFor <ExpressionType>();
 }
示例#43
0
 protected CollectionCodecBase(Type type, Type elementType, ICodecContainer codecContainer)
 {
     this.type = type;
     this.elementType = elementType;
     elementCodec = codecContainer.GetEmittingCodecFor(elementType);
 }
示例#44
0
 public ClassArrayCodec(Type elementType, ICodecContainer codecContainer)
     : base(elementType, codecContainer)
 {
 }
示例#45
0
 public OutgoingMethodCallProcessor(IReadOnlyDictionary <string, IServiceTopology> topology, IRequestSenderContainer requestSenderContainer, ICodecContainer codecContainer)
 {
     this.topology = topology;
     this.requestSenderContainer = requestSenderContainer;
     exceptionCodec = codecContainer.GetManualCodecFor <Exception>();
 }
示例#46
0
 public BinaryExpressionSubcodec(ExpressionCodec commonCodec, ICodecContainer codecContainer) : base(commonCodec, codecContainer)
 {
     boolCodec       = codecContainer.GetManualCodecFor <bool>();
     methodInfoCodec = codecContainer.GetManualCodecFor <MethodInfo>();
 }
示例#47
0
 public IndexExpressionSubcodec(ExpressionCodec commonCodec, ICodecContainer codecContainer)
     : base(commonCodec, codecContainer)
 {
     propertyInfoCodec    = codecContainer.GetManualCodecFor <PropertyInfo>();
     expressionArrayCodec = codecContainer.GetManualCodecFor <Expression[]>();
 }
示例#48
0
 public TypeEqualExpressionSubcodec(ExpressionCodec commonCodec, ICodecContainer codecContainer)
     : base(commonCodec, codecContainer)
 {
     typeCodec = codecContainer.GetManualCodecFor <Type>();
 }