예제 #1
0
        private static object DeserializeInstance(Func <IParticipant>[] participantProviders, byte[] serializedData)
        {
            // Register a factory for deserialization in current (new) app domain.

            Assert.That(PipelineRegistry.HasInstanceProvider, Is.False);
            var defaultPipelineMock = MockRepository.GenerateStrictMock <IPipeline>();

            defaultPipelineMock.Stub(_ => _.ParticipantConfigurationID).Return("Mock Default Pipeline");
            IPipelineRegistry pipelineRegistry = new DefaultPipelineRegistry(defaultPipelineMock);

            PipelineRegistry.SetInstanceProvider(() => pipelineRegistry);

            var participants = participantProviders.Select(pp => pp()).Concat(new[] { new ModifyingParticipant() });
            // Avoid no-modification optimization.
            var pipeline = new DefaultPipelineFactory().Create(c_participantConfigurationID, participants.ToArray());

            pipelineRegistry.Register(pipeline);

            try
            {
                return(Serializer.Deserialize(serializedData));
            }
            finally
            {
                PipelineRegistryTestHelper.ResetPipelineRegistry();
            }
        }
        public void PipelineConfiguration()
        {
            var configurationID = "configurationID";
            var participant1    = CreateParticipant((id, ctx) => Assert.That(ctx.ParticipantConfigurationID, Is.EqualTo(configurationID)));
            var participant2    = CreateParticipant();

            var pipeline = new DefaultPipelineFactory().Create(configurationID, participant1, participant2);

            Assert.That(pipeline.ParticipantConfigurationID, Is.EqualTo(configurationID));
            Assert.That(pipeline.Participants, Is.EqualTo(new[] { participant1, participant2 }));
        }
예제 #3
0
 public ServiceBusConfiguration()
 {
     WorkerAvailabilityManager = new WorkerAvailabilityManager();
     Modules = new ModuleCollection();
     TransactionScope = new TransactionScopeConfiguration();
     QueueManager = Core.QueueManager.Default();
     Serializer = new DefaultSerializer();
     MessageHandlerFactory = new DefaultMessageHandlerFactory();
     MessageRouteProvider = new DefaultMessageRouteProvider();
     ForwardingRouteProvider = new DefaultForwardingRouteProvider();
     PipelineFactory = new DefaultPipelineFactory();
     TransactionScopeFactory = new DefaultTransactionScopeFactory();
     Policy = new DefaultServiceBusPolicy();
     ThreadActivityFactory = new DefaultThreadActivityFactory();
 }
예제 #4
0
        protected IPipeline CreatePipelineExactAssemblyLocation(string participantConfigurationID, PipelineSettings settings, params IParticipant[] participants)
        {
            // Avoid no-modification optimization.
            if (participants.Length == 0)
            {
                participants = new[] { CreateParticipant(CreateModifyingAction((id, ctx) => { })) }
            }
            ;

            var pipeline = new DefaultPipelineFactory().Create(participantConfigurationID, settings, participants);

            _codeManager = pipeline.CodeManager;

            return(pipeline);
        }
예제 #5
0
        public void InstantiateAssembledType()
        {
            var pipelineFactory             = new DefaultPipelineFactory();
            var equivalentReflectionService = pipelineFactory.Create(_pipeline.ParticipantConfigurationID, new ModifyingParticipant()).ReflectionService;
            var otherReflectionService      = pipelineFactory.Create("other id", new ModifyingParticipant()).ReflectionService;

            var assembledType1 = _reflectionService.GetAssembledType(typeof(RequestedType1));
            var assembledType2 = equivalentReflectionService.GetAssembledType(typeof(RequestedType1));
            var assembledType3 = otherReflectionService.GetAssembledType(typeof(RequestedType1));

            var instance1 = _reflectionService.InstantiateAssembledType(assembledType1, ParamList.Empty, false);
            var instance2 = _reflectionService.InstantiateAssembledType(assembledType2, ParamList.Empty, false);
            var instance3 = _reflectionService.InstantiateAssembledType(assembledType3, ParamList.Empty, false);

            // We though about disallowing instantiating assembled types created by a pipeline with a different participant configuration ID.
            // But the implementation would require us to add the [TypePipeAssemblyAttribute] attribute immediately, and query for it in a completely
            // different place. So we decided (for now) that it is not worth the effort.
            //var message = "The provided assembled type 'RequestedType1_Proxy_1' was generated by an incompatible pipeline 'other id'.";
            //Assert.That (() => _reflectionService.InstantiateAssembledType (assembledType3), Throws.ArgumentException.With.Message.EqualTo (message));

            Assert.That(instance1.GetType(), Is.SameAs(assembledType1));
            Assert.That(instance2.GetType(), Is.SameAs(assembledType2));
            Assert.That(instance3.GetType(), Is.SameAs(assembledType3));
        }