当前位置: 首页>>代码示例>>C#>>正文


C# IKernel.TryGet方法代码示例

本文整理汇总了C#中IKernel.TryGet方法的典型用法代码示例。如果您正苦于以下问题:C# IKernel.TryGet方法的具体用法?C# IKernel.TryGet怎么用?C# IKernel.TryGet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IKernel的用法示例。


在下文中一共展示了IKernel.TryGet方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MyTestProductBzService

 public MyTestProductBzService(IKernel kernel)
 {
     _kernel = kernel;
     
     productService = kernel.TryGet<IProductDataService>() ?? new ProductDataService();
    
 }
开发者ID:keke78ui9,项目名称:ASP.NET-MVC-Unit-Test,代码行数:7,代码来源:MyTestProductBzService.cs

示例2: GetSiteCopyOptionInfo

        private SiteCopyOptionInfo GetSiteCopyOptionInfo(SiteCopyOption option, IKernel kernel)
        {
            var cloneSiteParts = kernel.TryGet(option.SiteCopyActionType) as ICloneSiteParts;
            if (cloneSiteParts == null)
                return null;

            return new SiteCopyOptionInfo(option.SiteId, cloneSiteParts);
        }
开发者ID:neozhu,项目名称:MrCMS,代码行数:8,代码来源:CloneSiteService.cs

示例3: Application_Start

        protected void Application_Start(object sender, EventArgs e)
        {
            _kernel = new StandardKernel();
            _kernel.Bind<ISiteUrlRepository>().To<TableStorageSiteUrlRepository>();
            _kernel.Bind<ISiteResultReceiver>().To<WindowsAzureQueueSiteResultReceiver>().InSingletonScope();
            _kernel.Bind<IStorageQueueConfiguration>().To<WebSiteQueueConfiguration>();

            var resolver = new NinjectDependencyResolver(_kernel);
            GlobalHost.DependencyResolver = resolver;
            RouteTable.Routes.MapHubs();

            _kernel.TryGet<ISiteResultReceiver>().StartWatching();
        }
开发者ID:prateek08,项目名称:SiteMonitR,代码行数:13,代码来源:Global.asax.cs

示例4: RegisterGlobalFilters

 private static void RegisterGlobalFilters(GlobalFilterCollection filters, IKernel kernel)
 {
     filters.Add(new HandleErrorAttribute());
     filters.Add(kernel.TryGet(typeof(UserProviderFilterAttribute)));
 }
开发者ID:elylucas,项目名称:Rails-vs-.NET,代码行数:5,代码来源:Global.asax.cs

