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


C# ReadType类代码示例

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


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

示例1: GarminUSBReader_Progress

 private void GarminUSBReader_Progress(ReadType readType, int step, int maxSteps, double partCompleted)
 {
     if (InvokeRequired)
       {
     BeginInvoke(new ProgressDelegate(GarminUSBReader_Progress), readType, step, maxSteps, partCompleted);
     return;
       }
       status.Text = string.Format(Strings.Status, step, maxSteps, GetReadTypeString(readType));
       progressBar.Value = (int)(100 * partCompleted);
 }
开发者ID:romanbdev,项目名称:quickroute-gps,代码行数:10,代码来源:ProgressIndicator.cs

示例2: _SocketState

		public _SocketState(Stream strm,long lengthToRead,long maxLength,object tag,SocketCallBack callBack)
		{			
			m_pStream     = strm;
			m_LenthToRead = lengthToRead;
			m_MaxLength   = maxLength;
			m_Tag         = tag;
			m_pCallback   = callBack;

			m_RecvType = ReadType.Length;
		}
开发者ID:sidneylimafilho,项目名称:InfoControl,代码行数:10,代码来源:_SocketState.cs

示例3: GetReadTypeString

 private static string GetReadTypeString(ReadType readType)
 {
     switch (readType)
       {
     case ReadType.ProductData:
       return Strings.ProductData;
     case ReadType.Runs:
       return Strings.Runs;
     case ReadType.Laps:
       return Strings.Laps;
     case ReadType.Tracks:
       return Strings.Tracks;
       }
       return "";
 }
开发者ID:romanbdev,项目名称:quickroute-gps,代码行数:15,代码来源:ProgressIndicator.cs

示例4: JsonContract

 internal JsonContract(Type underlyingType)
 {
   ValidationUtils.ArgumentNotNull((object) underlyingType, "underlyingType");
   this.UnderlyingType = underlyingType;
   this.IsNullable = ReflectionUtils.IsNullable(underlyingType);
   this.NonNullableUnderlyingType = !this.IsNullable || !ReflectionUtils.IsNullableType(underlyingType) ? underlyingType : Nullable.GetUnderlyingType(underlyingType);
   this.CreatedType = this.NonNullableUnderlyingType;
   this.IsConvertable = ConvertUtils.IsConvertible(this.NonNullableUnderlyingType);
   if (this.NonNullableUnderlyingType == typeof (byte[]))
     this.InternalReadType = ReadType.ReadAsBytes;
   else if (this.NonNullableUnderlyingType == typeof (int))
     this.InternalReadType = ReadType.ReadAsInt32;
   else if (this.NonNullableUnderlyingType == typeof (Decimal))
     this.InternalReadType = ReadType.ReadAsDecimal;
   else if (this.NonNullableUnderlyingType == typeof (string))
     this.InternalReadType = ReadType.ReadAsString;
   else if (this.NonNullableUnderlyingType == typeof (DateTime))
     this.InternalReadType = ReadType.ReadAsDateTime;
   else
     this.InternalReadType = ReadType.Read;
 }
开发者ID:Zeludon,项目名称:FEZ,代码行数:21,代码来源:JsonContract.cs

