本文整理汇总了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>());
}
示例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>());
}
示例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();
}
示例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);
}
示例5: BuildNullMessageContext
protected virtual NullMessageContext BuildNullMessageContext(IComponentContext c)
{
return new NullMessageContext(c.ResolveOptional<IReceiveFromEndpoints>().EndpointAddress);
}
示例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);
}
示例7: InitializePhysics
public virtual void InitializePhysics(bool force, IComponentContext engineRegistrations)
{
TextureCache = engineRegistrations.Resolve<IResourceCache<Texture2D>>();
Engine = engineRegistrations.ResolveOptional<EngineGame>();
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}