Example #1
0
        void IFlickrParsable.Load(System.Xml.XmlReader reader)
        {
            reader.Read();

            while (reader.LocalName != "auth" && reader.LocalName != "oauth")
            {
                switch (reader.LocalName)
                {
                    case "token":
                        Token = reader.ReadElementContentAsString();
                        break;
                    case "perms":
                        Permissions = (AuthLevel)Enum.Parse(typeof(AuthLevel), reader.ReadElementContentAsString(), true);
                        break;
                    case "user":
                        User = new FoundUser();
                        ((IFlickrParsable)User).Load(reader);
                        break;
                    default:
                        UtilityMethods.CheckParsingException(reader);
                        reader.Skip();
                        break;
                }
            }
        }
 public void ReadXml(System.Xml.XmlReader reader)
 {
     reader.MoveToContent(); 
     this.Code = reader.ReadElementContentAsInt();
     this.Message = reader.ReadElementContentAsString();
     this.DataAreaId = reader.ReadElementContentAsString();
 }
Example #3
0
        void IFlickrParsable.Load(System.Xml.XmlReader reader)
        {
            while (reader.MoveToNextAttribute())
            {
                switch (reader.LocalName)
                {
                    case "nsid":
                        InstitutionId = reader.Value;
                        break;
                    case "date_launch":
                        DateLaunched = UtilityMethods.UnixTimestampToDate(reader.Value);
                        break;
                    default:
                        UtilityMethods.CheckParsingException(reader);
                        break;
                }
            }

            reader.Read();

            while (reader.NodeType != System.Xml.XmlNodeType.EndElement)
            {
                switch (reader.LocalName)
                {
                    case "name":
                        InstitutionName = reader.ReadElementContentAsString();
                        break;
                    case "urls":
                        reader.Read();
                        while (reader.LocalName == "url")
                        {
                            string type = reader.GetAttribute("type");
                            string url = reader.ReadElementContentAsString();
                            switch (type)
                            {
                                case "site":
                                    SiteUrl = url;
                                    break;
                                case "flickr":
                                    FlickrUrl = url;
                                    break;
                                case "license":
                                    LicenseUrl = url;
                                    break;
                            }
                        }
                        reader.Read();
                        break;
                }
            }

            reader.Read();
        }
 public static Font readFont(System.Xml.XmlReader reader)
 {
     reader.ReadToDescendant("FontFamily");
     string fontFamily = reader.ReadElementContentAsString();
     float size = reader.ReadElementContentAsFloat();
     FontStyle style = FontStyle.Regular;
     // the style (italic, bold, etc...)
     if (Map.DataVersionOfTheFileLoaded >= 6)
         style = (FontStyle)Enum.Parse(typeof(FontStyle), reader.ReadElementContentAsString());
     // end of Font
     reader.ReadEndElement();
     return new Font(fontFamily, size, style);
 }
Example #5
0
        void IFlickrParsable.Load(System.Xml.XmlReader reader)
        {
            Load(reader, false);

            if (reader.LocalName == "comment")
                Comment = reader.ReadElementContentAsString();

            if (reader.LocalName == "description")
                Description = reader.ReadElementContentAsString();

            if (reader.NodeType == System.Xml.XmlNodeType.EndElement && reader.LocalName == "photo")
                reader.Skip();
        }