示例5: JsonContract

 // Token: 0x060002A5 RID: 677
 // RVA: 0x0002EEF0 File Offset: 0x0002D0F0
 internal JsonContract(Type underlyingType)
 {
     ValidationUtils.ArgumentNotNull(underlyingType, "underlyingType");
     this.UnderlyingType = underlyingType;
     this.IsNullable = ReflectionUtils.IsNullable(underlyingType);
     this.NonNullableUnderlyingType = ((!this.IsNullable || !ReflectionUtils.IsNullableType(underlyingType)) ? underlyingType : Nullable.GetUnderlyingType(underlyingType));
     this.CreatedType = this.NonNullableUnderlyingType;
     this.IsConvertable = ConvertUtils.IsConvertible(this.NonNullableUnderlyingType);
     this.IsEnum = TypeExtensions.IsEnum(this.NonNullableUnderlyingType);
     if (this.NonNullableUnderlyingType == typeof(byte[]))
     {
         this.InternalReadType = ReadType.ReadAsBytes;
         return;
     }
     if (this.NonNullableUnderlyingType == typeof(int))
     {
         this.InternalReadType = ReadType.ReadAsInt32;
         return;
     }
     if (this.NonNullableUnderlyingType == typeof(decimal))
     {
         this.InternalReadType = ReadType.ReadAsDecimal;
         return;
     }
     if (this.NonNullableUnderlyingType == typeof(string))
     {
         this.InternalReadType = ReadType.ReadAsString;
         return;
     }
     if (this.NonNullableUnderlyingType == typeof(DateTime))
     {
         this.InternalReadType = ReadType.ReadAsDateTime;
         return;
     }
     this.InternalReadType = ReadType.Read;
 }
开发者ID:newchild,项目名称:Project-DayZero,代码行数:38,代码来源:JsonContract.cs

示例6: ReadAsDecimalInternal

        internal decimal? ReadAsDecimalInternal()
        {
            _readType = ReadType.ReadAsDecimal;

            JsonToken t;

            do
            {
                if (!ReadInternal())
                {
                    SetToken(JsonToken.None);
                    return null;
                }
                else
                {
                    t = TokenType;
                }
            } while (t == JsonToken.Comment);

            if (t == JsonToken.Integer || t == JsonToken.Float)
            {
                if (!(Value is decimal))
                    SetToken(JsonToken.Float, Convert.ToDecimal(Value, CultureInfo.InvariantCulture), false);

                return (decimal)Value;
            }

            if (t == JsonToken.Null)
                return null;

            if (t == JsonToken.String)
            {
                string s = (string)Value;
                if (string.IsNullOrEmpty(s))
                {
                    SetToken(JsonToken.Null);
                    return null;
                }

                decimal d;
                if (decimal.TryParse(s, NumberStyles.Number, Culture, out d))
                {
                    SetToken(JsonToken.Float, d, false);
                    return d;
                }
                else
                {
                    throw JsonReaderException.Create(this, "Could not convert string to decimal: {0}.".FormatWith(CultureInfo.InvariantCulture, Value));
                }
            }

            if (t == JsonToken.EndArray)
                return null;

            throw JsonReaderException.Create(this, "Error reading decimal. Unexpected token: {0}.".FormatWith(CultureInfo.InvariantCulture, t));
        }
开发者ID:sdgdsffdsfff,项目名称:hermes.net,代码行数:56,代码来源:JsonReader.cs

示例7: ReadAsDateTimeOffsetInternal

        internal DateTimeOffset? ReadAsDateTimeOffsetInternal()
        {
            _readType = ReadType.ReadAsDateTimeOffset;

            JsonToken t;

            do
            {
                if (!ReadInternal())
                {
                    SetToken(JsonToken.None);
                    return null;
                }
                else
                {
                    t = TokenType;
                }
            } while (t == JsonToken.Comment);

            if (t == JsonToken.Date)
            {
                if (Value is DateTime)
                    SetToken(JsonToken.Date, new DateTimeOffset((DateTime)Value), false);

                return (DateTimeOffset)Value;
            }

            if (t == JsonToken.Null)
                return null;

            if (t == JsonToken.String)
            {
                string s = (string)Value;
                if (string.IsNullOrEmpty(s))
                {
                    SetToken(JsonToken.Null);
                    return null;
                }

                DateTimeOffset dt;
                if (DateTimeUtils.TryParseDateTimeOffset(s, _dateFormatString, Culture, out dt))
                {
                    SetToken(JsonToken.Date, dt, false);
                    return dt;
                }

                if (DateTimeOffset.TryParse(s, Culture, DateTimeStyles.RoundtripKind, out dt))
                {
                    SetToken(JsonToken.Date, dt, false);
                    return dt;
                }
                
                throw JsonReaderException.Create(this, "Could not convert string to DateTimeOffset: {0}.".FormatWith(CultureInfo.InvariantCulture, Value));
            }

            if (t == JsonToken.EndArray)
                return null;

            throw JsonReaderException.Create(this, "Error reading date. Unexpected token: {0}.".FormatWith(CultureInfo.InvariantCulture, t));
        }
