Esempio n. 1
0
        protected override void AttachToComponentRegistration(IComponentRegistry componentRegistry, IComponentRegistration registration)
        {
            var implementationType = registration.Activator.LimitType;

            foreach (var autoWireType in autoWireTypes)
            {
                var constructors = implementationType.GetConstructorsWithDependency(autoWireType);

                if (constructors.Any())
                {
                    registration.Preparing += (sender, e) =>
                    {
                        var parameter = new TypedParameter(autoWireType,
                            e.Context.Resolve(autoWireType, new TypedParameter(typeof(Type), implementationType)));
                        e.Parameters = e.Parameters.Concat(new[] { parameter });
                    };
                }
                else
                {
                    var props = implementationType.GetPropertiesWithDependency(autoWireType);
                    if (props.Any())
                    {
                        registration.Activated += (s, e) =>
                        {
                            foreach (var prop in props)
                            {
                                prop.SetValue(e.Instance,
                                    e.Context.Resolve(autoWireType));
                            }
                        };
                    }
                }
            }

            foreach (var serviceType in typebasedServiceTypes)
            {
                var constructorInjectors = BuildConstructorServiceInjectors(implementationType, serviceType).ToArray();
                if (constructorInjectors.Any())
                {
                    registration.Preparing += (s, e) =>
                    {
                        foreach (var ci in constructorInjectors)
                            ci(e);
                    };
                    return;
                }

                // build an array of actions on this type to assign loggers to member properties
                var injectors = BuildPropertyServiceInjectors(implementationType, serviceType).ToArray();

                if (injectors.Any())
                {
                    registration.Activated += (s, e) =>
                    {
                        foreach (var injector in injectors)
                            injector(e.Context, e.Instance);
                    };
                }
            }
        }
Esempio n. 2
0
 public override void Init(IEntity entity)
 {
     base.Init(entity);
     IImageComponent image = entity.GetComponent<IImageComponent>();
     TypedParameter imageParam = new TypedParameter(typeof(IHasImage), image);
     _scale = _resolver.Resolve<IScale>(imageParam);
 }
		private ITransport ProvideTransport(AutoFake fake)
		{
			var dateTimeParam = new TypedParameter(typeof(IDateTimeProvider), null);
			var memoryStreamParam = new TypedParameter(typeof(IMemoryStreamProvider), null);
			var serializerParam = new TypedParameter(typeof(IElasticsearchSerializer), null);
			return fake.Provide<ITransport, Transport>(dateTimeParam, serializerParam, memoryStreamParam);
		}
Esempio n. 4
0
		public IButton GetButton(string id, IAnimation idle, IAnimation hovered, IAnimation pushed, 
			float x, float y, string text = "", ITextConfig config = null, bool addToUi = true,
			float width = -1f, float height = -1f)
		{
			if (width == -1f && idle != null && idle.Frames.Count > 0)
			{
				width = idle.Frames[0].Sprite.Width;
			}
			if (height == -1f && idle != null && idle.Frames.Count > 0)
			{
				height = idle.Frames[0].Sprite.Height;
			}
			TypedParameter idParam = new TypedParameter (typeof(string), id);			
			IButton button = _resolver.Resolve <IButton>(idParam);
            button.LabelRenderSize = new AGS.API.SizeF(width, height);
            if (idle != null && idle.Frames.Count > 0) button.IdleAnimation = idle;
            if (hovered != null && hovered.Frames.Count > 0) button.HoverAnimation = hovered;
            if (pushed != null && pushed.Frames.Count > 0) button.PushedAnimation = pushed;

            button.StartAnimation(button.IdleAnimation);
			button.Tint =  Colors.White;
			button.X = x;
			button.Y = y;
			button.TextConfig = config;
			button.Text = text;

			if (addToUi)
				_gameState.UI.Add(button);

			return button;
		}
 public ExecuteQueryCommand(IQueryView view, Project prj, string hqlQueryText, TypedParameter[] typedParameters)
 {
     this.view = view;
     this.prj = prj;
     this.hqlQueryText = hqlQueryText;
     this.typedParameters = typedParameters;
 }
		public override void Init(IEntity entity)
		{
			base.Init(entity);
			TypedParameter defaults = new TypedParameter (typeof(IInteractions), _gameEvents.DefaultInteractions);
			TypedParameter objParam = new TypedParameter (typeof(IObject), entity as IObject);
			Interactions = _resolver.Container.Resolve<IInteractions>(defaults, objParam);
		}
        public override void Init(IEntity entity)
        {
            base.Init(entity);
            IAnimationContainer animation = entity.GetComponent<IAnimationContainer>();
            TypedParameter animationParam = new TypedParameter(typeof(IAnimationContainer), animation);            

            _pixelPerfect = _resolver.Resolve<IPixelPerfectCollidable>(animationParam);
        }
Esempio n. 8
0
		public ICharacter GetCharacter(string id, IOutfit outfit, IAnimationContainer container)
		{
			TypedParameter outfitParam = new TypedParameter (typeof(IOutfit), outfit);
			TypedParameter idParam = new TypedParameter (typeof(string), id);
			TypedParameter animationParam = new TypedParameter (typeof(IAnimationContainer), container);
			ICharacter character = _resolver.Resolve<ICharacter>(outfitParam, idParam, animationParam);
			return character;
		}
Esempio n. 9
0
 public IAudioClip LoadAudioClip(string filePath, string id = null)
 {
     ISoundData soundData = loadSoundData(filePath);
     if (soundData == null) return null;
     TypedParameter idParam = new TypedParameter(typeof(string), id ?? filePath);
     TypedParameter soundParam = new TypedParameter(typeof(ISoundData), soundData);
     return _resolver.Container.Resolve<IAudioClip>(idParam, soundParam);
 }
Esempio n. 10
0
        public void MatchesIdenticallyTypedParameter()
        {
            var param = AParamOfCConstructor();

            var typedParam = new TypedParameter(typeof(A), new A());

            Func<object> vp;
            Assert.True(typedParam.CanSupplyValue(param, new Container(), out vp));
        }
Esempio n. 11
0
        public void DoesNotMatchUnrelatedParameter()
        {
            var param = AParamOfCConstructor();

            var typedParam = new TypedParameter(typeof(string), "Yo!");

            Func<object> vp;
            Assert.False(typedParam.CanSupplyValue(param, new Container(), out vp));
        }