Example #6
0
        void IFlickrParsable.Load(System.Xml.XmlReader reader)
        {
            Load(reader, false);

            if (reader.LocalName != "stats")
            {
                UtilityMethods.CheckParsingException(reader);
            }

            while (reader.MoveToNextAttribute())
            {
                switch (reader.LocalName)
                {
                    case "views":
                        StatViews = int.Parse(reader.Value, System.Globalization.NumberFormatInfo.InvariantInfo);
                        break;
                    case "comments":
                        StatComments = int.Parse(reader.Value, System.Globalization.NumberFormatInfo.InvariantInfo);
                        break;
                    case "favorites":
                        StatFavorites = int.Parse(reader.Value, System.Globalization.NumberFormatInfo.InvariantInfo);
                        break;
                    default:
                        UtilityMethods.CheckParsingException(reader);
                        break;
                }
            }

            reader.Read();

            if (reader.LocalName == "description")
                Description = reader.ReadElementContentAsString();

            reader.Skip();
        }
        /// <summary>
        /// Generates a serializable continuation token from its XML representation.
        /// </summary>
        /// <param name="reader">The <see cref="T:System.Xml.XmlReader"/> stream from which the continuation token is deserialized.</param>
        public void ReadXml(System.Xml.XmlReader reader)
        {
            CommonUtils.AssertNotNull("reader", reader);

            reader.MoveToContent();

            bool isEmptyElement = reader.IsEmptyElement;
            reader.ReadStartElement();

            if (!isEmptyElement)
            {
                while (reader.NodeType == XmlNodeType.Element && !reader.IsEmptyElement)
                {
                    if (!reader.IsEmptyElement)
                    {
                        switch (reader.Name)
                        {
                            case Constants.ContinuationConstants.VersionElement:
                                string version = reader.ReadElementContentAsString();

                                // For future versioning
                                break;
                            case Constants.ContinuationConstants.NextMarkerElement:
                                this.NextMarker = reader.ReadElementContentAsString();
                                break;
                            case Constants.ContinuationConstants.TypeElement:
                                string continuationType = reader.ReadElementContentAsString();
                                if ("Queue" != continuationType)
                                {
                                    throw new System.Xml.XmlException(SR.UnexpectedContinuationType);
                                }

                                break;
                            default:
                                throw new XmlException(string.Format(SR.UnexpectedElement, reader.Name));
                        }
                    }
                    else
                    {
                        throw new XmlException(string.Format(SR.UnexpectedEmptyElement, reader.Name));
                    }
                }

                reader.ReadEndElement();
            }
        }
 public static Color readColor(System.Xml.XmlReader reader)
 {
     reader.ReadToDescendant("IsKnownColor");
     bool isKnownColor = reader.ReadElementContentAsBoolean();
     string colorName = reader.ReadElementContentAsString();
     reader.ReadEndElement();
     if (isKnownColor)
         return Color.FromName(colorName);
     else
         return Color.FromArgb(int.Parse(colorName, System.Globalization.NumberStyles.HexNumber));
 }
Example #9
0
File: File.cs Project: faboo/faux
        public override void ReadXml(System.Xml.XmlReader reader)
        {
            reader.ReadStartElement();

            while (reader.IsStartElement())
            {
                if (reader.Name == "Name")
                {
                    Name = reader.ReadElementContentAsString();
                }
                else if (reader.Name == "RealPath")
                {
                    RealPath = reader.ReadElementContentAsString();
                }
                else
                {
                    reader.Read();
                }
            }

            reader.ReadEndElement();
        }
Example #10
0
 public void ReadXml(System.Xml.XmlReader reader)
 {
     m_stairMapping = new Dictionary<Guid, Point>();
     reader.ReadStartElement();
     int count = reader.ReadElementContentAsInt();
     for (int i = 0; i < count; ++i)
     {
         Guid g = new Guid(reader.ReadElementContentAsString());
         Point destination = new Point();
         destination = destination.ReadXml(reader);
         m_stairMapping[g] = destination;
     }
     reader.ReadEndElement();
 }
Example #11
0
File: Node.cs Project: faboo/faux
        public virtual void ReadXml(System.Xml.XmlReader reader)
        {
            reader.ReadStartElement();

            while (reader.IsStartElement())
            {
                if (reader.Name == "Name")
                {
                    Name = reader.ReadElementContentAsString();
                }
                else
                {
                    reader.Read();
                }
            }

            reader.ReadEndElement();
        }
Example #12
0
        public void ReadXml(System.Xml.XmlReader reader)
        {
            reader.MoveToContent();
            this.Name = reader.GetAttribute("Name");

            this.Won = bool.Parse(reader.GetAttribute("Won"));

            reader.ReadStartElement();
            // players
            int playerCount = int.Parse(reader.GetAttribute("Count"));
            for (int i = 0; i < playerCount; i++)
            {
                // opponent
                if (i == 0)
                {
                    reader.ReadStartElement();
                }
                PlayerRecord player = new PlayerRecord();
                this.Players.Add(player);

                player.Name = reader.GetAttribute("Name");
                player.Score = int.Parse(reader.GetAttribute("Score"));

                // deck
                reader.ReadStartElement();
                player.Deck = reader.ReadElementContentAsString();
                reader.ReadEndElement();
            }
            reader.ReadEndElement();

            // turns
            int turnCount = int.Parse(reader.GetAttribute("Count"));
            reader.ReadStartElement();
            for (int i = 0; i < turnCount; i++)
            {
                this.Log.Add(reader.ReadElementContentAsString());
            }
        }
Example #13
0
        void IFlickrParsable.Load(System.Xml.XmlReader reader)
        {
            Tags = new Collection<string>();

            while (reader.MoveToNextAttribute())
            {
                switch (reader.LocalName)
                {
                    case "total":
                        TotalTags = reader.ReadContentAsInt();
                        break;
                }
            }

            reader.Read();

            while (reader.LocalName == "tag")
            {
                Tags.Add(reader.ReadElementContentAsString());
            }

            reader.Read();
        }
