• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# JsonConverter类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中JsonConverter的典型用法代码示例。如果您正苦于以下问题:C# JsonConverter类的具体用法?C# JsonConverter怎么用?C# JsonConverter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



JsonConverter类属于命名空间,在下文中一共展示了JsonConverter类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: SerializeVector3

    /// <summary>
    /// Simple Vector3 Serialization
    /// </summary>
    public void SerializeVector3()
    {
        LogStart("Vector3 Serialization");
        try
        {
            
            var v = new Vector3(2, 4, 6);

			var converters = new JsonConverter[]
			{
				new Vector3Converter()
			};

            var serialized = JsonConvert.SerializeObject(v, Formatting.None, converters);
            LogSerialized(serialized);
            var v2 = JsonConvert.DeserializeObject<Vector3>(serialized);

            LogResult("4", v2.y);

            if (v2.y != v.y)
            {
                DisplayFail("Vector3 Serialization", BAD_RESULT_MESSAGE);
            }

            DisplaySuccess("Vector3 Serialization");
        }
        catch(Exception ex)
        {
            DisplayFail("Vector3 Serialization", ex.Message);
        }

        LogEnd(1);
    }
开发者ID:derlin,项目名称:SymbiosArt-VR,代码行数:36,代码来源:JsonTestScript.cs


示例2: MainPage

        public MainPage()
        {
            InitializeComponent();

            isoSettings = IsolatedStorageSettings.ApplicationSettings;

            basicJsonObjectConverter = new JsonConverter<BasicJsonObject>();
            // TODO Remove
            App.Settings.APP_ID = "cylinder-manager-e30";
            App.Settings.API_KEY = "d6c6b4b7aa0f4162a04f23ebd34c6d2e";
            App.Settings.ADMIN_KEY = "e4b4709e31924777a4521df5fbf57692";

            data = new BasicJsonObject();
            // use two-way binding to set BasicjsonObject's key/value pairs
            JsonObjectGrid.DataContext = data;

            if (isoSettings.Contains(SETTINGS_BUCKET_NAME))
                BucketName_Box.Text = isoSettings[SETTINGS_BUCKET_NAME] as string;
            if (isoSettings.Contains(SETTINGS_OBJECT_ID))
                ObjectId_Box.Text = isoSettings[SETTINGS_OBJECT_ID] as string;
            if (isoSettings.Contains(SETTINGS_CCID))
                CCID_Box.Text = isoSettings[SETTINGS_CCID] as string;
            if (isoSettings.Contains(SETTINGS_CLIENT_ID))
                ClientId_Box.Text = isoSettings[SETTINGS_CLIENT_ID] as string;
        }
开发者ID:ledlie,项目名称:simperium-windows-phone-lib-driver,代码行数:25,代码来源:MainPage.xaml.cs


示例3: TryConvertingFromStreamEmptyToSimpleObject

 public void TryConvertingFromStreamEmptyToSimpleObject()
 {
     using (Stream stream = examples.EmptyObject())
     {
         JsonConverter<ObjectWithName> converter = new JsonConverter<ObjectWithName>();
         ObjectWithName objectExpected = converter.ConvertFrom(stream);
     }
 }
开发者ID:victorbernardino,项目名称:JsonConsumer,代码行数:8,代码来源:JsonConverterTests.cs


示例4: TryConvertingFromJsonToSimpleObject

 public void TryConvertingFromJsonToSimpleObject()
 {
     using (Stream stream = examples.JsonStream())
     {
         JsonConverter<ObjectWithName> converter = new JsonConverter<ObjectWithName>();
         ObjectWithName objectPopulated = converter.ConvertFrom(stream);
         Assert.IsTrue(objectPopulated.Name == Constants.MockObjectValue);
     }
 }
开发者ID:victorbernardino,项目名称:JsonConsumer,代码行数:9,代码来源:JsonConverterTests.cs


示例5: TryConvertingFromEmptyValidObjectToSimpleObject

 public void TryConvertingFromEmptyValidObjectToSimpleObject()
 {
     using (Stream stream = examples.EmptyValidObject())
     {
         JsonConverter<ObjectWithName> converter = new JsonConverter<ObjectWithName>();
         ObjectWithName objectExpected = converter.ConvertFrom(stream);
         Assert.IsTrue(objectExpected.Name == new ObjectWithName().Name);
     }
 }
开发者ID:victorbernardino,项目名称:JsonConsumer,代码行数:9,代码来源:JsonConverterTests.cs


