UnixTimestampToDate() public static method

Converts a long, representing a unix timestamp number into a DateTime object.
public static UnixTimestampToDate ( long timestamp ) : System.DateTime
timestamp long The unix timestamp.
return System.DateTime
Beispiel #1
0
        private void ParseDates(System.Xml.XmlReader reader)
        {
            while (reader.MoveToNextAttribute())
            {
                switch (reader.LocalName)
                {
                    case "posted":
                        DatePosted = UtilityMethods.UnixTimestampToDate(reader.Value);
                        break;
                    case "taken":
                        DateTaken = UtilityMethods.ParseDateWithGranularity(reader.Value);
                        break;
                    case "takengranularity":
                        DateTakenGranularity = (DateGranularity)int.Parse(reader.Value, System.Globalization.NumberFormatInfo.InvariantInfo);
                        break;
                    case "lastupdate":
                        DateLastUpdated = UtilityMethods.UnixTimestampToDate(reader.Value);
                        break;
                    default:
                        UtilityMethods.CheckParsingException(reader);
                        break;
                }
            }

            reader.Read();
        }
Beispiel #2
0
        void IFlickrParsable.Load(System.Xml.XmlReader reader)
        {
            if (reader.LocalName != "photocount")
            {
                UtilityMethods.CheckParsingException(reader);
            }

            while (reader.MoveToNextAttribute())
            {
                switch (reader.LocalName)
                {
                case "count":
                    Count = int.Parse(reader.Value, System.Globalization.NumberFormatInfo.InvariantInfo);
                    break;

                case "fromdate":
                    FromDate = UtilityMethods.UnixTimestampToDate(reader.Value);
                    break;

                case "todate":
                    ToDate = UtilityMethods.UnixTimestampToDate(reader.Value);
                    break;

                default:
                    UtilityMethods.CheckParsingException(reader);
                    break;
                }
            }

            reader.Read();
        }
Beispiel #3
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();
        }
Beispiel #4
0
        void IFlickrParsable.Load(XmlReader reader)
        {
            while (reader.MoveToNextAttribute())
            {
                switch (reader.Name)
                {
                case "nsid":
                    UserId = reader.Value;
                    break;

                case "username":
                    UserName = reader.Value;
                    break;

                case "favedate":
                    FavoriteDate = UtilityMethods.UnixTimestampToDate(reader.Value);
                    break;

                default:
                    break;
                }
            }

            reader.Skip();
        }
Beispiel #5
0
        void IFlickrParsable.Load(System.Xml.XmlReader reader)
        {
            if (reader.LocalName != "comment")
            {
                UtilityMethods.CheckParsingException(reader);
            }

            while (reader.MoveToNextAttribute())
            {
                switch (reader.LocalName)
                {
                case "id":
                    CommentId = reader.Value;
                    break;

                case "author":
                    AuthorUserId = reader.Value;
                    break;

                case "authorname":
                    AuthorUserName = reader.Value;
                    break;

                case "permalink":
                    Permalink = reader.Value;
                    break;

                case "datecreate":
                    DateCreated = UtilityMethods.UnixTimestampToDate(reader.Value);
                    break;

                case "iconserver":
                    IconServer = reader.Value;
                    break;

                case "iconfarm":
                    IconFarm = reader.Value;
                    break;

                case "path_alias":
                    AuthorPathAlias = reader.Value;
                    break;

                case "realname":
                    AuthorRealName = reader.Value;
                    break;

                default:
                    UtilityMethods.CheckParsingException(reader);
                    break;
                }
            }

            reader.Read();

            CommentHtml = reader.ReadContentAsString();

            reader.Skip();
        }
Beispiel #6
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();
        }
