Permissions for the selected photo.
Inheritance: IFlickrParsable
Ejemplo n.º 1
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();
        }
Ejemplo n.º 2
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();
            }
        }
Ejemplo n.º 3
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_q":
                        urlLargeSquare = reader.Value;
                        break;
                    case "width_q":
                        LargeSquareThumbnailWidth = reader.ReadContentAsInt();
                        break;
                    case "height_q":
                        LargeSquareThumbnailHeight = reader.ReadContentAsInt();
                        break;
                    case "url_n":
                        urlSmall320 = reader.Value;
                        break;
                    case "width_n":
                        Small320Width = reader.ReadContentAsInt();
                        break;
                    case "height_n":
                        Small320Height = 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;
                    case "context":
                        GeoContext = (GeoContext)reader.ReadContentAsInt();
                        break;
                    case "rotation":
                        Rotation = reader.ReadContentAsInt();
                        break;
                    default:
                        if (!allowExtraAtrributes) UtilityMethods.CheckParsingException(reader);
                        break;
                }
            }

            reader.Read();

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