コード例 #1
0
        /// <summary>
        /// Gets an instance of <see cref="IHttpPostData"/> representing the POST parameters.
        /// </summary>
        public IHttpPostData GetPostData()
        {
            IHttpPostData postData = new HttpPostData {
                IsMultipart = !String.IsNullOrWhiteSpace(Source)
            };

            if (!String.IsNullOrWhiteSpace(Source))
            {
                postData.AddFile("source", Source);
            }
            if (!String.IsNullOrWhiteSpace(Url))
            {
                postData.Add("url", Url);
            }
            if (!String.IsNullOrWhiteSpace(Message))
            {
                postData.Add("message", Message);
            }
            if (!String.IsNullOrWhiteSpace(Place))
            {
                postData.Add("place", Place);
            }
            if (NoStory)
            {
                postData.Add("no_story", "true");
            }
            return(postData);
        }
コード例 #2
0
        /// <summary>
        /// Gets an instance of <see cref="IHttpPostData"/> representing the POST parameters.
        /// </summary>
        public IHttpPostData GetPostData()
        {
            // Check wether a photo was specified
            if (string.IsNullOrWhiteSpace(Photo))
            {
                throw new PropertyNotSetException("Photo");
            }

            HttpPostData data = new HttpPostData {
                IsMultipart = true
            };

            data.AddFile("photo", Photo);
            if (!string.IsNullOrWhiteSpace(Title))
            {
                data.Add("title", Title);
            }
            if (!string.IsNullOrWhiteSpace(Description))
            {
                data.Add("description", Description);
            }
            if (Tags != null && Tags.Length > 0)
            {
                data.Add("tags", string.Join(" ", Tags));
            }

            // Append the visiblity (if not private)
            switch (Visibility)
            {
            case FlickrPhotoSafetyVisibility.Public: {
                data.Add("is_public", "1");
                break;
            }

            case FlickrPhotoSafetyVisibility.Friends: {
                data.Add("is_friend", "1");
                break;
            }

            case FlickrPhotoSafetyVisibility.Family: {
                data.Add("is_family", "1");
                break;
            }

            case FlickrPhotoSafetyVisibility.FriendsAndFamily: {
                data.Add("is_friend", "1");
                data.Add("is_public", "1");
                break;
            }
            }

            // Append the safety level (if specified)
            switch (SafetyLevel)
            {
            case FlickrPhotoSafetyLevel.Safe: data.Add("safety_level", "1"); break;

            case FlickrPhotoSafetyLevel.Moderate: data.Add("safety_level", "2"); break;

            case FlickrPhotoSafetyLevel.Restricted: data.Add("safety_level", "3"); break;
            }

            if (ContentType != FlickrPhotoContentType.NotSpecified)
            {
                data.Add("content_type", (int)ContentType);
            }

            if (IsHidden)
            {
                data.Add("hidden", "2");
            }

            return(data);
        }