Beispiel #7
0
        private void LoadAttributes(System.Xml.XmlReader reader)
        {
            while (reader.MoveToNextAttribute())
            {
                switch (reader.LocalName)
                {
                    case "id":
                        PhotoId = reader.Value;
                        break;
                    case "secret":
                        Secret = reader.Value;
                        break;
                    case "server":
                        Server = reader.Value;
                        break;
                    case "farm":
                        Farm = reader.Value;
                        break;
                    case "originalformat":
                        OriginalFormat = reader.Value;
                        break;
                    case "originalsecret":
                        OriginalSecret = reader.Value;
                        break;
                    case "dateuploaded":
                        DateUploaded = UtilityMethods.UnixTimestampToDate(reader.Value);
                        break;
                    case "isfavorite":
                        IsFavorite = reader.Value == "1";
                        break;
                    case "license":
                        License = (LicenseType)int.Parse(reader.Value, System.Globalization.NumberFormatInfo.InvariantInfo);
                        break;
                    case "views":
                        ViewCount = int.Parse(reader.Value, System.Globalization.NumberFormatInfo.InvariantInfo);
                        break;
                    case "rotation":
                        Rotation = int.Parse(reader.Value, System.Globalization.NumberFormatInfo.InvariantInfo);
                        break;
                    case "media":
                        Media = reader.Value == "photo" ? MediaType.Photos : MediaType.Videos;
                        break;
                    case "safety_level":
                        SafetyLevel = (SafetyLevel)reader.ReadContentAsInt();
                        break;
                    default:
                        UtilityMethods.CheckParsingException(reader);
                        break;
                }
            }

            reader.Read();
        }
Beispiel #8
0
        void IFlickrParsable.Load(System.Xml.XmlReader reader)
        {
            if (reader.LocalName != "photos")
            {
                UtilityMethods.CheckParsingException(reader);
            }

            while (reader.MoveToNextAttribute())
            {
                switch (reader.LocalName)
                {
                case "total":
                    Total = int.Parse(reader.Value, System.Globalization.CultureInfo.InvariantCulture);
                    break;

                case "interval":
                    Interval = int.Parse(reader.Value, System.Globalization.CultureInfo.InvariantCulture);
                    break;

                case "panda":
                    PandaName = reader.Value;
                    break;

                case "lastupdate":
                    LastUpdated = UtilityMethods.UnixTimestampToDate(reader.Value);
                    break;

                default:
                    UtilityMethods.CheckParsingException(reader);
                    break;
                }
            }

            reader.Read();

            while (reader.LocalName == "photo")
            {
                var p = new Photo();
                ((IFlickrParsable)p).Load(reader);
                if (!string.IsNullOrEmpty(p.PhotoId))
                {
                    Add(p);
                }
            }

            // Skip to next element (if any)
            reader.Skip();
        }
Beispiel #9
0
        void IFlickrParsable.Load(XmlReader reader)
        {
            if (reader.LocalName != "subscription")
            {
                UtilityMethods.CheckParsingException(reader);
            }

            while (reader.MoveToNextAttribute())
            {
                switch (reader.LocalName)
                {
                case "topic":
                    Topic = reader.Value;
                    break;

                case "callback":
                    Callback = reader.Value;
                    break;

                case "pending":
                    IsPending = reader.Value == "1";
                    break;

                case "date_create":
                    DateCreated = UtilityMethods.UnixTimestampToDate(reader.Value);
                    break;

                case "lease_seconds":
                    LeaseSeconds = reader.ReadContentAsInt();
                    break;

                case "expiry":
                    Expiry = UtilityMethods.UnixTimestampToDate(reader.Value);
                    break;

                case "verify_attempts":
                    VerifyAttempts = reader.ReadContentAsInt();
                    break;

                default:
                    UtilityMethods.CheckParsingException(reader);
                    break;
                }
            }

            reader.Read();
        }
Beispiel #10
0
        void IFlickrParsable.Load(XmlReader reader)
        {
            if (reader.LocalName != "photocount")
            {
                UtilityMethods.CheckParsingException(reader);
            }

            while (reader.MoveToNextAttribute())
            {
                switch (reader.LocalName)
                {
                case "count":
                    Count = int.Parse(reader.Value, NumberFormatInfo.InvariantInfo);
                    break;

                case "fromdate":
                    if (Regex.IsMatch(reader.Value, "^\\d+$"))
                    {
                        FromDate = UtilityMethods.UnixTimestampToDate(reader.Value);
                    }
                    else
                    {
                        FromDate = UtilityMethods.MySqlToDate(reader.Value);
                    }
                    break;

                case "todate":
                    if (Regex.IsMatch(reader.Value, "^\\d+$"))
                    {
                        ToDate = UtilityMethods.UnixTimestampToDate(reader.Value);
                    }
                    else
                    {
                        ToDate = UtilityMethods.MySqlToDate(reader.Value);
                    }
                    break;

                default:
                    UtilityMethods.CheckParsingException(reader);
                    break;
                }
            }

            reader.Read();
        }
