private void LoadedHandler(object sender, RoutedEventArgs e) { if (DesignerProperties.GetIsInDesignMode(this)) return; _game = new MyGame(ParticleEditor.Handle); var controlArg = new ConstructorArgument( ApplicationProperties.IParticleEditorControllerGameWorldArgName, _game.GameWorld); _particleController = DependencyInjectorHelper .ParticleEditorKernel .Get<IParticleEditorController>(controlArg); _particleController.ParticleEditorControl = this; /*_transformModeModel = DependencyInjectorHelper .ParticleEditorKernel .Get<TransformModeViewModel>(); TranslateButton.DataContext = _transformModeModel; FreeMovementButton.DataContext = _transformModeModel; RotateButton.DataContext = _transformModeModel; ScaleButton.DataContext = _transformModeModel;*/ }
public SceneViewerControl() { Tabs = new ObservableCollection<SceneTabViewModel>(); RemoveTab = new RelayCommand((obj) => { Tabs.Remove(obj as SceneTabViewModel); //MessageBox.Show("New Folder!"); }); InitializeComponent(); AssignPanelEventHandling(xna); ScenesControl.ItemsSource = Tabs; if (DesignerProperties.GetIsInDesignMode(this)) return; _game = new MyGame(xna.Handle); _game.GameWorld.UpdateWorld = false; _context = _game.GraphicsContext; var gameWorldArg = new ConstructorArgument( ApplicationProperties.ISceneViewerGameWorldArgName, _game.GameWorld); _controller = DependencyInjectorHelper .MainWindowKernel .Get<ISceneViewerController>(gameWorldArg); _controller.Control = this; }
private void BindDataAccess() { ConstructorArgument parameter = new ConstructorArgument("connectionString", Settings.EntityConnectionString); Bind<mbEntities>().ToSelf().InRequestScope().WithParameter(parameter); Bind(typeof(IRepository<>)).To(typeof(EntityRepository<>)).InRequestScope(); Bind<IUnitOfWork>().ToMethod(item => item.Kernel.Get<mbEntities>()); Bind<DbContext>().ToMethod(item => item.Kernel.Get<mbEntities>()); }
public override void Load() { ConstructorArgument parameter = new ConstructorArgument("connectionString", Settings.EntityConnectionString); Bind<mbEntities>().ToSelf().InRequestScope().WithParameter(parameter); Bind<IUnitOfWork>().ToMethod(item => item.Kernel.Get<mbEntities>()); Bind<DbContext>().ToMethod(item => item.Kernel.Get<mbEntities>()); Bind<IStoredProcedures>().To<StoredProcedures>().InRequestScope(); Bind(typeof(IRepository<>)).To(typeof(EntityRepository<>)).InRequestScope(); }
public void CtorIsUsedWhenParameterIsSupplied() { kernel.Bind<Barracks>().ToSelf(); var constructorArgument = new ConstructorArgument("warrior", new Samurai(new Sword())); var barracks = kernel.Get<Barracks>(constructorArgument); barracks.Should().NotBeNull(); barracks.Warrior.Should().NotBeNull(); barracks.Warrior.Weapon.Should().NotBeNull(); barracks.Weapon.Should().BeNull(); }
public FilterViewModel CreateEditorViewModel(Filter filter) { var parameter = new ConstructorArgument("filter", filter,true); if (filter is CompositeFilter) { return _kernel.Get<CompositeFilterViewModel>(parameter); } else { return _kernel.Get<FilterViewModel>(parameter); } }
public void CtorIsUsedWhenParameterIsSupplied() { using(IKernel kernel = new StandardKernel()) { kernel.Bind<Barracks>().ToSelf(); var constructorArgument = new ConstructorArgument("warrior", new Samurai(new Sword())); var barracks = kernel.Get<Barracks>(constructorArgument); Assert.NotNull(barracks); Assert.NotNull(barracks.Warrior); Assert.NotNull(barracks.Warrior.Weapon); Assert.Null(barracks.Weapon); } }
public void Setup() { _kernel = new StandardKernel(new AccountProviderModule()); _accessToken = "some access token"; _userCredentials = new UserCredential { Email = "some email", SocialNetworkId = "some user id in social network", AccessToken = _accessToken, SocialNetworkName = "some social network", AccessTokenExpiresIn = "24:00:00", ConsumerSecret = "some consumer secret", ConsumerKey = "some consumer key", AccessTokenSecret = "some access token secret" }; _userCredentialsParam = new ConstructorArgument("userCredential", _userCredentials); }
public void Get_Google_Account_Provider_Instance() { // Arrange _socialNetwork = "Google"; var userCredentialParam = new ConstructorArgument("userCredential", _userCredentials); //Act var provider = _kernel.Get<IAccountProvider>(_socialNetwork, userCredentialParam); //Assert provider.Should() .BeOfType<GoogleAccountProvider>("we asked account provider instance for google"); }
/// <summary> /// Creates a <see cref="T:System.ServiceModel.ServiceHost"/> for a /// specified type of service with a specific base address. /// </summary> /// <param name="serviceType"> /// Specifies the type of service to host. /// </param> /// <param name="baseAddresses"> /// The <see cref="T:System.Array"/> of type <see cref="T:System.Uri"/> /// that contains the base addresses for the service hosted. /// </param> /// <returns> /// A <see cref="T:System.ServiceModel.ServiceHost"/> for the type of /// service specified with a specific base address. /// </returns> protected override ServiceHost CreateServiceHost( Type serviceType, Uri[] baseAddresses ) { var serviceTypeParameter = new ConstructorArgument( "serviceType", serviceType ); var baseAddressesParameter = new ConstructorArgument( "baseAddresses", baseAddresses ); return KernelContainer.Kernel.Get<ServiceHost>( serviceTypeParameter, baseAddressesParameter ); }
private static AbstractCommandModel MapButtonWrapperToModel(AbstractDialogModel dialog, AbstractButton wrapper) { var kernal = Application.Current.CurrentKernel(); var modelParameter = new ConstructorArgument("model", dialog); if (wrapper is ResultButton) return kernal.Get<ReturnResultModel>( new IParameter[] { modelParameter, new ConstructorArgument("result", (wrapper as ResultButton).TaskResult) }); if (wrapper is UrlButton) { var link = kernal.Get<UrlLink>(); link.Target = (wrapper as UrlButton).Value; return kernal.Get<OpenLinkModel>( new IParameter[] { modelParameter, new ConstructorArgument("link", link) } ); } if (wrapper is SettingsButton) { var link = kernal.Get<SettingsLink>(); link.Target = (wrapper as SettingsButton).Key; link.Value = "true"; return kernal.Get<ModifySettingsModel>( new IParameter[] { modelParameter, new ConstructorArgument("wrapper", link) } ); } if (wrapper is TopicButton) { var value = (wrapper as TopicButton).Value; return kernal.Get<OpenTopicModel>( new IParameter[] { modelParameter, new ConstructorArgument("topic",value) } ); } if (wrapper is StoredResultButton) { return kernal.Get<ReturnStoredResultModel>( new IParameter[] { modelParameter, new ConstructorArgument("key",(wrapper as StoredResultButton).Key) }); } if (wrapper is OpenAdvancedMenuButton) { var group = (wrapper as OpenAdvancedMenuButton).Group; return kernal.Get<OpenAdvancedButtonModel>( new IParameter[] { modelParameter, new ConstructorArgument("group", group) }); } if (wrapper is DisabledButton) return kernal.Get<DisabledCommandModel>(modelParameter); if (wrapper is CancelButton) return kernal.Get<CancelButtonModel>(modelParameter); if (wrapper is DoNothingButton) return kernal.Get<DoNothingCommandModel>(modelParameter); return null; }
public TestableStandardInstanceProvider( Func<Planning.Bindings.IBindingMetadata, bool> constraint, string name, ConstructorArgument[] constructorArguments, object[] expectedArguments) { this.constraint = constraint; this.name = name; this.constructorArguments = constructorArguments; this.expectedArguments = expectedArguments; }
private void OnSourceControlClick(CommandBarButton Ctrl, ref bool CancelDefault) { if (_sourceControlPresenter == null) { var kernel = new StandardKernel(new SourceControlBindings()); var vbeArg = new ConstructorArgument("vbe", this.IDE); var addinArg = new ConstructorArgument("addin", this.AddIn); _sourceControlPresenter = kernel.Get<SourceControlPresenter>(vbeArg, addinArg); } _sourceControlPresenter.Show(); }
protected override ServiceHost CreateServiceHost(Type serviceType, Uri[] baseAddresses) { var serviceTypeParameter = new ConstructorArgument("serviceType", serviceType); var baseAddressesParameter = new ConstructorArgument("baseAddresses", baseAddresses); return kernelInstance.Get<WebServiceHost>("webService", serviceTypeParameter, baseAddressesParameter); }
/// <summary> /// Creates a <see cref="T:System.ServiceModel.ServiceHost"/> for a /// specified type of service with a specific base address. /// </summary> /// <param name="serviceType"> /// Specifies the type of service to host. /// </param> /// <param name="baseAddresses"> /// The <see cref="T:System.Array"/> of type <see cref="T:System.Uri"/> /// that contains the base addresses for the service hosted. /// </param> /// <returns> /// A <see cref="T:System.ServiceModel.ServiceHost"/> for the type of /// service specified with a specific base address. /// </returns> protected override ServiceHost CreateServiceHost(Type serviceType, Uri[] baseAddresses) { var baseAddressesArgument = new ConstructorArgument("baseAddresses", baseAddresses); var serviceTypeArgument = new ConstructorArgument("serviceType", serviceType); return kernelInstance.Get<NinjectDataServiceHost>(serviceTypeArgument, baseAddressesArgument); }
public void LoadedHandler(object sender, RoutedEventArgs e) { if (DesignerProperties.GetIsInDesignMode(this)) return; var controlArg = new ConstructorArgument( ApplicationProperties.IGameObjectsControllerArgName, this); _controller = DependencyInjectorHelper .MainWindowKernel .Get<IGameObjectsController>(controlArg); base.DataContext = _controller.LoadGameObjectsTree(); #region Initialize Commands AddNewSceneCommand = new RelayCommand(AddSceneTo); AddNewFolderCommand = new RelayCommand( (obj) => { MessageBox.Show("TODO add new folder"); }); ImportSceneCommand = new RelayCommand( (obj) => { MessageBox.Show("TODO import scene"); }); #endregion }
/// <summary> /// Gets the constructor arguments that shall be passed with the instance request. /// </summary> /// <param name="methodInfo">The method info of the method that was called on the factory.</param> /// <param name="arguments">The arguments that were passed to the factory.</param> /// <returns>The constructor arguments that shall be passed with the instance request.</returns> protected virtual IConstructorArgument[] GetConstructorArguments(MethodInfo methodInfo, object[] arguments) { var parameters = methodInfo.GetParameters(); var constructorArguments = new ConstructorArgument[parameters.Length]; for (int i = 0; i < parameters.Length; i++) { constructorArguments[i] = new ConstructorArgument(parameters[i].Name, arguments[i]); } return constructorArguments; }
private void LoadedHandler(object sender, RoutedEventArgs e) { if (DesignerProperties.GetIsInDesignMode(this)) return; _game = new MyGame(PuppeteerEditor.Handle); _game.GameWorld.UpdateWorld = false; var controlArg = new ConstructorArgument( ApplicationProperties.IPuppeteerControllerGameWorldArgName, _game.GameWorld); PuppeteerController = DependencyInjectorHelper .PuppeteerKernel .Get<IPuppeteerController>(controlArg); //_puppeteerController.GameWorld = _game.GameWorld; PuppeteerController.PuppeteerControl = this; if (OnLoaded != null) OnLoaded(this); SelectBoneMode.IsChecked = true; _transformModeModel = DependencyInjectorHelper .PuppeteerKernel .Get<TransformModeViewModel>(); TranslateButton.DataContext = _transformModeModel; FreeMovementButton.DataContext = _transformModeModel; RotateButton.DataContext = _transformModeModel; ScaleButton.DataContext = _transformModeModel; _workingModesModel = DependencyInjectorHelper .PuppeteerKernel .Get<PuppeteerWorkingModesModel>(); SelectBoneMode.DataContext = _workingModesModel; SelectAssetMode.DataContext = _workingModesModel; AddBoneMode.DataContext = _workingModesModel; }
public static IAccountProvider GetAccountProvider(UserCredential credential) { var userCredential = new ConstructorArgument("userCredential", credential); return MvcApplication.Container.Get<IAccountProvider>(credential.SocialNetworkName, userCredential); }
public static void init(IKernel _kernel) { //var _kernel = new StandardKernel(); Microsoft.Practices.ServiceLocation.ServiceLocator.SetLocatorProvider(() => { return new CommonServiceLocator.NinjectAdapter.NinjectServiceLocator(_kernel); }); Configure .Using(new NInjectContainerAdapter(_kernel)) .ConfigureData<EFConfiguration>(EfConfig => { EfConfig.WithObjectContext(() => { ConstructorArgument parameter2 = new ConstructorArgument("connectionString", System.Configuration.ConfigurationManager.ConnectionStrings["HelloWordEntities"].ConnectionString); //装系统的方法注入构造函数 _kernel.Bind<ObjectContext>().To<HelloWorld.Model.HelloWordEntities>().InSingletonScope().WithParameter(parameter2); var Entities2 = _kernel.Get<HelloWorld.Model.HelloWordEntities>(); return Entities2; }); //EfConfig.WithObjectContext(() => //{ // ConstructorArgument parameter = new ConstructorArgument("connectionString", System.Configuration.ConfigurationManager.ConnectionStrings["GameWeiBoEntities"].ConnectionString); // //装系统的方法注入构造函数 // _kernel.Bind<ObjectContext>().To<Kt.GameWeiBo.Data.GameWeiBoEntities>().InRequestScope().WithParameter(parameter); // var Entities = _kernel.Get<Kt.GameWeiBo.Data.GameWeiBoEntities>(); // return Entities; //}); //EfConfig.WithObjectContext(() => //{ // ConstructorArgument parameter = new ConstructorArgument("connectionString", System.Configuration.ConfigurationManager.ConnectionStrings["UserHomeEntities"].ConnectionString); // //装系统的方法注入构造函数 // _kernel.Bind<ObjectContext>().To<Kt.UserHome.Data.UserHomeEntities>().InRequestScope().WithParameter(parameter); // var Entities = _kernel.Get<Kt.UserHome.Data.UserHomeEntities>(); // return Entities; //}); //EfConfig.WithObjectContext(() => //{ // ConstructorArgument parameter = new ConstructorArgument("connectionString", System.Configuration.ConfigurationManager.ConnectionStrings["GameGroupEntities"].ConnectionString); // //装系统的方法注入构造函数 // _kernel.Bind<ObjectContext>().To<Kt.GameGroup.Data.GameGroupEntities>().InRequestScope().WithParameter(parameter); // var Entities = _kernel.Get<Kt.GameGroup.Data.GameGroupEntities>(); // return Entities; //}); }) //.ConfigureState<DefaultStateConfiguration>(config => config.Configure(new NInjectContainerAdapter(_kernel))) .ConfigureState<DefaultStateConfiguration>() //.ConfigureUnitOfWork<DefaultUnitOfWorkConfiguration>(x => x.AutoCompleteScope()) ; }