开发者ID:Zainulabdeen,项目名称:Newtonsoft.Json,代码行数:60,代码来源:JsonReader.cs

示例8: ReadAsBytesInternal

        internal byte[] ReadAsBytesInternal()
        {
            _readType = ReadType.ReadAsBytes;

            JsonToken t;

            do
            {
                if (!ReadInternal())
                {
                    SetToken(JsonToken.None);
                    return null;
                }
                else
                {
                    t = TokenType;
                }
            } while (t == JsonToken.Comment);

            if (IsWrappedInTypeObject())
            {
                byte[] data = ReadAsBytes();
                ReadInternal();
                SetToken(JsonToken.Bytes, data, false);
                return data;
            }

            // attempt to convert possible base 64 string to bytes
            if (t == JsonToken.String)
            {
                string s = (string)Value;

                byte[] data;

                Guid g;
                if (s.Length == 0)
                {
                    data = new byte[0];
                }
                else if (ConvertUtils.TryConvertGuid(s, out g))
                {
                    data = g.ToByteArray();
                }
                else
                {
                    data = Convert.FromBase64String(s);
                }

                SetToken(JsonToken.Bytes, data, false);
                return data;
            }

            if (t == JsonToken.Null)
                return null;

            if (t == JsonToken.Bytes)
            {
                if (ValueType == typeof(Guid))
                {
                    byte[] data = ((Guid)Value).ToByteArray();
                    SetToken(JsonToken.Bytes, data, false);
                    return data;
                }

                return (byte[])Value;
            }

            if (t == JsonToken.StartArray)
            {
                List<byte> data = new List<byte>();

                while (ReadInternal())
                {
                    t = TokenType;
                    switch (t)
                    {
                        case JsonToken.Integer:
                            data.Add(Convert.ToByte(Value, CultureInfo.InvariantCulture));
                            break;
                        case JsonToken.EndArray:
                            byte[] d = data.ToArray();
                            SetToken(JsonToken.Bytes, d, false);
                            return d;
                        case JsonToken.Comment:
                            // skip
                            break;
                        default:
                            throw JsonReaderException.Create(this, "Unexpected token when reading bytes: {0}.".FormatWith(CultureInfo.InvariantCulture, t));
                    }
                }

                throw JsonReaderException.Create(this, "Unexpected end when reading bytes.");
            }

            if (t == JsonToken.EndArray)
                return null;

            throw JsonReaderException.Create(this, "Error reading bytes. Unexpected token: {0}.".FormatWith(CultureInfo.InvariantCulture, t));
        }
开发者ID:sdgdsffdsfff,项目名称:hermes.net,代码行数:99,代码来源:JsonReader.cs

示例9: ReadAsStringInternal

    internal string ReadAsStringInternal()
    {
      _readType = ReadType.ReadAsString;

      do
      {
        if (!ReadInternal())
        {
          SetToken(JsonToken.None);
          return null;
        }
      } while (TokenType == JsonToken.Comment);

      if (TokenType == JsonToken.String)
        return (string)Value;

      if (TokenType == JsonToken.Null)
        return null;

      if (IsPrimitiveToken(TokenType))
      {
        if (Value != null)
        {
          string s;
          if (ConvertUtils.IsConvertible(Value))
            s = ConvertUtils.ToConvertible(Value).ToString(Culture);
          else if (Value is IFormattable)
            s = ((IFormattable)Value).ToString(null, Culture);
          else
            s = Value.ToString();

          SetToken(JsonToken.String, s);
          return s;
        }
      }

      if (TokenType == JsonToken.EndArray)
        return null;

      throw CreateReaderException(this, "Error reading string. Unexpected token: {0}.".FormatWith(CultureInfo.InvariantCulture, TokenType));
    }