Esempio n. 12
0
        public void DoesNotMatchPolymorphicallyTypedParameter()
        {
            var param = AParamOfCConstructor();

            var typedParam = new TypedParameter(typeof(B), new B());

            Func<object> vp;
            Assert.False(typedParam.CanSupplyValue(param, new Container(), out vp));
        }
Esempio n. 13
0
		public IObject GetObject(string id, string[] sayWhenLook = null, string[] sayWhenInteract = null)
		{
			TypedParameter idParam = new TypedParameter (typeof(string), id);
			IObject obj = _resolver.Resolve<IObject>(idParam);

            subscribeSentences(sayWhenLook, obj.Interactions.OnInteract(AGSInteractions.LOOK));
            subscribeSentences(sayWhenInteract, obj.Interactions.OnInteract(AGSInteractions.INTERACT));

			return obj;
		}
Esempio n. 14
0
		public IInventoryWindow GetInventoryWindow(string id, IImage image, float itemWidth, float itemHeight, IInventory inventory)
		{
			TypedParameter idParam = new TypedParameter (typeof(string), id);
			TypedParameter imageParam = new TypedParameter (typeof(IImage), image);
			IInventoryWindow inventoryWindow = _resolver.Resolve<IInventoryWindow>(idParam, imageParam);
			inventoryWindow.Tint =  Colors.Transparent;
			inventoryWindow.ItemSize = new AGS.API.SizeF (itemWidth, itemHeight);
            inventoryWindow.Inventory = inventory ?? _gameState.Player.Inventory;
			return inventoryWindow;
		}
Esempio n. 15
0
		private static ISayBehavior getSayBehavior(float buttonHeight)
		{
			TypedParameter outfitParameter = new TypedParameter (typeof(IHasOutfit), null);
			ISayLocationProvider location = new MessageBoxLocation (AGSGame.Game);
			TypedParameter locationParameter = new TypedParameter (typeof(ISayLocationProvider), location);
			TypedParameter faceDirectionParameter = new TypedParameter (typeof(IFaceDirectionBehavior), null);
			TypedParameter configParameter = new TypedParameter (typeof(ISayConfig), AGSSayConfig.FromConfig(Config, buttonHeight));
			return AGSGame.Resolver.Container.Resolve<ISayBehavior>(locationParameter, outfitParameter, 
				faceDirectionParameter, configParameter);
		}
Esempio n. 16
0
		public static ITransport ProvideDefaultTransport(
			AutoFake fake,
			IDateTimeProvider dateTimeProvider = null,
			IMemoryStreamProvider memoryStreamProvider = null
		)
		{
			var dateTimeParam = new TypedParameter(typeof(IDateTimeProvider), dateTimeProvider);
			var memoryStreamParam = new TypedParameter(typeof(IMemoryStreamProvider), memoryStreamProvider);
			var serializerParam = new TypedParameter(typeof(IElasticsearchSerializer), null);
			return fake.Provide<ITransport, Transport>(dateTimeParam, serializerParam, memoryStreamParam);
		}
Esempio n. 17
0
		public IPanel GetPanel(string id, IImage image, float x, float y, bool addToUi = true)
		{
			TypedParameter idParam = new TypedParameter (typeof(string), id);
			TypedParameter imageParameter = new TypedParameter (typeof(IImage), image);
			IPanel panel = _resolver.Resolve<IPanel>(idParam, imageParameter);
			panel.X = x;
			panel.Y = y;
			if (addToUi)
				_gameState.UI.Add(panel);
			return panel;
		}
Esempio n. 18
0
		public IRoom GetRoom(string id, float leftEdge = 0f, float rightEdge = 0f, float topEdge = 0f, float bottomEdge = 0f)
		{
			AGSEdges edges = new AGSEdges (GetEdge(leftEdge), GetEdge(rightEdge), GetEdge(topEdge), GetEdge(bottomEdge));
			TypedParameter edgeParam = new TypedParameter (typeof(IAGSEdges), edges);
			TypedParameter idParam = new TypedParameter (typeof(string), id);
			IRoom room = _resolver.Resolve<IRoom>(idParam, edgeParam);
			room.Viewport.Camera = _resolver.Resolve<ICamera>();
            IGameState state = _resolver.Resolve<IGameState>();
            room.Viewport.Camera.Target = () => state.Player;
			return room;
		}
Esempio n. 19
0
 partial void beforeInitComponents(Resolver resolver, IOutfit outfit)
 {
     TypedParameter objParameter = new TypedParameter(typeof(IObject), this);
     if (outfit != null) _faceDirectionBehavior.CurrentDirectionalAnimation = outfit[AGSOutfit.Idle];
     TypedParameter outfitParameter = new TypedParameter(typeof(IHasOutfit), this);
     ISayLocationProvider location = resolver.Container.Resolve<ISayLocationProvider>(objParameter);
     TypedParameter locationParameter = new TypedParameter(typeof(ISayLocationProvider), location);
     TypedParameter faceDirectionParameter = new TypedParameter(typeof(IFaceDirectionBehavior), _faceDirectionBehavior);
     _sayBehavior = resolver.Container.Resolve<ISayBehavior>(locationParameter, outfitParameter, faceDirectionParameter);
     _walkBehavior = resolver.Container.Resolve<IWalkBehavior>(objParameter, outfitParameter, faceDirectionParameter);
     AddComponent(_sayBehavior);
     AddComponent(_walkBehavior);
 }
Esempio n. 20
0
        internal static object TryDecorateRegistration(
            IComponentRegistration registration,
            object instance,
            IComponentContext context,
            IEnumerable <Parameter> parameters)
        {
            var decoratorRegistrations = context.ComponentRegistry.DecoratorsFor(registration);

            // ReSharper disable once PossibleMultipleEnumeration
            if (!decoratorRegistrations.Any())
            {
                return(instance);
            }

            // ReSharper disable once PossibleMultipleEnumeration
            var decorators = decoratorRegistrations
                             .Select(r => new
            {
                Registration = r,
                Service      = r.Services.OfType <DecoratorService>().First()
            })
                             .ToArray();

            if (decorators.Length == 0)
            {
                return(instance);
            }

            var serviceType       = decorators[0].Service.ServiceType;
            var resolveParameters = parameters as Parameter[] ?? parameters.ToArray();

            var decoratorContext = DecoratorContext.Create(instance.GetType(), serviceType, instance);

            foreach (var decorator in decorators)
            {
                if (!decorator.Service.Condition(decoratorContext))
                {
                    continue;
                }

                var serviceParameter = new TypedParameter(serviceType, instance);
                var contextParameter = new TypedParameter(typeof(IDecoratorContext), decoratorContext);
                var invokeParameters = resolveParameters.Concat(new Parameter[] { serviceParameter, contextParameter });
                instance = context.ResolveComponent(decorator.Registration, invokeParameters);

                decoratorContext = decoratorContext.UpdateContext(instance);
            }

            return(instance);
        }
    public static void RegisterDecorator <T, TImplements>(this ContainerBuilder builder) where T : TImplements
    {
        var nameOfServiceToDecorate = GetOutermostNameOf <TImplements>();

        builder.RegisterType <T>();
        builder.Register(c =>
        {
            var impl = c.ResolveNamed <TImplements>(nameOfServiceToDecorate);
            impl     = c.Resolve <T>(TypedParameter.From(impl));
            return(impl);
        })
        .As <TImplements>()
        .Named <TImplements>(GetNameOf <TImplements>());
    }