Beispiel #11
0
        void IFlickrParsable.Load(XmlReader reader)
        {
            while (reader.MoveToNextAttribute())
            {
                switch (reader.LocalName)
                {
                case "usage":
                    Usage = reader.ReadContentAsInt();
                    break;

                case "predicate":
                    PredicateName = reader.Value;
                    break;

                case "namespace":
                    NamespaceName = reader.Value;
                    break;

                case "first_added":
                    DateFirstAdded = UtilityMethods.UnixTimestampToDate(reader.Value);
                    break;

                case "last_added":
                    DateLastUsed = UtilityMethods.UnixTimestampToDate(reader.Value);
                    break;
                }
            }

            reader.Read();

            if (reader.NodeType == XmlNodeType.Text)
            {
                ValueText = reader.ReadContentAsString();
            }

            reader.Read();
        }
Beispiel #12
0
        void IFlickrParsable.Load(XmlReader reader)
        {
            while (reader.MoveToNextAttribute())
            {
                switch (reader.LocalName)
                {
                case "id":
                case "nsid":
                    UserId = reader.Value;
                    break;

                case "join_date":
                    JoinDate = UtilityMethods.UnixTimestampToDate(reader.Value);
                    break;

                case "occupation":
                    Occupation = reader.Value;
                    break;

                case "hometown":
                    HomeTown = reader.Value;
                    break;

                case "showcase_set":
                    ShowcaseSet = reader.Value;
                    break;

                case "showcase_set_title":
                    ShowcaseSetTitle = reader.Value;
                    break;

                case "first_name":
                    FirstName = reader.Value;
                    break;

                case "last_name":
                    LastName = reader.Value;
                    break;

                case "profile_description":
                    ProfileDescription = reader.Value;
                    break;

                case "website":
                    WebSite = reader.Value;
                    break;

                case "city":
                    City = reader.Value;
                    break;

                case "country":
                    Country = reader.Value;
                    break;

                case "facebook":
                    Facebook = reader.Value;
                    break;

                case "twitter":
                    Twitter = reader.Value;
                    break;

                case "tumblr":
                    Tumblr = reader.Value;
                    break;

                case "instagram":
                    Instagram = reader.Value;
                    break;

                case "pinterest":
                    Pinterest = reader.Value;
                    break;

                default:
                    UtilityMethods.CheckParsingException(reader);
                    break;
                }
            }
        }
