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


C# IComponentContext.ResolveOptional方法代码示例

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


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

示例1: CloudInfrastructureProviders

 static CloudInfrastructureProviders CloudInfrastructureProviders(IComponentContext c)
 {
     return new CloudInfrastructureProviders(
         c.Resolve<CloudStorageProviders>(),
         c.ResolveOptional<IProvisioningProvider>(),
         c.ResolveOptional<ILog>());
 }
开发者ID:alexmg,项目名称:lokad-cloud,代码行数:7,代码来源:StorageModule.cs

示例2: RuntimeProviders

 static RuntimeProviders RuntimeProviders(IComponentContext c)
 {
     return CloudStorage
         .ForAzureAccount(c.Resolve<CloudStorageAccount>())
         .WithObserver(c.Resolve<ICloudStorageObserver>())
         .WithRuntimeFinalizer(c.ResolveOptional<IRuntimeFinalizer>())
         .BuildRuntimeProviders(c.ResolveOptional<ILog>());
 }
开发者ID:kmaclean,项目名称:lokad-cloud,代码行数:8,代码来源:StorageModule.cs

示例3: QueueStorageProvider

 static IQueueStorageProvider QueueStorageProvider(IComponentContext c)
 {
     return CloudStorage
         .ForAzureAccount(c.Resolve<CloudStorageAccount>())
         .WithDataSerializer(c.Resolve<IDataSerializer>())
         .WithObserver(c.Resolve<ICloudStorageObserver>())
         .WithRuntimeFinalizer(c.ResolveOptional<IRuntimeFinalizer>())
         .BuildQueueStorage();
 }
开发者ID:kmaclean,项目名称:lokad-cloud,代码行数:9,代码来源:StorageModule.cs

示例4: BuildMessageBus

        protected virtual TransactionalBus BuildMessageBus(IComponentContext c)
        {
            var bus = new MessageBus(
                c.Resolve<ITransportMessages>(),
                c.Resolve<IStoreSubscriptions>(),
                this.endpoints,
                c.ResolveOptional<IMessageContext>() ?? c.Resolve<NullMessageContext>(),
                c.Resolve<MessageBuilder>(),
                c.Resolve<IDiscoverMessageTypes>());

            return new TransactionalBus(c.Resolve<IHandleUnitOfWork>(), bus);
        }
开发者ID:JamesTryand,项目名称:NanoMessageBus,代码行数:12,代码来源:MessageBusWireup.cs

示例5: BuildNullMessageContext

 protected virtual NullMessageContext BuildNullMessageContext(IComponentContext c)
 {
     return new NullMessageContext(c.ResolveOptional<IReceiveFromEndpoints>().EndpointAddress);
 }
开发者ID:JamesTryand,项目名称:NanoMessageBus,代码行数:4,代码来源:MessageBusWireup.cs

示例6: InitializePhysics

        public override void InitializePhysics(bool force, IComponentContext engineRegistrations)
        {
            if (force || !initialized)
            {
                var cache = engineRegistrations.Resolve<IResourceCache<Texture2D>>();
                var world = engineRegistrations.Resolve<PhysicsManager>().World;
                engine = engineRegistrations.ResolveOptional<EngineGame>();
                Physics = BodyFactory.CreateBody(world, Position, this);

                if (engine != null && engine.GamepadEnabled)
                {
                    ACTION_POPUP = InputManager.Instance.GamepadTextures[InputManager.ButtonActions.Interact];
                }

                float spriteWidthMeters = PhysicsConstants.PixelsToMeters(Width);
                float spriteHeightMeters = PhysicsConstants.PixelsToMeters(Height);

                var rect = FixtureFactory.AttachRectangle(
                    spriteWidthMeters,
                    PhysicsConstants.PixelsToMeters(10),
                    1.4f,
                    Vector2.Zero,
                    Physics);

                Physics.BodyType = BodyType.Static;
                Physics.IgnoreGravity = true;
                Physics.IsSensor = false;

                Physics.RegisterOnCollidedListener<UserControlledCharacter>(OnCollidedWith);
                Physics.RegisterOnSeparatedListener<UserControlledCharacter>(OnSeparation);

                popupTrigger = new ItemPopup(
                    ACTION_POPUP,
                    new Vector2(Physics.Position.X, Physics.Position.Y - PhysicsConstants.PixelsToMeters(100)),
                    cache);

                initialized = true;
            }

            base.InitializePhysics(false, engineRegistrations);
        }
