public WeblogConfigurationWizardPanelSelectProvider()
        {
            // This call is required by the Windows.Forms Form Designer.
            InitializeComponent();

            this.labelHeader.Text = Res.Get(StringId.ConfigWizardSelectProvider);
            this.labelSelectProvider.Text = Res.Get(StringId.CWSelectProviderWeblogTypeLabel);
            this.labelServerAPIUrl.Text = Res.Get(StringId.CWSelectProviderApiUrlLabel);
            this.labelText.Text = Res.Get(StringId.CWSelectProviderText);

            if (BidiHelper.IsRightToLeft)
                textBoxServerApiUrl.TextAlign = HorizontalAlignment.Right;

            this.textBoxServerApiUrl.RightToLeft = RightToLeft.No;

            // Load up the combo and select the first item
            //adding marketization--only show providers for this market
            HashSet marketSupportedIds = new HashSet();
            marketSupportedIds.AddAll(
                StringHelper.Split(
                    MarketizationOptions.GetFeatureParameter(MarketizationOptions.Feature.BlogProviders, "supported"), ";"));
            foreach (IBlogProvider provider in BlogProviderManager.Providers)
                if (provider.Visible && marketSupportedIds.Contains(provider.Id))
                    comboBoxSelectProvider.Items.Add(new BlogProviderDescriptionProxy(provider));

            comboBoxSelectProvider.SelectedIndex = 0;

            labelText.Text = string.Format(CultureInfo.CurrentCulture, labelText.Text, ApplicationEnvironment.ProductNameQualified);
        }
        private static object ReadXmlVideoProviders(XmlDocument providersDocument)
        {
            XmlNode providersNode = providersDocument.SelectSingleNode("//videoProviders");
            if (providersNode == null)
                throw new Exception("Invalid videoProviders.xml file detected");

            // get the list of providers from the xml
            ArrayList providers = new ArrayList();
            HashSet marketSupportedIds = new HashSet();
            marketSupportedIds.AddAll(
                StringHelper.Split(
                MarketizationOptions.GetFeatureParameter(MarketizationOptions.Feature.VideoProviders, "supported"), ";"));
            XmlNodeList providerNodes = providersDocument.SelectNodes("//videoProviders/provider");
            foreach (XmlNode providerNode in providerNodes)
            {
                VideoProvider provider = VideoProviderFromXml(providerNode);
                if (marketSupportedIds.Contains(provider.ServiceId))
                    providers.Add(provider);
            }

            // return list of providers
            return providers.ToArray(typeof(VideoProvider));
        }
 public void LoadCategories()
 {
     initMode = true;
     try
     {
         nodes = CategoriesToNodes(ctx.Categories);
         treeView.Nodes.Clear();
         treeView.Nodes.AddRange(FilteredNodes(RealNodes, delegate { return true; }));
         HashSet selectedCategories = new HashSet();
         selectedCategories.AddAll(ctx.SelectedCategories);
         if (selectedCategories.Count > 0)
             WalkNodes(treeView.Nodes, delegate (TreeNode n)
                     {
                         n.Checked = selectedCategories.Contains(((TreeNode)n.Tag).Tag as BlogPostCategory);
                     });
         treeView.ExpandAll();
     }
     finally
     {
         initMode = false;
     }
 }
