Ejemplo n.º 1
0
        object GetInstance(MessageHeaders headers, Type serviceType)
        {
            ActorId id       = ActorIdHelper.Get(headers);
            object  instance = Activator.CreateInstance(serviceType, new ActorService(), id);

            TestHelper.ActivateActor <S>(instance as IActor, State);
            return(instance);
        }
Ejemplo n.º 2
0
        object GetInstance(MessageHeaders headers, Type serviceType)
        {
            ActorId id       = ActorIdHelper.Get(headers);
            object  instance = Activator.CreateInstance(serviceType, new ActorService(new StatefulServiceContext(), ActorTypeInformation.Get(serviceType)), id);

            TestHelper.ActivateActor <S>(instance as IActor, State);
            return(instance);
        }
Ejemplo n.º 3
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);
            }
        }
Ejemplo n.º 4
0
        void MockActorId <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;
                ActorIdHelper.Add(OperationContext.Current.OutgoingMessageHeaders, actorId);
            }
            else
            {
                Uri actorAddress = ServiceAddress(target.GetType());
                actorId.ApplicationName    = actorAddress.Segments[1].TrimEnd('/');
                actorId.ActorInterfaceName = typeof(I).FullName;

                FieldInfo request = typeof(OperationContext).GetField("request", BindingFlags.NonPublic | BindingFlags.Instance);
                Message   message = Message.CreateMessage(MessageVersion.Soap12, "void");
                request.SetValue(OperationContext.Current, message);
                ActorIdHelper.Add(OperationContext.Current.IncomingMessageHeaders, actorId);
            }
        }