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


C# IKernel.Unbind方法代码示例

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


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

示例1: BindClasses

        private void BindClasses(IKernel k, IConfig config, string configFile, UUID hostID)
        {
            k.Unbind<IPrimFactory>();
            k.Unbind<IConfigSource>();

            k.Bind<IPrimFactory>().To<MRMPrimFactory>().InSingletonScope().WithConstructorArgument("hostID", hostID);
            k.Bind<IConfigSource>().To<DotNetConfigSource>().InSingletonScope().WithConstructorArgument("path", configFile);

            if (!config.Contains(CONTROL + ASSEMBLY))
                throw new Exception("Unable to start up. Control is not properly specified in the configuration file. " +
                    "Config must include the key '" + CONTROL + ASSEMBLY + "' in section 'Bootstrap'.");
            if (!config.Contains(MODEL + ASSEMBLY))
                throw new Exception("Unable to start up. Model is not properly specified in the configuration file. " +
                    "Config must include the key '" + MODEL + ASSEMBLY + "' in section 'Bootstrap'.");
            if (!config.Contains(VIEW + ASSEMBLY))
                throw new Exception("Unable to start up. View is not properly specified in the configuration file. " +
                    "Config must include the key '" + VIEW + ASSEMBLY + "' in section 'Bootstrap'.");

            if (!config.Contains(CONTROL + CLASS))
                throw new Exception("Unable to start up. Control is not properly specified in the configuration file. " +
                    "Config must include the key '" + CONTROL + CLASS + "' in section 'Bootstrap'.");
            if (!config.Contains(MODEL + CLASS))
                throw new Exception("Unable to start up. Model is not properly specified in the configuration file. " +
                    "Config must include the key '" + MODEL + CLASS + "' in section 'Bootstrap'.");
            if (!config.Contains(VIEW + CLASS))
                throw new Exception("Unable to start up. View is not properly specified in the configuration file. " +
                    "Config must include the key '" + VIEW + CLASS + "' in section 'Bootstrap'.");

            string baseDir = AppDomain.CurrentDomain.BaseDirectory;
            string controlAssembly = Path.Combine(baseDir, config.GetString(CONTROL + ASSEMBLY));
            string modelAssembly = Path.Combine(baseDir, config.GetString(MODEL + ASSEMBLY));
            string viewAssembly = Path.Combine(baseDir, config.GetString(VIEW + ASSEMBLY));

            string controlName = config.GetString(CONTROL + CLASS);
            string modelName = config.GetString(MODEL + CLASS);
            string ViewName = config.GetString(VIEW + CLASS);

            TestModule(CONTROL, controlAssembly, controlName, typeof(IControl));
            TestModule(MODEL, modelAssembly, modelName, typeof(IModel));
            TestModule(VIEW, viewAssembly, ViewName, typeof(IView));

            IDynamicLoaderModule loader = k.Get<IDynamicLoaderModule>();

            k.Unbind<IView>();
            k.Unbind<IModel>();
            k.Unbind<IControl>();
            loader.BindDynamic(typeof(IView), viewAssembly, ViewName, true);
            loader.BindDynamic(typeof(IModel), modelAssembly, modelName, true);
            loader.BindDynamic(typeof(IControl), controlAssembly, controlName, true);

            k.Unbind<IKeyTableFactory>();
            string tableLibrary = Path.Combine(baseDir, config.GetString(TABLE + ASSEMBLY, typeof(MapTableFactory).Assembly.Location));
            string tableType = config.GetString(TABLE + CLASS, typeof(MapTableFactory).FullName);
            loader.BindDynamic(typeof(IKeyTableFactory), tableLibrary, tableType, true);

            k.Unbind<IAlgorithm>();
            string algorithmFolder = Path.Combine(baseDir, config.GetString("AlgorithmFolder", "."));
            loader.BindAllInFolder(typeof(IAlgorithm), algorithmFolder);

            _clearCreated = config.GetBoolean("ClearCreated", true);
        }
开发者ID:JohnMcCaffery,项目名称:RoutingIsland,代码行数:61,代码来源:MRMSystem.cs