示例6: SerializeValue

    private void SerializeValue(JsonWriter writer, object value, JsonConverter memberConverter)
    {
      JsonConverter converter = memberConverter;

      if (value == null)
      {
        writer.WriteNull();
      }
      else if (converter != null
        || _serializer.HasClassConverter(value.GetType(), out converter)
        || _serializer.HasMatchingConverter(value.GetType(), out converter))
      {
        SerializeConvertable(writer, converter, value);
      }
      else if (JsonConvert.IsJsonPrimitive(value))
      {
        writer.WriteValue(value);
      }
      else if (value is JToken)
      {
        ((JToken)value).WriteTo(writer, (_serializer.Converters != null) ? _serializer.Converters.ToArray() : null);
      }
      else if (value is JsonRaw)
      {
        writer.WriteRawValue(((JsonRaw)value).Content);
      }
      else
      {
        JsonContract contract = _serializer.ContractResolver.ResolveContract(value.GetType());

        if (contract is JsonObjectContract)
        {
          SerializeObject(writer, value, (JsonObjectContract)contract);
        }
        else if (contract is JsonDictionaryContract)
        {
          SerializeDictionary(writer, (IDictionary)value, (JsonDictionaryContract)contract);
        }
        else if (contract is JsonArrayContract)
        {
          if (value is IList)
          {
            SerializeList(writer, (IList)value, (JsonArrayContract)contract);
          }
          else if (value is IEnumerable)
          {
            SerializeEnumerable(writer, (IEnumerable)value, (JsonArrayContract)contract);
          }
          else
          {
            throw new Exception("Cannot serialize '{0}' into a JSON array. Type does not implement IEnumerable.".FormatWith(CultureInfo.InvariantCulture, value.GetType()));
          }
        }
      }
    }
开发者ID:oduma,项目名称:Sciendo.Fitas.Droid,代码行数:55,代码来源:JsonSerializerWriter.cs


示例7: JsonMemberMapping

 public JsonMemberMapping(string mappingName, MemberInfo member, bool ignored, bool readable, bool writable, JsonConverter memberConverter, object defaultValue, bool required)
 {
     _mappingName = mappingName;
       _member = member;
       _ignored = ignored;
       _readable = readable;
       _writable = writable;
       _memberConverter = memberConverter;
       _defaultValue = defaultValue;
       _required = required;
 }
开发者ID:jabbo,项目名称:Jabbo,代码行数:11,代码来源:JsonMemberMapping.cs


示例8: SetPropertyValue

 // Token: 0x06000BC8 RID: 3016
 // RVA: 0x00044828 File Offset: 0x00042A28
 private bool SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, object target)
 {
     bool flag;
     object value;
     JsonContract contract;
     bool flag2;
     if (this.CalculatePropertyDetails(property, ref propertyConverter, containerContract, containerProperty, reader, target, out flag, out value, out contract, out flag2))
     {
         return false;
     }
     object obj;
     if (propertyConverter != null && propertyConverter.CanRead)
     {
         if (!flag2 && target != null && property.Readable)
         {
             value = property.ValueProvider.GetValue(target);
         }
         obj = this.DeserializeConvertable(propertyConverter, reader, property.PropertyType, value);
     }
     else
     {
         obj = this.CreateValueInternal(reader, property.PropertyType, contract, property, containerContract, containerProperty, flag ? value : null);
     }
     if ((!flag || obj != value) && this.ShouldSetPropertyValue(property, obj))
     {
         property.ValueProvider.SetValue(target, obj);
         if (property.SetIsSpecified != null)
         {
             if (this.TraceWriter != null && this.TraceWriter.LevelFilter >= TraceLevel.Verbose)
             {
                 this.TraceWriter.Trace(TraceLevel.Verbose, JsonPosition.FormatMessage(reader as IJsonLineInfo, reader.Path, StringUtils.FormatWith("IsSpecified for property '{0}' on {1} set to true.", CultureInfo.InvariantCulture, property.PropertyName, property.DeclaringType)), null);
             }
             property.SetIsSpecified(target, true);
         }
         return true;
     }
     return flag;
 }
开发者ID:newchild,项目名称:Project-DayZero,代码行数:40,代码来源:JsonSerializerInternalReader.cs


