本文整理汇总了C#中ContainerContext类的典型用法代码示例。如果您正苦于以下问题:C# ContainerContext类的具体用法?C# ContainerContext怎么用?C# ContainerContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ContainerContext类属于命名空间,在下文中一共展示了ContainerContext类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReturnMediatorFromNestedContainer
public void ReturnMediatorFromNestedContainer()
{
var nestedContainer = MockRepository.GenerateStrictMock<IContainer>();
nestedContainer.Expect(c => c.Configure(Arg<Action<ConfigurationExpression>>.Is.NotNull))
.Repeat.Once();
var expected = MockRepository.GenerateStrictMock<IMediator>();
nestedContainer.Expect(c => c.GetInstance<IMediator>())
.Return(expected)
.Repeat.Once();
nestedContainer.Expect(c => c.Dispose())
.Repeat.Once();
var container = MockRepository.GenerateStrictMock<IContainer>();
container.Expect(c => c.GetNestedContainer())
.Return(nestedContainer)
.Repeat.Once();
IMediator actual;
using (var context = new ContainerContext(container))
actual = context.Mediator;
nestedContainer.VerifyAllExpectations();
actual.Should().Be.SameInstanceAs(expected);
}
示例2: Process
/// <summary>
/// Execute extension's job in given context
/// </summary>
/// <param name="context"> </param>
public void Process(ContainerContext context) {
var appbound = context.Object as IApplicationBound;
if (null == appbound) {
return;
}
if (ContainerOperation.AfterCreate == context.Operation) {
appbound.SetApplication(Application);
}
}
示例3: CreateANestedContainerWhenConstructed
public void CreateANestedContainerWhenConstructed()
{
var nestedContainer = MockRepository.GenerateStrictMock<IContainer>();
nestedContainer.Expect(c => c.Configure(Arg<Action<ConfigurationExpression>>.Is.NotNull))
.Repeat.Once();
var container = MockRepository.GenerateStrictMock<IContainer>();
container.Expect(c => c.GetNestedContainer())
.Return(nestedContainer)
.Repeat.Once();
var context = new ContainerContext(container);
container.VerifyAllExpectations();
}
示例4: ReadType
private void ReadType(BsonType type)
{
switch (type)
{
case BsonType.Number:
double d = ReadDouble();
if (_floatParseHandling == FloatParseHandling.Decimal)
SetToken(JsonToken.Float, Convert.ToDecimal(d, CultureInfo.InvariantCulture));
else
SetToken(JsonToken.Float, d);
break;
case BsonType.String:
case BsonType.Symbol:
SetToken(JsonToken.String, ReadLengthString());
break;
case BsonType.Object:
{
SetToken(JsonToken.StartObject);
ContainerContext newContext = new ContainerContext(BsonType.Object);
PushContext(newContext);
newContext.Length = ReadInt32();
break;
}
case BsonType.Array:
{
SetToken(JsonToken.StartArray);
ContainerContext newContext = new ContainerContext(BsonType.Array);
PushContext(newContext);
newContext.Length = ReadInt32();
break;
}
case BsonType.Binary:
SetToken(JsonToken.Bytes, ReadBinary());
break;
case BsonType.Undefined:
SetToken(JsonToken.Undefined);
break;
case BsonType.Oid:
byte[] oid = ReadBytes(12);
SetToken(JsonToken.Bytes, oid);
break;
case BsonType.Boolean:
bool b = Convert.ToBoolean(ReadByte());
SetToken(JsonToken.Boolean, b);
break;
case BsonType.Date:
long ticks = ReadInt64();
DateTime utcDateTime = DateTimeUtils.ConvertJavaScriptTicksToDateTime(ticks);
DateTime dateTime;
switch (DateTimeKindHandling)
{
case DateTimeKind.Unspecified:
dateTime = DateTime.SpecifyKind(utcDateTime, DateTimeKind.Unspecified);
break;
case DateTimeKind.Local:
dateTime = utcDateTime.ToLocalTime();
break;
default:
dateTime = utcDateTime;
break;
}
SetToken(JsonToken.Date, dateTime);
break;
case BsonType.Null:
SetToken(JsonToken.Null);
break;
case BsonType.Regex:
string expression = ReadString();
string modifiers = ReadString();
string regex = @"/" + expression + @"/" + modifiers;
SetToken(JsonToken.String, regex);
break;
case BsonType.Reference:
SetToken(JsonToken.StartObject);
_bsonReaderState = BsonReaderState.ReferenceStart;
break;
case BsonType.Code:
SetToken(JsonToken.String, ReadLengthString());
break;
case BsonType.CodeWScope:
SetToken(JsonToken.StartObject);
_bsonReaderState = BsonReaderState.CodeWScopeStart;
break;
case BsonType.Integer:
SetToken(JsonToken.Integer, (long)ReadInt32());
break;
case BsonType.TimeStamp:
case BsonType.Long:
SetToken(JsonToken.Integer, ReadInt64());
break;
default:
throw new ArgumentOutOfRangeException("type", "Unexpected BsonType value: " + type);
}
}
示例5: PushContext
private void PushContext(ContainerContext newContext)
{
_stack.Add(newContext);
_currentContext = newContext;
}
示例6: ReadNormal
private bool ReadNormal()
{
switch (CurrentState)
{
case State.Start:
{
JsonToken token = (!_readRootValueAsArray) ? JsonToken.StartObject : JsonToken.StartArray;
BsonType type = (!_readRootValueAsArray) ? BsonType.Object : BsonType.Array;
SetToken(token);
ContainerContext newContext = new ContainerContext(type);
PushContext(newContext);
newContext.Length = ReadInt32();
return true;
}
case State.Complete:
case State.Closed:
return false;
case State.Property:
{
ReadType(_currentElementType);
return true;
}
case State.ObjectStart:
case State.ArrayStart:
case State.PostValue:
ContainerContext context = _currentContext;
if (context == null)
return false;
int lengthMinusEnd = context.Length - 1;
if (context.Position < lengthMinusEnd)
{
if (context.Type == BsonType.Array)
{
ReadElement();
ReadType(_currentElementType);
return true;
}
else
{
SetToken(JsonToken.PropertyName, ReadElement());
return true;
}
}
else if (context.Position == lengthMinusEnd)
{
if (ReadByte() != 0)
throw JsonReaderException.Create(this, "Unexpected end of object byte value.");
PopContext();
if (_currentContext != null)
MovePosition(context.Length);
JsonToken endToken = (context.Type == BsonType.Object) ? JsonToken.EndObject : JsonToken.EndArray;
SetToken(endToken);
return true;
}
else
{
throw JsonReaderException.Create(this, "Read past end of current container context.");
}
case State.ConstructorStart:
break;
case State.Constructor:
break;
case State.Error:
break;
case State.Finished:
break;
default:
throw new ArgumentOutOfRangeException();
}
return false;
}
示例7: ReadCodeWScope
private bool ReadCodeWScope()
{
switch (_bsonReaderState)
{
case BsonReaderState.CodeWScopeStart:
SetToken(JsonToken.PropertyName, "$code");
_bsonReaderState = BsonReaderState.CodeWScopeCode;
return true;
case BsonReaderState.CodeWScopeCode:
// total CodeWScope size - not used
ReadInt32();
SetToken(JsonToken.String, ReadLengthString());
_bsonReaderState = BsonReaderState.CodeWScopeScope;
return true;
case BsonReaderState.CodeWScopeScope:
if (CurrentState == State.PostValue)
{
SetToken(JsonToken.PropertyName, "$scope");
return true;
}
else
{
SetToken(JsonToken.StartObject);
_bsonReaderState = BsonReaderState.CodeWScopeScopeObject;
ContainerContext newContext = new ContainerContext(BsonType.Object);
PushContext(newContext);
newContext.Length = ReadInt32();
return true;
}
case BsonReaderState.CodeWScopeScopeObject:
bool result = ReadNormal();
if (result && TokenType == JsonToken.EndObject)
_bsonReaderState = BsonReaderState.CodeWScopeScopeEnd;
return result;
case BsonReaderState.CodeWScopeScopeEnd:
SetToken(JsonToken.EndObject);
_bsonReaderState = BsonReaderState.Normal;
return true;
default:
throw new ArgumentOutOfRangeException();
}
}
示例8: Process
public void Process(ContainerContext context) {
if (context.Component.ServiceType == typeof (ILogger)) {
if (context.Component.Lifestyle == Lifestyle.Extension && null != context.Component.Implementation) {
_manager.Loggers.Add((ILogger) context.Component.Implementation);
}
else if (!string.IsNullOrEmpty(context.Component.Name)) {
_manager.Loggers.Add(Container.Get<ILogger>(context.Component.Name));
}
}
}
示例9: ReadType
private void ReadType(BsonType type)
{
switch (type)
{
case BsonType.Number:
SetToken(JsonToken.Float, ReadDouble());
break;
case BsonType.String:
case BsonType.Symbol:
SetToken(JsonToken.String, ReadLengthString());
break;
case BsonType.Object:
{
SetToken(JsonToken.StartObject);
ContainerContext newContext = new ContainerContext(JTokenType.Object);
_stack.Add(newContext);
newContext.Length = ReadInt32();
break;
}
case BsonType.Array:
{
SetToken(JsonToken.StartArray);
ContainerContext newContext = new ContainerContext(JTokenType.Array);
_stack.Add(newContext);
newContext.Length = ReadInt32();
break;
}
case BsonType.Binary:
SetToken(JsonToken.Bytes, ReadBinary());
break;
case BsonType.Undefined:
SetToken(JsonToken.Undefined);
break;
case BsonType.Oid:
byte[] oid = ReadBytes(12);
SetToken(JsonToken.Bytes, oid);
break;
case BsonType.Boolean:
bool b = Convert.ToBoolean(ReadByte());
SetToken(JsonToken.Boolean, b);
break;
case BsonType.Date:
long ticks = ReadInt64();
DateTime dateTime = JsonConvert.ConvertJavaScriptTicksToDateTime(ticks);
SetToken(JsonToken.Date, dateTime);
break;
case BsonType.Null:
SetToken(JsonToken.Null);
break;
case BsonType.Regex:
string expression = ReadString();
string modifiers = ReadString();
string regex = @"/" + expression + @"/" + modifiers;
SetToken(JsonToken.String, regex);
break;
case BsonType.Reference:
SetToken(JsonToken.StartObject);
_bsonReaderState = BsonReaderState.ReferenceStart;
break;
case BsonType.Code:
SetToken(JsonToken.String, ReadLengthString());
break;
case BsonType.CodeWScope:
SetToken(JsonToken.StartObject);
_bsonReaderState = BsonReaderState.CodeWScopeStart;
break;
case BsonType.Integer:
SetToken(JsonToken.Integer, (long)ReadInt32());
break;
case BsonType.TimeStamp:
case BsonType.Long:
SetToken(JsonToken.Integer, ReadInt64());
break;
default:
throw new ArgumentOutOfRangeException("type", "Unexpected BsonType value: " + type);
}
}
示例10: PopContext
private void PopContext()
{
_stack.RemoveAt(_stack.Count - 1);
if (_stack.Count == 0)
_currentContext = null;
else
_currentContext = _stack[_stack.Count - 1];
}
示例11: PopContext
private void PopContext()
{
_stack.RemoveAt(_stack.Count - 1);
_currentContext = _stack.Count == 0 ? null : _stack[_stack.Count - 1];
}