Esempio n. 22
0
        public IAudioClip LoadAudioClip(string filePath, string id = null)
        {
            Debug.WriteLine("Loading AudioClip: " + filePath);
            ISoundData soundData = loadSoundData(filePath);

            if (soundData == null)
            {
                return(null);
            }
            TypedParameter idParam    = new TypedParameter(typeof(string), id ?? filePath);
            TypedParameter soundParam = new TypedParameter(typeof(ISoundData), soundData);

            return(_resolver.Container.Resolve <IAudioClip>(idParam, soundParam));
        }
Esempio n. 23
0
            public void ParametersGoToTheDecoratedInstance()
            {
                var expected = new Implementer1();
                var resolved = _container.Resolve <IParameterizedService>(TypedParameter.From <IService>(new Implementer1()));
                var dec2     = Assert.IsType <ParameterizedDecorator2>(resolved);

                Assert.Empty(dec2.Parameters);
                var dec1 = Assert.IsType <ParameterizedDecorator1>(dec2.Implementer);

                Assert.Empty(dec1.Parameters);
                var imp = Assert.IsType <ParameterizedImplementer>(dec1.Implementer);

                Assert.Single(imp.Parameters);
            }
Esempio n. 24
0
        protected override void AttachToComponentRegistration(IComponentRegistry componentRegistry, IComponentRegistration registration)
        {
            bool needsCacheManager = registration.Activator.LimitType
                                     .GetConstructors().Any(x => x.GetParameters().Any(xx => xx.ParameterType == typeof(ICacheManager)));

            if (needsCacheManager)
            {
                registration.Preparing += (sender, e) =>
                {
                    var parameter = new TypedParameter(typeof(ICacheManager), e.Context.Resolve <ICacheManager>(new TypedParameter(typeof(Type), registration.Activator.LimitType)));
                    e.Parameters = e.Parameters.Concat(new[] { parameter });
                };
            }
        }
        private static void RegisterBlockchain(ContainerBuilder builder, string blockchainType, Func <IComponentContext, IBlockchainApiClient> mockResolver)
        {
            builder.Register(mockResolver)
            .Named <IBlockchainApiClient>(blockchainType)
            .SingleInstance();

            builder.RegisterType <DepositWalletsBalanceProcessingPeriodicalHandler>()
            .As <IStartable>()
            .AutoActivate()
            .SingleInstance()
            .WithParameter(TypedParameter.From(TimeSpan.FromSeconds(1)))
            .WithParameter(TypedParameter.From(100))
            .WithParameter(TypedParameter.From(blockchainType));
        }
Esempio n. 26
0
        public async Task SendResumeAsyncTest()
        {
            var chain = Chain.PostToChain().Select(m => m.Text).Switch(
                new RegexCase <IDialog <string> >(new Regex("^resume"), (context, data) => { context.UserData.SetValue("resume", true); return(Chain.Return("resumed!")); }),
                new DefaultCase <string, IDialog <string> >((context, data) => { return(Chain.Return(data)); })).Unwrap().PostToUser();

            using (new FiberTestBase.ResolveMoqAssembly(chain))
                using (var container = Build(Options.InMemoryBotDataStore, chain))
                {
                    var msg = DialogTestBase.MakeTestMessage();
                    msg.Text = "testMsg";

                    using (var scope = DialogModule.BeginLifetimeScope(container, msg))
                    {
                        Func <IDialog <object> > MakeRoot = () => chain;
                        scope.Resolve <Func <IDialog <object> > >(TypedParameter.From(MakeRoot));

                        await Conversation.SendAsync(scope, msg);

                        var reply = scope.Resolve <Queue <IMessageActivity> >().Dequeue();

                        var botData = scope.Resolve <IBotData>();
                        await botData.LoadAsync(default(CancellationToken));

                        var dataBag = scope.Resolve <Func <IBotDataBag> >()();
                        Assert.IsTrue(dataBag.ContainsKey(ResumptionContext.RESUMPTION_CONTEXT_KEY));
                        Assert.IsNotNull(scope.Resolve <ConversationReference>());
                    }

                    var conversationReference = msg.ToConversationReference();
                    var continuationMessage   = conversationReference.GetPostToBotMessage();
                    using (var scope = DialogModule.BeginLifetimeScope(container, continuationMessage))
                    {
                        Func <IDialog <object> > MakeRoot = () => { throw new InvalidOperationException(); };
                        scope.Resolve <Func <IDialog <object> > >(TypedParameter.From(MakeRoot));

                        await scope.Resolve <IPostToBot>().PostAsync(new Activity {
                            Text = "resume"
                        }, CancellationToken.None);

                        var reply = scope.Resolve <Queue <IMessageActivity> >().Dequeue();
                        Assert.AreEqual("resumed!", reply.Text);

                        var botData = scope.Resolve <IBotData>();
                        await botData.LoadAsync(default(CancellationToken));

                        Assert.IsTrue(botData.UserData.GetValue <bool>("resume"));
                    }
                }
        }
Esempio n. 27
0
        protected override void Load(ContainerBuilder builder)
        {
            builder.RegisterType <IdentityStorage>()
            .As <Presentation.Common.Security.IIdentityStorage>()
            .SingleInstance()
            .WithParameter(TypedParameter.From(TimeSpan.FromMinutes(Configuration.CookieExpirationMins)));

            builder.RegisterDefaultDependencies(Assemblies.All.Presentation());

            RegisterLocalizer(builder);
            RegisterJsonizer(builder);

            base.Load(builder);
        }