开发者ID:pquinn,项目名称:time-sink,代码行数:41,代码来源:TutorialBreakBridge.cs

示例7: InitializePhysics

 public virtual void InitializePhysics(bool force, IComponentContext engineRegistrations)
 {
     TextureCache = engineRegistrations.Resolve<IResourceCache<Texture2D>>();
     Engine = engineRegistrations.ResolveOptional<EngineGame>();
 }
开发者ID:pquinn,项目名称:time-sink,代码行数:5,代码来源:Entity.cs

示例8: ResolveScriptDependency

        protected SchedulerTaskScriptDependencies ResolveScriptDependency(ISchedulerTaskScript script, IComponentContext context)
        {
            if (script.DependencyClassType == null || script.DependencyClassType == typeof(void))
            {
                //TODO: return some default dependency
                return null;
            }

            var result = context.ResolveOptional(script.DependencyClassType) as SchedulerTaskScriptDependencies;

            //creating instance manually
            if (result == null)
            {
                result = Activator.CreateInstance(script.DependencyClassType)
                         as SchedulerTaskScriptDependencies;
                if (result == null) throw new Exception("Script Dependency can not be resolved. Check the dependency type");
                context.InjectProperties(result);
            }

            if(result==null) throw new Exception("Script Dependency can not be resolved");
            return result;
        }
开发者ID:ikutsin,项目名称:BinaryAnalysis.Core,代码行数:22,代码来源:SchedulerTask.cs

示例9: InitializePhysics

        public override void InitializePhysics(bool force, IComponentContext engineRegistrations)
        {
            if (force || !initialized)
            {
                var cache = engineRegistrations.Resolve<IResourceCache<Texture2D>>();
                var texture = cache.GetResource(TextureName);
                var world = engineRegistrations.Resolve<PhysicsManager>().World;
                game = engineRegistrations.ResolveOptional<EngineGame>();

                if (game != null && game.GamepadEnabled)
                {
                    ACTION_POPUP = InputManager.Instance.GamepadTextures[InputManager.ButtonActions.Pickup];
                }

                //Width = texture.Width;
                //Height = texture.Height;
                Physics = BodyFactory.CreateRectangle(
                    world,
                    PhysicsConstants.PixelsToMeters(Width),
                    PhysicsConstants.PixelsToMeters(Height),
                    1,
                    Position);
                Physics.FixedRotation = true;
                Physics.BodyType = BodyType.Static;
                Physics.UserData = this;

                var fix = Physics.FixtureList[0];
                fix.CollisionCategories = Category.Cat3;
                fix.CollidesWith = Category.Cat1;

                HitSensor = BodyFactory.CreateRectangle(
                    world,
                    PhysicsConstants.PixelsToMeters(Width) * 2,
                    PhysicsConstants.PixelsToMeters(Height),
                    1,
                    Position);
                HitSensor.IsSensor = true;
                HitSensor.CollisionCategories = Category.Cat2;
                HitSensor.CollidesWith = Category.Cat2;

                HitSensor.RegisterOnCollidedListener<UserControlledCharacter>(OnCollidedWith);
                HitSensor.RegisterOnSeparatedListener<UserControlledCharacter>(OnSeparation);

                popup = new ItemPopup(ACTION_POPUP,
                    Physics.Position + new Vector2(0, -PhysicsConstants.PixelsToMeters(Height / 2 + POPUP_OFFSET)),
                    cache);

                initialized = true;
            }

            base.InitializePhysics(false, engineRegistrations);
        }
开发者ID:pquinn,项目名称:time-sink,代码行数:52,代码来源:NonPlayerCharacter.cs

示例10: InitializePhysics

        public override void InitializePhysics(bool force, IComponentContext engineRegistrations)
        {
            if (force || !initialized)
            {
                var world = engineRegistrations.Resolve<PhysicsManager>().World;
                levelManager = engineRegistrations.Resolve<LevelManager>();
                engineGame = engineRegistrations.ResolveOptional<EngineGame>();

                Physics = BodyFactory.CreateRectangle(
                    world,
                    PhysicsConstants.PixelsToMeters(Width),
                    PhysicsConstants.PixelsToMeters(Height),
                    1,
                    Position,
                    this);
                Physics.BodyType = BodyType.Static;
                Physics.IsSensor = true;
                _geom = Physics.FixtureList;

                RegisterCollisions();

                initialized = true;
            }

            base.InitializePhysics(false, engineRegistrations);
        }