示例9: GetConverter

 private JsonConverter GetConverter(JsonContract contract, JsonConverter memberConverter)
 {
   JsonConverter converter = null;
   if (memberConverter != null)
   {
     // member attribute converter
     converter = memberConverter;
   }
   else if (contract != null)
   {
     JsonConverter matchingConverter;
     if (contract.Converter != null)
       // class attribute converter
       converter = contract.Converter;
     else if ((matchingConverter = Serializer.GetMatchingConverter(contract.UnderlyingType)) != null)
       // passed in converters
       converter = matchingConverter;
     else if (contract.InternalConverter != null)
       // internally specified converter
       converter = contract.InternalConverter;
   }
   return converter;
 }
开发者ID:bladefist,项目名称:Newtonsoft.Json,代码行数:23,代码来源:JsonSerializerInternalReader.cs


示例10: CreateValueProperty

    private object CreateValueProperty(JsonReader reader, JsonProperty property, JsonConverter propertyConverter, object target, bool gottenCurrentValue, object currentValue)
    {
      JsonContract contract;
      JsonConverter converter;

      if (property.PropertyContract == null)
        property.PropertyContract = GetContractSafe(property.PropertyType);

      if (currentValue == null)
      {
        contract = property.PropertyContract;
        converter = propertyConverter;
      }
      else
      {
        contract = GetContractSafe(currentValue.GetType());

        if (contract != property.PropertyContract)
          converter = GetConverter(contract, property.MemberConverter);
        else
          converter = propertyConverter;
      }

      Type objectType = property.PropertyType;

      if (converter != null && converter.CanRead)
      {
        if (!gottenCurrentValue && target != null && property.Readable)
          currentValue = property.ValueProvider.GetValue(target);

        return converter.ReadJson(reader, objectType, currentValue, GetInternalSerializer());
      }

      return CreateValueInternal(reader, objectType, contract, property, currentValue);
    }
开发者ID:bladefist,项目名称:Newtonsoft.Json,代码行数:35,代码来源:JsonSerializerInternalReader.cs


示例11: SerializeConvertable

    private void SerializeConvertable(JsonWriter writer, JsonConverter converter, object value, JsonContract contract, JsonContainerContract collectionContract, JsonProperty containerProperty)
    {
      if (ShouldWriteReference(value, null, contract, collectionContract, containerProperty))
      {
        WriteReference(writer, value);
      }
      else
      {
        if (!CheckForCircularReference(writer, value, null, contract, collectionContract, containerProperty))
          return;

        _serializeStack.Add(value);

        if (TraceWriter != null && TraceWriter.LevelFilter >= TraceLevel.Info)
          TraceWriter.Trace(TraceLevel.Info, JsonPosition.FormatMessage(null, writer.Path, "Started serializing {0} with converter {1}.".FormatWith(CultureInfo.InvariantCulture, value.GetType(), converter.GetType())), null);

        converter.WriteJson(writer, value, GetInternalSerializer());

        if (TraceWriter != null && TraceWriter.LevelFilter >= TraceLevel.Info)
          TraceWriter.Trace(TraceLevel.Info, JsonPosition.FormatMessage(null, writer.Path, "Finished serializing {0} with converter {1}.".FormatWith(CultureInfo.InvariantCulture, value.GetType(), converter.GetType())), null);

        _serializeStack.RemoveAt(_serializeStack.Count - 1);
      }
    }
开发者ID:EnergonV,项目名称:BestCS,代码行数:24,代码来源:JsonSerializerInternalWriter.cs


示例12: CalculatePropertyDetails

        private bool CalculatePropertyDetails(JsonProperty property, ref JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, object target, out bool useExistingValue, out object currentValue, out JsonContract propertyContract, out bool gottenCurrentValue)
        {
            currentValue = null;
              useExistingValue = false;
              propertyContract = null;
              gottenCurrentValue = false;

              if (property.Ignored)
            return true;

              JsonToken tokenType = reader.TokenType;

              if (property.PropertyContract == null)
            property.PropertyContract = GetContractSafe(property.PropertyType);

              ObjectCreationHandling objectCreationHandling =
            property.ObjectCreationHandling.GetValueOrDefault(Serializer._objectCreationHandling);

              if ((objectCreationHandling != ObjectCreationHandling.Replace)
              && (tokenType == JsonToken.StartArray || tokenType == JsonToken.StartObject)
              && property.Readable)
              {
            currentValue = property.ValueProvider.GetValue(target);
            gottenCurrentValue = true;

            if (currentValue != null)
            {
              propertyContract = GetContractSafe(currentValue.GetType());

              useExistingValue = (!propertyContract.IsReadOnlyOrFixedSize && !propertyContract.UnderlyingType.IsValueType());
            }
              }

              if (!property.Writable && !useExistingValue)
            return true;

              // test tokentype here because null might not be convertable to some types, e.g. ignoring null when applied to DateTime
              if (property.NullValueHandling.GetValueOrDefault(Serializer._nullValueHandling) == NullValueHandling.Ignore && tokenType == JsonToken.Null)
            return true;

              // test tokentype here because default value might not be convertable to actual type, e.g. default of "" for DateTime
              if (HasFlag(property.DefaultValueHandling.GetValueOrDefault(Serializer._defaultValueHandling), DefaultValueHandling.Ignore)
              && !HasFlag(property.DefaultValueHandling.GetValueOrDefault(Serializer._defaultValueHandling), DefaultValueHandling.Populate)
              && JsonReader.IsPrimitiveToken(tokenType)
              && MiscellaneousUtils.ValueEquals(reader.Value, property.GetResolvedDefaultValue()))
            return true;

              if (currentValue == null)
              {
            propertyContract = property.PropertyContract;
              }
              else
              {
            propertyContract = GetContractSafe(currentValue.GetType());

            if (propertyContract != property.PropertyContract)
              propertyConverter = GetConverter(propertyContract, property.MemberConverter, containerContract, containerProperty);
              }

              return false;
        }