示例5: Load

        public void Load(IKernel kernel)
        {
            if (kernel.TryGet<IRawLaunchArguments>() == null)
            {
                kernel.Bind<IRawLaunchArguments>()
                    .ToMethod(x => new DefaultRawLaunchArguments(new string[0]))
                    .InSingletonScope();
            }

            kernel.Bind<IAssetLoader>().To<FontAssetLoader>().InSingletonScope();
            kernel.Bind<IAssetLoader>().To<LanguageAssetLoader>().InSingletonScope();
            kernel.Bind<IAssetLoader>().To<TextureAssetLoader>().InSingletonScope();
            kernel.Bind<IAssetLoader>().To<LevelAssetLoader>().InSingletonScope();
            kernel.Bind<IAssetLoader>().To<AudioAssetLoader>().InSingletonScope();
            kernel.Bind<IAssetLoader>().To<TilesetAssetLoader>().InSingletonScope();
            kernel.Bind<IAssetLoader>().To<EffectAssetLoader>().InSingletonScope();
            kernel.Bind<IAssetLoader>().To<UberEffectAssetLoader>().InSingletonScope();
            kernel.Bind<IAssetLoader>().To<AIAssetLoader>().InSingletonScope();
            kernel.Bind<IAssetLoader>().To<ModelAssetLoader>().InSingletonScope();
            kernel.Bind<IAssetLoader>().To<TextureAtlasAssetLoader>().InSingletonScope();
            kernel.Bind<IAssetLoader>().To<VariableAssetLoader>().InSingletonScope();
            kernel.Bind<IAssetLoader>().To<ConfigurationAssetLoader>().InSingletonScope();
            kernel.Bind<IAssetLoader>().To<UserInterfaceAssetLoader>().InSingletonScope();
            kernel.Bind<IAssetSaver>().To<FontAssetSaver>().InSingletonScope();
            kernel.Bind<IAssetSaver>().To<LanguageAssetSaver>().InSingletonScope();
            kernel.Bind<IAssetSaver>().To<TextureAssetSaver>().InSingletonScope();
            kernel.Bind<IAssetSaver>().To<LevelAssetSaver>().InSingletonScope();
            kernel.Bind<IAssetSaver>().To<AudioAssetSaver>().InSingletonScope();
            kernel.Bind<IAssetSaver>().To<TilesetAssetSaver>().InSingletonScope();
            kernel.Bind<IAssetSaver>().To<EffectAssetSaver>().InSingletonScope();
            kernel.Bind<IAssetSaver>().To<UberEffectAssetSaver>().InSingletonScope();
            kernel.Bind<IAssetSaver>().To<ModelAssetSaver>().InSingletonScope();
            kernel.Bind<IAssetSaver>().To<TextureAtlasAssetSaver>().InSingletonScope();
            kernel.Bind<IAssetSaver>().To<VariableAssetSaver>().InSingletonScope();
            kernel.Bind<IAssetSaver>().To<ConfigurationAssetSaver>().InSingletonScope();
            kernel.Bind<IAssetSaver>().To<UserInterfaceAssetSaver>().InSingletonScope();
            kernel.Bind<IRawAssetLoader>().To<RawAssetLoader>().InSingletonScope();
            kernel.Bind<IRawAssetSaver>().To<RawAssetSaver>().InSingletonScope();
            kernel.Bind<ITransparentAssetCompiler>().To<DefaultTransparentAssetCompiler>().InSingletonScope();
            kernel.Bind<IModelSerializer>().To<ModelSerializerGeneric>().InSingletonScope();
            kernel.Bind<ITextureFromHintPath>().To<TextureFromHintPath>().InSingletonScope();
            kernel.Bind<IEffectSemantic>().To<WorldViewProjectionEffectSemantic>().DiscardNodeOnResolve();
            kernel.Bind<IEffectSemantic>().To<TextureEffectSemantic>().DiscardNodeOnResolve();
            kernel.Bind<IEffectSemantic>().To<BonesEffectSemantic>().DiscardNodeOnResolve();
            kernel.Bind<IEffectSemantic>().To<ColorDiffuseEffectSemantic>().DiscardNodeOnResolve();
            kernel.Bind<IEffectSemantic>().To<ScreenDimensionsEffectSemantic>().DiscardNodeOnResolve();
            kernel.Bind<IEffectSemantic>().To<NormalMapEffectSemantic>().DiscardNodeOnResolve();
            kernel.Bind<IEffectSemantic>().To<SpecularEffectSemantic>().DiscardNodeOnResolve();
            kernel.Bind<IEffectSemantic>().To<CameraPositionEffectSemantic>().DiscardNodeOnResolve();

#if PLATFORM_WINDOWS || PLATFORM_MACOS || PLATFORM_LINUX
            kernel.Bind<IAutomaticAssetReload>().To<DefaultAutomaticAssetReload>().InSingletonScope();
#if DEBUG
            this.LoadRawAssetStrategies(kernel);
#endif
            kernel.Bind<ILoadStrategy>().To<LocalSourceLoadStrategy>().InSingletonScope();
            kernel.Bind<ILoadStrategy>().To<EmbeddedSourceLoadStrategy>().InSingletonScope();
            kernel.Bind<ILoadStrategy>().To<LocalCompiledLoadStrategy>().InSingletonScope();
            kernel.Bind<ILoadStrategy>().To<EmbeddedCompiledLoadStrategy>().InSingletonScope();
            kernel.Bind<ILoadStrategy>().To<AssemblyLoadStrategy>().InSingletonScope();
#elif PLATFORM_ANDROID || PLATFORM_OUYA
            kernel.Bind<IAutomaticAssetReload>().To<DisabledAutomaticAssetReload>().InSingletonScope();
            kernel.Bind<ILoadStrategy>().To<AndroidSourceLoadStrategy>().InSingletonScope();
            kernel.Bind<ILoadStrategy>().To<AndroidCompiledLoadStrategy>().InSingletonScope();
            kernel.Bind<ILoadStrategy>().To<EmbeddedCompiledLoadStrategy>().InSingletonScope();
            kernel.Bind<ILoadStrategy>().To<EmbeddedSourceLoadStrategy>().InSingletonScope();
#elif PLATFORM_IOS || PLATFORM_TVOS
            kernel.Bind<IAutomaticAssetReload>().To<DisabledAutomaticAssetReload>().InSingletonScope();
            // TODO: We still need to implement load strategies for normal content on iOS.
            kernel.Bind<ILoadStrategy>().To<EmbeddedCompiledLoadStrategy>().InSingletonScope();
            kernel.Bind<ILoadStrategy>().To<EmbeddedSourceLoadStrategy>().InSingletonScope();
#endif

            // MonoGame compilation requires 64-bit for content compilation.
            if (IntPtr.Size == 8)
            {
#if PLATFORM_WINDOWS || PLATFORM_LINUX
                kernel.Bind<IAssetCompiler<TextureAsset>>().To<TextureAssetCompiler>().InSingletonScope();
                kernel.Bind<IAssetCompiler<ModelAsset>>().To<ModelAssetCompiler>().InSingletonScope();
                kernel.Bind<IAssetCompiler<AudioAsset>>().To<AudioAssetCompiler>().InSingletonScope();
                kernel.Bind<IAssetCompiler<TextureAtlasAsset>>().To<TextureAtlasAssetCompiler>().InSingletonScope();
#if PLATFORM_WINDOWS
                kernel.Bind<IAssetCompiler<EffectAsset>>().To<EffectAssetCompiler>().InSingletonScope();
                kernel.Bind<IAssetCompiler<UberEffectAsset>>().To<UberEffectAssetCompiler>().InSingletonScope();
                kernel.Bind<IAssetCompiler<FontAsset>>().To<FontAssetCompiler>().InSingletonScope();
#elif PLATFORM_LINUX
                kernel.Bind<IAssetCompiler<EffectAsset>>().To<EffectAssetRemoteCompiler>().InSingletonScope();
                kernel.Bind<IAssetCompiler<FontAsset>>().To<FontAssetRemoteCompiler>().InSingletonScope();
#endif
#endif
            }
        }
开发者ID:RedpointGames,项目名称:Protogame,代码行数:92,代码来源:ProtogameAssetModule.cs


注:本文中的IKernel.TryGet方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。