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


C# XmlReader.ReadContentAsDouble方法代码示例

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


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

示例1: Restore

        public void Restore(XmlReader reader)
        {
            int count = reader.AttributeCount;
            for (int i = 0; i < count; ++i)
            {
                reader.MoveToAttribute(i);
                switch (reader.Name)
                {
                    case "top":
                        Top = reader.ReadContentAsDouble();
                        break;

                    case "left":
                        Left = reader.ReadContentAsDouble();
                        break;

                    case "width":
                        Width = reader.ReadContentAsDouble();
                        break;

                    case "height":
                        Height = reader.ReadContentAsDouble();
                        break;

                    case "state":
                        State = (WindowState) Enum.Parse(typeof (WindowState), reader.Value);
                        break;
                }
            }
        }
开发者ID:Kittyfisto,项目名称:Tailviewer,代码行数:30,代码来源:WindowSettings.cs

示例2: ReadXml

 public override void ReadXml(XmlReader reader)
 {
     reader.ReadStartElement();
     reader.ReadStartElement("X");
     var x = reader.ReadContentAsDouble();
     reader.ReadEndElement();
     reader.ReadStartElement("Y");
     var y = reader.ReadContentAsDouble();
     reader.ReadEndElement();
     Value = new Point(x, y);
     reader.ReadEndElement();
 }
开发者ID:OronDF343,项目名称:Sky-Jukebox,代码行数:12,代码来源:PointProperty.cs

示例3: ReadXml

 public void ReadXml(XmlReader reader)
 {
     reader.MoveToAttribute("span");
       if (reader.NodeType == XmlNodeType.Attribute)
     Span = (int)reader.ReadContentAsDouble();
       reader.MoveToElement();
       Text = reader.ReadElementContentAsString();
       double length;
       if (double.TryParse(Text, out length))
     Length = length;
 }
开发者ID:samgoat,项目名称:NC,代码行数:11,代码来源:Rope.cs

示例4: DeserializeXml

        /// <summary>
        /// Restores the specified part of the state of a serialised object from an XML stream.
        /// </summary>
        /// Members that don't have a serialised value are left untouched.
        /// Unknown XML elements are reported to <see cref="AW2.Helpers.Log"/>.
        /// If the deserialised object is of a type that implements <see cref="IConsistencyCheckable"/>,
        /// the object is made consistent after deserialisation.
        /// <param name="reader">Where to read the serialised data.</param>
        /// <param name="elementName">Name of the XML element where the object is stored.</param>
        /// <param name="objType">Type of the value to deserialise.</param>
        /// <param name="limitationAttribute">Limit the deserialisation to members with this attribute.</param>
        /// <param name="tolerant">If true, errors are not raised for missing or extra XML elements.</param>
        /// <returns>The deserialised object.</returns>
        public static object DeserializeXml(XmlReader reader, string elementName, Type objType, Type limitationAttribute, bool tolerant)
        {
            try
            {
                // Sanity checks
                if (limitationAttribute != null &&
                    !typeof(Attribute).IsAssignableFrom(limitationAttribute))
                    throw new ArgumentException("Expected an attribute, got " + limitationAttribute.Name);

                // XML consistency checks
                if (!reader.IsStartElement())
                    throw new XmlException("Deserialisation expected start element");
                if (!reader.IsStartElement(elementName))
                    throw new XmlException("Deserialisation expected start element " + elementName + " but got " + reader.Name);

                var writtenType = GetWrittenType(reader, elementName, objType);

                // Deserialise
                object returnValue;
                bool emptyXmlElement = reader.IsEmptyElement;
                reader.Read();
                if (emptyXmlElement)
                    returnValue = Serialization.CreateInstance(writtenType);
                else if (writtenType.IsPrimitive || writtenType == typeof(string))
                    returnValue = reader.ReadContentAs(writtenType, null);
                else if (writtenType.IsEnum)
                    returnValue = DeserializeXmlEnum(reader, writtenType);
                else if (writtenType == typeof(Color))
                    returnValue = DeserializeXmlColor(reader, limitationAttribute, tolerant);
                else if (writtenType == typeof(TimeSpan))
                    returnValue = TimeSpan.FromSeconds(reader.ReadContentAsDouble());
                else if (writtenType == typeof(Curve))
                    returnValue = DeserializeXmlCurve(reader, limitationAttribute, tolerant);
                else if (IsIEnumerable(writtenType))
                    returnValue = DeserializeXmlIEnumerable(reader, objType, limitationAttribute, writtenType, tolerant);
                else
                    returnValue = DeserializeXmlOther(reader, limitationAttribute, writtenType, tolerant);

                if (!emptyXmlElement)
                    reader.ReadEndElement();
                if (writtenType != objType)
                    returnValue = Cast(returnValue, objType);
                if (typeof(IConsistencyCheckable).IsAssignableFrom(writtenType))
                    ((IConsistencyCheckable)returnValue).MakeConsistent(limitationAttribute);
                return returnValue;
            }
            catch (MemberSerializationException e)
            {
                e.MemberName = elementName + "." + e.MemberName;
                throw;
            }
        }