开发者ID:pquinn,项目名称:time-sink,代码行数:26,代码来源:Trigger.cs

示例11: InitializePhysics

        public override void InitializePhysics(bool force, IComponentContext engineRegistrations)
        {
            if (force || !initialized)
            {
                var cache = engineRegistrations.Resolve<IResourceCache<Texture2D>>();
                var world = engineRegistrations.Resolve<PhysicsManager>().World;
                engine = engineRegistrations.ResolveOptional<EngineGame>();
                Physics = BodyFactory.CreateBody(world, Position, this);

                if (engine != null && engine.GamepadEnabled)
                {
                    UP_POPUP = InputManager.Instance.GamepadTextures[InputManager.ButtonActions.UpAction];
                    DOWN_POPUP = InputManager.Instance.GamepadTextures[InputManager.ButtonActions.DownAction];
                }

                float spriteWidthMeters = PhysicsConstants.PixelsToMeters(Width);
                float spriteHeightMeters = PhysicsConstants.PixelsToMeters(Height);

                var rect = FixtureFactory.AttachRectangle(
                    spriteWidthMeters,
                    spriteHeightMeters,
                    1.4f,
                    Vector2.Zero,
                    Physics);

                Physics.BodyType = BodyType.Static;
                Physics.IsSensor = true;

                Physics.RegisterOnCollidedListener<UserControlledCharacter>(OnCollidedWith);
                Physics.RegisterOnSeparatedListener<UserControlledCharacter>(OnSeparation);

                if (DoorType == DoorType.Up)
                {
                    popup = new ItemPopup(
                        UP_POPUP,
                        Physics.Position + new Vector2(0, -PhysicsConstants.PixelsToMeters(Height / 2)),
                        cache);
                }
                else if (DoorType == DoorType.Down)
                {
                    popup = new ItemPopup(
                        DOWN_POPUP,
                        Physics.Position + new Vector2(0, -PhysicsConstants.PixelsToMeters(Height / 2)),
                        cache);
                }
                else
                {
                    popup = null;
                }

                initialized = true;
            }

            base.InitializePhysics(false, engineRegistrations);
        }
开发者ID:pquinn,项目名称:time-sink,代码行数:55,代码来源:UseDoor.cs

示例12: InitializePhysics

        public override void InitializePhysics(bool force, IComponentContext engineRegistrations)
        {
            if (force || !initialized)
            {
                var cache = engineRegistrations.Resolve<IResourceCache<Texture2D>>();
                var world = engineRegistrations.Resolve<PhysicsManager>().World;
                engine = engineRegistrations.ResolveOptional<EngineGame>();
                var texture = cache.GetResource(EDITOR_PREVIEW);
                previewScale = new Vector2(Width / texture.Width, Height / texture.Height);

                Physics = BodyFactory.CreateBody(world, Position, this);

                float spriteWidthMeters = PhysicsConstants.PixelsToMeters(Width);
                float spriteHeightMeters = PhysicsConstants.PixelsToMeters(Height);

                string texture1 = InputTextureLookup(Key1, engine);

                if (Key2 != 999)
                {
                    string texture2 = InputTextureLookup(Key2, engine);
                    display2 = new ItemPopup(texture2, Vector2.Zero, cache, new Vector2(40, -90));

                    plusCombine = new ItemPopup("Textures/Keys/plusCombine", Vector2.Zero, cache, new Vector2(0, -90));

                    display1 = new ItemPopup(texture1, Vector2.Zero, cache, new Vector2(-40, -90));
                }
                else
                {
                    display2 = null;

                    display1 = new ItemPopup(texture1, Vector2.Zero, cache, new Vector2(0, -90));
                }

                var rect = FixtureFactory.AttachRectangle(
                    spriteWidthMeters,
                    spriteHeightMeters,
                    1.4f,
                    Vector2.Zero,
                    Physics);

                Physics.BodyType = BodyType.Static;
                Physics.IsSensor = true;

                Physics.RegisterOnCollidedListener<UserControlledCharacter>(OnCollidedWith);
                Physics.RegisterOnSeparatedListener<UserControlledCharacter>(OnSeparation);

                initialized = true;
            }

            base.InitializePhysics(false, engineRegistrations);
        }
开发者ID:pquinn,项目名称:time-sink,代码行数:51,代码来源:TutorialTrigger.cs


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