コード例 #1
0
 public void visit(XmlElement element)
 {
     if (oauthSpec != null)
     {
         throw new SpecParserException("ModulePrefs/OAuth may only occur once.");
     }
     oauthSpec = new OAuthSpec(element, _base);
 }
コード例 #2
0
        /**
         * @param element
         * @param specUrl
         */
        public ModulePrefs(XmlElement element, Uri inbase)
        {
            this._base = inbase;
            attributes = new Dictionary <String, String>();
            XmlNamedNodeMap attributeNodes = element.Attributes;

            for (int i = 0; i < attributeNodes.Count; i++)
            {
                XmlNode node = attributeNodes.Item(i);
                attributes.Add(node.Name, node.Value);
            }

            if (getTitle() == null)
            {
                throw new SpecParserException("ModulePrefs@title is required.");
            }

            categories = new List <string>()
            {
                getAttribute(ATTR_CATEGORY, ""), getAttribute(ATTR_CATEGORY2, "")
            };

            // Child elements
            PreloadVisitor preloadVisitor = new PreloadVisitor(_base);
            FeatureVisitor featureVisitor = new FeatureVisitor(_base);
            OAuthVisitor   oauthVisitor   = new OAuthVisitor(_base);
            IconVisitor    iconVisitor    = new IconVisitor(_base);
            LocaleVisitor  localeVisitor  = new LocaleVisitor(_base);
            LinkVisitor    linkVisitor    = new LinkVisitor(_base);

            Dictionary <String, ElementVisitor> visitors = new Dictionary <String, ElementVisitor>();

            visitors.Add("Preload", preloadVisitor);
            visitors.Add("Optional", featureVisitor);
            visitors.Add("Require", featureVisitor);
            visitors.Add("OAuth", oauthVisitor);
            visitors.Add("Icon", iconVisitor);
            visitors.Add("Locale", localeVisitor);
            visitors.Add("Link", linkVisitor);

            walk(element, visitors);

            preloads = preloadVisitor.preloaded;
            features = featureVisitor.features;
            icons    = iconVisitor.icons;
            locales  = localeVisitor.localeMap;
            links    = linkVisitor.linkMap;
            oauth    = oauthVisitor.oauthSpec;
        }
コード例 #3
0
        /**
         * Produces a new, substituted ModulePrefs
         */
        private ModulePrefs(ModulePrefs prefs, Substitutions substituter)
        {
            _base      = prefs._base;
            categories = prefs.getCategories();
            features   = prefs.getFeatures();
            locales    = prefs.getLocales();
            oauth      = prefs.oauth;

            List <Preload> preloads = new List <Preload>();

            if (prefs.preloads != null)
            {
                foreach (Preload preload in prefs.preloads)
                {
                    preloads.Add(preload.substitute(substituter));
                }
            }
            this.preloads = preloads;

            List <Icon> icons = new List <Icon>(prefs.icons.Count);

            foreach (Icon icon in prefs.icons)
            {
                icons.Add(icon.substitute(substituter));
            }
            this.icons = icons;

            Dictionary <String, LinkSpec> links = new Dictionary <String, LinkSpec>(prefs.links.Count);

            foreach (LinkSpec link in prefs.links.Values)
            {
                LinkSpec sub = link.substitute(substituter);
                links.Add(sub.getRel(), sub);
            }
            this.links = links;

            Dictionary <String, String> attributes = new Dictionary <String, String>(prefs.attributes.Count);

            foreach (var attr in prefs.attributes)
            {
                String substituted = substituter.substituteString(null, attr.Value);
                attributes.Add(attr.Key, substituted);
            }
            this.attributes = attributes;
        }
コード例 #4
0
 /// <summary>
 /// Initializes a new instance of the OAuthVisitor structure.
 /// </summary>
 public OAuthVisitor(Uri url)
 {
     _base          = url;
     this.oauthSpec = null;
 }