Example #14
0
        private void LoadElements(System.Xml.XmlReader reader)
        {
            while (reader.LocalName != "photo")
            {
                switch (reader.LocalName)
                {
                    case "owner":
                        ParseOwner(reader);
                        break;
                    case "title":
                        Title = reader.ReadElementContentAsString();
                        break;
                    case "description":
                        Description = reader.ReadElementContentAsString();
                        break;
                    case "visibility":
                        ParseVisibility(reader);
                        break;
                    case "permissions":
                        ParsePermissions(reader);
                        break;
                    case "editability":
                        ParseEditability(reader);
                        break;
                    case "publiceditability":
                        ParsePublicEditability(reader);
                        break;
                    case "dates":
                        ParseDates(reader);
                        break;
                    case "usage":
                        ParseUsage(reader);
                        break;
                    case "comments":
                        CommentsCount = reader.ReadElementContentAsInt();
                        break;
                    case "notes":
                        ParseNotes(reader);
                        break;
                    case "tags":
                        ParseTags(reader);
                        break;
                    case "urls":
                        ParseUrls(reader);
                        break;
                    case "location":
                        Location = new PlaceInfo();
                        ((IFlickrParsable)Location).Load(reader);
                        break;
                    case "people":
                        ParsePeople(reader);
                        break;
                    case "geoperms":
                        GeoPermissions = new GeoPermissions();
                        ((IFlickrParsable)GeoPermissions).Load(reader);
                        break;
                    case "video":
                        VideoInfo = new VideoInfo();
                        ((IFlickrParsable)VideoInfo).Load(reader);
                        break;
                    default:
                        UtilityMethods.CheckParsingException(reader);
                        reader.Skip();
                        break;

                }
            }

            reader.Skip();
        }
Example #15
0
        void IFlickrParsable.Load(System.Xml.XmlReader reader)
        {
            if (reader.LocalName != "exif")
                UtilityMethods.CheckParsingException(reader);

            while (reader.MoveToNextAttribute())
            {
                switch (reader.LocalName)
                {
                    case "tagspace":
                        TagSpace = reader.Value;
                        break;
                    case "tagspaceid":
                        TagSpaceId = int.Parse(reader.Value, System.Globalization.NumberFormatInfo.InvariantInfo);
                        break;
                    case "tag":
                        Tag = reader.Value;
                        break;
                    case "label":
                        Label = reader.Value;
                        break;
                    default:
                        UtilityMethods.CheckParsingException(reader);
                        break;
                }
            }

            reader.Read();

            while (reader.LocalName != "exif")
            {
                switch (reader.LocalName)
                {
                    case "raw":
                        Raw = reader.ReadElementContentAsString();
                        break;
                    case "clean":
                        Clean = reader.ReadElementContentAsString();
                        break;
                    default:
                        UtilityMethods.CheckParsingException(reader);
                        reader.Skip();
                        break;
                }
            }

            reader.Read();
        }
Example #16
0
        void IFlickrParsable.Load(System.Xml.XmlReader reader)
        {
            if (reader.LocalName != "collection")
                UtilityMethods.CheckParsingException(reader);

            while (reader.MoveToNextAttribute())
            {
                switch (reader.Name)
                {
                    case "id":
                        CollectionId = reader.Value;
                        break;
                    case "child_count":
                        ChildCount = int.Parse(reader.Value, System.Globalization.CultureInfo.InvariantCulture);
                        break;
                    case "datecreate":
                        DateCreated = UtilityMethods.UnixTimestampToDate(reader.Value);
                        break;
                    case "iconlarge":
                        IconLarge = reader.Value;
                        break;
                    case "iconsmall":
                        IconSmall = reader.Value;
                        break;
                    case "server":
                        Server = reader.Value;
                        break;
                    case "secret":
                        Secret = reader.Value;
                        break;
                    default:
                        UtilityMethods.CheckParsingException(reader);
                        break;
                }
            }

            reader.Read();

            while (reader.LocalName != "collection")
            {
                switch (reader.Name)
                {
                    case "title":
                        Title = reader.ReadElementContentAsString();
                        break;
                    case "description":
                        Description = reader.ReadElementContentAsString();
                        break;
                    case "iconphotos":
                        reader.Read();

                        while (reader.LocalName == "photo")
                        {
                            var p = new Photo();
                            ((IFlickrParsable)p).Load(reader);

                            _iconPhotos.Add(p);
                        }
                        reader.Read();
                        return;
                    default:
                        UtilityMethods.CheckParsingException(reader);
                        break;
                }
            }

            reader.Skip();
        }
