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


C# BsonReader.ReadString方法代码示例

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


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

示例1: _Deserialize

 public OXmlParagraphElement _Deserialize(BsonReader bsonReader, IBsonSerializationOptions options)
 {
     OXmlParagraphElement paragraph = new OXmlParagraphElement();
     while (true)
     {
         BsonType bsonType = bsonReader.ReadBsonType();
         if (bsonType == BsonType.EndOfDocument)
             break;
         //if (bsonType != BsonType.String)
         //    throw new PBException("error ZStringArray cannot contain value of type {0}", bsonType);
         //var value = bsonReader.ReadString();
         string name = bsonReader.ReadName();
         switch (name.ToLower())
         {
             case "type":
                 if (bsonType != BsonType.String)
                     throw new PBException($"wrong type value {bsonType}");
                 string type = bsonReader.ReadString();
                 if (type.ToLower() != "paragraph")
                     throw new PBException($"invalid Type {type} when deserialize OXmlParagraphElement");
                 break;
             case "style":
                 if (bsonType == BsonType.Null)
                     break;
                 if (bsonType != BsonType.String)
                     throw new PBException($"wrong style value {bsonType}");
                 paragraph.Style = bsonReader.ReadString();
                 break;
             default:
                 throw new PBException($"unknow Paragraph value \"{name}\"");
         }
     }
     return paragraph;
 }
开发者ID:labeuze,项目名称:source,代码行数:34,代码来源:OXmlParagraphElementSerializer.cs

示例2: _Deserialize

 public OXmlOpenHeaderElement _Deserialize(BsonReader bsonReader, IBsonSerializationOptions options)
 {
     OXmlOpenHeaderElement element = new OXmlOpenHeaderElement();
     while (true)
     {
         BsonType bsonType = bsonReader.ReadBsonType();
         if (bsonType == BsonType.EndOfDocument)
             break;
         string name = bsonReader.ReadName();
         switch (name.ToLower())
         {
             case "type":
                 if (bsonType != BsonType.String)
                     throw new PBException($"wrong type value {bsonType}");
                 string type = bsonReader.ReadString();
                 //"openfooter"
                 if (type.ToLower() != "openheader")
                     throw new PBException($"invalid Type {type} when deserialize OXmlOpenHeader");
                 break;
             case "headertype":
                 if (bsonType == BsonType.Null)
                     break;
                 if (bsonType != BsonType.String)
                     throw new PBException($"wrong HeaderType value {bsonType}");
                 element.HeaderType = bsonReader.ReadString().zParseEnum<HeaderFooterValues>();
                 break;
             default:
                 //OpenHeaderFooter
                 throw new PBException($"unknow OpenHeader value \"{name}\"");
         }
     }
     return element;
 }
开发者ID:labeuze,项目名称:source,代码行数:33,代码来源:OXmlOpenHeaderElementSerializer.cs

示例3: _Deserialize

 public OXmlSimpleFieldElement _Deserialize(BsonReader bsonReader, IBsonSerializationOptions options)
 {
     OXmlSimpleFieldElement element = new OXmlSimpleFieldElement();
     while (true)
     {
         BsonType bsonType = bsonReader.ReadBsonType();
         if (bsonType == BsonType.EndOfDocument)
             break;
         string name = bsonReader.ReadName();
         switch (name.ToLower())
         {
             case "type":
                 if (bsonType != BsonType.String)
                     throw new PBException($"wrong type value {bsonType}");
                 string type = bsonReader.ReadString();
                 if (type.ToLower() != "simplefield")
                     throw new PBException($"invalid Type {type} when deserialize OXmlSimpleFieldElement");
                 break;
             case "instruction":
                 if (bsonType == BsonType.Null)
                     break;
                 if (bsonType != BsonType.String)
                     throw new PBException($"wrong Instruction value {bsonType}");
                 element.Instruction = bsonReader.ReadString();
                 break;
             default:
                 throw new PBException($"unknow SimpleField value \"{name}\"");
         }
     }
     return element;
 }