Esempio n. 28
0
 public SavedAddressDialog CreateSavedAddressDialog(
     string prompt,
     string useSavedAddressPrompt,
     string saveAddressPrompt,
     IDictionary <string, string> savedAddresses,
     IEnumerable <string> saveOptionNames)
 {
     return(this.Scope.Resolve <SavedAddressDialog>(
                new NamedParameter("prompt", prompt),
                new NamedParameter("useSavedAddressPrompt", useSavedAddressPrompt),
                new NamedParameter("saveAddressPrompt", saveAddressPrompt),
                TypedParameter.From(savedAddresses),
                TypedParameter.From(saveOptionNames)));
 }
Esempio n. 29
0
        protected override void AttachToComponentRegistration(IComponentRegistry componentRegistry, IComponentRegistration registration)
        {
            registration.Preparing +=
                (sender, args) =>
            {
                var forType = args.Component.Activator.LimitType;

                var logParameter = new ResolvedParameter(
                    (p, c) => p.ParameterType == typeof(ILogger),
                    (p, c) => c.Resolve <ILogger>(TypedParameter.From(forType)));

                args.Parameters = args.Parameters.Union(new[] { logParameter });
            };
        }
Esempio n. 30
0
        public async Task LinqQuerySyntax_Throws_ClosureCaptureException()
        {
            var prompts = new[] { "p1", "p2" };
            var query   = new PromptDialog.PromptString(prompts[0], prompts[0], attempts: 1).Select(p => new PromptDialog.PromptString(prompts[1], prompts[1], attempts: 1)).Unwrap().PostToUser();

            using (var container = Build(includeReflection: false))
            {
                var formatter = container.Resolve <IFormatter>(TypedParameter.From(new Message()));
                using (var stream = new MemoryStream())
                {
                    formatter.Serialize(stream, query);
                }
            }
        }
Esempio n. 31
0
        private ISlider getSlider(string id, IImage image, IImage handleImage, float value, float min, float max,
                                  IObject parent = null, ITextConfig config = null, bool addToUi = true)
        {
            IObject graphics = _object.GetObject($"{id}(graphics)");

            graphics.Image          = image ?? new EmptyImage(10f, 100f);
            graphics.IgnoreViewport = true;
            ILabel label = null;

            if (config != null)
            {
                label = GetLabel($"{id}(label)", "", graphics.Width, 30f, 0f, -30f, parent, config, false);
                if (parent != null)
                {
                    label.RenderLayer = parent.RenderLayer;
                }
                label.Pivot = new PointF(0.5f, 0f);
            }

            IObject handle = _object.GetObject($"{id}(handle)");

            handle.Image          = handleImage ?? new EmptyImage(20f, 20f);
            handle.IgnoreViewport = true;

            TypedParameter idParam = new TypedParameter(typeof(string), id);
            ISlider        slider  = _resolver.Container.Resolve <ISlider>(idParam, idParam);

            setParent(slider, parent);
            setParent(handle, slider);
            setParent(graphics, slider);
            slider.Label          = label;
            slider.MinValue       = min;
            slider.MaxValue       = max;
            slider.Value          = value;
            slider.Graphics       = graphics;
            slider.HandleGraphics = handle;
            slider.IgnoreViewport = true;
            if (parent != null)
            {
                slider.RenderLayer                = parent.RenderLayer;
                slider.Graphics.RenderLayer       = parent.RenderLayer;
                slider.HandleGraphics.RenderLayer = parent.RenderLayer;
            }

            if (addToUi)
            {
                _gameState.UI.Add(slider);
            }
            return(slider);
        }
Esempio n. 32
0
        protected override void Load(ContainerBuilder builder)
        {
            var connectionStringManager = _settings.ConnectionString(x => x.DashJob.Db.DataConnString);

            builder.RegisterChaosKitty(_settings.CurrentValue.DashJob.ChaosKitty);

            builder.RegisterType <BroadcastRepository>()
            .As <IBroadcastRepository>()
            .WithParameter(TypedParameter.From(connectionStringManager))
            .SingleInstance();

            builder.RegisterType <BroadcastInProgressRepository>()
            .As <IBroadcastInProgressRepository>()
            .WithParameter(TypedParameter.From(connectionStringManager))
            .SingleInstance();

            builder.RegisterType <BalanceRepository>()
            .As <IBalanceRepository>()
            .WithParameter(TypedParameter.From(connectionStringManager))
            .SingleInstance();

            builder.RegisterType <BalancePositiveRepository>()
            .As <IBalancePositiveRepository>()
            .WithParameter(TypedParameter.From(connectionStringManager))
            .SingleInstance();

            builder.RegisterType <DashInsightClient>()
            .As <IDashInsightClient>()
            .WithParameter("url", _settings.CurrentValue.DashJob.InsightApiUrl)
            .SingleInstance();

            builder.RegisterType <PeriodicalService>()
            .As <IPeriodicalService>()
            .WithParameter(TypedParameter.From(_settings.CurrentValue.DashJob.MinConfirmations))
            .SingleInstance();

            builder.RegisterType <BalanceHandler>()
            .As <IStartable>()
            .AutoActivate()
            .WithParameter("period", _settings.CurrentValue.DashJob.BalanceCheckerInterval)
            .WithParameter("disableErrorsSending", _settings.CurrentValue.DashJob.DisableErrorsSending)
            .SingleInstance();

            builder.RegisterType <BroadcastHandler>()
            .As <IStartable>()
            .AutoActivate()
            .WithParameter("period", _settings.CurrentValue.DashJob.BroadcastCheckerInterval)
            .WithParameter("disableErrorsSending", _settings.CurrentValue.DashJob.DisableErrorsSending)
            .SingleInstance();
        }
Esempio n. 33
0
        IGetsQueryForTickets GetTicketQuery(IComponentContext context, IEnumerable <Parameter> autofacParams)
        {
            var baseProvider           = context.Resolve <TicketQueryProvider>();
            var specificationParameter = GetSpecificationParameter(autofacParams);

            if (specificationParameter == null)
            {
                return(baseProvider);
            }

            var decoratedParam = new TypedParameter(typeof(IGetsQueryForTickets), baseProvider);

            return(context.Resolve <SpecificationQueryProviderDecorator>(decoratedParam, specificationParameter));
        }
        public void ModuleInitalizeDomainServices()
        {
            var builder           = new ContainerBuilder();
            var domainServiceMock = new Mock <DomainService>();

            builder.RegisterInstance(domainServiceMock.Object).As <DomainService>();
            builder.RegisterModule <AutofacDomainServiceModule>();
            using (var container = builder.Build())
            {
                var service = container.Resolve <DomainService>(TypedParameter.From(domainServiceContext));
                Assert.IsNotNull(service);
                domainServiceMock.Verify(ds => ds.Initialize(domainServiceContext));
            }
        }