Beispiel #13
0
        /// <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;

                case "views":
                    Views = int.Parse(reader.Value, System.Globalization.CultureInfo.InvariantCulture);
                    break;

                case "media":
                    Media = reader.Value;
                    break;

                case "media_status":
                    MediaStatus = reader.Value;
                    break;

                case "iconserver":
                    IconServer = reader.Value;
                    break;

                case "iconfarm":
                    IconFarm = reader.Value;
                    break;

                case "username":
                    OwnerName = reader.Value;
                    break;

                case "isprimary":
                case "is_primary":
                    break;

                case "pathalias":
                    PathAlias = reader.Value;
                    break;

                case "url_sq":
                    urlSquare = reader.Value;
                    break;

                case "width_sq":
                    SquareThumbnailWidth = reader.ReadContentAsInt();
                    break;

                case "height_sq":
                    SquareThumbnailHeight = reader.ReadContentAsInt();
                    break;

                case "url_t":
                    urlThumbnail = reader.Value;
                    break;

                case "width_t":
                    ThumbnailWidth = reader.ReadContentAsInt();
                    break;

                case "height_t":
                    ThumbnailHeight = reader.ReadContentAsInt();
                    break;

                case "url_s":
                    urlSmall = reader.Value;
                    break;

                case "width_s":
                    SmallWidth = reader.ReadContentAsInt();
                    break;

                case "height_s":
                    SmallHeight = reader.ReadContentAsInt();
                    break;

                case "url_m":
                    urlMedium = reader.Value;
                    break;

                case "width_m":
                    MediumWidth = reader.ReadContentAsInt();
                    break;

                case "height_m":
                    MediumHeight = reader.ReadContentAsInt();
                    break;

                case "url_l":
                    urlLarge = reader.Value;
                    break;

                case "width_l":
                    LargeWidth = reader.ReadContentAsInt();
                    break;

                case "height_l":
                    LargeHeight = reader.ReadContentAsInt();
                    break;

                case "url_z":
                    urlMedium640 = reader.Value;
                    break;

                case "width_z":
                    Medium640Width = reader.ReadContentAsInt();
                    break;

                case "height_z":
                    Medium640Height = reader.ReadContentAsInt();
                    break;

                case "url_o":
                    urlOriginal = reader.Value;
                    break;

                case "width_o":
                    OriginalWidth = reader.ReadContentAsInt();
                    break;

                case "height_o":
                    OriginalHeight = reader.ReadContentAsInt();
                    break;

                case "dateadded":
                    DateAddedToGroup = UtilityMethods.UnixTimestampToDate(reader.Value);
                    break;

                case "date_faved":
                    DateFavorited = UtilityMethods.UnixTimestampToDate(reader.Value);
                    break;

                case "has_comment":     // Gallery photos return this, but we ignore it and set GalleryPhoto.Comment instead.
                    break;

                case "can_comment":
                    CanComment = reader.Value == "1";
                    break;

                case "can_addmeta":
                    CanAddMeta = reader.Value == "1";
                    break;

                case "can_blog":
                    CanBlog = reader.Value == "1";
                    break;

                case "can_print":
                    CanPrint = reader.Value == "1";
                    break;

                case "can_download":
                    CanDownload = reader.Value == "1";
                    break;

                case "can_share":
                    CanShare = reader.Value == "1";
                    break;

                case "geo_is_family":
                    if (GeoPermissions == null)
                    {
                        GeoPermissions         = new GeoPermissions();
                        GeoPermissions.PhotoId = PhotoId;
                    }
                    GeoPermissions.IsFamily = reader.Value == "1";
                    break;

                case "geo_is_friend":
                    if (GeoPermissions == null)
                    {
                        GeoPermissions         = new GeoPermissions();
                        GeoPermissions.PhotoId = PhotoId;
                    }
                    GeoPermissions.IsFriend = reader.Value == "1";
                    break;

                case "geo_is_public":
                    if (GeoPermissions == null)
                    {
                        GeoPermissions         = new GeoPermissions();
                        GeoPermissions.PhotoId = PhotoId;
                    }
                    GeoPermissions.IsPublic = reader.Value == "1";
                    break;

                case "geo_is_contact":
                    if (GeoPermissions == null)
                    {
                        GeoPermissions         = new GeoPermissions();
                        GeoPermissions.PhotoId = PhotoId;
                    }
                    GeoPermissions.IsContact = reader.Value == "1";
                    break;

                default:
                    if (!allowExtraAtrributes)
                    {
                        UtilityMethods.CheckParsingException(reader);
                    }
                    break;
                }
            }

            reader.Read();

            if (reader.LocalName == "description")
            {
                Description = reader.ReadElementContentAsString();
            }
        }
        void IFlickrParsable.Load(XmlReader reader)
        {
            if (reader == null)
            {
                throw new ArgumentNullException("reader");
            }
            if (reader.LocalName != "replies")
            {
                UtilityMethods.CheckParsingException(reader);
                return;
            }

            reader.Read();
            if (reader.LocalName != "topic")
            {
                UtilityMethods.CheckParsingException(reader);
                return;
            }

            while (reader.MoveToNextAttribute())
            {
                switch (reader.LocalName)
                {
                case "topic_id":
                    TopicId = reader.Value;
                    break;

                case "subject":
                    Subject = reader.Value;
                    break;

                case "group_id":
                    GroupId = reader.Value;
                    break;

                case "name":
                    GroupName = reader.Value;
                    break;

                case "author":
                    AuthorUserId = reader.Value;
                    break;

                case "authorname":
                    AuthorName = reader.Value;
                    break;

                case "author_path_alias":
                    AuthorPathAlias = reader.Value == "" ? null : reader.Value;
                    break;

                case "is_pro":
                    AuthorIsPro = reader.Value == "1";
                    break;

                case "role":
                    AuthorRole = UtilityMethods.ParseRoleToMemberType(reader.Value);
                    break;

                case "iconserver":
                    GroupIconServer = reader.Value;
                    break;

                case "iconfarm":
                    GroupIconFarm = reader.Value;
                    break;

                case "group_alias":
                    GroupAlias = reader.Value;
                    if (GroupAlias == String.Empty)
                    {
                        GroupAlias = null;
                    }
                    break;

                case "author_iconfarm":
                    AuthorIconFarm = reader.Value;
                    break;

                case "author_iconserver":
                    AuthorIconServer = reader.Value;
                    break;

                case "author_is_deleted":
                    AuthorIsDeleted = reader.Value == "1";
                    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 "lastedit":
                    DateLastEdit = reader.Value == "0" ? null : (DateTime?)UtilityMethods.UnixTimestampToDate(reader.Value);
                    break;

                case "total":
                    Total = reader.ReadContentAsInt();
                    break;

                case "pages":
                    Pages = reader.ReadContentAsInt();
                    break;

                case "page":
                    Page = reader.ReadContentAsInt();
                    break;

                case "per_page":
                    PerPage = reader.ReadContentAsInt();
                    break;

                default:
                    UtilityMethods.CheckParsingException(reader);
                    break;
                }
            }

            reader.Read();

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

            while (reader.LocalName == "reply" && reader.NodeType == XmlNodeType.Element)
            {
                var reply = new TopicReply();
                ((IFlickrParsable)reply).Load(reader);
                Add(reply);
            }
        }