开发者ID:labeuze,项目名称:source,代码行数:31,代码来源:OXmlSimpleFieldElementSerializer.cs

示例4: Deserialize

        public object Deserialize(BsonReader bsonReader, Type nominalType, Type actualType, IBsonSerializationOptions options)
        {
            object value = null;
            var valueType = actualType.GetConceptValueType();
			if (valueType == typeof(Guid)) {
				var guidBytes = new byte[16];
				BsonBinarySubType subType;
				bsonReader.ReadBinaryData (out guidBytes, out subType);
				value = new Guid (guidBytes);
			} else if (valueType == typeof(double))
				value = bsonReader.ReadDouble ();
			else if (valueType == typeof(float))
				value = (float)bsonReader.ReadDouble ();
			else if (valueType == typeof(Int32))
				value = bsonReader.ReadInt32 ();
			else if (valueType == typeof(Int64))
				value = bsonReader.ReadInt64 ();
			else if (valueType == typeof(bool))
				value = bsonReader.ReadBoolean ();
			else if (valueType == typeof(string))
				value = bsonReader.ReadString ();
			else if (valueType == typeof(decimal))
				value = decimal.Parse (bsonReader.ReadString ());
            
            var concept = ConceptFactory.CreateConceptInstance(actualType, value);
            return concept;
        }
开发者ID:jarlef,项目名称:Bifrost,代码行数:27,代码来源:ConceptSerializer.cs

示例5: Deserialize

        // public methods
        /// <summary>
        /// Deserializes an object from a BsonReader.
        /// </summary>
        /// <param name="bsonReader">The BsonReader.</param>
        /// <param name="nominalType">The nominal type of the object.</param>
        /// <param name="actualType">The actual type of the object.</param>
        /// <param name="options">The serialization options.</param>
        /// <returns>
        /// An object.
        /// </returns>
        public override object Deserialize(BsonReader bsonReader, Type nominalType, Type actualType, IBsonSerializationOptions options)
        {
            if (bsonReader.GetCurrentBsonType() == BsonType.Null)
            {
                bsonReader.ReadNull();
                return null;
            }
            else
            {
                bsonReader.ReadStartDocument();
                DeserializeType(bsonReader, "link");
                bsonReader.ReadName("properties");
                bsonReader.ReadStartDocument();
                var href = bsonReader.ReadString("href");
                string hrefType = null;
                if (bsonReader.ReadBsonType() != BsonType.EndOfDocument)
                {
                    hrefType = bsonReader.ReadString("type");
                }
                bsonReader.ReadEndDocument();
                bsonReader.ReadEndDocument();

                return new GeoJsonLinkedCoordinateReferenceSystem(href, hrefType);
            }
        }
开发者ID:Khosrow-Azizi,项目名称:MasterExperimentV2,代码行数:36,代码来源:GeoJsonLinkedCoordinateReferenceSystemSerializer.cs

示例6: Deserialize

        // public methods
        /// <summary>
        /// Deserializes an object from a BsonReader.
        /// </summary>
        /// <param name="bsonReader">The BsonReader.</param>
        /// <param name="nominalType">The nominal type of the object.</param>
        /// <param name="actualType">The actual type of the object.</param>
        /// <param name="options">The serialization options.</param>
        /// <returns>An object.</returns>
        public override object Deserialize(
            BsonReader bsonReader,
            Type nominalType,
            Type actualType,
            IBsonSerializationOptions options)
        {
            VerifyTypes(nominalType, actualType, typeof(CultureInfo));

            var bsonType = bsonReader.GetCurrentBsonType();
            switch (bsonType)
            {
                case BsonType.Null:
                    bsonReader.ReadNull();
                    return null;
                case BsonType.Document:
                    bsonReader.ReadStartDocument();
                    var name = bsonReader.ReadString("Name");
                    var useUserOverride = bsonReader.ReadBoolean("UseUserOverride");
                    bsonReader.ReadEndDocument();
                    return new CultureInfo(name, useUserOverride);
                case BsonType.String:
                    return new CultureInfo(bsonReader.ReadString());
                default:
                    var message = string.Format("Cannot deserialize CultureInfo from BsonType {0}.", bsonType);
                    throw new FileFormatException(message);
            }
        }