Example #17
0
        public override void ReadXml(System.Xml.XmlReader reader)
        {
            string effectName = reader.ReadElementContentAsString();
            m_consumable = ItemFactory.Instance.ConsumableEffectFactory.GetEffect(Type, effectName);
            Attributes["Charges"] = reader.ReadElementContentAsString();
            Attributes["MaxCharges"] = reader.ReadElementContentAsString();

            SetupEffectAndStrengthAttributes();
        }
        /// <summary>
        /// Generates a Suggestion object from it's XML representation
        /// </summary>
        /// <param name="reader">XmlReader posistioned at the start node
        /// of the Suggestion XML</param>
        public void ReadXml(System.Xml.XmlReader reader)
        {
            string xsTypes =
                "http://schemas.microsoft.com/exchange/services/2006/types";

            // Store the LocalName of the element we are currently at.
            // This should be "Suggestion".
            //
            // This also serves as our key to our position in the stream.
            // Once we reach an EndElement with this name, then we
            // are done with our portion of the XmlStream.
            //
            string toplevelElementName = reader.LocalName;
            reader.Read();

            while (true)
            {
                // Check to see if we are done processing
                if ((reader.NodeType == XmlNodeType.EndElement) &&
                    (0 == String.Compare(reader.LocalName, toplevelElementName)))
                {
                    // We are done, consume this EndElement and stop processing
                    reader.Read();
                    break;
                }

                if (reader.NodeType == XmlNodeType.EndElement)
                {
                    // This likely means we are at the closing tag of
                    // </AttendeeConflictDataArray>
                    // No data here to process.
                    reader.Read();
                    continue;
                }

                // Consume MeetingTime
                if (0 == String.Compare(reader.LocalName, "MeetingTime"))
                {
                    // MeetingTime is the primary reason we needed to implement
                    // IXmlSerializable, the server will always append a UTC offset
                    // to the date/time string in the MeetingTime element.  This
                    // offset can not be trusted.  The 'time' of the suggestion is
                    // always valid if treated as Local time.
                    //
                    // We will use a Regular Expression to extract whatever was
                    // supplied as a local time only
                    //
                    string meetingTimeValue = reader.ReadElementContentAsString();
                    System.Text.RegularExpressions.Regex regex =
                        new System.Text.RegularExpressions.Regex(
                            @"(?<untimezoned>\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2})",
                            System.Text.RegularExpressions.RegexOptions.Compiled);

                    string nonUTCOffsettingString =
                        regex.Match(meetingTimeValue).Result("${untimezoned}");
                    this.meetingTimeField = DateTime.Parse(nonUTCOffsettingString);
                }

                // Consume IsWorkTime
                if (0 == String.Compare(reader.LocalName, "IsWorkTime"))
                {
                    this.isWorkTimeField = reader.ReadElementContentAsBoolean();
                }

                // Consume SuggestionQuality
                if (0 == String.Compare(reader.LocalName, "SuggestionQuality"))
                {
                    string value = reader.ReadElementContentAsString();
                    this.suggestionQualityField =
                        (SuggestionQuality)Enum.Parse(typeof
                            (SuggestionQuality), value);
                }

                // Consume AttendeeConflictDataArray
                if (0 == String.Compare(reader.LocalName,
                    "AttendeeConflictDataArray"))
                {
                    // Unfortunately, the XmlSerializer can't just de-serialize an
                    // array of items, therefore we need to look at the types of
                    // each indivudal elements of the array and de-serialize them
                    // based on their type.
                    XmlDocument xmld = new XmlDocument();
                    string outerXml = reader.ReadOuterXml();
                    xmld.LoadXml(outerXml);

                    if (!xmld.HasChildNodes)
                    {
                        // This an an empty AttendeeConflictDataArray, so were done.
                        this.attendeeConflictDataArrayField =
                            new AttendeeConflictData[0];
                        continue;
                    }

                    XmlNodeList attendeeConflictNodes = xmld.FirstChild.ChildNodes;
                    List<AttendeeConflictData> attendeeConflictDataList =
                        new List<AttendeeConflictData>(attendeeConflictNodes.Count);

                    foreach (XmlNode xmln in attendeeConflictNodes)
                    {
                        if (0 == String.Compare(xmln.Name,
                            "IndividualAttendeeConflictData"))
                        {
                            using (System.IO.StringReader strdr =
                                new System.IO.StringReader(xmln.OuterXml))
                            {
                                XmlSerializer xmls =
                                    new XmlSerializer(
                                        typeof(IndividualAttendeeConflictData),
                                        xsTypes);

                                attendeeConflictDataList.Add(
                                    (IndividualAttendeeConflictData)
                                    xmls.Deserialize(strdr));
                            }
                        }
                        if (0 == String.Compare(xmln.Name,
                            "GroupAttendeeConflictData"))
                        {
                            using (System.IO.StringReader strdr =
                                new System.IO.StringReader(xmln.OuterXml))
                            {
                                XmlSerializer xmls =
                                    new XmlSerializer(
                                        typeof(GroupAttendeeConflictData),
                                        xsTypes);

                                attendeeConflictDataList.Add(
                                    (GroupAttendeeConflictData)
                                    xmls.Deserialize(strdr));
                            }
                        }
                        if (0 == String.Compare(xmln.Name,
                            "UnknownAttendeeConflictData"))
                        {
                            using (System.IO.StringReader strdr =
                                new System.IO.StringReader(xmln.OuterXml))
                            {
                                XmlSerializer xmls =
                                    new XmlSerializer(
                                        typeof(UnknownAttendeeConflictData),
                                        xsTypes);

                                attendeeConflictDataList.Add(
                                    (UnknownAttendeeConflictData)
                                    xmls.Deserialize(strdr));
                            }
                        }
                        if (0 == String.Compare(xmln.Name,
                            "TooBigGroupAttendeeConflictData"))
                        {
                            using (System.IO.StringReader strdr =
                                new System.IO.StringReader(xmln.OuterXml))
                            {
                                XmlSerializer xmls =
                                    new XmlSerializer(
                                        typeof(TooBigGroupAttendeeConflictData),
                                        xsTypes);

                                attendeeConflictDataList.Add(
                                    (TooBigGroupAttendeeConflictData)
                                    xmls.Deserialize(strdr));
                            }
                        }
                    }

                    // Convert our list of AttendeeConflictData to an array
                    this.attendeeConflictDataArrayField =
                        attendeeConflictDataList.ToArray();
                }
            }
        }
		protected override void DeserializeElement(System.Xml.XmlReader reader, bool serializeCollectionKey)
		{
			this.Content = reader.ReadElementContentAsString();
		}