Beispiel #15
0
        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 "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;

                case "lastedit":
                    DateLastEdited = reader.Value == "" || reader.Value == "0" ? (DateTime?)null : UtilityMethods.UnixTimestampToDate(reader.Value);
                    break;

                case "pro_badge":
                    ProBadgeStyle = reader.Value;
                    break;

                default:
                    UtilityMethods.CheckParsingException(reader);
                    break;
                }
            }

            reader.Read();

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

            reader.Skip();
        }
Beispiel #16
0
        void IFlickrParsable.Load(System.Xml.XmlReader reader)
        {
            if (reader.LocalName != "photoset")
            {
                UtilityMethods.CheckParsingException(reader);
            }

            while (reader.MoveToNextAttribute())
            {
                switch (reader.LocalName)
                {
                case "id":
                    PhotosetId = reader.Value;
                    break;

                case "url":
                    Url = reader.Value;
                    break;

                case "owner_id":
                case "owner":
                    OwnerId = reader.Value;
                    break;

                case "username":
                    OwnerName = reader.Value;
                    break;

                case "primary":
                    PrimaryPhotoId = reader.Value;
                    break;

                case "secret":
                    Secret = reader.Value;
                    break;

                case "farm":
                    Farm = reader.Value;
                    break;

                case "server":
                    Server = reader.Value;
                    break;

                case "total":
                    break;

                case "photos":
                case "count_photos":
                    NumberOfPhotos = reader.ReadContentAsInt();
                    break;

                case "videos":
                case "count_videos":
                    NumberOfVideos = reader.ReadContentAsInt();
                    break;

                case "needs_interstitial":
                    // Who knows what this is for.
                    break;

                case "visibility_can_see_set":
                    // Who knows what this is for.
                    break;

                case "date_create":
                    DateCreated = UtilityMethods.UnixTimestampToDate(reader.Value);
                    break;

                case "date_update":
                    DateUpdated = UtilityMethods.UnixTimestampToDate(reader.Value);
                    break;

                case "view_count":
                case "count_views":
                    ViewCount = reader.ReadContentAsInt();
                    break;

                case "comment_count":
                case "count_comments":
                    CommentCount = reader.ReadContentAsInt();
                    break;

                case "can_comment":
                    CanComment = reader.Value == "1";
                    break;

                case "coverphoto_server":
                case "coverphoto_farm":
                    break;

                default:
                    UtilityMethods.CheckParsingException(reader);
                    break;
                }
            }

            reader.Read();

            PrimaryPhoto = new Photo
            {
                PhotoId = PrimaryPhotoId,
                Secret  = Secret,
                Server  = Server,
                Farm    = Farm
            };

            while (reader.LocalName != "photoset" && reader.NodeType != System.Xml.XmlNodeType.EndElement)
            {
                switch (reader.LocalName)
                {
                case "title":
                    Title = reader.ReadElementContentAsString();
                    break;

                case "description":
                    Description = reader.ReadElementContentAsString();
                    break;

                case "primary_photo_extras":
                    ((IFlickrParsable)PrimaryPhoto).Load(reader);
                    break;

                default:
                    UtilityMethods.CheckParsingException(reader);
                    reader.Skip();
                    break;
                }
            }

            reader.Read();
        }