开发者ID:vvnurmi,项目名称:assaultwing,代码行数:65,代码来源:Serialization.cs

示例5: ReadXml

        public void ReadXml(XmlReader reader)
        {
            reader.ReadStartElement();

            reader.ReadStartElement();
            Rolls = (short)reader.ReadContentAsInt();
            reader.ReadEndElement();

            reader.ReadStartElement();
            DiceFaces = (short)reader.ReadContentAsInt();
            reader.ReadEndElement();

            reader.ReadStartElement();
            Multiplier = (short)reader.ReadContentAsDouble();
            reader.ReadEndElement();

            reader.ReadStartElement();
            ToAdd = (short)reader.ReadContentAsInt();
            reader.ReadEndElement();

            reader.ReadEndElement();
        }
开发者ID:donblas,项目名称:magecrawl,代码行数:22,代码来源:DiceRoll.cs

示例6: WriteNumber

        /// <summary>
        /// Write a number.
        /// </summary>
        private static void WriteNumber(AmfStreamWriter writer, XmlReader input)
        {
            WriteTypeMarker(writer, Amf0TypeMarker.Number);

            var value = input.ReadContentAsDouble();
            writer.Write(value);
        }
开发者ID:artema,项目名称:DotAmf,代码行数:10,代码来源:Amf0Encoder.cs

示例7: while

        void IFlickrParsable.Load(XmlReader reader)
        {
            while (reader.MoveToNextAttribute())
            {
                switch (reader.LocalName)
                {
                    case "created":
                        DateCreated = UtilityMethods.UnixTimestampToDate(reader.Value);
                        break;
                    case "alpha":
                        Alpha = reader.ReadContentAsDouble();
                        break;
                    case "count_points":
                        PointCount = reader.ReadContentAsInt();
                        break;
                    case "count_edges":
                        EdgeCount = reader.ReadContentAsInt();
                        break;
                    case "has_donuthole":
                        HasDonutHole = reader.Value == "1";
                        break;
                    case "is_donuthole":
                        IsDonutHole = reader.Value == "1";
                        break;
                    default:
                        UtilityMethods.CheckParsingException(reader);
                        break;
                }
            }

            reader.Read();

            while (reader.NodeType != XmlNodeType.EndElement)
            {
                switch (reader.LocalName)
                {
                    case "polylines":
                        reader.Read();
                        while (reader.LocalName == "polyline")
                        {
                            var polyline = new Collection<PointD>();
                            string polystring = reader.ReadElementContentAsString();
                            string[] points = polystring.Split(' ');
                            foreach (string point in points)
                            {
                                string[] xy = point.Split(',');
                                if (xy.Length != 2)
                                    throw new ParsingException("Invalid polypoint found in polyline : '" + polystring +
                                                               "'");
                                polyline.Add(new PointD(double.Parse(xy[0], NumberFormatInfo.InvariantInfo),
                                                        double.Parse(xy[1], NumberFormatInfo.InvariantInfo)));
                            }
                            PolyLines.Add(polyline);
                        }
                        reader.Read();
                        break;
                    case "urls":
                        reader.Skip();
                        break;
                }
            }

            reader.Read();
        }
开发者ID:JamieKitson,项目名称:flickrnet-experimental,代码行数:64,代码来源:ShapeData.cs