开发者ID:huoxudong125,项目名称:SequoiaDB.Charp,代码行数:36,代码来源:CultureInfoSerializer.cs

示例7: Deserialize

 public override object Deserialize(
     BsonReader bsonReader,
     Type nominalType,
     IBsonSerializationOptions options
 ) {
     return XmlConvert.ToDateTime(bsonReader.ReadString(), XmlDateTimeSerializationMode.RoundtripKind);
 }
开发者ID:redforks,项目名称:mongo-csharp-driver,代码行数:7,代码来源:BsonDefaultSerializerTests.cs

示例8: Deserialize

        // public methods
        /// <summary>
        /// Deserializes an object from a BsonReader.
        /// </summary>
        /// <param name="bsonReader">The BsonReader.</param>
        /// <param name="nominalType">The nominal type of the object.</param>
        /// <param name="actualType">The actual type of the object.</param>
        /// <param name="options">The serialization options.</param>
        /// <returns>An object.</returns>
        public override object Deserialize(
            BsonReader bsonReader,
            Type nominalType,
            Type actualType,
            IBsonSerializationOptions options)
        {
            VerifyTypes(nominalType, actualType, typeof(bool));

            var bsonType = bsonReader.GetCurrentBsonType();
            switch (bsonType)
            {
                case BsonType.Boolean:
                    return bsonReader.ReadBoolean();
                case BsonType.Double:
                    return bsonReader.ReadDouble() != 0.0;
                case BsonType.Int32:
                    return bsonReader.ReadInt32() != 0;
                case BsonType.Int64:
                    return bsonReader.ReadInt64() != 0;
                case BsonType.Null:
                    bsonReader.ReadNull();
                    return false;
                case BsonType.String:
                    return XmlConvert.ToBoolean(bsonReader.ReadString().ToLower());
                default:
                    var message = string.Format("Cannot deserialize Boolean from BsonType {0}.", bsonType);
                    throw new FileFormatException(message);
            }
        }
开发者ID:huoxudong125,项目名称:SequoiaDB.Charp,代码行数:38,代码来源:BooleanSerializer.cs

示例9: Deserialize

        // public methods
        /// <summary>
        /// Deserializes an object from a BsonReader.
        /// </summary>
        /// <param name="bsonReader">The BsonReader.</param>
        /// <param name="nominalType">The nominal type of the object.</param>
        /// <param name="actualType">The actual type of the object.</param>
        /// <param name="options">The serialization options.</param>
        /// <returns>An object.</returns>
        public override object Deserialize(
            BsonReader bsonReader,
            Type nominalType,
            Type actualType,
            IBsonSerializationOptions options)
        {
            VerifyTypes(nominalType, actualType, typeof(double));
            var representationSerializationOptions = EnsureSerializationOptions<RepresentationSerializationOptions>(options);

            var bsonType = bsonReader.GetCurrentBsonType();
            switch (bsonType)
            {
                case BsonType.Double:
                    return bsonReader.ReadDouble();
                case BsonType.Int32:
                    return representationSerializationOptions.ToDouble(bsonReader.ReadInt32());
                case BsonType.Int64:
                    return representationSerializationOptions.ToDouble(bsonReader.ReadInt64());
                case BsonType.String:
                    return XmlConvert.ToDouble(bsonReader.ReadString());
                default:
                    var message = string.Format("Cannot deserialize Double from BsonType {0}.", bsonType);
                    throw new FileFormatException(message);
            }
        }
开发者ID:huoxudong125,项目名称:SequoiaDB.Charp,代码行数:34,代码来源:DoubleSerializer.cs

