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


C# ContainerContext类代码示例

本文整理汇总了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);
        }
开发者ID:jasondentler,项目名称:RockPaperScissors,代码行数:27,代码来源:ContainerContextShould.cs

示例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);
			}
		}
开发者ID:Qorpent,项目名称:qorpent.sys,代码行数:13,代码来源:ApplicationBoundContainerExtension.cs

示例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();
        }
开发者ID:jasondentler,项目名称:RockPaperScissors,代码行数:14,代码来源:ContainerContextShould.cs

示例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);
            }
        }
开发者ID:925coder,项目名称:Newtonsoft.Json,代码行数:100,代码来源:BsonReader.cs

示例5: PushContext

 private void PushContext(ContainerContext newContext)
 {
     _stack.Add(newContext);
     _currentContext = newContext;
 }
开发者ID:925coder,项目名称:Newtonsoft.Json,代码行数:5,代码来源:BsonReader.cs

示例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;
        }
开发者ID:925coder,项目名称:Newtonsoft.Json,代码行数:77,代码来源:BsonReader.cs

示例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();
            }
        }
开发者ID:925coder,项目名称:Newtonsoft.Json,代码行数:46,代码来源:BsonReader.cs

示例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));
					}
				}
			}
开发者ID:Qorpent,项目名称:qorpent.sys,代码行数:10,代码来源:DefaultLogManager.cs

示例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);
      }
    }
开发者ID:anukat2015,项目名称:sones,代码行数:80,代码来源:BsonReader.cs

示例10: PopContext

 private void PopContext()
 {
     _stack.RemoveAt(_stack.Count - 1);
     if (_stack.Count == 0)
         _currentContext = null;
     else
         _currentContext = _stack[_stack.Count - 1];
 }
开发者ID:925coder,项目名称:Newtonsoft.Json,代码行数:8,代码来源:BsonReader.cs

示例11: PopContext

 private void PopContext()
 {
     _stack.RemoveAt(_stack.Count - 1);
     _currentContext = _stack.Count == 0 ? null : _stack[_stack.Count - 1];
 }
开发者ID:sat1582,项目名称:CODEFramework,代码行数:5,代码来源:BsonReader.cs


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