Ejemplo n.º 1
0
 public object BeforeSendRequest(ref Message request, IClientChannel channel)
 {
     ActorIdHelper.Add(request.Headers, ActorId);
     ServiceContextHelper.Add(request.Headers, Context);
     OnAddHeaders(request.Headers);
     OnSending(request.Headers);
     return(null);
 }
Ejemplo n.º 2
0
        void MockServiceContext <I>(StatelessService target)
        {
            ServiceContext context = new ServiceContext();

            if (target == null)
            {
                Type serviceType = FabricRuntime.Services.Values.SelectMany(types => types.Where(type => type.GetInterfaces().Any(i => i == typeof(I)))).FirstOrDefault();
                context.ServiceName = ServiceAddress(serviceType);
                ServiceContextHelper.Add(OperationContext.Current.OutgoingMessageHeaders, context);
                AddStandardContexts(OperationContext.Current.OutgoingMessageHeaders);
            }
            else
            {
                context.ServiceName = ServiceAddress(target.GetType());
                MockMessage();
                ServiceContextHelper.Add(OperationContext.Current.IncomingMessageHeaders, context);
                AddStandardContexts(OperationContext.Current.IncomingMessageHeaders);
            }
        }
Ejemplo n.º 3
0
        void MockServiceContext <I>(StatelessService target)
        {
            ServiceContext context = new ServiceContext();

            if (target == null)
            {
                Type serviceType = FabricRuntime.Services.Values.SelectMany(types => types.Where(type => type.GetInterfaces().Any(i => i == typeof(I)))).FirstOrDefault();
                context.ServiceName = ServiceAddress(serviceType);
                ServiceContextHelper.Add(OperationContext.Current.OutgoingMessageHeaders, context);
            }
            else
            {
                context.ServiceName = ServiceAddress(target.GetType());

                FieldInfo request = typeof(OperationContext).GetField("request", BindingFlags.NonPublic | BindingFlags.Instance);
                Message   message = Message.CreateMessage(MessageVersion.Soap12, "void");
                request.SetValue(OperationContext.Current, message);
                ServiceContextHelper.Add(OperationContext.Current.IncomingMessageHeaders, context);
            }
        }
Ejemplo n.º 4
0
        void MockActorContexts <I>(ActorBase target)
        {
            ActorId actorId = new ActorId("Test");

            if (target == null)
            {
                Type actorType    = FabricRuntime.Actors.Values.SelectMany(types => types.Where(type => type.GetInterfaces().Any(i => i == typeof(I)))).FirstOrDefault();
                Uri  actorAddress = ServiceAddress(actorType);

                actorId.ApplicationName    = actorAddress.Segments[1].TrimEnd('/');
                actorId.ActorInterfaceName = typeof(I).FullName;
                actorId.ActorServiceName   = actorAddress.Segments[2];
                ActorIdHelper.Add(OperationContext.Current.OutgoingMessageHeaders, actorId);

                ServiceContextHelper.Add(OperationContext.Current.OutgoingMessageHeaders, new ServiceContext {
                    ServiceName = actorAddress
                });
                AddStandardContexts(OperationContext.Current.OutgoingMessageHeaders);
            }
            else
            {
                Uri actorAddress = ServiceAddress(target.GetType());

                actorId.ApplicationName    = actorAddress.Segments[1].TrimEnd('/');
                actorId.ActorInterfaceName = typeof(I).FullName;
                actorId.ActorServiceName   = actorAddress.Segments[2];

                MockMessage();
                ActorIdHelper.Add(OperationContext.Current.IncomingMessageHeaders, actorId);

                ServiceContextHelper.Add(OperationContext.Current.IncomingMessageHeaders, new ServiceContext {
                    ServiceName = actorAddress
                });
                AddStandardContexts(OperationContext.Current.IncomingMessageHeaders);
            }
        }