Esempio n. 35
0
        private void RegisterServiceClients(ContainerBuilder builder, AppSettings appSettings)
        {
            builder.RegisterType <NettingEngineInstanceManager>()
            .WithParameter(TypedParameter.From(appSettings.NettingEngineServiceClient.Instances))
            .As <INettingEngineInstanceManager>()
            .SingleInstance();

            builder.RegisterInstance(
                new AssetsService(new Uri(appSettings.AssetsServiceClient.ServiceUrl)))
            .As <IAssetsService>()
            .SingleInstance();

            builder.RegisterAssetsClient(AssetServiceSettings.Create(
                                             new Uri(appSettings.AssetsServiceClient.ServiceUrl),
                                             appSettings.TelegramReporterService.AssetsCacheExpirationPeriod));

            builder.RegisterBalancesClient(appSettings.BalancesServiceClient.ServiceUrl);
            builder.RegisterMarketMakerReportsClient(appSettings.MarketMakerReportsServiceClient, null);

            RegisterFiatMarketMakerReportsClient(builder,
                                                 appSettings.FiatMarketMakerReportsServiceClient);

            builder.RegisterMarketMakerArbitrageDetectorClient(new MarketMakerArbitrageDetectorServiceClientSettings
            {
                ServiceUrl = appSettings.MarketMakerArbitrageDetectorServiceClient.ServiceUrl
            }, null);

            builder.RegisterInstance(
                new LiquidityEngineUrlSettings(appSettings.LiquidityEngineServiceClient.Instances
                                               .Select(e => e.ServiceUrl).ToArray()))
            .SingleInstance();

            builder.RegisterIndexHedgingEngineClient(appSettings.IndexHedgingEngineClient, null);

            var cryptoIndexInstances = new List <CryptoIndexClientSettings>();

            foreach (var cics in appSettings.CryptoIndexServiceClient.Instances)
            {
                cryptoIndexInstances.Add(new CryptoIndexClientSettings
                {
                    DisplayName = cics.DisplayName, ServiceUrl = cics.ServiceUrl
                });
            }
            builder.RegisterInstance(
                new CryptoIndexInstancesSettings
            {
                Instances = cryptoIndexInstances.ToArray()
            })
            .SingleInstance();
        }
Esempio n. 36
0
        public void ActivatingArgsSuppliesParameters()
        {
            const int provided = 12;
            var       passed   = 0;

            var builder = new ContainerBuilder();

            builder.RegisterType <object>()
            .OnActivating(e => passed = e.Parameters.TypedAs <int>());
            var container = builder.Build();

            container.Resolve <object>(TypedParameter.From(provided));
            Assert.Equal(provided, passed);
        }
Esempio n. 37
0
		public AGSGameEvents(IEvent<AGSEventArgs> onLoad, IEvent<AGSEventArgs> onRepeatedlyExecute,
			IBlockingEvent<AGSEventArgs> onBeforeRender, IBlockingEvent<AGSEventArgs> onScreenResize,
			IEvent<AGSEventArgs> onSavedGameLoad, Resolver resolver)
		{
			OnLoad = onLoad;
			OnRepeatedlyExecute = onRepeatedlyExecute;
			OnBeforeRender = onBeforeRender;
			OnScreenResize = onScreenResize;
			OnSavedGameLoad = onSavedGameLoad;

			TypedParameter nullDefaults = new TypedParameter (typeof(IInteractions), null);
			TypedParameter nullObject = new TypedParameter (typeof(IObject), null);
			DefaultInteractions = resolver.Container.Resolve<IInteractions>(nullDefaults, nullObject);
		}
Esempio n. 38
0
        protected virtual IList <TypedParameter> GetDataServiceParameters(string serviceName, IList <TransactionTrackingQueryParameter> possibleParameters,
                                                                          out DataServicePublishFlags publishFlags)
        {
            publishFlags = DataServicePublishFlags.PublishToEndpointVersion20;

            List <TypedParameter> typedParameters = new List <TypedParameter>(possibleParameters.Count);

            foreach (TransactionTrackingQueryParameter parameter in possibleParameters)
            {
                TypedParameter typedParameter = new TypedParameter(parameter.ToString());
                switch (parameter)
                {
                case TransactionTrackingQueryParameter.TransactionId:
                case TransactionTrackingQueryParameter.Dataflow:
                case TransactionTrackingQueryParameter.Userid:
                case TransactionTrackingQueryParameter.Recipients:
                case TransactionTrackingQueryParameter.Organization:
                    typedParameter.IsRequired = false;
                    typedParameter.Type       = typeof(string);
                    break;

                case TransactionTrackingQueryParameter.toDate:
                case TransactionTrackingQueryParameter.fromDate:
                    typedParameter.IsRequired = false;
                    typedParameter.Type       = typeof(DateTime);
                    break;

                case TransactionTrackingQueryParameter.Status:
                    typedParameter.IsRequired       = false;
                    typedParameter.Type             = typeof(string);
                    typedParameter.AcceptableValues = CollectionUtils.CreateObjectList(EnumUtils.GetAllDescriptions <CommonTransactionStatusCode>());
                    break;

                case TransactionTrackingQueryParameter.Type:
                    typedParameter.IsRequired       = false;
                    typedParameter.Type             = typeof(string);
                    typedParameter.AcceptableValues = CollectionUtils.CreateObjectList(CollectionUtils.CreateStringList(NodeMethod.Download,
                                                                                                                        NodeMethod.Execute,
                                                                                                                        NodeMethod.GetStatus,
                                                                                                                        NodeMethod.Notify,
                                                                                                                        NodeMethod.Query,
                                                                                                                        NodeMethod.Solicit,
                                                                                                                        NodeMethod.Submit));
                    break;
                }
                typedParameters.Add(typedParameter);
            }
            return(typedParameters);
        }