Example #20
0
        void IFlickrParsable.Load(System.Xml.XmlReader reader)
        {
            reader.Read();

            while (reader.LocalName != "photos")
            {
                switch (reader.LocalName)
                {
                    case "firstdatetaken":
                        FirstTakenDate = UtilityMethods.ParseDateWithGranularity(reader.ReadElementContentAsString());
                        break;
                    case "firstdate":
                        FirstDate = UtilityMethods.UnixTimestampToDate(reader.ReadElementContentAsString());
                        break;
                    case "count":
                        PhotoCount = reader.ReadElementContentAsInt();
                        break;
                    case "views":
                        Views = reader.ReadElementContentAsInt();
                        break;
                    default:
                        UtilityMethods.CheckParsingException(reader);
                        reader.Skip();
                        break;
                }
            }

            reader.Read();
        }
        void IFlickrParsable.Load(System.Xml.XmlReader reader)
        {
            if (reader == null) throw new ArgumentNullException("reader");
            if (reader.LocalName != "reply") { UtilityMethods.CheckParsingException(reader); return; }

            while (reader.MoveToNextAttribute())
            {
                switch (reader.LocalName)
                {
                    case "id":
                        ReplyId = reader.Value;
                        break;
                    case "author":
                        AuthorUserId = reader.Value;
                        break;
                    case "authorname":
                        AuthorName = reader.Value;
                        break;
                    case "is_pro":
                        AuthorIsPro = reader.Value == "1";
                        break;
                    case "role":
                        AuthorRole = UtilityMethods.ParseRoleToMemberType(reader.Value);
                        break;
                    case "iconserver":
                        AuthorIconServer = reader.Value;
                        break;
                    case "iconfarm":
                        AuthorIconFarm = reader.Value;
                        break;
                    case "can_edit":
                        CanEdit = reader.Value == "1";
                        break;
                    case "can_delete":
                        CanDelete = reader.Value == "1";
                        break;
                    case "datecreate":
                        DateCreated = UtilityMethods.UnixTimestampToDate(reader.Value);
                        break;
                    case "lastedit":
                        DateLastEdited = UtilityMethods.UnixTimestampToDate(reader.Value);
                        break;
                    default:
                        UtilityMethods.CheckParsingException(reader);
                        break;
                }
            }

            reader.Read();

            if (reader.LocalName == "message")
                Message = reader.ReadElementContentAsString();

            reader.Skip();
        }
