本文整理汇总了C#中IKernel.Get方法的典型用法代码示例。如果您正苦于以下问题:C# IKernel.Get方法的具体用法?C# IKernel.Get怎么用?C# IKernel.Get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IKernel
的用法示例。
在下文中一共展示了IKernel.Get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetupCharacter
private static ICharacter SetupCharacter(IKernel kernel)
{
ICharacter adventurer = null;
do
{
ConsoleKeyInfo option = Console.ReadKey();
switch (option.Key)
{
case ConsoleKey.Escape:
Environment.Exit(0);
break;
case ConsoleKey.A:
adventurer = kernel.Get<Warrior>();
Console.WriteLine("You are a Warrior");
break;
case ConsoleKey.B:
adventurer = kernel.Get<Elf>();
Console.WriteLine("You are a Elf");
break;
case ConsoleKey.C:
adventurer = kernel.Get<Wizard>();
Console.WriteLine("You are a Wizard");
break;
}
} while (adventurer == null);
Console.WriteLine("Give a new name to your character\nName:");
adventurer.Name = Console.ReadLine();
return adventurer;
}
示例2: ClassInit
public static void ClassInit(TestContext context)
{
Debug.WriteLine("ClassInit " + context.TestName);
kernel = Helper.CreateKernel(new TestModule(), new BusinessIoc(), new DalIoc());
var auth = kernel.Get<IAuthenticationService>();
var uh = kernel.Get<IUtilisateurBusinessHelper<Utilisateur>>();
uh.DeleteAll().Wait();
uh.Create("999", "jcambert", "korben90", "Ambert", "Jean-Christophe", "[email protected]")
.ContinueWith(x =>
{
uh.AddRole(x.Result, "Administrateur");
})
.ContinueWith(x =>
{
uh.Save();
}).ContinueWith(x =>
{
var islogin = auth.Login("999", "jcambert", "korben90");
Assert.IsTrue(islogin.Result);
}).Wait()
;
Helper.CreateStandardPParametres(true).Wait();
Helper.CreateStandardParametres(true).Wait();
}
示例3: SetupAuth
private static void SetupAuth(IAppBuilder app, IKernel kernel)
{
app.UseFormsAuthentication(new FormsAuthenticationOptions
{
LoginPath = "/account/login",
LogoutPath = "/account/logout",
CookieHttpOnly = true,
AuthenticationType = Constants.JabbRAuthType,
CookieName = "jabbr.id",
ExpireTimeSpan = TimeSpan.FromDays(30),
DataProtection = kernel.Get<IDataProtection>(),
Provider = kernel.Get<IFormsAuthenticationProvider>()
});
//var config = new FederationConfiguration(loadConfig: false);
//config.WsFederationConfiguration.Issuer = "";
//config.WsFederationConfiguration.Realm = "http://localhost:16207/";
//config.WsFederationConfiguration.Reply = "http://localhost:16207/wsfederation";
//var cbi = new ConfigurationBasedIssuerNameRegistry();
//cbi.AddTrustedIssuer("", "");
//config.IdentityConfiguration.AudienceRestriction.AllowedAudienceUris.Add(new Uri("http://localhost:16207/"));
//config.IdentityConfiguration.IssuerNameRegistry = cbi;
//config.IdentityConfiguration.CertificateValidationMode = X509CertificateValidationMode.None;
//config.IdentityConfiguration.CertificateValidator = X509CertificateValidator.None;
//app.UseFederationAuthentication(new FederationAuthenticationOptions
//{
// ReturnPath = "/wsfederation",
// SigninAsAuthenticationType = Constants.JabbRAuthType,
// FederationConfiguration = config,
// Provider = new FederationAuthenticationProvider()
//});
app.Use(typeof(WindowsPrincipalHandler));
}
示例4: OnClick
public override void OnClick(IKernel kernel)
{
Item.Server.Favorite = true;
kernel.Get<IStorageService>().SaveChanges();
kernel.Get<IShellController>().CurrentView = Views.FavoritesServers;
}
示例5: ShellForm
public ShellForm(IKernel kernel)
{
Asserter.AssertIsNotNull(kernel, "kernel");
_kernel = kernel;
_applicationService = _kernel.Get<IApplicationService>();
_storageService = _kernel.Get<IStorageService>();
_settingsService = _kernel.Get<ISettingsService>();
_siteService = _kernel.Get<ISiteService>();
_controller = _kernel.Get<ShellController>();
Asserter.AssertIsNotNull(_applicationService, "_applicationService");
Asserter.AssertIsNotNull(_storageService, "_storageService");
Asserter.AssertIsNotNull(_settingsService, "_settingsService");
Asserter.AssertIsNotNull(_siteService, "_siteService");
InitializeComponent();
_siteService.Register(SiteNames.ContentSite, contentPanel);
_siteService.Register(SiteNames.NavigationSite, navigationPanel);
_siteService.Register(SiteNames.ContentActionsSite, contentActionPanel);
SetStyle(ControlStyles.OptimizedDoubleBuffer |
ControlStyles.AllPaintingInWmPaint |
ControlStyles.ResizeRedraw, true);
}
示例6: Form1
public Form1(IKernel kernel)
{
#region Splash screen Start
//this.Hide();
//Thread splashthread = new Thread(new ThreadStart(SplashScreen.ShowSplashScreen));
//splashthread.IsBackground = true;
//splashthread.Start();
#endregion
Kernel = kernel;
UserRepository = Kernel.Get<UserRepository>();
SystemRepository = Kernel.Get<SystemRepository>();
UserDesktopRepository = Kernel.Get<UserDesktopRepository>();
InitializeComponent();
var details = UserRepository.GetSessionDetails(AppSettings.Instance.LiveUserAccount.Username);
if (details.GoDaddyAccount == null && !string.IsNullOrEmpty(Settings.Default.GDUsername))
{
details.GoDaddyAccount = new GoDaddyAccount()
{
AccountId = Guid.NewGuid(), AccountUsername = details.Username, Password = Settings.Default.GDPassword,
Username = Settings.Default.GDUsername, UserID = AppSettings.Instance.LiveUserAccount.AccountID
};
SystemRepository.SaveGodaddyAccount(details.GoDaddyAccount);
}
AppSettings.Instance.SessionDetails = details;
AppSettings.Instance.GoDaddy = new GoDaddyAuctionSniper(AppSettings.Instance.SessionDetails.Username, Kernel.Get<IUserRepository>());
LoadAuctions();
Instance = this;
//Login();
}
示例7: MyClassInitialize
public static void MyClassInitialize(TestContext testContext)
{
kernel = new StandardKernel(new TestModule(), new DalIoc(), new BusinessIoc());
var auth = kernel.Get<IAuthenticationService>();
var uh = kernel.Get<IUtilisateurBusinessHelper<Utilisateur>>();
uh.DeleteAll().Wait();
uh.Create("999", "jcambert", "korben90", "Ambert", "Jean-Christophe", "[email protected]")
.ContinueWith(x =>
{
uh.AddRole(x.Result, "Administrateur");
})
.ContinueWith(x =>
{
uh.Save();
}).ContinueWith(x =>
{
var islogin = auth.Login("999", "jcambert", "korben90");
Assert.IsTrue(islogin.Result);
}).Wait()
;
ah = kernel.Get<ArticleBusinessHelper<Article>>();
ctx = kernel.Get<IDbContext>();
}
示例8: RegisterGlobalFilters
public static void RegisterGlobalFilters(GlobalFilterCollection filters, IKernel kernel)
{
filters.Add(new CustomHandleErrorAttribute(kernel.Get<ILog>()));
filters.Add(new CultureFilterAttribute(CompositionRootHelper.GetLanguage(kernel)));
filters.Add(new AccessAuthorizationFilter(() => kernel.Get<IIdentityService>()));
}
示例9: DataGenerator
public DataGenerator()
{
_ninjectKernel = new StandardKernel(new Modules.MockRepositoryModule());
_ninjectKernel.Bind<IClientService>().To<ClientService>();
_ninjectKernel.Bind<IUserAccountService>().To<UserAccountService>();
_clientService = _ninjectKernel.Get<IClientService>();
_userAccountService = _ninjectKernel.Get<IUserAccountService>();
}
示例10: SplashScreen
public SplashScreen(IKernel kernel)
{
InitializeComponent();
_kernel = kernel;
_applicationService = kernel.Get<IApplicationService>();
_storageService = kernel.Get<IStorageService>();
}
示例11: Init
public void Init()
{
ninject = new StandardKernel(new BindingsModule());
movementHandler = ninject.Get<IMovementHandler>();
player = ninject.Get<IPlayer>();
}
示例12: Patcher
public Patcher(IKernel kernel)
{
_kernel = kernel;
_storageService = kernel.Get<IStorageService>();
_settingsService = kernel.Get<ISettingsService>();
if (string.IsNullOrEmpty(_settingsService.UltimaOnlineDirectory))
throw new Exception("ConnectUO was unable to find the directory that Ultima Online is installed to.");
}
示例13: Configure
protected override void Configure()
{
_kernel = new Ninject.StandardKernel();
_kernel.Bind<IEventAggregator>().To<EventAggregator>().InSingletonScope();
_eventAggregator = _kernel.Get<IEventAggregator>();
// Singletons
_kernel.Bind<Settings>().ToSelf().InSingletonScope();
_kernel.Bind<PumpController>().ToSelf().InSingletonScope();
_kernel.Bind<ElementController>().ToSelf().InSingletonScope();
_kernel.Bind<Hardware>().ToSelf().InSingletonScope();
_kernel.Bind<HardwareInitializer>().ToSelf().InSingletonScope();
var settings = _kernel.Get<Settings>();
// Use real hardware if we have a GpioController - else use fakeys
var shouldUseRealHardware = (GpioController.GetDefault() != null);
if (shouldUseRealHardware)
{
// Configure the ADC for inputs
// _kernel.Bind<IAnalogToDigitalConvertor>().To<Mcp3208>();
_kernel.Bind<IAnalogToDigitalConvertor>().To<Mcp3008>().InSingletonScope();
// Configure the GPIO for outputs
var gpioController = GpioController.GetDefault();
var pumpGpioPin = gpioController.OpenPin(settings.PumpGpioPin);
var elementGpioPin = gpioController.OpenPin(settings.ElementGpioPin);
// Use real inputs/outputs where requested
_kernel.Bind<IOutputConnection>().To<GpioOutputConnection>();
_kernel.Bind<ITemperatureReader>().To<ThermistorTemperatureReader>();
// Get and configure the hardware object with correct pins etc
var hardware = _kernel.Get<Hardware>();
// - GPIO Outputs
(hardware.PumpOutputConnection as GpioOutputConnection)?.Configure(pumpGpioPin);
(hardware.ElementOutputConnection as GpioOutputConnection)?.Configure(elementGpioPin);
// - ADC inputs
((ThermistorTemperatureReader) hardware.RoofTemperatureReader).PinNumber = settings.RoofThermistorAdcPin;
((ThermistorTemperatureReader) hardware.TankTemperatureReader).PinNumber = settings.TankThermistorAdcPin;
((ThermistorTemperatureReader) hardware.InletTemperatureReader).PinNumber = settings.InletThermistorAdcPin;
} else {
// Use fake inputs / outputs where requested
_kernel.Bind<IOutputConnection>().To<FakeOutputConnection>();
_kernel.Bind<ITemperatureReader>().To<FakeTemperatureReader>();
// Setup some initial values for fake readings
var hardware = _kernel.Get<Hardware>();
((FakeTemperatureReader) hardware.RoofTemperatureReader).FakeTemperatureDegC = 50;
((FakeTemperatureReader) hardware.InletTemperatureReader).FakeTemperatureDegC = 40;
((FakeTemperatureReader) hardware.TankTemperatureReader).FakeTemperatureDegC = 30;
((FakeOutputConnection) hardware.PumpOutputConnection).State = false;
((FakeOutputConnection) hardware.ElementOutputConnection).State = false;
}
}
示例14: SetUp
public void SetUp()
{
_view = MockRepository.GenerateMock<ICradiatorView>();
_configSettings = MockRepository.GenerateMock<IConfigSettings>();
_configSettings.Expect(c => c.ProjectNameRegEx).Return(".*").Repeat.Any();
_kernel = new StandardKernel(new CradiatorNinjaModule(_view, _configSettings));
_factory = _kernel.Get<IWebClientFactory>();
_kernel.Get<BuildDataTransformer>();
}
示例15: CreateWith
public static IArmorGenerator CreateWith(IKernel kernel)
{
var collectionsSelector = kernel.Get<ICollectionsSelector>();
var percentileSelector = kernel.Get<IPercentileSelector>();
var mundaneWeaponGenerator = kernel.Get<MundaneItemGenerator>(ItemTypeConstants.Armor);
var magicalWeaponGenerator = kernel.Get<MagicalItemGenerator>(ItemTypeConstants.Armor);
var generator = kernel.Get<Generator>();
return new ArmorGenerator(collectionsSelector, percentileSelector, mundaneWeaponGenerator,
magicalWeaponGenerator, generator);
}