Esempio n. 39
0
        public async Task PromptFailureAsync <T>(Action <IDialogContext, ResumeAfter <T> > prompt)
        {
            var dialogRoot = MockDialog <T>();

            dialogRoot
            .Setup(d => d.StartAsync(It.IsAny <IDialogContext>()))
            .Returns <IDialogContext>(async c => { c.Wait(dialogRoot.Object.FirstMessage); });
            dialogRoot
            .Setup(d => d.FirstMessage(It.IsAny <IDialogContext>(), It.IsAny <IAwaitable <Connector.Message> >()))
            .Returns <IDialogContext, IAwaitable <object> >(async(c, a) => { prompt(c, dialogRoot.Object.PromptResult); });

            Func <IDialog <T> > MakeRoot = () => dialogRoot.Object;
            var toBot = new Message()
            {
                ConversationId = Guid.NewGuid().ToString()
            };

            using (new FiberTestBase.ResolveMoqAssembly(dialogRoot.Object))
                using (var container = Build(dialogRoot.Object))
                {
                    using (var scope = container.BeginLifetimeScope())
                    {
                        var store = scope.Resolve <IDialogContextStore>(TypedParameter.From(toBot));

                        await store.PostAsync(toBot, MakeRoot);

                        AssertMentions(PromptText, scope);
                    }

                    using (var scope = container.BeginLifetimeScope())
                    {
                        var store = scope.Resolve <IDialogContextStore>(TypedParameter.From(toBot));

                        await store.PostAsync(toBot, MakeRoot);

                        AssertMentions(RetryText, scope);
                    }

                    using (var scope = container.BeginLifetimeScope())
                    {
                        var store = scope.Resolve <IDialogContextStore>(TypedParameter.From(toBot));

                        await store.PostAsync(toBot, MakeRoot);

                        AssertMentions("too many attempts", scope);
                        dialogRoot.Verify(d => d.PromptResult(It.IsAny <IDialogContext>(), It.Is <IAwaitable <T> >(actual => actual.ToTask().IsFaulted)), Times.Once);
                    }
                }
        }
Esempio n. 40
0
        protected override void AttachToComponentRegistration(IComponentRegistry componentRegistry, IComponentRegistration registration)
        {
            // Ignore components that provide loggers
            if (registration.Services.OfType <TypedService>().Any(ts => ts.ServiceType == typeof(ILogger)))
            {
                return;
            }

            registration.Preparing += (sender, args) =>
            {
                var     serilogLogger = Log.ForContext(registration.Activator.LimitType);
                ILogger wridoLogger   = new SerilogLogger(serilogLogger);
                args.Parameters = new[] { TypedParameter.From(wridoLogger) }.Concat(args.Parameters);
            };
        }
Esempio n. 41
0
		public ILabel GetLabel(string id, string text, float width, float height, float x, float y, ITextConfig config = null, bool addToUi = true)
		{
			AGS.API.SizeF baseSize = new AGS.API.SizeF(width, height);			
			TypedParameter idParam = new TypedParameter (typeof(string), id);
			ILabel label = _resolver.Resolve<ILabel>(idParam);
            label.LabelRenderSize = baseSize;
			label.Text = text;
			label.X = x;
			label.Y = y;
			label.Tint =  Colors.Transparent;
			label.TextConfig = config ?? new AGSTextConfig();
			if (addToUi)
				_gameState.UI.Add(label);
			return label;
		}
        public void HandleParameters_RecognizedSurplusParameters()
        {
            SetupResult.On(queryView).Call(queryView.HqlQueryText).
                Return(QueryPresenterTests.parametrizedOne);
            parameters["name"] = new TypedParameter("name",typeof(string),"ayende");
            parameters["avg"] = new TypedParameter("avg",typeof(float),4.5f);

            queryView.SetParameterMissing("name",true);
            queryView.SetParameterMissing("id",false);
            queryView.SetParameterMissing("avg",true);

            mocks.ReplayAll();

            context.AnalyzeParameters();
        }
Esempio n. 43
0
        private void RegisterOrderBooks(ContainerBuilder builder)
        {
            var instanceName = _settings.CurrentValue.HighFrequencyTradingService.Cache.OrderBooksCacheInstance;

            RegisterRedisCache(builder, instanceName);

            builder.RegisterType <OrderBookService>()
            .As <IOrderBooksService>()
            .WithParameter(TypedParameter.From(_settings.CurrentValue.HighFrequencyTradingService.Cache.OrderBooksCacheKeyPattern))
            .WithParameter(
                new ResolvedParameter(
                    (pi, ctx) => pi.ParameterType == typeof(IDistributedCache),
                    (pi, ctx) => ctx.ResolveKeyed <IDistributedCache>(instanceName)))
            .SingleInstance();
        }
Esempio n. 44
0
        public static void TypeP()
        {
            using (var scope = Container.BeginLifetimeScope())
            {
                //var foo1 = scope.Resolve<Foo>();
                //Console.WriteLine(foo1.GetNumberOfRules());

                // resolve with custom rules, ok¡
                var rules = new List <IRule>();
                rules.Add(new Rule1());
                TypedParameter param = new TypedParameter(typeof(IEnumerable <IRule>), rules);
                var            foo2  = scope.Resolve <Foo>(param);
                Console.WriteLine(foo2.GetNumberOfRules());
            }
        }
Esempio n. 45
0
 public override void Init(IEntity entity)
 {
     base.Init(entity);
     entity.Bind <IImageComponent>(c =>
     {
         TypedParameter imageParam = new TypedParameter(typeof(IHasImage), c);
         _scale = _resolver.Container.Resolve <IScale>(imageParam);
         _scale.PropertyChanged += onScalePropertyChanged;
     }, c =>
     {
         _scale             = null;
         c.PropertyChanged -= onScalePropertyChanged;
     });
     entity.Bind <IAnimationComponent>(c => _animation = c, _ => _animation = null);
 }
Esempio n. 46
0
 /// <summary>
 /// Registers <see cref="ChaosKitty"/> singleton as <see cref="IChaosKitty"/>
 /// </summary>
 /// <param name="builder">The DI container builder</param>
 /// <param name="settings">Chaos settings. pass null to disable chaos</param>
 public static void RegisterChaosKitty([NotNull] this ContainerBuilder builder, [CanBeNull] ChaosSettings settings)
 {
     if (settings != null)
     {
         builder.RegisterType <ChaosKitty>()
         .As <IChaosKitty>()
         .WithParameter(TypedParameter.From(settings.StateOfChaos))
         .SingleInstance();
     }
     else
     {
         builder.RegisterType <SilentChaosKitty>()
         .As <IChaosKitty>();
     }
 }
            protected override void Register(RegistrationBuilder builder)
            {
                builder.Include(c =>
                {
                    c.RegisterInstance(this.configurationProvider)
                    .As <IConfigurationProvider>()
                    .SingleInstance()
                    .IfNotRegistered(typeof(IConfigurationProvider));

                    c.RegisterType <SettingsProvider>()
                    .As <ISettingsProvider>()
                    .WithParameter(TypedParameter.From(this.configurationProvider))
                    .SingleInstance();
                });
            }