Esempio n. 4
0
        private static void BuildMenuString(StringBuilder structure, XmlElement el, HashSet commandIds, Hashtable pairs)
        {
            int startLen = structure.Length;
            int pos = 0;
            bool lastWasSeparator = false;
            foreach (XmlNode childNode in el.ChildNodes)
            {
                XmlElement childEl = childNode as XmlElement;
                if (childEl == null)
                    continue;

                if (childEl.HasAttribute("Position"))
                    pos = int.Parse(childEl.GetAttribute("Position"), CultureInfo.InvariantCulture);

                string separator = "";
                if (childEl.Name == "Separator")
                {
                    lastWasSeparator = true;
                    continue;
                }
                else if (lastWasSeparator)
                {
                    separator = "-";
                    lastWasSeparator = false;
                }

                if (childEl.Name == "Menu" || childEl.Name == "Command")
                {
                    if (!childEl.HasAttribute("Identifier"))
                        throw new ConfigurationErrorsException(childEl.Name + " element was missing required attribute 'Identifier'");
                    string id = childEl.GetAttribute("Identifier");

                    if (childEl.Name == "Command")
                    {
                        if (!commandIds.Contains(id))
                            throw new ConfigurationErrorsException("Main menu definition uses unknown command id: " + id);
                    }

                    string idWithOrder = string.Format(CultureInfo.InvariantCulture, "{0}{1}@{2}", separator, id, (pos++ * 10));

                    if (structure.Length != 0)
                        structure.Append(" ");

                    switch (childEl.Name)
                    {
                        case "Menu":
                            if (!childEl.HasAttribute("Text"))
                                throw new ConfigurationErrorsException("Menu with id '" + id + "' was missing the required Text attribute");
                            string menuText = childEl.GetAttribute("Text");
                            pairs.Add("MainMenu." + id, new Values(menuText, ""));

                            structure.Append("(" + idWithOrder);
                            BuildMenuString(structure, childEl, commandIds, pairs);
                            structure.Append(")");
                            break;
                        case "Command":
                            structure.Append(idWithOrder);
                            break;
                    }
                }
                else
                    throw new ConfigurationErrorsException("Unexpected element " + childEl.Name);
            }
        }
Esempio n. 5
0
        protected BlogPost[] GetRecentPostsInternal(string blogId, int maxPosts, bool includeCategories, DateTime? now)
        {
            Login();

            FixupBlogId(ref blogId);

            HashSet seenIds = new HashSet();

            ArrayList blogPosts = new ArrayList();
            try
            {
                while (true)
                {
                    XmlDocument doc;
                    Uri thisUri = new Uri(blogId);

                    // This while-loop nonsense is necessary because New Blogger has a bug
                    // where the official URL for getting recent posts doesn't work when
                    // the orderby=published flag is set, but there's an un-official URL
                    // that will work correctly. Therefore, subclasses need the ability
                    // to inspect exceptions that occur, along with the URI that was used
                    // to make the request, and determine whether an alternate URI should
                    // be used.
                    while (true)
                    {
                        try
                        {
                            doc = xmlRestRequestHelper.Get(ref thisUri, RequestFilter);
                            break;
                        }
                        catch (Exception e)
                        {
                            Trace.WriteLine(e.ToString());
                            if (AttemptAlternateGetRecentPostUrl(e, ref blogId))
                                continue;
                            else
                                throw;
                        }
                    }

                    XmlNodeList nodeList = doc.SelectNodes("/atom:feed/atom:entry", _nsMgr);
                    if (nodeList.Count == 0)
                        break;
                    foreach (XmlElement node in nodeList)
                    {
                        BlogPost blogPost = this.Parse(node, includeCategories, thisUri);
                        if (blogPost != null)
                        {
                            if (seenIds.Contains(blogPost.Id))
                                throw new DuplicateEntryIdException();
                            seenIds.Add(blogPost.Id);

                            if (!now.HasValue || blogPost.DatePublished.CompareTo(now.Value) < 0)
                                blogPosts.Add(blogPost);
                        }
                        if (blogPosts.Count >= maxPosts)
                            break;
                    }
                    if (blogPosts.Count >= maxPosts)
                        break;

                    XmlElement nextNode = doc.SelectSingleNode("/atom:feed/atom:link[@rel='next']", _nsMgr) as XmlElement;
                    if (nextNode == null)
                        break;
                    blogId = XmlHelper.GetUrl(nextNode, "@href", thisUri);
                    if (blogId.Length == 0)
                        break;
                }
            }
            catch (DuplicateEntryIdException)
            {

                if (ApplicationDiagnostics.AutomationMode)
                    Trace.WriteLine("Duplicate IDs detected in feed");
                else
                    Trace.Fail("Duplicate IDs detected in feed");
            }
            return (BlogPost[])blogPosts.ToArray(typeof(BlogPost));
        }