Beispiel #17
0
        void IFlickrParsable.Load(System.Xml.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:
                    throw new ParsingException("Unknown attribute value: " + reader.LocalName + "=" + reader.Value);
                }
            }

            reader.Read();

            while (reader.NodeType != System.Xml.XmlNodeType.EndElement)
            {
                switch (reader.LocalName)
                {
                case "polylines":
                    reader.Read();
                    while (reader.LocalName == "polyline")
                    {
                        Collection <PointD> 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], System.Globalization.NumberFormatInfo.InvariantInfo), double.Parse(xy[1], System.Globalization.NumberFormatInfo.InvariantInfo)));
                        }
                        PolyLines.Add(polyline);
                    }
                    reader.Read();
                    break;

                case "urls":
                    reader.Skip();
                    break;
                }
            }

            reader.Read();
        }
        void IFlickrParsable.Load(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 "author_path_alias":
                    AuthorPathAlias = reader.Value == "" ? null : reader.Value;
                    break;

                case "author_is_deleted":
                    AuthorIsDeleted = reader.Value == "1";
                    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();
        }
Beispiel #19
0
        void IFlickrParsable.Load(XmlReader reader)
        {
            while (reader.MoveToNextAttribute())
            {
                switch (reader.LocalName)
                {
                case "type":
                    switch (reader.Value)
                    {
                    case "fave":
                        EventType = ActivityEventType.Favorite;
                        break;

                    case "note":
                        EventType = ActivityEventType.Note;
                        break;

                    case "comment":
                        EventType = ActivityEventType.Comment;
                        break;

                    case "added_to_gallery":
                        EventType = ActivityEventType.Gallery;
                        break;

                    case "tag":
                        EventType = ActivityEventType.Tag;
                        break;

                    case "group_invite":
                        EventType = ActivityEventType.GroupInvite;
                        break;

                    default:
                        UtilityMethods.CheckParsingException(reader);
                        break;
                    }
                    break;

                case "user":
                    UserId = reader.Value;
                    break;

                case "username":
                    UserName = reader.Value;
                    break;

                case "dateadded":
                    DateAdded = UtilityMethods.UnixTimestampToDate(reader.Value);
                    break;

                case "commentid":
                    CommentId = reader.Value;
                    break;

                case "noteid":
                    NoteId = reader.Value;
                    break;

                case "galleryid":
                    GalleryId = reader.Value;
                    break;

                case "iconserver":
                    IconServer = reader.Value;
                    break;

                case "iconfarm":
                    IconFarm = reader.Value;
                    break;

                case "realname":
                    RealName = reader.Value;
                    break;

                case "group_id":
                    GroupId = reader.Value;
                    break;

                case "group_name":
                    GroupName = reader.Value;
                    break;

                default:
                    UtilityMethods.CheckParsingException(reader);
                    break;
                }
            }

            reader.Read();

            if (reader.NodeType == XmlNodeType.Text)
            {
                Value = reader.ReadContentAsString();
                reader.Read();
            }
        }
Beispiel #20
0
        void IFlickrParsable.Load(XmlReader reader)
        {
            if (reader.LocalName != "values")
            {
                UtilityMethods.CheckParsingException(reader);
            }

            while (reader.MoveToNextAttribute())
            {
                switch (reader.LocalName)
                {
                case "page":
                    Page = int.Parse(reader.Value, NumberFormatInfo.InvariantInfo);
                    break;

                case "total":
                    Total = int.Parse(reader.Value, NumberFormatInfo.InvariantInfo);
                    break;

                case "pages":
                    Pages = int.Parse(reader.Value, NumberFormatInfo.InvariantInfo);
                    break;

                case "per_page":
                case "perpage":
                    PerPage = int.Parse(reader.Value, NumberFormatInfo.InvariantInfo);
                    break;

                case "namespace":
                    NamespaceName = reader.Value;
                    break;

                case "predicate":
                    PredicateName = reader.Value;
                    break;

                case "added_since":
                    DateAddedSince = UtilityMethods.UnixTimestampToDate(reader.Value);
                    break;

                case "value":
                    // This sometimes gets returned - it always appears to be blank.
                    break;

                default:
                    UtilityMethods.CheckParsingException(reader);
                    break;
                }
            }

            reader.Read();

            while (reader.LocalName == "value")
            {
                var item = new Value();
                ((IFlickrParsable)item).Load(reader);
                if (!String.IsNullOrEmpty(NamespaceName) && String.IsNullOrEmpty(item.NamespaceName))
                {
                    item.NamespaceName = NamespaceName;
                }
                if (!String.IsNullOrEmpty(PredicateName) && String.IsNullOrEmpty(item.PredicateName))
                {
                    item.PredicateName = PredicateName;
                }
                Add(item);
            }

            reader.Skip();
        }