示例10: Deserialize

        public override object Deserialize(BsonReader bsonReader, Type nominalType, Type actualType, IBsonSerializationOptions options)
        {
            if (_trace)
                pb.Trace.WriteLine("ZStringArraySerializer.Deserialize()");

            VerifyTypes(nominalType, actualType, typeof(ZStringArray));

            var bsonType = bsonReader.GetCurrentBsonType();
            switch (bsonType)
            {
                case BsonType.Array:
                    bsonReader.ReadStartArray();
                    //return new ZString(bsonReader.ReadString());
                    var array = new List<string>();
                    bsonType = bsonReader.ReadBsonType();
                    while (bsonType != BsonType.EndOfDocument)
                    {
                        if (bsonType != BsonType.String)
                            throw new PBException("error ZStringArray cannot contain value of type {0}", bsonType);
                        var value = bsonReader.ReadString();
                        array.Add(value);
                        bsonType = bsonReader.ReadBsonType();
                    }
                    bsonReader.ReadEndArray();
                    return new ZStringArray(array.ToArray());
                default:
                    throw new PBException("error cannot deserialize ZStringArray from BsonType {0}.", bsonType);
            }
        }
开发者ID:labeuze,项目名称:source,代码行数:29,代码来源:ZStringArraySerializer.cs

示例11: Deserialize

        // public methods
        /// <summary>
        /// Deserializes an object from a BsonReader.
        /// </summary>
        /// <param name="bsonReader">The BsonReader.</param>
        /// <param name="nominalType">The nominal type of the object.</param>
        /// <param name="actualType">The actual type of the object.</param>
        /// <param name="options">The serialization options.</param>
        /// <returns>An object.</returns>
        public override object Deserialize(
            BsonReader bsonReader,
            Type nominalType,
            Type actualType,
            IBsonSerializationOptions options)
        {
            VerifyTypes(nominalType, actualType, typeof(DateTimeOffset));
            var dateTimeSerializationOptions = EnsureSerializationOptions<DateTimeSerializationOptions>(options);

            var bsonType = bsonReader.GetCurrentBsonType();
            DateTimeOffset value;
            switch (bsonType)
            {
                case BsonType.DateTime:
                    // use an intermediate BsonDateTime so MinValue and MaxValue are handled correctly
                    value = (new BsonDateTime(bsonReader.ReadDateTime())).ToUniversalTime();
                    break;
                case BsonType.Document:
                    bsonReader.ReadStartDocument();
                    bsonReader.ReadDateTime("DateTimeUTC"); // ignore value (use Ticks instead)
                    value = new DateTime(bsonReader.ReadInt64("Ticks"), DateTimeKind.Utc);
                    bsonReader.ReadEndDocument();
                    break;
                case BsonType.Int64:
                    value = new DateTime(bsonReader.ReadInt64(), DateTimeKind.Utc);
                    break;
                case BsonType.String:
                    // note: we're not using XmlConvert because of bugs in Mono
                    if (dateTimeSerializationOptions.DateOnly)
                    {
                        value = DateTime.SpecifyKind(DateTime.ParseExact(bsonReader.ReadString(), "yyyy-MM-dd", null), DateTimeKind.Utc);
                    }
                    else
                    {
                        var formats = new string[] { "yyyy-MM-ddK", "yyyy-MM-ddTHH:mm:ssK", "yyyy-MM-ddTHH:mm:ss.FFFFFFFK" };
                        value = DateTime.ParseExact(bsonReader.ReadString(), formats, null, DateTimeStyles.AdjustToUniversal | DateTimeStyles.AssumeUniversal);
                    }
                    break;
                default:
                    var message = string.Format("Cannot deserialize DateTimeOffset from BsonType {0}.", bsonType);
                    throw new FormatException(message);
            }

            return value;
        }
开发者ID:Jiangew,项目名称:quartz.net-mongodb,代码行数:54,代码来源:DateTimeOffsetSerializer.cs

示例12: DeserializeType

 // protected methods
 protected void DeserializeType(BsonReader bsonReader, string expectedType)
 {
     var type = bsonReader.ReadString("type");
     if (type != expectedType)
     {
         var message = string.Format("Expected type to be '{0}'.", expectedType);
         throw new FormatException(message);
     }
 }