开发者ID:pvasek,项目名称:Newtonsoft.Json,代码行数:41,代码来源:JsonReader.cs

示例10: ReadAsBytesInternal

    internal byte[] ReadAsBytesInternal()
    {
      _readType = ReadType.ReadAsBytes;

      do
      {
        if (!ReadInternal())
        {
          SetToken(JsonToken.None);
          return null;
        }
      } while (TokenType == JsonToken.Comment);

      if (IsWrappedInTypeObject())
      {
        byte[] data = ReadAsBytes();
        ReadInternal();
        SetToken(JsonToken.Bytes, data);
        return data;
      }

      // attempt to convert possible base 64 string to bytes
      if (TokenType == JsonToken.String)
      {
        string s = (string)Value;
        byte[] data = (s.Length == 0) ? new byte[0] : Convert.FromBase64String(s);
        SetToken(JsonToken.Bytes, data);
      }

      if (TokenType == JsonToken.Null)
        return null;

      if (TokenType == JsonToken.Bytes)
        return (byte[])Value;

      if (TokenType == JsonToken.StartArray)
      {
        List<byte> data = new List<byte>();

        while (ReadInternal())
        {
          switch (TokenType)
          {
            case JsonToken.Integer:
              data.Add(Convert.ToByte(Value, CultureInfo.InvariantCulture));
              break;
            case JsonToken.EndArray:
              byte[] d = data.ToArray();
              SetToken(JsonToken.Bytes, d);
              return d;
            case JsonToken.Comment:
              // skip
              break;
            default:
              throw JsonReaderException.Create(this, "Unexpected token when reading bytes: {0}.".FormatWith(CultureInfo.InvariantCulture, TokenType));
          }
        }

        throw JsonReaderException.Create(this, "Unexpected end when reading bytes.");
      }

      if (TokenType == JsonToken.EndArray)
        return null;

      throw JsonReaderException.Create(this, "Error reading bytes. Unexpected token: {0}.".FormatWith(CultureInfo.InvariantCulture, TokenType));
    }
开发者ID:leesanghyun2,项目名称:mp-onlinevideos2,代码行数:66,代码来源:JsonReader.cs

示例11: Read

 /// <summary>
 /// Reads the next JSON token from the stream.
 /// </summary>
 /// <returns>
 /// true if the next token was read successfully; false if there are no more tokens to read.
 /// </returns>
 public override bool Read()
 {
   _readType = ReadType.Read;
   return ReadInternal();
 }
开发者ID:284247028,项目名称:MvvmCross,代码行数:11,代码来源:JsonTextReader.cs

示例12: ReadAsDecimal

    /// <summary>
    /// Reads the next JSON token from the stream as a <see cref="Nullable{Decimal}"/>.
    /// </summary>
    /// <returns>A <see cref="Nullable{Decimal}"/>.</returns>
    public override decimal? ReadAsDecimal()
    {
      _readType = ReadType.ReadAsDecimal;
      if (!ReadInternal())
        throw CreateJsonReaderException("Unexpected end when reading decimal: Line {0}, position {1}.", _currentLineNumber, _currentLinePosition);

      if (TokenType == JsonToken.Null)
        return null;
      if (TokenType == JsonToken.Float)
        return (decimal?)Value;

      throw CreateJsonReaderException("Unexpected token when reading decimal: {0}. Line {1}, position {2}.", TokenType, _currentLineNumber, _currentLinePosition);
    }
开发者ID:284247028,项目名称:MvvmCross,代码行数:17,代码来源:JsonTextReader.cs

