Ejemplo n.º 1
0
 /// <summary>
 /// This will build a proxy for the interface representing the gateway and register the 
 /// proxy instance in the container based on the definition.
 /// </summary>
 /// <param name="container"><seealso cref="IContainer"/></param>
 /// <param name="gatewayDefinition">Definition of the gateway</param>
 public void BuildProxy(IObjectBuilder container, IGatewayDefinition gatewayDefinition)
 {
     var methodInterceptor = new GatewayMethodInterceptor(container, gatewayDefinition);
     var gatewayInstance = container.Resolve<IReflection>().GetTypeForNamedInstance(gatewayDefinition.Contract);
     var proxy = BuildFor(gatewayInstance, methodInterceptor);
     container.Register(gatewayDefinition.Id, gatewayInstance, proxy);
 }
Ejemplo n.º 2
0
 protected override void Init(IObjectSetting objectSetting, IObjectBuilder objectBuilder)
 {
     base.Init(objectSetting, objectBuilder);
     var setting = objectSetting.ConfigSetting;
     var poolSetting = (IPoolLifetimeContainerSetting)setting.ToCachedSetting<PoolLifetimeContainerSetting>("pooling");
     if (poolSetting != null) {
         this.Enabled = poolSetting.Enabled;
         this.Debug = poolSetting.Debug;
         this.MaxPoolSize = poolSetting.MaxPoolSize;
     }
     var maxPoolSize = this.MaxPoolSize;
     if(maxPoolSize == 0 || !this.Enabled) {
         this.MaxPoolSize = maxPoolSize;
         this.Enabled = false;
         return;
     }
     if(maxPoolSize < 0) {
         maxPoolSize = int.MaxValue;
         this.Free = new Stack();
         this.Busy = new HashSet<object>();
     } else {
         this.Free = new Stack(maxPoolSize);
         this.Busy = new HashSet<object>();
     }
     this.MaxPoolSize = maxPoolSize;
 }
Ejemplo n.º 3
0
 /// <summary>
 /// 构造
 /// </summary>
 public ObjectBuildContext(IServiceLocator serviceLocator, IObjectSetting objectSetting, IObjectBuilder objectBuilder, IDictionary items)
     : base(items)
 {
     this.ServiceLocator = serviceLocator;
     this.ObjectSetting = objectSetting;
     this.ObjectBuilder = objectBuilder;
 }