Esempio n. 48
0
        protected override void AttachToComponentRegistration(Autofac.Core.IComponentRegistry componentRegistry, Autofac.Core.IComponentRegistration registration) {
            var needsCacheManager = registration.Activator.LimitType
                .GetConstructors()
                .Any(x => x.GetParameters()
                    .Any(xx => xx.ParameterType == typeof(ICacheManager)));

            if (needsCacheManager) {
                registration.Preparing += (sender, e) => {
                    var parameter = new TypedParameter(
                        typeof(ICacheManager),
                        e.Context.Resolve<ICacheManager>(new TypedParameter(typeof(Type), registration.Activator.LimitType)));
                    e.Parameters = e.Parameters.Concat(new[] { parameter });
                };
            }
        }
Esempio n. 49
0
        protected override void Load(ContainerBuilder builder)
        {
            builder.RegisterInstance(_log)
            .As <ILog>()
            .SingleInstance();

            builder.RegisterType <PersonalDataService>()
            .WithParameter(TypedParameter.From(_personalDataServiceClientSettings))
            .As <IPersonalDataService>()
            .SingleInstance();

            builder.RegisterType <ClientSwiftCredentialsInMemoryCache>()
            .As <IClientSwiftCredentialsCache>()
            .SingleInstance();
        }
        public void InterceptorCanBeWiredUsingInterceptedBy()
        {
            var builder = new ContainerBuilder();

            builder.RegisterType <D>()
            .EnableClassInterceptors()
            .InterceptedBy(typeof(AddOneInterceptor));
            builder.RegisterType <AddOneInterceptor>();
            var container = builder.Build();
            var i         = 10;
            var c         = container.Resolve <D>(TypedParameter.From(i));
            var got       = c.GetI();

            Assert.AreEqual(i + 1, got);
        }
Esempio n. 51
0
        /// <summary>
        /// Return the Query, Solicit, or Execute data service parameters for specified data service.
        /// This method should NOT call GetServiceImplementation().
        /// </summary>
        public override IList <TypedParameter> GetDataServiceParameters(string serviceName, out DataServicePublishFlags publishFlags)
        {
            publishFlags = DataServicePublishFlags.PublishToEndpointVersion11And20;
            List <TypedParameter> list = new List <TypedParameter>(1);

            var typedParameter = new TypedParameter(SERVICE_CATEGORY_KEY, "The service category to return (AllServices, Solicit, Query, Execute or Submit)",
                                                    true, typeof(string), true, SERVICE_CATEGORY_ALL_SERVICES);
            List <object> acceptableValues = new List <object>(10);

            acceptableValues.Add("AllServices");
            acceptableValues.AddRange(CollectionUtils.CreateObjectList(NodeMethod.Execute, NodeMethod.Query, NodeMethod.Solicit, NodeMethod.Submit));
            typedParameter.AcceptableValues = acceptableValues;
            list.Add(typedParameter);
            return(list);
        }
Esempio n. 52
0
        public void PropertySpecifiedAsResolveParameterWhenAutowiredMayBeBothConstructorAndProperty()
        {
            // Issue #289 tried to get parameters to work as passed in directly to resolve
            // but issue #789 found a problem with trying to do that. Now it's just
            // manual property injection that allows parameters.
            var builder = new ContainerBuilder();

            builder.RegisterType <ConstructorParamNotAttachedToProperty>().PropertiesAutowired();
            var container = builder.Build();

            var instance = container.Resolve <ConstructorParamNotAttachedToProperty>(TypedParameter.From("test"));

            Assert.Equal("test", instance._id);
            Assert.Equal("test", instance.Name);
        }
Esempio n. 53
0
        private void RegisterServices(ContainerBuilder builder)
        {
            builder.RegisterType <OrderBooksProviderService>()
            .WithParameter(TypedParameter.From(_settings.CurrentValue.OrderBookService.Db.OrderBooksCacheKeyPattern))
            .As <IOrderBooksProviderService>()
            .SingleInstance();

            builder.RegisterType <ExecutionOrderBooksProviderService>()
            .As <IExecutionOrderBooksProviderService>()
            .SingleInstance();

            builder.RegisterType <ConvertService>()
            .As <IConvertService>()
            .SingleInstance();
        }
 private void ux_Ok_Click(object sender, EventArgs e)
 {
     object val;
     Type type = (Type)types[ux_TypeList.Text];
     try
     {
         val = Convert.ChangeType(ux_Value.Text, type);
     }
     catch (Exception)
     {
         MessageBox.Show("Can't convert '" + ux_Value.Text + "' to " + ux_TypeList.Text);
         return;
     }
     parameter = new TypedParameter(ux_Name.Text,
         type, val);
     DialogResult = DialogResult.OK;
     Close();
 }