开发者ID:rv192,项目名称:Fussen,代码行数:61,代码来源:JsonSerializerInternalReader.cs


示例13: CalculatePropertyDetails

    private bool CalculatePropertyDetails(JsonProperty property, ref JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, object target, out bool useExistingValue, out object currentValue, out JsonContract propertyContract, out bool gottenCurrentValue)
    {
      currentValue = null;
      useExistingValue = false;
      propertyContract = null;
      gottenCurrentValue = false;

      if (property.Ignored)
      {
        reader.Skip();
        return true;
      }

      ObjectCreationHandling objectCreationHandling =
        property.ObjectCreationHandling.GetValueOrDefault(Serializer.ObjectCreationHandling);

      if ((objectCreationHandling == ObjectCreationHandling.Auto || objectCreationHandling == ObjectCreationHandling.Reuse)
          && (reader.TokenType == JsonToken.StartArray || reader.TokenType == JsonToken.StartObject)
          && property.Readable)
      {
        currentValue = property.ValueProvider.GetValue(target);
        gottenCurrentValue = true;

        useExistingValue = (currentValue != null
                            && !property.PropertyType.IsArray
                            && !ReflectionUtils.InheritsGenericDefinition(property.PropertyType, typeof (ReadOnlyCollection<>))
                            && !property.PropertyType.IsValueType());
      }

      if (!property.Writable && !useExistingValue)
      {
        reader.Skip();
        return true;
      }

      // test tokentype here because null might not be convertable to some types, e.g. ignoring null when applied to DateTime
      if (property.NullValueHandling.GetValueOrDefault(Serializer.NullValueHandling) == NullValueHandling.Ignore && reader.TokenType == JsonToken.Null)
      {
        reader.Skip();
        return true;
      }

      // test tokentype here because default value might not be convertable to actual type, e.g. default of "" for DateTime
      if (HasFlag(property.DefaultValueHandling.GetValueOrDefault(Serializer.DefaultValueHandling), DefaultValueHandling.Ignore)
          && JsonReader.IsPrimitiveToken(reader.TokenType)
          && MiscellaneousUtils.ValueEquals(reader.Value, property.GetResolvedDefaultValue()))
      {
        reader.Skip();
        return true;
      }

      if (property.PropertyContract == null)
        property.PropertyContract = GetContractSafe(property.PropertyType);

      if (currentValue == null)
      {
        propertyContract = property.PropertyContract;
      }
      else
      {
        propertyContract = GetContractSafe(currentValue.GetType());

        if (propertyContract != property.PropertyContract)
          propertyConverter = GetConverter(propertyContract, property.MemberConverter, containerContract, containerProperty);
      }

      return false;
    }
开发者ID:joshholl,项目名称:Newtonsoft.Json,代码行数:68,代码来源:JsonSerializerInternalReader.cs