示例2: ConnectWorld

        public ConnectWorld(
            IKernel kernel, 
            I2DRenderUtilities twodRenderUtilities, 
            IAssetManagerProvider assetManagerProvider, 
            IBackgroundCubeEntityFactory backgroundCubeEntityFactory, 
            ISkin skin, 
            IProfiler profiler,
            IPersistentStorage persistentStorage,
            bool startServer, 
            IPAddress address, 
            int port)
            : base(twodRenderUtilities, assetManagerProvider, backgroundCubeEntityFactory, skin)
        {
            this.m_2DRenderUtilities = twodRenderUtilities;
            this.m_PersistentStorage = persistentStorage;

            this.m_DefaultFont = assetManagerProvider.GetAssetManager().Get<FontAsset>("font.Default");
            this.m_Address = address;
            this.m_Port = port;
            TychaiaClient client = null;
            byte[] initial = null;
            Action cleanup = () =>
            {
                kernel.Unbind<INetworkAPI>();
                kernel.Unbind<IClientNetworkAPI>();
                if (client != null)
                {
                    client.Close();
                }

                this.TerminateExistingProcess();
            };

            if (startServer)
            {
                this.m_Actions = new Action[]
                {
                    () => this.m_Message = "Closing old process...", () => this.TerminateExistingProcess(),
                    () => this.m_Message = "Starting server...", () => this.StartServer(),
                    () => this.m_Message = "Creating client...", () => client = new TychaiaClient(port + 2, port + 3),
                    () => client.AttachProfiler(profiler),
                    () => this.m_Message = "Connecting to server...",
                    () => client.Connect(new DualIPEndPoint(address, port, port + 1)),
                    () => this.m_Message = "Binding node to kernel...",
                    () => kernel.Bind<INetworkAPI>().ToMethod(x => client),
                    () => kernel.Bind<IClientNetworkAPI>().ToMethod(x => client), () => this.m_Message = "Joining game...",
                    () => this.m_UniqueClientIdentifier = this.JoinGame(client), () => this.m_Message = "Retrieving initial game state...",
                    () => initial = client.LoadInitialState(), () => this.m_Message = "Starting client...",
                    () => this.m_PerformFinalAction = true
                };
            }
            else
            {
                this.m_Actions = new Action[]
                {
                    () => this.m_Message = "Creating client...", () => client = new TychaiaClient(port + 2, port + 3),
                    () => client.AttachProfiler(profiler),
                    () => this.m_Message = "Connecting to server...",
                    () => client.Connect(new DualIPEndPoint(address, port, port + 1)),
                    () => this.m_Message = "Binding node to kernel...",
                    () => kernel.Bind<INetworkAPI>().ToMethod(x => client),
                    () => kernel.Bind<IClientNetworkAPI>().ToMethod(x => client),
                    () => this.m_Message = "Joining game...",
                    () => this.m_UniqueClientIdentifier = this.JoinGame(client), () => this.m_Message = "Retrieving initial game state...",
                    () => initial = client.LoadInitialState(), () => this.m_Message = "Starting client...",
                    () => this.m_PerformFinalAction = true
                };
            }

            this.m_FinalAction =
                () =>
                this.TargetWorld =
                this.GameContext.CreateWorld<IWorldFactory>(x => x.CreateTychaiaGameWorld(this.m_UniqueClientIdentifier, cleanup));

            var thread = new Thread(this.Run) { IsBackground = true };
            thread.Start();

            AppDomain.CurrentDomain.ProcessExit += (sender, e) =>
            {
                if (this.m_Process != null)
                {
                    try
                    {
                        this.m_Process.Kill();
                        this.m_Process = null;
                    }
                    catch (InvalidOperationException)
                    {
                    }
                }
            };
            AppDomain.CurrentDomain.UnhandledException += (sender, e) =>
            {
                if (this.m_Process != null)
                {
                    try
                    {
                        this.m_Process.Kill();
                        this.m_Process = null;
                    }
//.........这里部分代码省略.........
开发者ID:TreeSeed,项目名称:Tychaia,代码行数:101,代码来源:ConnectWorld.cs

示例3: Register

 public void Register(Type type, IKernel kernel)
 {
     kernel.Unbind(type);
 }
开发者ID:dvabuzyarov,项目名称:Ninject.Extensions.MetadataRegistration,代码行数:4,代码来源:AsCustomAttributeUnitTests.cs


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