Esempio n. 55
0
        ConsoleOverlaySetView CreateConsoleOverlaySetView(IContext container, IEnumerable<Parameter> parameters)
        {
            ITexture consoleTexture = container.Resolve<ITexture>(new TypedParameter(typeof(Texture2D), ContentManager.Load<Texture2D>("Textures/blank")));
            IFont consoleFont = container.Resolve<IFont>(new TypedParameter(typeof(SpriteFont), ContentManager.Load<SpriteFont>("Fonts/detailsFont")));
            int edgeGap = OverlaySetView.EDGE_GAP;

            Rectangle consoleWindow = new Rectangle(edgeGap, edgeGap, (int)(ScreenSize.X / 2) - 30 - edgeGap, (int)ScreenSize.Y - InputBoxHeight - 3 * edgeGap);
            Rectangle messageWindow = new Rectangle((int)(ScreenSize.X / 2) + 30 + edgeGap, edgeGap, (int)(ScreenSize.X / 2) - 30 - 2 * edgeGap, (int)(ScreenSize.Y / 2) - 2 * edgeGap);
            Rectangle inputWindow = new Rectangle(edgeGap, (int)ScreenSize.Y - edgeGap - InputBoxHeight, (int)ScreenSize.X - 2 * edgeGap, InputBoxHeight);
            Rectangle possibleCompletionsWindow = new Rectangle((int)(consoleWindow.Right / 2), consoleWindow.Bottom - edgeGap, (int)(messageWindow.Width / 2), 0);

            var fontParameter = new TypedParameter(typeof(IFont), consoleFont);
            var commandConsoleParameter = new TypedParameter(typeof(IConsole<string>), container.Resolve<ICommandConsole>());
            var messageConsoleParameter = new TypedParameter(typeof(IConsole<ChatMessage>), container.Resolve<IMessageConsole>());
            var inputView = container.Resolve<InputOverlayView>(fontParameter, new NamedParameter("inputWindow", inputWindow));
            var commandConsoleView = container.Resolve<LogOverlayView<string>>(fontParameter, commandConsoleParameter, new NamedParameter("logWindow", consoleWindow), new TypedParameter(typeof(Color), Color.White));
            var messageConsoleView = container.Resolve<LogOverlayView<ChatMessage>>(fontParameter, messageConsoleParameter, new NamedParameter("logWindow", messageWindow), new TypedParameter(typeof(Color), Color.Green));
            var possibleCommandsView = container.Resolve<PossibleCommandsLogHudView>(fontParameter, new TypedParameter(typeof(ICommandConsole), container.Resolve<ICommandConsole>()), new NamedParameter("templateWindow", possibleCompletionsWindow), new TypedParameter(typeof(Color), Color.Yellow));

            return new ConsoleOverlaySetView(inputView, commandConsoleView, messageConsoleView, possibleCommandsView, container.Resolve<ISpriteBatch>(), consoleTexture, consoleFont);
        }
Esempio n. 56
0
		public IDialogOption GetDialogOption(string text, ITextConfig config = null, ITextConfig hoverConfig = null,
			ITextConfig hasBeenChosenConfig = null, bool speakOption = true, bool showOnce = false)
		{
			IGame game = _resolver.Resolve<IGame>();
			if (config == null) config = new AGSTextConfig (autoFit: AutoFit.TextShouldWrapAndLabelShouldFitHeight,
				brush: Hooks.BrushLoader.LoadSolidBrush(Colors.White), font: Hooks.FontLoader.LoadFont(null,10f));
			if (hoverConfig == null) hoverConfig = new AGSTextConfig (autoFit: AutoFit.TextShouldWrapAndLabelShouldFitHeight,
				brush: Hooks.BrushLoader.LoadSolidBrush(Colors.Yellow), font: Hooks.FontLoader.LoadFont(null, 10f));
            if (hasBeenChosenConfig == null) hasBeenChosenConfig = new AGSTextConfig(autoFit: AutoFit.TextShouldWrapAndLabelShouldFitHeight,
                brush: Hooks.BrushLoader.LoadSolidBrush(Colors.Gray), font: Hooks.FontLoader.LoadFont(null, 10f));
			ILabel label = _ui.GetLabel(string.Format("Dialog option: {0}", text), text, game.Settings.VirtualResolution.Width, 20f, 0f, 0f, config);
			label.Enabled = true;
			TypedParameter labelParam = new TypedParameter (typeof(ILabel), label);
			NamedParameter speakParam = new NamedParameter ("speakOption", speakOption);
			NamedParameter showOnceParam = new NamedParameter ("showOnce", showOnce);
            NamedParameter hoverParam = new NamedParameter ("hoverConfig", hoverConfig);
            NamedParameter wasChosenParam = new NamedParameter("hasBeenChosenConfig", hasBeenChosenConfig);
            TypedParameter playerParam = new TypedParameter(typeof(ICharacter), _gameState.Player);
            IDialogActions dialogActions = _resolver.Resolve<IDialogActions>(playerParam);
            TypedParameter dialogActionsParam = new TypedParameter(typeof(IDialogActions), dialogActions);
            IDialogOption option = _resolver.Resolve<IDialogOption>(labelParam, speakParam, showOnceParam, hoverParam, 
                                                                    wasChosenParam, playerParam, dialogActionsParam);
			return option;
		}
Esempio n. 57
0
		public IDialog GetDialog(string id, float x = 0f, float y = 0f, IObject graphics = null, bool showWhileOptionsAreRunning = false, 
			params IDialogOption[] options)
		{
			TypedParameter showParam = new TypedParameter (typeof(bool), showWhileOptionsAreRunning);
			if (graphics == null)
			{
				graphics = _object.GetObject(id);
				graphics.Tint =  Colors.Black;
				graphics.Anchor = new PointF ();
                graphics.IgnoreViewport = true;
                graphics.IgnoreScalingArea = true;
				_gameState.UI.Add(graphics);
			}
			TypedParameter graphicsParam = new TypedParameter (typeof(IObject), graphics);
            TypedParameter playerParam = new TypedParameter(typeof(ICharacter), _gameState.Player);
            IDialogActions dialogActions = _resolver.Resolve<IDialogActions>(playerParam);
            TypedParameter dialogActionsParam = new TypedParameter(typeof(IDialogActions), dialogActions);
            IDialog dialog = _resolver.Resolve<IDialog>(showParam, graphicsParam, dialogActionsParam);
			foreach (IDialogOption option in options)
			{
				dialog.Options.Add(option);
			}
			return dialog;
		}
 private QueryParameters TypedParameterToQueryParameter(TypedParameter[] parameters)
 {
     QueryParameters qp = new QueryParameters(new IType[0], new object[0]);
     qp.NamedParameters = TypedParametersToIDictionary(parameters);
     return qp;
 }
 private static TypedParameter[] ConvertDictionaryToTypedParameterArray(IDictionary parameters)
 {
     if (parameters == null)
         return new TypedParameter[0];
     TypedParameter[] typedParameters = new TypedParameter[parameters.Count];
     int i = 0;
     foreach (DictionaryEntry entry in parameters)
     {
         typedParameters[i] = ((TypedParameter) entry.Value);
         i++;
     }
     return typedParameters;
 }
 private static Dictionary<string, TypedValue> TypedParametersToIDictionary(TypedParameter[] parameters)
 {
     Dictionary<string, TypedValue> ht = new Dictionary<string, TypedValue>(parameters.Length);
     foreach (TypedParameter parameter in parameters)
     {
         ht[parameter.Name] = new TypedValue(parameter.IType, parameter.Value, EntityMode.Poco);
     }
     return ht;
 }