示例8: ParseOtherData

 override public void ParseOtherData(string readerName, XmlReader reader)
 {
     bool end = false;
     switch (readerName)
     {
         case "fat":
             this.fat = reader.Value;
             break;
         case "carbs":
             this.carbs = reader.Value;
             break;
         case "protein":
             this.protein = reader.Value;
             break;
         case "ingredients":
             this.ingredients = reader.Value;
             break;
         case "instructions":
             this.instructions = reader.Value;
             break;
         case "mealTime":
         case "exerciseTime":
             this.duration = reader.Value;
             break;
         case "type":
             this.exerciseType = reader.Value;
             break;
         case "percentLike":
             this.percentLike = reader.ReadContentAsDouble();
             break;
     }
 }
开发者ID:jpvarbed,项目名称:LifeFitHackathon,代码行数:32,代码来源:Model.cs

示例9: Load

        /// <summary>
        /// Protected method that does the actual initialization of the Photo instance. Should be called by subclasses of the Photo class.
        /// </summary>
        /// <param name="reader">The reader containing the XML to be parsed.</param>
        /// <param name="allowExtraAtrributes">Wheither to allow unknown extra attributes. In debug builds will throw an exception if this parameter is false and an unknown attribute is found.</param>
        protected void Load(XmlReader reader, bool allowExtraAtrributes)
        {
            if (reader.LocalName != "photo")
                UtilityMethods.CheckParsingException(reader);

            while (reader.MoveToNextAttribute())
            {
                switch (reader.LocalName)
                {
                    case "id":
                        PhotoId = reader.Value;
                        if (String.IsNullOrEmpty(reader.Value))
                        {
                            reader.Skip();
                            return;
                        }
                        break;
                    case "owner":
                        UserId = reader.Value;
                        break;
                    case "secret":
                        Secret = reader.Value;
                        break;
                    case "server":
                        Server = reader.Value;
                        break;
                    case "farm":
                        Farm = reader.Value;
                        break;
                    case "title":
                        Title = reader.Value;
                        break;
                    case "ispublic":
                        IsPublic = reader.Value == "1";
                        break;
                    case "isfamily":
                        IsFamily = reader.Value == "1";
                        break;
                    case "isfriend":
                        IsFriend = reader.Value == "1";
                        break;
                    case "tags":
                        foreach (string tag in reader.Value.Split(' '))
                        {
                            Tags.Add(tag);
                        }
                        break;
                    case "datetaken":
                        // For example : 2007-11-04 08:55:18
                        DateTaken = UtilityMethods.ParseDateWithGranularity(reader.Value);
                        break;
                    case "datetakengranularity":
                        break;
                    case "dateupload":
                        DateUploaded = UtilityMethods.UnixTimestampToDate(reader.Value);
                        break;
                    case "license":
                        License = (LicenseType)int.Parse(reader.Value, System.Globalization.CultureInfo.InvariantCulture);
                        break;
                    case "ownername":
                        OwnerName = reader.Value;
                        break;
                    case "lastupdate":
                        LastUpdated = UtilityMethods.UnixTimestampToDate(reader.Value);
                        break;
                    case "originalformat":
                        OriginalFormat = reader.Value;
                        break;
                    case "originalsecret":
                        OriginalSecret = reader.Value;
                        break;
                    case "place_id":
                        PlaceId = reader.Value;
                        break;
                    case "woeid":
                        WoeId = reader.Value;
                        break;
                    case "accuracy":
                        Accuracy = (GeoAccuracy)reader.ReadContentAsInt();
                        break;
                    case "latitude":
                        Latitude = reader.ReadContentAsDouble();
                        break;
                    case "longitude":
                        Longitude = reader.ReadContentAsDouble();
                        break;
                    case "machine_tags":
                        MachineTags = reader.Value;
                        break;
                    case "o_width":
                        OriginalWidth = int.Parse(reader.Value, System.Globalization.CultureInfo.InvariantCulture);
                        break;
                    case "o_height":
                        OriginalHeight = int.Parse(reader.Value, System.Globalization.CultureInfo.InvariantCulture);
                        break;
//.........这里部分代码省略.........
开发者ID:dimspace,项目名称:crackhead,代码行数:101,代码来源:Photo.cs

示例10: LoadAttributes

        private void LoadAttributes(XmlReader reader)
        {
            while (reader.MoveToNextAttribute())
            {
                switch (reader.LocalName)
                {
                    case "name":
                        Description = reader.Value;
                        break;
                    case "place_id":
                        PlaceId = reader.Value;
                        break;
                    case "place_url":
                        PlaceUrl = reader.Value;
                        break;
                    case "place_type_id":
                        PlaceType = (PlaceType)reader.ReadContentAsInt();
                        break;
                    case "place_type":
                        PlaceType = (PlaceType)Enum.Parse(typeof(PlaceType), reader.Value, true);
                        break;
                    case "woeid":
                        WoeId = reader.Value;
                        break;
                    case "woe_name":
                        WoeName = reader.Value;
                        break;
                    case "latitude":
                        Latitude = reader.ReadContentAsDouble();
                        break;
                    case "longitude":
                        Longitude = reader.ReadContentAsDouble();
                        break;
                    case "accuracy":
                        Accuracy = (GeoAccuracy)reader.ReadContentAsInt();
                        break;
                    case "context":
                        Context = (GeoContext)reader.ReadContentAsInt();
                        break;
                    case "timezone":
                        TimeZone = reader.Value;
                        break;
                    case "has_shapedata":
                        HasShapeData = reader.Value == "1";
                        break;
                    case "id":
                        // Ignore the Photo ID
                        break;
                    default:
                        UtilityMethods.CheckParsingException(reader);
                        break;
                }
            }

            reader.Read();
        }
开发者ID:JamieKitson,项目名称:flickrnet-experimental,代码行数:56,代码来源:PlaceInfo.cs

示例11: ReadDouble

 private static double ReadDouble(XmlReader reader)
 {
     reader.Read();
     var result = reader.ReadContentAsDouble();
     return result;
 }
开发者ID:artema,项目名称:DotAmf,代码行数:6,代码来源:DataContractAmfSerializer.cs

示例12: ReadDate

        private static DateTime ReadDate(XmlReader reader, SerializationContext context)
        {
            reader.Read();
            var milliseconds = reader.ReadContentAsDouble();
            var origin = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
            var offset = TimeSpan.FromMilliseconds(milliseconds);
            var result = origin + offset;

            context.References.Add(new AmfReference { Reference = result, AmfxType = AmfxContent.Date });

            return result;
        }
开发者ID:artema,项目名称:DotAmf,代码行数:12,代码来源:DataContractAmfSerializer.cs

示例13: ReadDataValues


//.........这里部分代码省略.........
                                    var newQualifier = new Qualifier {Code = qualifierCodes};
                                    qualifiers.Add(qualifierCodes, newQualifier);
                                    val.Qualifier = newQualifier;
                                }
                                else
                                {
                                    val.Qualifier = qualifiers[qualifierCodes];
                                }
                            }

                            //vertical offset
                            string offsetCode = r.GetAttribute("offsetTypeCode");
                            if (string.IsNullOrEmpty(offsetCode))
                            {
                                offsetCode = r.GetAttribute("offsetTypeID");
                            }
                            if (!String.IsNullOrEmpty(offsetCode))
                            {
                                if (!offsets.ContainsKey(offsetCode))
                                {
                                    offsets.Add(offsetCode, new OffsetType());
                                }
                                string offsetValue = r.GetAttribute("offsetValue");
                                if (!String.IsNullOrEmpty(offsetValue))
                                {
                                    val.OffsetValue = Convert.ToDouble(offsetValue, CultureInfo.InvariantCulture);
                                }
                            }
                            wrapper.OffsetID = offsetCode;
                        }

                        //data value
                        r.Read();
                        val.Value = r.ReadContentAsDouble();

                    }
                    else if (r.Name == "method")
                    {
                        var method = ReadMethod(r);
                        var methodCodeKey = method.Code.ToString(CultureInfo.InvariantCulture);
                        if (methods.ContainsKey(methodCodeKey))
                        {
                            methods[methodCodeKey] = method;
                        }
                    }
                    else if (r.Name == "source")
                    {
                        var source = ReadSource(r);
                        var sourceCodeKey = source.OriginId.ToString(CultureInfo.InvariantCulture);
                        if (sources.ContainsKey(sourceCodeKey))
                        {
                            sources[sourceCodeKey] = source;
                        }
                    }
                    else if (r.Name == "qualityControlLevel")
                    {
                        var qcLevel = ReadQualityControlLevel(r);
                        var qcCodeKey = qcLevel.Code;
                        if (qualityControlLevels.ContainsKey(qcCodeKey))
                        {
                            qualityControlLevels[qcCodeKey] = qcLevel;
                        }
                    }
                    else if (r.Name == "qualifier")
                    {
                        ReadQualifier(r, qualifiers);
开发者ID:jirikadlec2,项目名称:hydrodata,代码行数:67,代码来源:WaterOneFlow11Parser.cs

示例14: ToObject

        private static TableStorageField ToObject(XmlReader reader, string edmType, bool isNull, string propertyName)
        {
            object value;
            Type dataType;
            string formatString;

            if(edmType == TableStorageConstants.Edm.TYPE_BINARY)
            {
                if(isNull)
                {
                    value = DBNull.Value;
                }
                else
                {
                    using(Stream stream = new MemoryStream())
                    {
                        const int size = 256;
                        byte[] buffer = new byte[size];
                        int count;

                        while((count = reader.ReadContentAsBase64(buffer, 0, size)) > 0)
                        {
                            stream.Write(buffer, 0, count);
                        }

                        stream.Seek(0, SeekOrigin.Begin);

                        value = stream;
                    }
                }

                dataType = typeof(byte[]);
                formatString = "{0}";
            }
            else if(edmType == TableStorageConstants.Edm.TYPE_BOOLEAN)
            {
                if(isNull)
                {
                    value = DBNull.Value;
                }
                else
                {
                    value = reader.ReadContentAsBoolean();
                }

                dataType = typeof(bool);
                formatString = "{0}";
            }
            else if(edmType == TableStorageConstants.Edm.TYPE_DATETIME)
            {
                if(isNull)
                {
                    value = DBNull.Value;
                }
                else
                {
                    value = reader.ReadContentAsDateTime();
                }

                dataType = typeof(DateTime);
                formatString = TableStorageConstants.Edm.DATE_TIME_FORMAT;
            }
            else if(edmType == TableStorageConstants.Edm.TYPE_DOUBLE)
            {
                if(isNull)
                {
                    value = DBNull.Value;
                }
                else
                {
                    value = reader.ReadContentAsDouble();
                }

                dataType = typeof(double);
                formatString = "{0}";
            }
            else if(edmType == TableStorageConstants.Edm.TYPE_GUID)
            {
                if(isNull)
                {
                    value = DBNull.Value;
                }
                else
                {
                    value = Guid.Parse(reader.ReadContentAsString());
                }

                dataType = typeof(Guid);
                formatString = "{0:D}";
            }
            else if(edmType == TableStorageConstants.Edm.TYPE_INT)
            {
                if(isNull)
                {
                    value = DBNull.Value;
                }
                else
                {
                    value = reader.ReadContentAsInt();
                }
//.........这里部分代码省略.........
开发者ID:heymagurany,项目名称:TableStorageDataProvider,代码行数:101,代码来源:TableStorageDataReader.cs

示例15: while

 void IFlickrParsable.Load(XmlReader reader)
 {
     while (reader.MoveToNextAttribute())
       {
     switch (reader.LocalName)
     {
       case "name":
     this.Description = reader.Value;
     continue;
       case "place_id":
     this.PlaceId = reader.Value;
     continue;
       case "place_url":
     this.PlaceUrl = reader.Value;
     continue;
       case "place_type_id":
     this.PlaceType = (PlaceType) reader.ReadContentAsInt();
     continue;
       case "place_type":
     this.PlaceType = (PlaceType) Enum.Parse(typeof (PlaceType), reader.Value, true);
     continue;
       case "woeid":
     this.WoeId = reader.Value;
     continue;
       case "woe_name":
     this.WoeName = reader.Value;
     continue;
       case "latitude":
     this.Latitude = reader.ReadContentAsDouble();
     continue;
       case "longitude":
     this.Longitude = reader.ReadContentAsDouble();
     continue;
       case "timezone":
     this.TimeZone = reader.Value;
     continue;
       case "photo_count":
     this.PhotoCount = new int?(reader.ReadContentAsInt());
     continue;
       default:
     continue;
     }
       }
       reader.Read();
       while (reader.NodeType != XmlNodeType.EndElement)
       {
     if (reader.NodeType == XmlNodeType.Text)
     {
       this.Description = reader.ReadContentAsString();
     }
     else
     {
       string localName = reader.LocalName;
     }
       }
       reader.Read();
 }
开发者ID:rmck,项目名称:FlickrNet,代码行数:57,代码来源:Place.cs


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