Example #22
0
        protected virtual void ReadXmlBase(System.Xml.XmlReader reader)
        {
            Check.Assert(reader.LocalName == "id", "reader localName must be 'id'");
            if (this.id == null)
            {
                string objectIdType = reader.GetAttribute("type", RmXmlSerializer.XsiNamespace);
                this.id = ObjectId.GetObjectIdByType(objectIdType);
            }
            this.id.ReadXml(reader);

            Check.Assert(reader.LocalName == "namespace", "reader localName must be 'namespace'");
            this.namespaceValue = reader.ReadElementContentAsString();

            if (!reader.IsStartElement())
                reader.ReadEndElement();
            reader.MoveToContent();

            Check.Assert(reader.LocalName == "type", "reader localName must be 'type'");
            this.type = reader.ReadElementContentAsString();
        }
Example #23
0
 private void LoadElements(System.Xml.XmlReader reader)
 {
     while (reader.LocalName != "person")
     {
         switch (reader.LocalName)
         {
             case "timezone":
                 Timezone = new Timezone();
                 ((IFlickrParsable)Timezone).Load(reader);
                 break;
             case "username":
                 UserName = reader.ReadElementContentAsString();
                 break;
             case "location":
                 Location = reader.ReadElementContentAsString();
                 break;
             case "realname":
                 RealName = reader.ReadElementContentAsString();
                 break;
             case "photosurl":
                 PhotosUrl = reader.ReadElementContentAsString();
                 break;
             case "profileurl":
                 ProfileUrl = reader.ReadElementContentAsString();
                 break;
             case "description":
                 Description = reader.ReadElementContentAsString();
                 break;
             case "mobileurl":
                 MobileUrl = reader.ReadElementContentAsString();
                 break;
             case "photos":
                 PhotosSummary = new PersonPhotosSummary();
                 ((IFlickrParsable)PhotosSummary).Load(reader);
                 break;
             case "mbox_sha1sum":
                 MailboxSha1Hash = reader.ReadElementContentAsString();
                 break;
             case "datecreate":
                 DateCreated = reader.ReadElementContentAsString();
                 break;
             default:
                 UtilityMethods.CheckParsingException(reader);
                 reader.Skip();
                 break;
         }
     }
 }
Example #24
0
 /// <summary>
 /// Manually reads the element from the configuration XML
 /// </summary>
 /// <param name="reader">
 /// The XML reader for the current element
 /// </param>
 /// <param name="serializeCollectionKey">
 /// True to serialize only the collection key properties
 /// False otherwise
 /// </param>
 protected override void DeserializeElement(
     System.Xml.XmlReader reader,
     Boolean serializeCollectionKey)
 {
     this.Name = (String)reader.GetAttribute("name");
      this.Value = reader.ReadElementContentAsString();
      if (String.IsNullOrWhiteSpace(this.Name))
     throw new ConfigException(this, "Name");
 }
        /// <summary>
        /// Generates a serializable continuation token from its XML representation.
        /// </summary>
        /// <param name="reader">The <see cref="T:System.Xml.XmlReader"/> stream from which the continuation token is deserialized.</param>
        void IXmlSerializable.ReadXml(System.Xml.XmlReader reader)
        {
            CommonUtils.AssertNotNull("reader", reader);

            reader.MoveToContent();

            bool isEmptyElement = reader.IsEmptyElement;
            reader.ReadStartElement();

            if (!isEmptyElement)
            {
                bool more = true;
                while (more)
                {
                    if (reader.NodeType == XmlNodeType.Element && !reader.IsEmptyElement)
                    {
                        switch (reader.Name)
                        {
                            case VersionElement:
                                string version = reader.ReadElementContentAsString();
							Console.WriteLine(version);

                                // For future versioning
                                break;
                            case NextMarkerElement:
                                this.NextMarker = reader.ReadElementContentAsString();
                                break;
                            case NextPartitionKeyElement:
                                this.NextPartitionKey = reader.ReadElementContentAsString();
                                break;
                            case NextRowKeyElement:
                                this.NextRowKey = reader.ReadElementContentAsString();
                                break;
                            case NextTableNameElement:
                                this.NextTableName = reader.ReadElementContentAsString();
                                break;
                            case TypeElement:
                                this.Type = (ContinuationType)Enum.Parse(typeof(ContinuationType), reader.ReadElementContentAsString());
                                break;
                        }
                    }
                    else
                    {
                        more = reader.Read();
                    }
                }
            }
        }
        /// <summary>
        /// Generates a serializable continuation token from its XML representation.
        /// </summary>
        /// <param name="reader">The <see cref="T:System.Xml.XmlReader"/> stream from which the continuation token is deserialized.</param>
        public void ReadXml(System.Xml.XmlReader reader)
        {
            if (reader == null)
            {
                throw new ArgumentNullException("reader");
            }

            reader.MoveToContent();

            bool isEmptyElement = reader.IsEmptyElement;
            reader.ReadStartElement(Constants.ContinuationConstants.ContinuationTopElement);

            if (!isEmptyElement)
            {
                while (true)
                {
                    if (reader.NodeType == XmlNodeType.Element && !reader.IsEmptyElement)
                    {
                        switch (reader.Name)
                        {
                            case Constants.ContinuationConstants.VersionElement:
                                string version = reader.ReadElementContentAsString();
                                if (version != Constants.ContinuationConstants.CurrentVersion)
                                {
                                    throw new System.Xml.XmlException(string.Format(SR.UnexpectedElement, version));
                                }

                                break;
                            case Constants.ContinuationConstants.NextPartitionKeyElement:
                                this.NextPartitionKey = reader.ReadElementContentAsString();
                                break;
                            case Constants.ContinuationConstants.NextRowKeyElement:
                                this.NextRowKey = reader.ReadElementContentAsString();
                                break;
                            case Constants.ContinuationConstants.NextTableNameElement:
                                this.NextTableName = reader.ReadElementContentAsString();
                                break;
                            case Constants.ContinuationConstants.TypeElement:
                                string continuationType = reader.ReadElementContentAsString();
                                if ("Table" != continuationType)
                                {
                                    throw new System.Xml.XmlException(SR.UnexpectedContinuationType);
                                }

                                break;
                            default:
                                throw new System.Xml.XmlException(string.Format(SR.UnexpectedElement, reader.Name));
                        }
                    }
                    else
                    {
                        reader.ReadEndElement();
                        return;
                    }
                }
            }
        }