开发者ID:pwelter34,项目名称:mongo-csharp-driver,代码行数:10,代码来源:GeoJsonCoordinateReferenceSystemSerializer.cs

示例13: _Deserialize

 public OXmlDocDefaultsRunPropertiesElement _Deserialize(BsonReader bsonReader, IBsonSerializationOptions options)
 {
     OXmlDocDefaultsRunPropertiesElement element = new OXmlDocDefaultsRunPropertiesElement();
     while (true)
     {
         BsonType bsonType = bsonReader.ReadBsonType();
         if (bsonType == BsonType.EndOfDocument)
             break;
         string name = bsonReader.ReadName();
         switch (name.ToLower())
         {
             case "type":
                 if (bsonType != BsonType.String)
                     throw new PBException($"wrong type value {bsonType}");
                 string type = bsonReader.ReadString();
                 if (type.ToLower() != "docdefaultsrunproperties")
                     throw new PBException($"invalid Type {type} when deserialize OXmlDocDefaultsRunPropertiesElement");
                 break;
             case "runfonts":
                 if (bsonType == BsonType.Null)
                     break;
                 if (bsonType != BsonType.Document)
                     throw new PBException($"wrong RunFonts value {bsonType}");
                 element.RunFonts = OXmlCommonSerializer.ReadRunFonts(bsonReader);
                 break;
             case "fontsize":
                 if (bsonType == BsonType.Null)
                     break;
                 if (bsonType != BsonType.String)
                     throw new PBException($"wrong FontSize value {bsonType}");
                 element.FontSize = bsonReader.ReadString();
                 break;
             default:
                 throw new PBException($"unknow DocDefaultsRunProperties value \"{name}\"");
         }
     }
     return element;
 }
开发者ID:labeuze,项目名称:source,代码行数:38,代码来源:OXmlDocDefaultsRunPropertiesElementSerializer.cs

示例14: _Deserialize

 public OXmlTextElement _Deserialize(BsonReader bsonReader, IBsonSerializationOptions options)
 {
     OXmlTextElement element = new OXmlTextElement();
     while (true)
     {
         BsonType bsonType = bsonReader.ReadBsonType();
         if (bsonType == BsonType.EndOfDocument)
             break;
         string name = bsonReader.ReadName();
         switch (name.ToLower())
         {
             case "type":
                 if (bsonType != BsonType.String)
                     throw new PBException($"wrong type value {bsonType}");
                 string type = bsonReader.ReadString();
                 if (type.ToLower() != "text")
                     throw new PBException($"invalid Type {type} when deserialize OXmlTextElement");
                 break;
             case "text":
                 if (bsonType == BsonType.Null)
                     break;
                 if (bsonType != BsonType.String)
                     throw new PBException($"wrong text value {bsonType}");
                 element.Text = bsonReader.ReadString();
                 break;
             case "preservespace":
                 if (bsonType == BsonType.Null)
                     break;
                 if (bsonType != BsonType.Boolean)
                     throw new PBException($"wrong PreserveSpace value {bsonType}");
                 element.PreserveSpace = bsonReader.ReadBoolean();
                 break;
             default:
                 throw new PBException($"unknow Text value \"{name}\"");
         }
     }
     return element;
 }
开发者ID:labeuze,项目名称:source,代码行数:38,代码来源:OXmlTextElementSerializer.cs

示例15: Deserialize

        public override object Deserialize(BsonReader bsonReader, Type nominalType, Type actualType, IBsonSerializationOptions options)
        {
            VerifyTypes(nominalType, actualType, typeof(WebImage));

            var bsonType = bsonReader.GetCurrentBsonType();
            switch (bsonType)
            {
                case BsonType.String:
                    return new WebImage(bsonReader.ReadString());
                case BsonType.Null:
                    bsonReader.ReadNull();
                    return new WebImage(null);
                default:
                    throw new PBException("error cannot deserialize UrlImage from BsonType {0}.", bsonType);
            }
        }
开发者ID:labeuze,项目名称:source,代码行数:16,代码来源:UrlImageSerializer.cs


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