Beispiel #21
0
        void IFlickrParsable.Load(System.Xml.XmlReader reader)
        {
            while (reader.MoveToNextAttribute())
            {
                switch (reader.LocalName)
                {
                case "id":
                    GalleryId = reader.Value;
                    break;

                case "gallery_id":
                    // Duplicate of above but not compound
                    break;

                case "url":
                    if (reader.Value.IndexOf("www.flickr.com", StringComparison.Ordinal) > 0)
                    {
                        GalleryUrl = reader.Value.Replace("http://", "https://");
                    }
                    else
                    {
                        GalleryUrl = "https://www.flickr.com" + reader.Value;
                    }
                    break;

                case "owner":
                    OwnerId = reader.Value;
                    break;

                case "username":
                    Username = reader.Value;
                    break;

                case "date_create":
                    DateCreated = UtilityMethods.UnixTimestampToDate(reader.Value);
                    break;

                case "date_update":
                    DateLastUpdated = UtilityMethods.UnixTimestampToDate(reader.Value);
                    break;

                case "primary_photo_id":
                    PrimaryPhotoId = reader.Value;
                    break;

                case "iconserver":
                    OwnerServer = reader.Value;
                    break;

                case "iconfarm":
                    OwnerFarm = reader.Value;
                    break;

                case "primary_photo_server":
                case "server":
                    PrimaryPhotoServer = reader.Value;
                    break;

                case "primary_photo_farm":
                case "farm":
                    PrimaryPhotoFarm = reader.Value;
                    break;

                case "primary_photo_secret":
                case "secret":
                    PrimaryPhotoSecret = reader.Value;
                    break;

                case "count_photos":
                    PhotosCount = reader.ReadContentAsInt();
                    break;

                case "count_videos":
                    VideosCount = reader.ReadContentAsInt();
                    break;

                case "count_views":
                    ViewCount = reader.ReadContentAsInt();
                    break;

                case "count_total":
                    TotalCount = reader.ReadContentAsInt();
                    break;

                case "count_comments":
                    CommentCount = reader.ReadContentAsInt();
                    break;

                case "sort_group":
                    SortGroup = reader.Value == "" ? null : reader.Value;
                    break;

                case "current_state":
                    // Unknown attributes
                    break;

                default:
                    UtilityMethods.CheckParsingException(reader);
                    break;
                }
            }

            reader.Read();

            while (reader.NodeType != System.Xml.XmlNodeType.EndElement)
            {
                switch (reader.LocalName)
                {
                case "title":
                    Title = reader.ReadElementContentAsString();
                    break;

                case "description":
                    Description = reader.ReadElementContentAsString();
                    break;

                case "cover_photos":
                    reader.Skip();
                    break;

                default:
                    UtilityMethods.CheckParsingException(reader);
                    reader.Skip();
                    break;
                }
            }

            reader.Read();
        }
Beispiel #22
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();
        }