Example #27
0
        public override void ReadXml(System.Xml.XmlReader reader)
        {
            //XmlSerializer serializer = new XmlSerializer(typeof(PointF));

            //reader.Get("P"), StockAnalyzerApp.Global.EnglishCulture

            //this.Point1= (PointF)serializer.Deserialize(reader);
            //this.Point2= (PointF)serializer.Deserialize(reader);
            reader.ReadStartElement();

            // Point1
            reader.ReadStartElement();
            float x, y;
            x = reader.ReadElementContentAsFloat();
            y = reader.ReadElementContentAsFloat();
            this.Point1 = new PointF(x, y);
            reader.ReadEndElement();

            // Point2
            reader.ReadStartElement();
            x = reader.ReadElementContentAsFloat();
            y = reader.ReadElementContentAsFloat();
            this.Point2 = new PointF(x, y);
            reader.ReadEndElement();

            // Pen if exists
            if (reader.Name == "Pen")
            {
                this.Pen = GraphCurveType.PenFromString(reader.ReadElementContentAsString());
            }
            else
            {
                this.Pen = DefaultPen;
            }
            reader.ReadEndElement();
        }
Example #28
0
 //=========================================================================
 ///	<summary>
 ///		XML����ǂݍ���
 ///	</summary>
 /// <remarks>
 /// </remarks>
 /// <history>2006/XX/XX �V�K�쐬</history>
 //=========================================================================
 public void Read(System.Xml.XmlReader xr)
 {
     while (xr.Read())
     {
         if (xr.NodeType == System.Xml.XmlNodeType.Element)
         {
             if (xr.LocalName.Equals("StoryNumber"))
                 mStoryNumber = xr.ReadElementContentAsInt();
             else if (xr.LocalName.Equals("FilePath"))
                 mFilePath = xr.ReadElementContentAsString();
             // Ver1.9.18�ȑO����̈ȍ~
             else if (xr.LocalName.Equals("State"))
                 MigrationState( (State)xr.ReadElementContentAsInt() );
             else if (xr.LocalName.Equals("SubTitle"))
                 mSubTitle = xr.ReadElementContentAsString();
             else if (xr.LocalName.Equals("Unread"))
                 mIsUnread = xr.ReadElementContentAsInt() == 1 ? true : false;
             else if (xr.LocalName.Equals("ThumbnailMaked"))
                 mThumbnailMaked = xr.ReadElementContentAsInt() == 1 ? true : false;
             else if (xr.LocalName.Equals("DateTime"))
             {
                 string strDateTime = xr.ReadElementContentAsString();
                 mStartTime = new DateTime(Convert.ToInt64(strDateTime));
             }
             else if (xr.LocalName.Equals("HasPlan"))
                 mHasPlan			= bool.Parse( xr.ReadElementContentAsString() );
             else if (xr.LocalName.Equals("IsReserved"))
                 mIsReserved			= bool.Parse( xr.ReadElementContentAsString() );
             else if (xr.LocalName.Equals("ReserveStartTime"))
                 mReserveStartTime	= new DateTime( Convert.ToInt64( xr.ReadElementContentAsString() ) );
             else if (xr.LocalName.Equals("HasFile"))
                 mHasFile			= bool.Parse( xr.ReadElementContentAsString() );
             else if (xr.LocalName.Equals("IsReserveError"))
                 mIsReserveError		= bool.Parse( xr.ReadElementContentAsString() );
             else if (xr.LocalName.Equals("IsEncoded"))
                 mIsEncoded			= bool.Parse( xr.ReadElementContentAsString() );
             else if (xr.LocalName.Equals("IsStored"))
                 mIsStored			= bool.Parse( xr.ReadElementContentAsString() );
             else if (xr.LocalName.Equals("Length"))
                 mLength				= xr.ReadElementContentAsInt();
             else if (xr.LocalName.Equals("RepeatNumber"))
                 mRepeatNumber		= xr.ReadElementContentAsInt();
             else if (xr.LocalName.Equals("PlanError"))
                 PlanError			= bool.Parse( xr.ReadElementContentAsString() );
         }
         else if (xr.NodeType == System.Xml.XmlNodeType.EndElement)
             if (xr.LocalName.Equals("Records"))
                 break;
     }
 }
        void IFlickrParsable.Load(System.Xml.XmlReader reader)
        {
            if (reader == null) throw new ArgumentNullException("reader");
            if (reader.LocalName != "topic") { UtilityMethods.CheckParsingException(reader); return; }

            while (reader.MoveToNextAttribute())
            {
                switch (reader.LocalName)
                {
                    case "id":
                        TopicId = reader.Value;
                        break;
                    case "subject":
                        Subject = reader.Value;
                        break;
                    case "author":
                        AuthorUserId = reader.Value;
                        break;
                    case "authorname":
                        AuthorName = reader.Value;
                        break;
                    case "is_pro":
                        AuthorIsPro = reader.Value == "1";
                        break;
                    case "role":
                        AuthorRole = UtilityMethods.ParseRoleToMemberType(reader.Value);
                        break;
                    case "iconserver":
                        AuthorIconServer = reader.Value;
                        break;
                    case "iconfarm":
                        AuthorIconFarm = reader.Value;
                        break;
                    case "count_replies":
                        RepliesCount = reader.ReadContentAsInt();
                        break;
                    case "can_edit":
                        CanEdit = reader.Value == "1";
                        break;
                    case "can_delete":
                        CanDelete = reader.Value == "1";
                        break;
                    case "can_reply":
                        CanReply = reader.Value == "1";
                        break;
                    case "is_sticky":
                        IsSticky = reader.Value == "1";
                        break;
                    case "is_locked":
                        IsLocked = reader.Value == "1";
                        break;
                    case "datecreate":
                        DateCreated = UtilityMethods.UnixTimestampToDate(reader.Value);
                        break;
                    case "datelastpost":
                        DateLastPost = UtilityMethods.UnixTimestampToDate(reader.Value);
                        break;
                    case "last_reply":
                        LastReplyId = reader.Value;
                        break;
                    case "lastedit":
                        DateLastEdit = reader.Value == "0"
                            ? null
                            : (DateTime?) UtilityMethods.UnixTimestampToDate(reader.Value);
                        break;
                    case "group_id":
                        GroupId = reader.Value;
                        break;
                    case "name":
                        // Group Name
                        break;
                    case "author_path_alias":
                        AuthorPathAlias = reader.Value == "" ? null : reader.Value;
                        break;
                    case "author_is_deleted":
                        AuthorIsDeleted = reader.Value == "1";
                        break;
                    default:
                        UtilityMethods.CheckParsingException(reader);
                        break;
                }
            }

            reader.Read();

            if (reader.LocalName == "message")
                Message = reader.ReadElementContentAsString();

            reader.Skip();
        }
Example #30
0
 void System.Xml.Serialization.IXmlSerializable.ReadXml(System.Xml.XmlReader reader)
 {
     String text = reader.ReadElementContentAsString();
     BluetoothAddress tmpAddr = BluetoothAddress.Parse(text);
     this.data = tmpAddr.data;
 }