Ejemplo n.º 4
0
        /// <summary>
        /// This will scan an assembly for all adapters that can be registered for use.
        /// </summary>
        /// <param name="container"><seealso cref="IContainer"/></param>
        /// <param name="assembly">Assembly to scan</param>
        public void Scan(IObjectBuilder container, Assembly assembly)
        {
            var definitions = this.FindAllGatewaysAndBuildDefinition(assembly);

            foreach (var definition in definitions)
                this.BuildProxy(container, definition);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="objectBuilder"></param>
        public static void registerElement(IObjectBuilder objectBuilder, NavigationMeshService manager)
        {
            ParameterSequenceBuilder sequenceBuilder = new ParameterSequenceBuilder();
            sequenceBuilder.createSequence();

            objectBuilder.registerElement(new Constructor(manager), sequenceBuilder.CurrentSequence, typeof(NavigationMeshPose3D), "NavigationMeshPose3D", null);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="objectBuilder"></param>
        public static void registerElement(IObjectBuilder objectBuilder)
        {
            ParameterSequenceBuilder sequenceBuilder = new ParameterSequenceBuilder();
            sequenceBuilder.createSequence();

            objectBuilder.registerElement(new Constructor(), sequenceBuilder.CurrentSequence, typeof(ConsoleWriter), "ConsoleWriter", null);
        }
Ejemplo n.º 7
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="objectBuilder"></param>
 public static void registerElement(IObjectBuilder objectBuilder)
 {
     ParameterSequenceBuilder sequenceBuilder = new ParameterSequenceBuilder();
     sequenceBuilder.createSequence();
     basicRegistration(sequenceBuilder);
     objectBuilder.registerElement(new Constructor(), sequenceBuilder.CurrentSequence, typeof(MeshCollider), "MeshCollider");
 }
Ejemplo n.º 8
0
		public ThreadPoolConsumerPool(IServiceBus bus, IObjectBuilder objectBuilder, Pipe eventAggregator, TimeSpan receiveTimeout)
		{
			_objectBuilder = objectBuilder;
			_receiveTimeout = receiveTimeout;
			_eventAggregator = eventAggregator;
			_bus = bus;
		}
Ejemplo n.º 9
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="objectBuilder"></param>
        public static void registerElement(IObjectBuilder objectBuilder, GuiService guiService)
        {
            ParameterSequenceBuilder sequenceBuilder = new ParameterSequenceBuilder();
            sequenceBuilder.createSequence();

            objectBuilder.registerElement(new Constructor(guiService), sequenceBuilder.CurrentSequence, typeof(Button), "Button", null);
        }
Ejemplo n.º 10
0
 public IAdapterConfiguration Configure(IObjectBuilder builder)
 {
     this.Scheme = "vm";
     this.Uri = "vm://{channel name}";
     this.InputChannelAdapter = typeof (QueueChannelInputAdapter);
     this.OutputChannelAdapter = typeof(QueueChannelOutputAdapter);
     return this;
 }
Ejemplo n.º 11
0
 public IAdapterConfiguration Configure(IObjectBuilder builder)
 {
     this.Scheme = "stdio";
     this.Uri = "stdio://{unique name of console location}";
     this.InputChannelAdapter = typeof (StdioInputChannelAdapter);
     this.OutputChannelAdapter = typeof(StdioOutputChannelAdapter);
     return this;
 }
Ejemplo n.º 12
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="objectBuilder"></param>
        public static void registerElement(IObjectBuilder objectBuilder)
        {
            ParameterSequenceBuilder sequenceBuilder = new ParameterSequenceBuilder();
            sequenceBuilder.createSequence();
            sequenceBuilder.addParameter(new IntParameter("timeout", "1000")); // miliseconds

            objectBuilder.registerElement(new Constructor(), sequenceBuilder.CurrentSequence, typeof(AutoDestroyLogic),"AutoDestroyLogic", null);
        }
Ejemplo n.º 13
0
        public void SetUp()
        {
            listBuilderImpl = MockRepository.GenerateStub<IListBuilderImpl<MyClass>>();
            objectBuilder = MockRepository.GenerateStub<IObjectBuilder<MyClass>>();
            uniqueRandomGenerator = MockRepository.GenerateMock<IUniqueRandomGenerator>();

            declaration = new RandomDeclaration<MyClass>(listBuilderImpl, objectBuilder, uniqueRandomGenerator, amount, start, end);
        }
Ejemplo n.º 14
0
 public IAdapterConfiguration Configure(IObjectBuilder builder)
 {
     this.Scheme = "sql";
     this.Uri = "sql://{component id to connection information}";
     this.InputChannelAdapter = typeof (SqlInputChannelAdapter);
     this.OutputChannelAdapter = typeof(SqlOutputChannelAdapter);
     return this;
 }
Ejemplo n.º 15
0
 public void SetUp()
 {
     mocks = new MockRepository();
     objectBuilder = mocks.DynamicMock<IObjectBuilder<MyClass>>();
     operable = mocks.DynamicMultiMock<IDeclaration<MyClass>>(typeof(IOperable<MyClass>));
     func = x => x.Float = 1f;
     propertyExpression = x => x.IntGetterOnly;
 }
Ejemplo n.º 16
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="objectBuilder"></param>
        public static void registerElement(IObjectBuilder objectBuilder)
        {
            ParameterSequenceBuilder sequenceBuilder = new ParameterSequenceBuilder();
            sequenceBuilder.createSequence();
            basicRegistration(sequenceBuilder);
            sequenceBuilder.addParameter(new FloatParameter("radius", "0.5"));

            objectBuilder.registerElement(new Constructor(), sequenceBuilder.CurrentSequence, typeof(SphereCollider), "SphereCollider", null);
        }
Ejemplo n.º 17
0
 /// <summary>
 /// Constructs a <see cref="ServiceRegistration"/>
 /// </summary>
 /// <param name="lifetimeManager">The lifetime manager.</param>
 /// <param name="objectBuilder">THe object builder.</param>
 /// <param name="attributeConditions">The attribute conditions.</param>
 /// <param name="targetTypeCondition">The target type condition.</param>
 /// <param name="resolutionCondition">The resolution condition.</param>
 public ServiceRegistration(ILifetime lifetimeManager, IObjectBuilder objectBuilder, HashSet<Type> attributeConditions = null,
     Type targetTypeCondition = null, Func<TypeInformation, bool> resolutionCondition = null)
 {
     this.lifetimeManager = lifetimeManager;
     this.objectBuilder = objectBuilder;
     this.attributeConditions = attributeConditions;
     this.targetTypeCondition = targetTypeCondition;
     this.resolutionCondition = resolutionCondition;
 }
Ejemplo n.º 18
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="objectBuilder"></param>
        public static void registerElement(IObjectBuilder objectBuilder, AnimationService animationService)
        {
            ParameterSequenceBuilder sequenceBuilder = new ParameterSequenceBuilder();
            sequenceBuilder.createSequence();
            sequenceBuilder.addParameter(new FloatParameter("position","0.0,0.0,0.0"));
            sequenceBuilder.addParameter(new IdParameter("animation",""));

            objectBuilder.registerElement(new Constructor(animationService), sequenceBuilder.CurrentSequence, typeof(AnimationPosition3D), "AnimationPosition3D", null);
        }
Ejemplo n.º 19
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="objectBuilder"></param>
 public static void registerElement(IObjectBuilder objectBuilder)
 {
     ParameterSequenceBuilder sequenceBuilder = new ParameterSequenceBuilder();
     sequenceBuilder.createSequence();
     sequenceBuilder.addParameter(new IdParameter("id",""));
     sequenceBuilder.addParameter(new IdParameter("enterScript", ""));
     sequenceBuilder.addParameter(new IdParameter("exitScript", ""));
     objectBuilder.registerElement(new Constructor(), sequenceBuilder.CurrentSequence, typeof(ScriptState), "ScriptState", null);
 }
Ejemplo n.º 20
0
        public void SetUp()
        {
            mocks = new MockRepository();
            listBuilderImpl = mocks.DynamicMock<IListBuilderImpl<SimpleClass>>();
            objectBuilder = mocks.StrictMock<IObjectBuilder<SimpleClass>>();
            listBuilderImpl.Stub(x => x.Capacity).Return(2);

            declaration = new GlobalDeclaration<SimpleClass>(listBuilderImpl, objectBuilder);
        }
Ejemplo n.º 21
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="objectBuilder"></param>
        public static void registerElement(IObjectBuilder objectBuilder, IInputManager inputManager)
        {
            ParameterSequenceBuilder sequenceBuilder = new ParameterSequenceBuilder();
            sequenceBuilder.createSequence();
            sequenceBuilder.addParameter(new FloatParameter("position", "0,0,0")); //
            sequenceBuilder.addParameter(new FloatParameter("speed","1"));

            objectBuilder.registerElement(new Constructor(inputManager), sequenceBuilder.CurrentSequence, typeof(KeyboardPosition3D), "KeyboardPosition3D", null);
        }
Ejemplo n.º 22
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="objectBuilder"></param>
        public static void registerElement(IObjectBuilder objectBuilder, AnimationService animationService)
        {
            ParameterSequenceBuilder sequenceBuilder = new ParameterSequenceBuilder();
            sequenceBuilder.createSequence();
            sequenceBuilder.addParameter(new IdParameter("animationId",XnaScrapId.INVALID_ID.ToString()));
            sequenceBuilder.addParameter(new FloatParameter("time","0.0"));
            sequenceBuilder.addParameter(new SequenceParameter("values", new FloatParameter("timeAndValue","0.0,0.0"))); //

            objectBuilder.registerElement(new Constructor(animationService), sequenceBuilder.CurrentSequence, typeof(AnimationValueCreator), "AnimationValueCreator", null);
        }
Ejemplo n.º 23
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="objectBuilder"></param>
        public static void registerElement(IObjectBuilder objectBuilder, IInputManager inputManager)
        {
            ParameterSequenceBuilder sequenceBuilder = new ParameterSequenceBuilder();
            sequenceBuilder.createSequence();
            sequenceBuilder.addParameter(new BoolParameter("invertY", "false")); //
            sequenceBuilder.addParameter(new BoolParameter("invertX", "false")); //
            sequenceBuilder.addParameter(new FloatParameter("scale", "0.001"));

            objectBuilder.registerElement(new Constructor(inputManager), sequenceBuilder.CurrentSequence, typeof(TouchRotation3D), "TouchRotation3D", null);
        }
Ejemplo n.º 24
0
 public void SetUp()
 {
     builderSetup = new BuilderSetup();
     mocks = new MockRepository();
     listBuilderImpl = mocks.DynamicMock<IListBuilderImpl<SimpleClass>>();
     objectBuilder = mocks.StrictMock<IObjectBuilder<SimpleClass>>();
     listBuilderImpl.Stub(x => x.Capacity).Return(2);
     listBuilderImpl.Stub(x => x.BuilderSetup).Return(builderSetup);
     objectBuilder.Stub(x => x.BuilderSetup).Return(builderSetup).Repeat.Any(); ;
 }
Ejemplo n.º 25
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="objectBuilder"></param>
        public static void registerElement(IObjectBuilder objectBuilder)
        {
            ParameterSequenceBuilder sequenceBuilder = new ParameterSequenceBuilder();
            sequenceBuilder.createSequence();
            basicRegistration(sequenceBuilder);
            sequenceBuilder.addParameter(new FloatParameter("radius", "1.0"));
            sequenceBuilder.addParameter(new FloatParameter("height", "1.0"));

            objectBuilder.registerElement(new Constructor(), sequenceBuilder.CurrentSequence, typeof(CapsuleCollider), "CapsuleCollider");
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Gets the instance managed by the <see cref="SingletonLifetime"/>
        /// </summary>
        /// <param name="objectBuilder">An <see cref="IObjectBuilder"/> implementation.</param>
        /// <param name="resolutionInfo">The info about the actual resolution.</param>
        /// <param name="resolveType">The type info about the resolved type.</param>
        /// <returns>The lifetime managed object.</returns>
        public object GetInstance(IObjectBuilder objectBuilder, ResolutionInfo resolutionInfo, TypeInformation resolveType)
        {
            if (this.instance != null) return this.instance;
            lock (this.syncObject)
            {
                if (this.instance != null) return this.instance;
                this.instance = objectBuilder.BuildInstance(resolutionInfo, resolveType);
            }

            return this.instance;
        }
		internal static void Initialise()
		{
			var builder = new AutofacObjectBuilder();
			RegisterDependencies();

			Builder = builder;

			Logger.Instance = new Logger(true);
			Logger.EventBus = builder.BuildObject<IEventBus>();
			ApiResult.Logger = Logger.Instance;
		}
Ejemplo n.º 28
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="objectBuilder"></param>
        public static void registerElement(IObjectBuilder objectBuilder)
        {
            ParameterSequenceBuilder sequenceBuilder = new ParameterSequenceBuilder();
            sequenceBuilder.createSequence();
            basicRegistration(sequenceBuilder);
            sequenceBuilder.addParameter(new FloatParameter("normal", "0.0,1.0,0.0"));
            sequenceBuilder.addParameter(new FloatParameter("d", "0.0"));
            sequenceBuilder.addParameter(new FloatParameter("bb_min", "-0.5,-0.5,-0.5"));
            sequenceBuilder.addParameter(new FloatParameter("bb_max", "0.5,0.5,0.5"));

            objectBuilder.registerElement(new Constructor(), sequenceBuilder.CurrentSequence, typeof(PlaneCollider), "PlaneCollider");
        }
Ejemplo n.º 29
0
 public void runScriptOnce(String name, IObjectBuilder script)
 {
     throw new NotImplementedException("Implement runScriptOnce and ScriptExporter");
     IScriptExporter exporter = null;// App.CurrentProject.Exporter;
     if (exporter == null)
     {
         MessageBox.Show("No Exporter set", "Error");
         return;
     }
     String scriptExported = script.exportScript(exporter);
     send("PUT /Scripts/" + name + "/ " + scriptExported + " HTTP/1.1", (byte)Connection.CommandType.C_PUT, runScriptOnceCallbackRest, name);
 }
Ejemplo n.º 30
0
        public MessageDistributor(
            NsqBus bus,
            IObjectBuilder objectBuilder,
            ILogger logger,
            MessageHandlerMetadata messageHandlerMetadata
        )
        {
            if (bus == null)
                throw new ArgumentNullException("bus");
            if (objectBuilder == null)
                throw new ArgumentNullException("objectBuilder");
            if (logger == null)
                throw new ArgumentNullException("logger");
            if (messageHandlerMetadata == null)
                throw new ArgumentNullException("messageHandlerMetadata");

            _bus = bus;
            _objectBuilder = objectBuilder;
            _logger = logger;

            _serializer = messageHandlerMetadata.Serializer;
            _handlerType = messageHandlerMetadata.HandlerType;
            _messageType = messageHandlerMetadata.MessageType;
            _messageAuditor = messageHandlerMetadata.MessageAuditor;
            _topic = messageHandlerMetadata.Topic;
            _channel = messageHandlerMetadata.Channel;

            var possibleMethods = _handlerType.GetMethods().Where(p => p.Name == "Handle" && !p.IsGenericMethod);
            foreach (var possibleMethod in possibleMethods)
            {
                var parameters = possibleMethod.GetParameters();
                if (parameters.Length == 1 && parameters[0].ParameterType == _messageType)
                {
                    _handleMethod = possibleMethod;
                    break;
                }
            }

            if (_handleMethod == null)
                throw new Exception(string.Format("Handle({0}) not found on {1}", _messageType, _handlerType));

            if (!_messageType.IsInterface)
            {
                _concreteMessageType = _messageType;
            }
            else
            {
                _concreteMessageType = InterfaceBuilder.CreateType(_messageType);
            }
        }
Ejemplo n.º 31
0
 public object Load(ConstructionNode node, IObjectBuilder builder, BuildContext trackingContext)
 {
     return(new TemplateContent(node, builder, trackingContext));
 }
 public SelectedComponentMessageSink(ISubscriberContext context)
 {
     _builder = context.Builder;
 }
        public void TestIntialize()
        {
            _objectBuilder = new ObjectBuilder(SetupObjectBuilder);

            _dbEntityValidationException = new DbEntityValidationException("Foobar", new List <DbEntityValidationResult>());
        }
Ejemplo n.º 34
0
 public BetweenSet(IObjectBuilder builder, int min, int max)
 {
     Min     = min;
     Max     = max;
     Builder = builder;
 }
Ejemplo n.º 35
0
 public RangeDeclaration(IListBuilderImpl <T> listBuilderImpl, IObjectBuilder <T> objectBuilder, int start, int end)
     : base(listBuilderImpl, objectBuilder)
 {
     this._start = start;
     this._end   = end;
 }
Ejemplo n.º 36
0
 public BundleService(IApplicationContext context, IAssemblyLoaderService assemblyLoaderService, IObjectBuilder builder)
 {
     _bundlePath            = context.BundlePath;
     _context               = context;
     _assemblyLoaderService = assemblyLoaderService;
     _builder               = builder;
 }
 public bool TryGetObjectBuilder(TAddress address, out IObjectBuilder <TAddress> objectBuilder)
 {
     objectBuilder = this.ObjectBuilderProviderFunc(address);
     return(objectBuilder != null);
 }
 public void TestIntialize()
 {
     _objectBuilder = new ObjectBuilder(ObjectBuilderHelper.SetupObjectBuilder);
 }
Ejemplo n.º 39
0
 public BetweenSet(IObjectBuilder builder, int max)
     : this(builder, 0, max)
 {
 }
Ejemplo n.º 40
0
        public SubscriptionManagerForm(IObjectBuilder builder)
        {
            _builder = builder;

            InitializeComponent();
        }
Ejemplo n.º 41
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="MessageBuilder" /> class.
 /// </summary>
 /// <param name="objectBuilder">The object builder.</param>
 private MessageBuilder(IObjectBuilder objectBuilder)
 {
     _objectBuilder = objectBuilder;
 }
Ejemplo n.º 42
0
 /// <summary>
 ///     Creates the specified object builder.
 /// </summary>
 /// <param name="objectBuilder">The object builder.</param>
 public static void Create(IObjectBuilder objectBuilder)
 {
     Instance = new MessageBuilder(objectBuilder);
 }
Ejemplo n.º 43
0
        /// <inheritdoc />
        public override Expression GetExpression(IContainerContext containerContext, IServiceRegistration serviceRegistration, IObjectBuilder objectBuilder, ResolutionContext resolutionContext, Type resolveType)
        {
            var expression = base.GetExpression(containerContext, serviceRegistration, objectBuilder, resolutionContext, resolveType);

            if (expression == null)
            {
                return(null);
            }

            var factory = expression.NodeType == ExpressionType.New && ((NewExpression)expression).Arguments.Count == 0
                ? scope => Activator.CreateInstance(expression.Type)
                : expression.CompileDelegate(resolutionContext);

            return(resolutionContext.RootScope.GetOrAddScopedItem(base.ScopeId, base.Sync, factory).AsConstant());
        }
Ejemplo n.º 44
0
 public void SetObjectBuilder(IObjectBuilder objectBuilder)
 {
     ObjectBuilder = objectBuilder;
 }
Ejemplo n.º 45
0
 public void SetUp()
 {
     mocks           = new MockRepository();
     listBuilderImpl = mocks.DynamicMock <IListBuilderImpl <SimpleClass> >();
     objectBuilder   = mocks.StrictMock <IObjectBuilder <SimpleClass> >();
 }
Ejemplo n.º 46
0
        public IBusService Create(IServiceBus bus, IObjectBuilder builder)
        {
            var service = new HealthClient(_intervalInSeconds);

            return(service);
        }
Ejemplo n.º 47
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Declaration&lt;T&gt;"/> class.
 /// </summary>
 /// <param name="listBuilderImpl">The list builder.</param>
 /// <param name="objectBuilder">The object builder.</param>
 protected Declaration(IListBuilderImpl <T> listBuilderImpl, IObjectBuilder <T> objectBuilder)
 {
     this.listBuilderImpl      = listBuilderImpl;
     this.objectBuilder        = objectBuilder;
     MasterListAffectedIndexes = new List <int>();
 }
Ejemplo n.º 48
0
 public RandomDeclaration(IListBuilderImpl <T> listBuilderImpl, IObjectBuilder <T> objectBuilder, IUniqueRandomGenerator uniqueRandomGenerator, int amount, int start, int end)
     : base(listBuilderImpl, objectBuilder, start, end)
 {
     this.uniqueRandomGenerator = uniqueRandomGenerator;
     this.amount = amount;
 }
Ejemplo n.º 49
0
 public TemplateContent(ConstructionNode node, IObjectBuilder builder, BuildContext buildContext)
 {
     this.node         = node;
     this.builder      = builder;
     this.buildContext = buildContext;
 }
Ejemplo n.º 50
0
 public SubTaskWorker(IServiceBus bus, IObjectBuilder builder)
 {
     Bus     = bus;
     Builder = builder;
 }
Ejemplo n.º 51
0
        /// <inheritdoc />
        public override Expression GetExpression(IContainerContext containerContext, IServiceRegistration serviceRegistration, IObjectBuilder objectBuilder, ResolutionContext resolutionContext, Type resolveType)
        {
            if (this.instanceExpression != null)
            {
                return(this.instanceExpression);
            }
            lock (this.sync)
            {
                if (this.instanceExpression != null)
                {
                    return(this.instanceExpression);
                }

                var expression = base.GetExpression(containerContext, serviceRegistration, objectBuilder, resolutionContext, resolveType);
                if (expression == null)
                {
                    return(null);
                }

                var instance = expression.NodeType == ExpressionType.New && ((NewExpression)expression).Arguments.Count == 0
                    ? Activator.CreateInstance(expression.Type)
                    : expression.CompileDelegate(resolutionContext)(containerContext.Container.RootScope);

                return(this.instanceExpression = instance.AsConstant());
            }
        }
Ejemplo n.º 52
0
 public static MessagePipeline CreateDefault(IObjectBuilder builder, object data)
 {
     return(new MessagePipelineConfigurator(builder, data)._pipeline);
 }
Ejemplo n.º 53
0
        public void Test()
        {
            IObjectBuilder builder = ConfigurationBroker.GetConfigurationObject <IObjectBuilder>();

            Assert.IsNotNull(builder);
        }
Ejemplo n.º 54
0
 public ObjectOnBuild WithBuilder(IObjectBuilder builder)
 {
     this.Builder = builder;
     return(this);
 }
Ejemplo n.º 55
0
        /// <summary>
        /// Produces a factory expression to produce scoped instances.
        /// </summary>
        /// <param name="containerContext">The container context.</param>
        /// <param name="serviceRegistration">The service registration.</param>
        /// <param name="objectBuilder">The object builder.</param>
        /// <param name="resolutionContext">The resolution context.</param>
        /// <param name="resolveType">The resolve type.</param>
        /// <returns>The factory expression.</returns>
        public Expression GetFactoryExpression(IContainerContext containerContext, IServiceRegistration serviceRegistration, IObjectBuilder objectBuilder, ResolutionContext resolutionContext, Type resolveType)
        {
            var expr = base.GetExpression(containerContext, serviceRegistration, objectBuilder, resolutionContext, resolveType);

            return(expr?.AsLambda(resolutionContext.CurrentScopeParameter));
        }
Ejemplo n.º 56
0
        /// <inheritdoc />
        public override Expression GetExpression(IServiceRegistration serviceRegistration, IObjectBuilder objectBuilder, ResolutionInfo resolutionInfo, Type resolveType)
        {
            if (this.expression != null)
            {
                return(this.expression);
            }
            lock (this.syncObject)
            {
                if (this.expression != null)
                {
                    return(this.expression);
                }
                var expr = base.GetExpression(serviceRegistration, objectBuilder, resolutionInfo, resolveType);
                if (expr == null)
                {
                    return(null);
                }

                if (expr.NodeType == ExpressionType.New && ((NewExpression)expr).Arguments.Count == 0)
                {
                    this.instance = Activator.CreateInstance(expr.Type);
                }
                else
                {
                    this.instance = expr.CompileDelegate(Constants.ScopeExpression)(resolutionInfo.RootScope);
                }

                this.expression = Expression.Constant(this.instance);
            }

            return(this.expression);
        }
Ejemplo n.º 57
0
 public GlobalDeclaration(IListBuilderImpl <T> listBuilderImpl, IObjectBuilder <T> objectBuilder)
     : base(listBuilderImpl, objectBuilder)
 {
 }
Ejemplo n.º 58
0
        public IBusService Create(IServiceBus bus, IObjectBuilder builder)
        {
            var ef = builder.GetInstance <IEndpointFactory>();

            return(new RoutingService(_routes, ef));
        }
Ejemplo n.º 59
0
        public MessageDistributor(
            NsqBus bus,
            IObjectBuilder objectBuilder,
            ILogger logger,
            MessageHandlerMetadata messageHandlerMetadata
            )
        {
            if (bus == null)
            {
                throw new ArgumentNullException("bus");
            }
            if (objectBuilder == null)
            {
                throw new ArgumentNullException("objectBuilder");
            }
            if (logger == null)
            {
                throw new ArgumentNullException("logger");
            }
            if (messageHandlerMetadata == null)
            {
                throw new ArgumentNullException("messageHandlerMetadata");
            }

            _bus           = bus;
            _objectBuilder = objectBuilder;
            _logger        = logger;

            _serializer     = messageHandlerMetadata.Serializer;
            _handlerType    = messageHandlerMetadata.HandlerType;
            _messageType    = messageHandlerMetadata.MessageType;
            _messageAuditor = messageHandlerMetadata.MessageAuditor;
            _topic          = messageHandlerMetadata.Topic;
            _channel        = messageHandlerMetadata.Channel;

            var possibleMethods = _handlerType.GetMethods().Where(p => p.Name == "Handle" && !p.IsGenericMethod);

            foreach (var possibleMethod in possibleMethods)
            {
                var parameters = possibleMethod.GetParameters();
                if (parameters.Length == 1 && parameters[0].ParameterType == _messageType)
                {
                    _handleMethod = possibleMethod;
                    break;
                }
            }

            if (_handleMethod == null)
            {
                throw new Exception(string.Format("Handle({0}) not found on {1}", _messageType, _handlerType));
            }

            if (!_messageType.IsInterface)
            {
                _concreteMessageType = _messageType;
            }
            else
            {
                //  _concreteMessageType = InterfaceBuilder.CreateType(_messageType);
            }
        }
Ejemplo n.º 60
0
 protected BaseBuilder(IObjectBuilder objectBuilder) : this(null, objectBuilder)
 {
 }