示例14: CreateValue

        private object CreateValue(JsonReader reader, Type objectType, object existingValue, JsonConverter memberConverter)
        {
            JsonConverter converter;

              if (memberConverter != null)
            return memberConverter.ReadJson(reader, objectType, GetInternalSerializer());

              if (objectType != null && _serializer.HasClassConverter(objectType, out converter))
            return converter.ReadJson(reader, objectType, GetInternalSerializer());

              if (objectType != null && _serializer.HasMatchingConverter(objectType, out converter))
            return converter.ReadJson(reader, objectType, GetInternalSerializer());

              if (objectType == typeof (JsonRaw))
            return JsonRaw.Create(reader);

              do
              {
            switch (reader.TokenType)
            {
            // populate a typed object or generic dictionary/array
            // depending upon whether an objectType was supplied
              case JsonToken.StartObject:
            return CreateObject(reader, objectType, existingValue);
              case JsonToken.StartArray:
            return CreateList(reader, objectType, existingValue, null);
              case JsonToken.Integer:
              case JsonToken.Float:
              case JsonToken.String:
              case JsonToken.Boolean:
              case JsonToken.Date:
            return EnsureType(reader.Value, objectType);
              case JsonToken.StartConstructor:
              case JsonToken.EndConstructor:
            string constructorName = reader.Value.ToString();

            return constructorName;
              case JsonToken.Null:
              case JsonToken.Undefined:
            if (objectType == typeof (DBNull))
              return DBNull.Value;

            return null;
              case JsonToken.Comment:
            // ignore
            break;
              default:
            throw new JsonSerializationException("Unexpected token while deserializing object: " + reader.TokenType);
            }
              } while (reader.Read());

              throw new JsonSerializationException("Unexpected end when deserializing object.");
        }
开发者ID:BGCX262,项目名称:zulu-omoto-pos-client-svn-to-git,代码行数:53,代码来源:JsonSerializerReader.cs


示例15: TryConvertingFromStreamNullToSimpleObject

 public void TryConvertingFromStreamNullToSimpleObject()
 {
     JsonConverter<ObjectWithName> converter = new JsonConverter<ObjectWithName>();
     ObjectWithName objectExpected = converter.ConvertFrom(null);
     Assert.IsTrue(objectExpected.Name == new ObjectWithName().Name);
 }
开发者ID:victorbernardino,项目名称:JsonConsumer,代码行数:6,代码来源:JsonConverterTests.cs


示例16: DeserializeConvertable

 // Token: 0x06000BD8 RID: 3032
 // RVA: 0x00045C64 File Offset: 0x00043E64
 private object DeserializeConvertable(JsonConverter converter, JsonReader reader, Type objectType, object existingValue)
 {
     if (this.TraceWriter != null && this.TraceWriter.LevelFilter >= TraceLevel.Info)
     {
         this.TraceWriter.Trace(TraceLevel.Info, JsonPosition.FormatMessage(reader as IJsonLineInfo, reader.Path, StringUtils.FormatWith("Started deserializing {0} with converter {1}.", CultureInfo.InvariantCulture, objectType, converter.GetType())), null);
     }
     object result = converter.ReadJson(reader, objectType, existingValue, this.GetInternalSerializer());
     if (this.TraceWriter != null && this.TraceWriter.LevelFilter >= TraceLevel.Info)
     {
         this.TraceWriter.Trace(TraceLevel.Info, JsonPosition.FormatMessage(reader as IJsonLineInfo, reader.Path, StringUtils.FormatWith("Finished deserializing {0} with converter {1}.", CultureInfo.InvariantCulture, objectType, converter.GetType())), null);
     }
     return result;
 }
开发者ID:newchild,项目名称:Project-DayZero,代码行数:15,代码来源:JsonSerializerInternalReader.cs