示例13: ReadAsDateTimeInternal

        internal DateTime? ReadAsDateTimeInternal()
        {
            _readType = ReadType.ReadAsDateTime;

            do
            {
                if (!ReadInternal())
                {
                    SetToken(JsonToken.None);
                    return null;
                }
            } while (TokenType == JsonToken.Comment);

            if (TokenType == JsonToken.Date)
                return (DateTime)Value;

            if (TokenType == JsonToken.Null)
                return null;

            if (TokenType == JsonToken.String)
            {
                string s = (string)Value;
                if (string.IsNullOrEmpty(s))
                {
                    SetToken(JsonToken.Null);
                    return null;
                }

                DateTime dt;
                object temp;
                if (DateTimeUtils.TryParseDateTime(s, DateParseHandling.DateTime, DateTimeZoneHandling, _dateFormatString, Culture, out temp))
                {
                    dt = (DateTime)temp;
                    dt = DateTimeUtils.EnsureDateTime(dt, DateTimeZoneHandling);
                    SetToken(JsonToken.Date, dt, false);
                    return dt;
                }

                if (DateTime.TryParse(s, Culture, DateTimeStyles.RoundtripKind, out dt))
                {
                    dt = DateTimeUtils.EnsureDateTime(dt, DateTimeZoneHandling);
                    SetToken(JsonToken.Date, dt, false);
                    return dt;
                }

                throw JsonReaderException.Create(this, "Could not convert string to DateTime: {0}.".FormatWith(CultureInfo.InvariantCulture, Value));
            }

            if (TokenType == JsonToken.EndArray)
                return null;

            throw JsonReaderException.Create(this, "Error reading date. Unexpected token: {0}.".FormatWith(CultureInfo.InvariantCulture, TokenType));
        }
开发者ID:sdgdsffdsfff,项目名称:hermes.net,代码行数:53,代码来源:JsonReader.cs

示例14: JsonContract

        internal JsonContract(Type underlyingType)
        {
            ValidationUtils.ArgumentNotNull(underlyingType, nameof(underlyingType));

            UnderlyingType = underlyingType;

            IsNullable = ReflectionUtils.IsNullable(underlyingType);
            NonNullableUnderlyingType = (IsNullable && ReflectionUtils.IsNullableType(underlyingType)) ? Nullable.GetUnderlyingType(underlyingType) : underlyingType;

            CreatedType = NonNullableUnderlyingType;

            IsConvertable = ConvertUtils.IsConvertible(NonNullableUnderlyingType);
            IsEnum = NonNullableUnderlyingType.IsEnum();

            InternalReadType = ReadType.Read;
        }
开发者ID:cilliemalan,项目名称:Cargo,代码行数:16,代码来源:JsonContract.cs

示例15: ReadAsInt32Internal

        internal int? ReadAsInt32Internal()
        {
            _readType = ReadType.ReadAsInt32;

            JsonToken t;

            do
            {
                if (!ReadInternal())
                {
                    SetToken(JsonToken.None);
                    return null;
                }
                else
                {
                    t = TokenType;
                }
            } while (t == JsonToken.Comment);

            if (t == JsonToken.Integer || t == JsonToken.Float)
            {
                if (!(Value is int))
                    SetToken(JsonToken.Integer, Convert.ToInt32(Value, CultureInfo.InvariantCulture), false);

                return (int)Value;
            }

            if (t == JsonToken.Null)
                return null;

            int i;
            if (t == JsonToken.String)
            {
                string s = (string)Value;
                if (string.IsNullOrEmpty(s))
                {
                    SetToken(JsonToken.Null);
                    return null;
                }

                if (int.TryParse(s, NumberStyles.Integer, Culture, out i))
                {
                    SetToken(JsonToken.Integer, i, false);
                    return i;
                }
                else
                {
                    throw JsonReaderException.Create(this, "Could not convert string to integer: {0}.".FormatWith(CultureInfo.InvariantCulture, Value));
                }
            }

            if (t == JsonToken.EndArray)
                return null;

            throw JsonReaderException.Create(this, "Error reading integer. Unexpected token: {0}.".FormatWith(CultureInfo.InvariantCulture, TokenType));
        }
开发者ID:sdgdsffdsfff,项目名称:hermes.net,代码行数:56,代码来源:JsonReader.cs


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