Beispiel #23
0
        void IFlickrParsable.Load(XmlReader reader)
        {
            while (reader.MoveToNextAttribute())
            {
                switch (reader.LocalName)
                {
                case "nsid":
                case "id":
                    GroupId = reader.Value;
                    break;

                case "iconserver":
                    IconServer = reader.Value;
                    break;

                case "iconfarm":
                    IconFarm = reader.Value;
                    break;

                case "lang":
                    Language = reader.Value;
                    break;

                case "ispoolmoderated":
                    IsPoolModerated = reader.Value == "1";
                    break;

                default:
                    UtilityMethods.CheckParsingException(reader);
                    break;
                }
            }

            reader.Read();

            while (reader.LocalName != "group")
            {
                switch (reader.LocalName)
                {
                case "name":
                    GroupName = reader.ReadElementContentAsString();
                    break;

                case "description":
                    Description = reader.ReadElementContentAsString();
                    break;

                case "members":
                    Members = reader.ReadElementContentAsInt();
                    break;

                case "privacy":
                    Privacy = (PoolPrivacy)reader.ReadElementContentAsInt();
                    break;

                case "blast":
                    BlastDateAdded = UtilityMethods.UnixTimestampToDate(reader.GetAttribute("date_blast_added"));
                    BlastUserId    = reader.GetAttribute("user_id");
                    BlastHtml      = reader.ReadElementContentAsString();
                    break;

                case "throttle":
                    ThrottleInfo = new GroupThrottleInfo();
                    ((IFlickrParsable)ThrottleInfo).Load(reader);
                    break;

                case "restrictions":
                    Restrictions = new GroupInfoRestrictions();
                    ((IFlickrParsable)Restrictions).Load(reader);
                    break;

                default:
                    UtilityMethods.CheckParsingException(reader);
                    reader.Skip();
                    break;
                }
            }

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

            while (reader.MoveToNextAttribute())
            {
                switch (reader.LocalName)
                {
                case "id":
                    SuggestionId = reader.Value;
                    break;

                case "photo_id":
                    PhotoId = reader.Value;
                    break;

                case "date_suggested":
                    DateSuggested = UtilityMethods.UnixTimestampToDate(reader.Value);
                    break;

                default:
                    UtilityMethods.CheckParsingException(reader);
                    break;
                }
            }

            reader.Read();

            while (reader.LocalName != "suggestion" && reader.NodeType != System.Xml.XmlNodeType.EndElement)
            {
                switch (reader.LocalName)
                {
                case "suggested_by":
                    SuggestedByUserId   = reader.GetAttribute("nsid");
                    SuggestedByUserName = reader.GetAttribute("username");
                    reader.Skip();
                    break;

                case "note":
                    Note = reader.ReadElementContentAsString();
                    break;

                case "location":
                    while (reader.MoveToNextAttribute())
                    {
                        switch (reader.LocalName)
                        {
                        case "woeid":
                            WoeId = reader.Value;
                            break;

                        case "latitude":
                            Latitude = reader.ReadContentAsDouble();
                            break;

                        case "longitude":
                            Longitude = reader.ReadContentAsDouble();
                            break;

                        case "accuracy":
                            Accuracy = (GeoAccuracy)reader.ReadContentAsInt();
                            break;

                        default:
                            UtilityMethods.CheckParsingException(reader);
                            break;
                        }
                    }
                    reader.Skip();
                    break;

                default:
                    UtilityMethods.CheckParsingException(reader);
                    break;
                }
            }
        }
Beispiel #25
0
        void IFlickrParsable.Load(System.Xml.XmlReader reader)
        {
            while (reader.MoveToNextAttribute())
            {
                switch (reader.LocalName)
                {
                case "id":
                    GalleryId = reader.Value;
                    break;

                case "url":
                    if (reader.Value.IndexOf("www.flickr.com") > 0)
                    {
                        GalleryUrl = reader.Value;
                    }
                    else
                    {
                        GalleryUrl = "http://www.flickr.com" + reader.Value;
                    }
                    break;

                case "owner":
                    OwnerId = reader.Value;
                    break;

                case "username":
                    Username = reader.Value;
                    break;

                case "date_create":
                    DateCreated = UtilityMethods.UnixTimestampToDate(reader.Value);
                    break;

                case "date_update":
                    DateLastUpdated = UtilityMethods.UnixTimestampToDate(reader.Value);
                    break;

                case "primary_photo_id":
                    PrimaryPhotoId = reader.Value;
                    break;

                case "iconserver":
                    OwnerServer = reader.Value;
                    break;

                case "iconfarm":
                    OwnerFarm = reader.Value;
                    break;

                case "primary_photo_server":
                case "server":
                    PrimaryPhotoServer = reader.Value;
                    break;

                case "primary_photo_farm":
                case "farm":
                    PrimaryPhotoFarm = reader.Value;
                    break;

                case "primary_photo_secret":
                case "secret":
                    PrimaryPhotoSecret = reader.Value;
                    break;

                case "count_photos":
                    PhotosCount = reader.ReadContentAsInt();
                    break;

                case "count_videos":
                    VideosCount = reader.ReadContentAsInt();
                    break;

                case "count_views":
                    ViewCount = reader.ReadContentAsInt();
                    break;

                case "count_comments":
                    CommentCount = reader.ReadContentAsInt();
                    break;

                default:
                    UtilityMethods.CheckParsingException(reader);
                    break;
                }
            }

            reader.Read();

            while (reader.NodeType != System.Xml.XmlNodeType.EndElement)
            {
                switch (reader.LocalName)
                {
                case "title":
                    Title = reader.ReadElementContentAsString();
                    break;

                case "description":
                    Description = reader.ReadElementContentAsString();
                    break;

                default:
                    UtilityMethods.CheckParsingException(reader);
                    reader.Skip();
                    break;
                }
            }

            reader.Read();
        }