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


C# Context.Store方法代码示例

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


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

示例1: TestLookup

        public void TestLookup()
        {
            var allocationInstruction =
                new MessageTemplate(ObjectMother.AllocationInstruction)
                    {
                        TypeReference = new QName("AllocationInstruction")
                    };

            var allocations = new Sequence(ObjectMother.Allocations) {TypeReference = new QName("Allocation")};

            var context = new Context();

            context.Store(DictionaryFields.Type, allocationInstruction, new QName("ID"), String("1234"));

            Assert.AreEqual(String("1234"),
                            context.Lookup(DictionaryFields.Type, allocationInstruction, new QName("ID")));
            Assert.AreEqual(ScalarValue.Undefined,
                            context.Lookup(DictionaryFields.Type, allocations.Group, new QName("ID")));
        }
开发者ID:shariqkudcs,项目名称:openfastdotnet,代码行数:19,代码来源:ApplicationTypeDictionaryTest.cs

示例2: Encode

 public override byte[] Encode(FieldValue fieldValue, Group encodeTemplate, Context context, BitVectorBuilder presenceMapBuilder)
 {
     var priorValue = context.Lookup(Dictionary, encodeTemplate, Key);
     var value_Renamed = (ScalarValue) fieldValue;
     if (!operatorCodec.CanEncode(value_Renamed, this))
     {
         Global.HandleError(Error.FastConstants.D3_CANT_ENCODE_VALUE, "The scalar " + this + " cannot encode the value " + value_Renamed);
     }
     var valueToEncode = operatorCodec.GetValueToEncode(value_Renamed, priorValue, this, presenceMapBuilder);
     if (operator_Renamed.ShouldStoreValue(value_Renamed))
     {
         context.Store(Dictionary, encodeTemplate, Key, value_Renamed);
     }
     if (valueToEncode == null)
     {
         return new byte[0];
     }
     byte[] encoding = typeCodec.Encode(valueToEncode);
     if (context.TraceEnabled && encoding.Length > 0)
     {
         context.GetEncodeTrace().Field(this, fieldValue, valueToEncode, encoding, presenceMapBuilder.Index);
     }
     return encoding;
 }
开发者ID:marlonbomfim,项目名称:openfastdotnet,代码行数:24,代码来源:Scalar.cs

示例3: Decode

 public override FieldValue Decode(System.IO.Stream in_Renamed, Group decodeTemplate, Context context, BitVectorReader presenceMapReader)
 {
     try
     {
         ScalarValue previousValue = null;
         if (operator_Renamed.UsesDictionary())
         {
             previousValue = context.Lookup(Dictionary, decodeTemplate, Key);
             ValidateDictionaryTypeAgainstFieldType(previousValue, type);
         }
         ScalarValue value_Renamed;
         int pmapIndex = presenceMapReader.Index;
         if (IsPresent(presenceMapReader))
         {
             if (context.TraceEnabled)
                 in_Renamed = new RecordingInputStream(in_Renamed);
             if (!operatorCodec.ShouldDecodeType())
             {
                 return operatorCodec.DecodeValue(null, null, this);
             }
             ScalarValue decodedValue = typeCodec.Decode(in_Renamed);
             value_Renamed = DecodeValue(decodedValue, previousValue);
             if (context.TraceEnabled)
                 context.DecodeTrace.Field(this, value_Renamed, decodedValue, ((RecordingInputStream) in_Renamed).Buffer, pmapIndex);
         }
         else
         {
             value_Renamed = Decode(previousValue);
         }
         ValidateDecodedValueIsCorrectForType(value_Renamed, type);
         if (!((Operator == Template.Operator.Operator.DELTA) && (value_Renamed == null)))
         {
             context.Store(Dictionary, decodeTemplate, Key, value_Renamed);
         }
         return value_Renamed;
     }
     catch (FastException e)
     {
         throw new FastException("Error occurred while decoding " + this, e.Code, e);
     }
 }