コード例 #5
0
ファイル: ModulePrefs.cs プロジェクト: s7loves/pesta
 /// <summary>
 /// Initializes a new instance of the OAuthVisitor structure.
 /// </summary>
 public OAuthVisitor(Uri url)
 {
     _base = url;
     this.oauthSpec = null;
 }
コード例 #6
0
ファイル: ModulePrefs.cs プロジェクト: s7loves/pesta
 public void visit(XmlElement element)
 {
     if (oauthSpec != null)
     {
         throw new SpecParserException("ModulePrefs/OAuth may only occur once.");
     }
     oauthSpec = new OAuthSpec(element, _base);
 }
コード例 #7
0
ファイル: ModulePrefs.cs プロジェクト: s7loves/pesta
        /**
         * Produces a new, substituted ModulePrefs
         */
        private ModulePrefs(ModulePrefs prefs, Substitutions substituter)
        {
            _base = prefs._base;
            categories = prefs.getCategories();
            features = prefs.getFeatures();
            locales = prefs.getLocales();
            oauth = prefs.oauth;

            List<Preload> preloads = new List<Preload>();
            if (prefs.preloads != null)
            {
                foreach (Preload preload in prefs.preloads)
                {
                    preloads.Add(preload.substitute(substituter));
                }
            }
            this.preloads = preloads;

            List<Icon> icons = new List<Icon>(prefs.icons.Count);
            foreach (Icon icon in prefs.icons)
            {
                icons.Add(icon.substitute(substituter));
            }
            this.icons = icons;

            Dictionary<String, LinkSpec> links = new Dictionary<String, LinkSpec>(prefs.links.Count);
            foreach (LinkSpec link in prefs.links.Values)
            {
                LinkSpec sub = link.substitute(substituter);
                links.Add(sub.getRel(), sub);
            }
            this.links = links;

            Dictionary<String, String> attributes = new Dictionary<String, String>(prefs.attributes.Count);
            foreach (var attr in prefs.attributes)
            {
                String substituted = substituter.substituteString(null, attr.Value);
                attributes.Add(attr.Key, substituted);
            }
            this.attributes = attributes;
        }
コード例 #8
0
ファイル: ModulePrefs.cs プロジェクト: s7loves/pesta
        /**
         * @param element
         * @param specUrl
         */
        public ModulePrefs(XmlElement element, Uri inbase)
        {
            this._base = inbase;
            attributes = new Dictionary<String, String>();
            XmlNamedNodeMap attributeNodes = element.Attributes;
            for (int i = 0; i < attributeNodes.Count; i++)
            {
                XmlNode node = attributeNodes.Item(i);
                attributes.Add(node.Name, node.Value);
            }

            if (getTitle() == null)
            {
                throw new SpecParserException("ModulePrefs@title is required.");
            }

            categories = new List<string>() { getAttribute(ATTR_CATEGORY, ""), getAttribute(ATTR_CATEGORY2, "") };

            // Child elements
            PreloadVisitor preloadVisitor = new PreloadVisitor(_base);
            FeatureVisitor featureVisitor = new FeatureVisitor(_base);
            OAuthVisitor oauthVisitor = new OAuthVisitor(_base);
            IconVisitor iconVisitor = new IconVisitor(_base);
            LocaleVisitor localeVisitor = new LocaleVisitor(_base);
            LinkVisitor linkVisitor = new LinkVisitor(_base);

            Dictionary<String, ElementVisitor> visitors = new Dictionary<String, ElementVisitor>();
            visitors.Add("Preload", preloadVisitor);
            visitors.Add("Optional", featureVisitor);
            visitors.Add("Require", featureVisitor);
            visitors.Add("OAuth", oauthVisitor);
            visitors.Add("Icon", iconVisitor);
            visitors.Add("Locale", localeVisitor);
            visitors.Add("Link", linkVisitor);

            walk(element, visitors);

            preloads = preloadVisitor.preloaded;
            features = featureVisitor.features;
            icons = iconVisitor.icons;
            locales = localeVisitor.localeMap;
            links = linkVisitor.linkMap;
            oauth = oauthVisitor.oauthSpec;
        }