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


C# BsonReader.FindStringElement方法代码示例

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


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

示例1: 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>
        // actualType ignored
        public override object Deserialize(BsonReader bsonReader, Type nominalType, Type actualType, IBsonSerializationOptions options)
        {
            if (_trace)
                pb.Trace.WriteLine("OXmlElementSerializer.Deserialize()");

            var bsonType = bsonReader.GetCurrentBsonType();
            if (bsonType == BsonType.Null)
            {
                bsonReader.ReadNull();
                return null;
            }
            else if (bsonType != BsonType.Document)
                throw new PBException($"deserialize OXmlElement, invalid BsonType {bsonType}.");
            bsonReader.ReadStartDocument();
            string type = bsonReader.FindStringElement("Type");
            OXmlElement value;
            switch (type.ToLower())
            {
                case "line":
                    value = new OXmlElement { Type = OXmlElementType.Line };
                    break;
                case "tabstop":
                    value = new OXmlElement { Type = OXmlElementType.TabStop };
                    break;
                case "paragraph":
                    //value = OXmlParagraphElementSerializer.Instance.Deserialize(bsonReader, typeof(OXmlParagraphElement), options);
                    value = OXmlParagraphElementSerializer.Instance._Deserialize(bsonReader, options);
                    break;
                case "text":
                    value = OXmlTextElementSerializer.Instance._Deserialize(bsonReader, options);
                    break;
                case "simplefield":
                    value = OXmlSimpleFieldElementSerializer.Instance._Deserialize(bsonReader, options);
                    break;
                case "docsection":
                    value = OXmlDocSectionElementSerializer.Instance._Deserialize(bsonReader, options);
                    break;
                case "docdefaultsrunproperties":
                    value = OXmlDocDefaultsRunPropertiesElementSerializer.Instance._Deserialize(bsonReader, options);
                    break;
                case "docdefaultsparagraphproperties":
                    //value = new OXmlDocDefaultsParagraphPropertiesElement();
                    value = new OXmlElement { Type = OXmlElementType.DocDefaultsParagraphProperties };
                    break;
                case "openheader":
                    value = OXmlOpenHeaderElementSerializer.Instance._Deserialize(bsonReader, options);
                    break;
                case "closeheader":
                    value = new OXmlElement { Type = OXmlElementType.CloseHeader };
                    break;
                case "openfooter":
                    value = OXmlOpenFooterElementSerializer.Instance._Deserialize(bsonReader, options);
                    break;
                case "closefooter":
                    value = new OXmlElement { Type = OXmlElementType.CloseFooter };
                    break;
                case "style":
                    value = OXmlStyleElementSerializer.Instance._Deserialize(bsonReader, options);
                    break;
                case "picture":
                    //value = OXmlPictureElementSerializer.Instance._Deserialize(bsonReader, options);
                    value = OXmlPictureElementCreator.CreatePicture(zmongo.ReadBsonDocumentWOStartEnd(bsonReader));
                    break;
                default:
                    throw new PBException($"deserialize OXmlElement, invalid Type {type}.");
            }
            bsonReader.ReadEndDocument();
            return value;


            //switch (bsonType)
            //{
            //    case BsonType.Array: return (ZValue)ZStringArraySerializer.Instance.Deserialize(bsonReader, typeof(ZStringArray), options);
            //    //case BsonType.Binary: return (BsonValue)BsonBinaryDataSerializer.Instance.Deserialize(bsonReader, typeof(BsonBinaryData), options);
            //    //case BsonType.Boolean: return (BsonValue)BsonBooleanSerializer.Instance.Deserialize(bsonReader, typeof(BsonBoolean), options);
            //    //case BsonType.DateTime: return (BsonValue)BsonDateTimeSerializer.Instance.Deserialize(bsonReader, typeof(BsonDateTime), options);
            //    //case BsonType.Document: return (BsonValue)BsonDocumentSerializer.Instance.Deserialize(bsonReader, typeof(BsonDocument), options);
            //    //case BsonType.Double: return (BsonValue)BsonDoubleSerializer.Instance.Deserialize(bsonReader, typeof(BsonDouble), options);
            //    case BsonType.Int32: return (ZValue)ZIntSerializer.Instance.Deserialize(bsonReader, typeof(ZInt), options);
            //    //case BsonType.Int64: return (BsonValue)BsonInt64Serializer.Instance.Deserialize(bsonReader, typeof(BsonInt64), options);
            //    //case BsonType.JavaScript: return (BsonValue)BsonJavaScriptSerializer.Instance.Deserialize(bsonReader, typeof(BsonJavaScript), options);
            //    //case BsonType.JavaScriptWithScope: return (BsonValue)BsonJavaScriptWithScopeSerializer.Instance.Deserialize(bsonReader, typeof(BsonJavaScriptWithScope), options);
            //    //case BsonType.MaxKey: return (BsonValue)BsonMaxKeySerializer.Instance.Deserialize(bsonReader, typeof(BsonMaxKey), options);
            //    //case BsonType.MinKey: return (BsonValue)BsonMinKeySerializer.Instance.Deserialize(bsonReader, typeof(BsonMinKey), options);
            //    //case BsonType.Null: return (BsonValue)BsonNullSerializer.Instance.Deserialize(bsonReader, typeof(BsonNull), options);
            //    case BsonType.Document:
            //        return ReadZValueFromBsonDocument(bsonReader);
            //    case BsonType.Null:
            //        bsonReader.ReadNull();
            //        return null;
//.........这里部分代码省略.........
开发者ID:labeuze,项目名称:source,代码行数:101,代码来源:OXmlElementSerializer.cs


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