开发者ID:marlonbomfim,项目名称:openfastdotnet,代码行数:41,代码来源:Scalar.cs

示例4: Encode

        public override byte[] Encode(IFieldValue fieldValue, Group encodeTemplate, Context context,
                                      BitVectorBuilder presenceMapBuilder)
        {
            IDictionary dict = context.GetDictionary(Dictionary);

            ScalarValue priorValue = context.Lookup(dict, encodeTemplate, Key);
            var value = (ScalarValue) fieldValue;
            if (!_operatorCodec.CanEncode(value, this))
            {
                Global.ErrorHandler.OnError(null, DynError.CantEncodeValue,
                                            "The scalar {0} cannot encode the value {1}", this, value);
            }
            ScalarValue valueToEncode = _operatorCodec.GetValueToEncode(value, priorValue, this,
                                                                        presenceMapBuilder);
            if (_operator.ShouldStoreValue(value))
            {
                context.Store(dict, encodeTemplate, Key, value);
            }
            if (valueToEncode == null)
            {
                return ByteUtil.EmptyByteArray;
            }
            byte[] encoding = _typeCodec.Encode(valueToEncode);
            if (context.TraceEnabled && encoding.Length > 0)
            {
                context.EncodeTrace.Field(this, fieldValue, valueToEncode, encoding, presenceMapBuilder.Index);
            }
            return encoding;
        }
开发者ID:shariqkudcs,项目名称:openfastdotnet,代码行数:29,代码来源:Scalar.cs

示例5: Decode

        public override IFieldValue Decode(Stream inStream, Group decodeTemplate, Context context,
                                           BitVectorReader presenceMapReader)
        {
            try
            {
                ScalarValue priorValue = null;
                IDictionary dict = null;
                QName key = Key;

                ScalarValue value;
                int pmapIndex = presenceMapReader.Index;
                if (IsPresent(presenceMapReader))
                {
                    if (context.TraceEnabled)
                        inStream = new RecordingInputStream(inStream);

                    if (!_operatorCodec.ShouldDecodeType)
                        return _operatorCodec.DecodeValue(null, null, this);

                    if (_operatorCodec.DecodeNewValueNeedsPrevious)
                    {
                        dict = context.GetDictionary(Dictionary);
                        priorValue = context.Lookup(dict, decodeTemplate, key);
                        ValidateDictionaryTypeAgainstFieldType(priorValue, _fastType);
                    }

                    ScalarValue decodedValue = _typeCodec.Decode(inStream);
                    value = _operatorCodec.DecodeValue(decodedValue, priorValue, this);

                    if (context.TraceEnabled)
                        context.DecodeTrace.Field(this, value, decodedValue,
                                                  ((RecordingInputStream) inStream).Buffer, pmapIndex);
                }
                else
                {
                    if (_operatorCodec.DecodeEmptyValueNeedsPrevious)
                    {
                        dict = context.GetDictionary(Dictionary);
                        priorValue = context.Lookup(dict, decodeTemplate, key);
                        ValidateDictionaryTypeAgainstFieldType(priorValue, _fastType);
                    }

                    value = _operatorCodec.DecodeEmptyValue(priorValue, this);
                }

                ValidateDecodedValueIsCorrectForType(value, _fastType);

            #warning TODO: Review if this previous "if" statement is needed.
                // if (Operator != Template.Operator.Operator.DELTA || value != null)
                if (value != null &&
                    (_operatorCodec.DecodeNewValueNeedsPrevious || _operatorCodec.DecodeEmptyValueNeedsPrevious))
                {
                    context.Store(dict ?? context.GetDictionary(Dictionary), decodeTemplate, key, value);
                }

                return value;
            }
            catch (DynErrorException e)
            {
                throw new DynErrorException(e, e.Error, "Error occurred while decoding {0}", this);
            }
        }
开发者ID:shariqkudcs,项目名称:openfastdotnet,代码行数:62,代码来源:Scalar.cs


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