Exemplo n.º 1
0
 public SubredditSettings(Reddit reddit, Subreddit subreddit)
 {
     Subreddit = subreddit;
     Reddit    = reddit;
     // Default settings, for use when reduced information is given
     AllowAsDefault    = true;
     Domain            = null;
     Sidebar           = string.Empty;
     Language          = "en";
     Title             = Subreddit.DisplayName;
     WikiEditKarma     = 100;
     WikiEditAge       = 10;
     UseDomainCss      = false;
     UseDomainSidebar  = false;
     HeaderHoverText   = string.Empty;
     NSFW              = false;
     PublicDescription = string.Empty;
     WikiEditMode      = WikiEditMode.None;
     SubredditType     = SubredditType.Public;
     ShowThumbnails    = true;
     ContentOptions    = ContentOptions.All;
 }
Exemplo n.º 2
0
 public SubredditStyle(Reddit reddit, Subreddit subreddit)
 {
     Reddit    = reddit;
     Subreddit = subreddit;
 }
Exemplo n.º 3
0
        public SubredditSettings(Subreddit subreddit, Reddit reddit, JObject json)
            : this(reddit, subreddit)
        {
            var data = json["data"];

            AllowAsDefault    = data["default_set"].ValueOrDefault <bool>();
            Domain            = data["domain"].ValueOrDefault <string>();
            Sidebar           = HttpUtility.HtmlDecode(data["description"].ValueOrDefault <string>() ?? string.Empty);
            Language          = data["language"].ValueOrDefault <string>();
            Title             = data["title"].ValueOrDefault <string>();
            WikiEditKarma     = data["wiki_edit_karma"].ValueOrDefault <int>();
            UseDomainCss      = data["domain_css"].ValueOrDefault <bool>();
            UseDomainSidebar  = data["domain_sidebar"].ValueOrDefault <bool>();
            HeaderHoverText   = data["header_hover_text"].ValueOrDefault <string>();
            NSFW              = data["over_18"].ValueOrDefault <bool>();
            PublicDescription = HttpUtility.HtmlDecode(data["public_description"].ValueOrDefault <string>() ?? string.Empty);
            if (data["wikimode"] != null)
            {
                string wikiMode = data["wikimode"].ValueOrDefault <string>();
                switch (wikiMode)
                {
                case "disabled":
                    WikiEditMode = WikiEditMode.None;
                    break;

                case "modonly":
                    WikiEditMode = WikiEditMode.Moderators;
                    break;

                case "anyone":
                    WikiEditMode = WikiEditMode.All;
                    break;
                }
            }
            if (data["subreddit_type"] != null)
            {
                string type = data["subreddit_type"].ValueOrDefault <string>();
                switch (type)
                {
                case "public":
                    SubredditType = SubredditType.Public;
                    break;

                case "private":
                    SubredditType = SubredditType.Private;
                    break;

                case "restricted":
                    SubredditType = SubredditType.Restricted;
                    break;
                }
            }
            ShowThumbnails = data["show_media"].ValueOrDefault <bool>();
            WikiEditAge    = data["wiki_edit_age"].ValueOrDefault <int>();
            if (data["content_options"] != null)
            {
                string contentOptions = data["content_options"].ValueOrDefault <string>();
                switch (contentOptions)
                {
                case "any":
                    ContentOptions = ContentOptions.All;
                    break;

                case "link":
                    ContentOptions = ContentOptions.LinkOnly;
                    break;

                case "self":
                    ContentOptions = ContentOptions.SelfOnly;
                    break;
                }
            }
        }