示例17: CalculatePropertyDetails

 // Token: 0x06000BC9 RID: 3017
 // RVA: 0x00044940 File Offset: 0x00042B40
 private bool CalculatePropertyDetails(JsonProperty property, ref JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, object target, out bool useExistingValue, out object currentValue, out JsonContract propertyContract, out bool gottenCurrentValue)
 {
     currentValue = null;
     useExistingValue = false;
     propertyContract = null;
     gottenCurrentValue = false;
     if (property.Ignored)
     {
         return true;
     }
     JsonToken tokenType = reader.TokenType;
     if (property.PropertyContract == null)
     {
         property.PropertyContract = this.GetContractSafe(property.PropertyType);
     }
     ObjectCreationHandling valueOrDefault = property.ObjectCreationHandling.GetValueOrDefault(this.Serializer._objectCreationHandling);
     if (valueOrDefault != ObjectCreationHandling.Replace && (tokenType == JsonToken.StartArray || tokenType == JsonToken.StartObject) && property.Readable)
     {
         currentValue = property.ValueProvider.GetValue(target);
         gottenCurrentValue = true;
         if (currentValue != null)
         {
             propertyContract = this.GetContractSafe(currentValue.GetType());
             useExistingValue = (!propertyContract.IsReadOnlyOrFixedSize && !TypeExtensions.IsValueType(propertyContract.UnderlyingType));
         }
     }
     if (!property.Writable && !useExistingValue)
     {
         return true;
     }
     if (property.NullValueHandling.GetValueOrDefault(this.Serializer._nullValueHandling) == NullValueHandling.Ignore && tokenType == JsonToken.Null)
     {
         return true;
     }
     if (this.HasFlag(property.DefaultValueHandling.GetValueOrDefault(this.Serializer._defaultValueHandling), DefaultValueHandling.Ignore) && !this.HasFlag(property.DefaultValueHandling.GetValueOrDefault(this.Serializer._defaultValueHandling), DefaultValueHandling.Populate) && JsonTokenUtils.IsPrimitiveToken(tokenType) && MiscellaneousUtils.ValueEquals(reader.Value, property.GetResolvedDefaultValue()))
     {
         return true;
     }
     if (currentValue == null)
     {
         propertyContract = property.PropertyContract;
     }
     else
     {
         propertyContract = this.GetContractSafe(currentValue.GetType());
         if (propertyContract != property.PropertyContract)
         {
             propertyConverter = this.GetConverter(propertyContract, property.MemberConverter, containerContract, containerProperty);
         }
     }
     return false;
 }
开发者ID:newchild,项目名称:Project-DayZero,代码行数:54,代码来源:JsonSerializerInternalReader.cs


示例18: ReadForType

    private bool ReadForType(JsonReader reader, Type t, JsonConverter propertyConverter)
    {
      // don't read properties with converters as a specific value
      // the value might be a string which will then get converted which will error if read as date for example
      bool hasConverter = (GetConverter(GetContractSafe(t), propertyConverter) != null);

      if (hasConverter)
        return reader.Read();

      if (t == typeof(byte[]))
      {
        reader.ReadAsBytes();
        return true;
      }
      else if ((t == typeof(decimal) || t == typeof(decimal?)))
      {
        reader.ReadAsDecimal();
        return true;
      }
#if !NET20
      else if ((t == typeof(DateTimeOffset) || t == typeof(DateTimeOffset?)))
      {
        reader.ReadAsDateTimeOffset();
        return true;
      }
#endif

      do
      {
        if (!reader.Read())
          return false;
      } while (reader.TokenType == JsonToken.Comment);

      return true;
    }
开发者ID:TheoBo,项目名称:Wallet.Net,代码行数:35,代码来源:JsonSerializerInternalReader.cs


示例19: SetPropertyValue

    private void SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, object target)
    {
      object currentValue;
      bool useExistingValue;
      JsonContract propertyContract;
      bool gottenCurrentValue;

      if (CalculatePropertyDetails(property, ref propertyConverter, containerContract, containerProperty, reader, target, out useExistingValue, out currentValue, out propertyContract, out gottenCurrentValue))
        return;

      object value;

      if (propertyConverter != null && propertyConverter.CanRead)
      {
        if (!gottenCurrentValue && target != null && property.Readable)
          currentValue = property.ValueProvider.GetValue(target);

        value = propertyConverter.ReadJson(reader, property.PropertyType, currentValue, GetInternalSerializer());
      }
      else
      {
        value = CreateValueInternal(reader, property.PropertyType, propertyContract, property, containerContract, containerProperty, (useExistingValue) ? currentValue : null);
      }

      // always set the value if useExistingValue is false,
      // otherwise also set it if CreateValue returns a new value compared to the currentValue
      // this could happen because of a JsonConverter against the type
      if ((!useExistingValue || value != currentValue)
        && ShouldSetPropertyValue(property, value))
      {
        property.ValueProvider.SetValue(target, value);

        if (property.SetIsSpecified != null)
          property.SetIsSpecified(target, true);
      }
    }
开发者ID:Contatta,项目名称:Newtonsoft.Json,代码行数:36,代码来源:JsonSerializerInternalReader.cs


示例20: DeserializeConvertable

 private object DeserializeConvertable(JsonConverter converter, JsonReader reader, Type objectType, object existingValue)
 {
     object value = converter.ReadJson(reader, objectType, existingValue, GetInternalSerializer());
     return value;
 }
开发者ID:UnifyKit,项目名称:OsmSharp,代码行数:5,代码来源:JsonSerializerInternalReader.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# JsonData类代码示例发布时间:2022-05-24
下一篇:
C# JsonContainerType类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap