private SiteMapNode GetNodeFromProvider(string providerName) { SiteMapProvider providerFromName = this.GetProviderFromName(providerName); SiteMapNode rootNodeCore = null; if (providerFromName is XmlSiteMapProvider) { XmlSiteMapProvider provider2 = (XmlSiteMapProvider)providerFromName; StringCollection strings = new StringCollection(); if (this._parentSiteMapFileCollection != null) { foreach (string str in this._parentSiteMapFileCollection) { strings.Add(str); } } provider2.BuildSiteMap(); strings.Add(this._normalizedVirtualPath.VirtualPathString); if (strings.Contains(VirtualPath.GetVirtualPathString(provider2._normalizedVirtualPath))) { throw new InvalidOperationException(System.Web.SR.GetString("XmlSiteMapProvider_FileName_already_in_use", new object[] { provider2._virtualPath })); } provider2._parentSiteMapFileCollection = strings; } rootNodeCore = providerFromName.GetRootNodeCore(); if (rootNodeCore == null) { throw new InvalidOperationException(System.Web.SR.GetString("XmlSiteMapProvider_invalid_GetRootNodeCore", new object[] { providerFromName.Name })); } this.ChildProviderTable.Add(providerFromName, rootNodeCore); this._childProviderList = null; providerFromName.ParentProvider = this; return(rootNodeCore); }
private SiteMapNode GetNodeFromSiteMapFile(XmlNode xmlNode, VirtualPath siteMapFile) { SiteMapNode node = null; // For external sitemap files, its secuity setting is inherited from parent provider bool secuityTrimmingEnabled = SecurityTrimmingEnabled; HandlerBase.GetAndRemoveBooleanAttribute(xmlNode, _securityTrimmingEnabledAttrName, ref secuityTrimmingEnabled); // No other attributes or non-comment nodes are allowed on a siteMapFile node HandlerBase.CheckForUnrecognizedAttributes(xmlNode); HandlerBase.CheckForNonCommentChildNodes(xmlNode); XmlSiteMapProvider childProvider = new XmlSiteMapProvider(); // siteMapFile was relative to the sitemap file where this xmlnode is defined, make it an application path. siteMapFile = _normalizedVirtualPath.Parent.Combine(siteMapFile); childProvider.ParentProvider = this; childProvider.Initialize(siteMapFile, secuityTrimmingEnabled); childProvider.BuildSiteMap(); node = childProvider._siteMapNode; ChildProviderTable.Add(childProvider, node); _childProviderList = null; return(node); }
private static SiteMapProvider CreateProvider() { SiteMapProvider xmlProvider = new XmlSiteMapProvider(); xmlProvider.Initialize("internal", new NameValueCollection { { "securityTrimmingEnabled", "true" }, { "siteMapFile", "Web.sitemap" } }); return xmlProvider; }
private void OnConfigFileChange(object sender, FileChangeEvent e) { XmlSiteMapProvider parentProvider = this.ParentProvider as XmlSiteMapProvider; if (parentProvider != null) { parentProvider.OnConfigFileChange(sender, e); } this.Clear(); }
private void OnConfigFileChange(Object sender, FileChangeEvent e) { // Notifiy the parent for the change. XmlSiteMapProvider parentProvider = ParentProvider as XmlSiteMapProvider; if (parentProvider != null) { parentProvider.OnConfigFileChange(sender, e); } Clear(); }
private static void Init () { lock (locker) { if (provider == null) { providers = new SiteMapProviderCollection (); provider = new XmlSiteMapProvider (); NameValueCollection attributes = new NameValueCollection (); attributes.Add ("siteMapFile", "Web.sitemap"); ((ProviderBase)provider).Initialize ("AspNetXmlSiteMapProvider", attributes); providers.Add ((ProviderBase)provider); } } }
private SiteMapNode GetNodeFromProvider(string providerName) { SiteMapProvider provider = GetProviderFromName(providerName); SiteMapNode node = null; // Check infinite recursive sitemap files if (provider is XmlSiteMapProvider) { XmlSiteMapProvider xmlProvider = (XmlSiteMapProvider)provider; StringCollection parentSiteMapFileCollection = new StringCollection(); if (_parentSiteMapFileCollection != null) { foreach (string filename in _parentSiteMapFileCollection) { parentSiteMapFileCollection.Add(filename); } } // Make sure the provider is initialized before adding to the collection. xmlProvider.BuildSiteMap(); parentSiteMapFileCollection.Add(_normalizedVirtualPath.VirtualPathString); if (parentSiteMapFileCollection.Contains(VirtualPath.GetVirtualPathString(xmlProvider._normalizedVirtualPath))) { throw new InvalidOperationException(SR.GetString(SR.XmlSiteMapProvider_FileName_already_in_use, xmlProvider._virtualPath)); } xmlProvider._parentSiteMapFileCollection = parentSiteMapFileCollection; } node = provider.GetRootNodeCore(); if (node == null) { throw new InvalidOperationException( SR.GetString(SR.XmlSiteMapProvider_invalid_GetRootNodeCore, ((ProviderBase)provider).Name)); } ChildProviderTable.Add(provider, node); _childProviderList = null; provider.ParentProvider = this; return(node); }
private XmlDocument GetConfigDocument() { if (this._document == null) { if (!this._initialized) { throw new InvalidOperationException(System.Web.SR.GetString("XmlSiteMapProvider_Not_Initialized")); } if (this._virtualPath == null) { throw new ArgumentException(System.Web.SR.GetString("XmlSiteMapProvider_missing_siteMapFile", new object[] { "siteMapFile" })); } if (!this._virtualPath.Extension.Equals(".sitemap", StringComparison.OrdinalIgnoreCase)) { throw new InvalidOperationException(System.Web.SR.GetString("XmlSiteMapProvider_Invalid_Extension", new object[] { this._virtualPath })); } this._normalizedVirtualPath = this._virtualPath.CombineWithAppRoot(); this._normalizedVirtualPath.FailIfNotWithinAppRoot(); this.CheckSiteMapFileExists(); this._parentSiteMapFileCollection = new StringCollection(); XmlSiteMapProvider parentProvider = this.ParentProvider as XmlSiteMapProvider; if ((parentProvider != null) && (parentProvider._parentSiteMapFileCollection != null)) { if (parentProvider._parentSiteMapFileCollection.Contains(this._normalizedVirtualPath.VirtualPathString)) { throw new InvalidOperationException(System.Web.SR.GetString("XmlSiteMapProvider_FileName_already_in_use", new object[] { this._virtualPath })); } foreach (string str in parentProvider._parentSiteMapFileCollection) { this._parentSiteMapFileCollection.Add(str); } } this._parentSiteMapFileCollection.Add(this._normalizedVirtualPath.VirtualPathString); this._filename = HostingEnvironment.MapPathInternal(this._normalizedVirtualPath); if (!string.IsNullOrEmpty(this._filename)) { this._handler = new FileChangeEventHandler(this.OnConfigFileChange); HttpRuntime.FileChangesMonitor.StartMonitoringFile(this._filename, this._handler); base.ResourceKey = new FileInfo(this._filename).Name; } this._document = new ConfigXmlDocument(); } return(this._document); }
private SiteMapNode GetNodeFromSiteMapFile(XmlNode xmlNode, VirtualPath siteMapFile) { SiteMapNode node = null; bool securityTrimmingEnabled = base.SecurityTrimmingEnabled; System.Web.Configuration.HandlerBase.GetAndRemoveBooleanAttribute(xmlNode, "securityTrimmingEnabled", ref securityTrimmingEnabled); System.Web.Configuration.HandlerBase.CheckForUnrecognizedAttributes(xmlNode); System.Web.Configuration.HandlerBase.CheckForNonCommentChildNodes(xmlNode); XmlSiteMapProvider key = new XmlSiteMapProvider(); siteMapFile = this._normalizedVirtualPath.Parent.Combine(siteMapFile); key.ParentProvider = this; key.Initialize(siteMapFile, securityTrimmingEnabled); key.BuildSiteMap(); node = key._siteMapNode; this.ChildProviderTable.Add(key, node); this._childProviderList = null; return(node); }
public static SiteMapDataSource GetSiteMapDataSource(string role) { string url = String.Empty; if (role.Equals("Admin")) url = "~/Admin/AdminHomePage.aspx"; else if (role.Equals("User")) url = "~/User/UserHomePage.aspx"; XmlSiteMapProvider xmlSiteMap = new XmlSiteMapProvider(); System.Collections.Specialized.NameValueCollection myCollection = new System.Collections.Specialized.NameValueCollection(1); myCollection.Add("siteMapFile", "Web.sitemap"); xmlSiteMap.Initialize("provider", myCollection); xmlSiteMap.BuildSiteMap(); SiteMapDataSource siteMap = new SiteMapDataSource(); siteMap.StartingNodeUrl = url; /* This will not show the starting node and hence giving it * the horizontal cool look :) * */ siteMap.ShowStartingNode = false; return siteMap; }
private SiteMapNode GetNodeFromSiteMapFile(XmlNode xmlNode, VirtualPath siteMapFile) { SiteMapNode node = null; bool securityTrimmingEnabled = base.SecurityTrimmingEnabled; System.Web.Configuration.HandlerBase.GetAndRemoveBooleanAttribute(xmlNode, "securityTrimmingEnabled", ref securityTrimmingEnabled); System.Web.Configuration.HandlerBase.CheckForUnrecognizedAttributes(xmlNode); System.Web.Configuration.HandlerBase.CheckForNonCommentChildNodes(xmlNode); XmlSiteMapProvider key = new XmlSiteMapProvider(); siteMapFile = this._normalizedVirtualPath.Parent.Combine(siteMapFile); key.ParentProvider = this; key.Initialize(siteMapFile, securityTrimmingEnabled); key.BuildSiteMap(); node = key._siteMapNode; this.ChildProviderTable.Add(key, node); this._childProviderList = null; return node; }
private void EnsureChildSiteMapProviderUpToDate(SiteMapProvider childProvider) { SiteMapNode node = (SiteMapNode)this.ChildProviderTable[childProvider]; SiteMapNode rootNodeCore = childProvider.GetRootNodeCore(); if (rootNodeCore == null) { throw new ProviderException(System.Web.SR.GetString("XmlSiteMapProvider_invalid_sitemapnode_returned", new object[] { childProvider.Name })); } if (!node.Equals(rootNodeCore) && (node != null)) { lock (base._lock) { node = (SiteMapNode)this.ChildProviderTable[childProvider]; if (node != null) { rootNodeCore = childProvider.GetRootNodeCore(); if (rootNodeCore == null) { throw new ProviderException(System.Web.SR.GetString("XmlSiteMapProvider_invalid_sitemapnode_returned", new object[] { childProvider.Name })); } if (!node.Equals(rootNodeCore)) { if (this._siteMapNode.Equals(node)) { base.UrlTable.Remove(node.Url); base.KeyTable.Remove(node.Key); base.UrlTable.Add(rootNodeCore.Url, rootNodeCore); base.KeyTable.Add(rootNodeCore.Key, rootNodeCore); this._siteMapNode = rootNodeCore; } SiteMapNode node3 = (SiteMapNode)base.ParentNodeTable[node]; if (node3 != null) { SiteMapNodeCollection nodes = (SiteMapNodeCollection)base.ChildNodeCollectionTable[node3]; int index = nodes.IndexOf(node); if (index != -1) { nodes.Remove(node); nodes.Insert(index, rootNodeCore); } else { nodes.Add(rootNodeCore); } base.ParentNodeTable[rootNodeCore] = node3; base.ParentNodeTable.Remove(node); base.UrlTable.Remove(node.Url); base.KeyTable.Remove(node.Key); base.UrlTable.Add(rootNodeCore.Url, rootNodeCore); base.KeyTable.Add(rootNodeCore.Key, rootNodeCore); } else { XmlSiteMapProvider parentProvider = this.ParentProvider as XmlSiteMapProvider; if (parentProvider != null) { parentProvider.EnsureChildSiteMapProviderUpToDate(this); } } this.ChildProviderTable[childProvider] = rootNodeCore; this._childProviderList = null; } } } } }
private XmlDocument GetConfigDocument() { if (_document != null) { return(_document); } if (!_initialized) { throw new InvalidOperationException( SR.GetString(SR.XmlSiteMapProvider_Not_Initialized)); } // Do the error checking here if (_virtualPath == null) { throw new ArgumentException( SR.GetString(SR.XmlSiteMapProvider_missing_siteMapFile, _siteMapFileAttribute)); } if (!_virtualPath.Extension.Equals(_xmlSiteMapFileExtension, StringComparison.OrdinalIgnoreCase)) { throw new InvalidOperationException( SR.GetString(SR.XmlSiteMapProvider_Invalid_Extension, _virtualPath)); } _normalizedVirtualPath = _virtualPath.CombineWithAppRoot(); _normalizedVirtualPath.FailIfNotWithinAppRoot(); // Make sure the file exists CheckSiteMapFileExists(); _parentSiteMapFileCollection = new StringCollection(); XmlSiteMapProvider xmlParentProvider = ParentProvider as XmlSiteMapProvider; if (xmlParentProvider != null && xmlParentProvider._parentSiteMapFileCollection != null) { if (xmlParentProvider._parentSiteMapFileCollection.Contains(_normalizedVirtualPath.VirtualPathString)) { throw new InvalidOperationException( SR.GetString(SR.XmlSiteMapProvider_FileName_already_in_use, _virtualPath)); } // Copy the sitemapfiles in used from parent provider to current provider. foreach (string filename in xmlParentProvider._parentSiteMapFileCollection) { _parentSiteMapFileCollection.Add(filename); } } // Add current sitemap file to the collection _parentSiteMapFileCollection.Add(_normalizedVirtualPath.VirtualPathString); _filename = HostingEnvironment.MapPathInternal(_normalizedVirtualPath); if (!String.IsNullOrEmpty(_filename)) { _handler = new FileChangeEventHandler(this.OnConfigFileChange); HttpRuntime.FileChangesMonitor.StartMonitoringFile(_filename, _handler); ResourceKey = (new FileInfo(_filename)).Name; } _document = new ConfigXmlDocument(); return(_document); }
private void EnsureChildSiteMapProviderUpToDate(SiteMapProvider childProvider) { SiteMapNode oldNode = (SiteMapNode)ChildProviderTable[childProvider]; SiteMapNode newNode = childProvider.GetRootNodeCore(); if (newNode == null) { throw new ProviderException(SR.GetString(SR.XmlSiteMapProvider_invalid_sitemapnode_returned, childProvider.Name)); } // child providers have been updated. if (!oldNode.Equals(newNode)) { // If the child provider table has been updated, simply return null. // This will happen when the current provider's sitemap file is changed or Clear() is called; if (oldNode == null) { return; } lock (_lock) { oldNode = (SiteMapNode)ChildProviderTable[childProvider]; // If the child provider table has been updated, simply return null. See above. if (oldNode == null) { return; } newNode = childProvider.GetRootNodeCore(); if (newNode == null) { throw new ProviderException(SR.GetString(SR.XmlSiteMapProvider_invalid_sitemapnode_returned, childProvider.Name)); } if (!oldNode.Equals(newNode)) { // If the current provider does not contain any nodes but one child provider // ie. _siteMapNode == oldNode // the oldNode needs to be removed from Url table and the new node will be added. if (_siteMapNode.Equals(oldNode)) { UrlTable.Remove(oldNode.Url); KeyTable.Remove(oldNode.Key); UrlTable.Add(newNode.Url, newNode); KeyTable.Add(newNode.Key, newNode); _siteMapNode = newNode; } // First find the parent node SiteMapNode parent = (SiteMapNode)ParentNodeTable[oldNode]; // parent is null when the provider does not contain any static nodes, ie. // it only contains definition to include one child provider. if (parent != null) { // Update the child nodes table SiteMapNodeCollection list = (SiteMapNodeCollection)ChildNodeCollectionTable[parent]; // Add the newNode to where the oldNode is within parent node's collection. int index = list.IndexOf(oldNode); if (index != -1) { list.Remove(oldNode); list.Insert(index, newNode); } else { list.Add(newNode); } // Update the parent table ParentNodeTable[newNode] = parent; ParentNodeTable.Remove(oldNode); // Update the Url table UrlTable.Remove(oldNode.Url); KeyTable.Remove(oldNode.Key); UrlTable.Add(newNode.Url, newNode); KeyTable.Add(newNode.Key, newNode); } else { // Notify the parent provider to update its child provider collection. XmlSiteMapProvider provider = ParentProvider as XmlSiteMapProvider; if (provider != null) { provider.EnsureChildSiteMapProviderUpToDate(this); } } // Update provider nodes; ChildProviderTable[childProvider] = newNode; _childProviderList = null; } } } }
public override SiteMapNode BuildSiteMap() { if (rootNode == null) lock (this) { if (rootNode == null) { if (log.IsDebugEnabled) log.Debug("Dynamically filling site map with atome site maps..."); rootNode = BuildRootNode(); foreach (string siteMap in GetSiteMapPaths()) { var provider = new XmlSiteMapProvider(); var attributes = new NameValueCollection(); attributes.Add("siteMapFile", siteMap); provider.Initialize("test", attributes); AddNode(provider.RootNode, rootNode); if (log.IsDebugEnabled) log.Debug("site map " + siteMap + " added."); } } } return rootNode; }
void BuildSiteMapRecursive(XmlNode xmlNode, SiteMapNode parent) { if (xmlNode.Name != "siteMapNode") { throw new ConfigurationException("incorrect element name", xmlNode); } string attrValue = GetNonEmptyOptionalAttribute(xmlNode, "provider"); if (attrValue != null) { SiteMapProvider provider = SiteMap.Providers [attrValue]; if (provider == null) { throw new ProviderException("Provider with name [" + attrValue + "] was not found."); } provider.ParentProvider = this; SiteMapNode providerRoot = provider.GetRootNodeCore(); if (parent == null) { root = providerRoot; } else { AddNodeNoCheck(providerRoot, parent); } return; } attrValue = GetNonEmptyOptionalAttribute(xmlNode, "siteMapFile"); if (attrValue != null) { var nvc = new NameValueCollection(); nvc.Add("siteMapFile", attrValue); string description = GetOptionalAttribute(xmlNode, "description"); if (!String.IsNullOrEmpty(description)) { nvc.Add("description", description); } string name = MapUrl(attrValue); var provider = new XmlSiteMapProvider(); provider.Initialize(name, nvc); SiteMapNode providerRoot = provider.GetRootNodeCore(); if (parent == null) { root = providerRoot; } else { AddNodeNoCheck(providerRoot, parent); } return; } SiteMapNode curNode = ConvertToSiteMapNode(xmlNode); if (parent == null) { root = curNode; } else { AddNodeNoCheck(curNode, parent); } XmlNodeList childNodes = xmlNode.ChildNodes; if (childNodes == null || childNodes.Count < 1) { return; } foreach (XmlNode child in childNodes) { if (child.NodeType != XmlNodeType.Element) { continue; } BuildSiteMapRecursive(child, curNode); } }
public ActionResult Index() { string url = ""; string xml = ""; oAuthTwitter oAuth = new oAuthTwitter(); if (Request["oauth_token"] == null) { //Redirect the user to Twitter for authorization. //Using oauth_callback for local testing. oAuth.CallBackUrl = "http://localhost/MvcApplication1/Twitter"; Response.Redirect(oAuth.AuthorizationLinkGet()); } else { //Get the access token and secret. oAuth.AccessTokenGet(Request["oauth_token"], Request["oauth_verifier"]); if (oAuth.TokenSecret.Length > 0) { //We now have the credentials, so make a call to the Twitter API. url = "http://twitter.com/account/verify_credentials.xml"; xml = oAuth.oAuthWebRequest(oAuthTwitter.Method.GET, url, String.Empty); //apiResponse.InnerHtml = Server.HtmlEncode(xml); String parametroApertura = "<screen_name>"; String parametroCierre = "</screen_name>"; String xmlParseado = parsear(xml, parametroApertura, parametroCierre); ViewData["XML"] = xmlParseado; ViewData["login"] = "******"; Session.Timeout = 5; Session["data"] = xmlParseado; Session["tokken"] =oAuth.TokenSecret; //POST Test IRepositorioPersona<Persona> repo = new PersonaRepositorio(); Persona p = repo.GetById(xmlParseado); if (p == null) { url = "http://twitter.com/statuses/update.xml"; xml = oAuth.oAuthWebRequest(oAuthTwitter.Method.POST, url,"status=" +oAuth.UrlEncode("Yo, ya me uni a la red @TwistedUCAB ... que esperas Unete! y comparte tus viajes tambien.")); } //apiResponse.InnerHtml = Server.HtmlEncode(xml); XmlSiteMapProvider my = new XmlSiteMapProvider(); return RedirectToAction("Verificar", "Persona"); } } return RedirectToAction("Index", "Home"); }
void BuildSiteMapRecursive (XmlNode xmlNode, SiteMapNode parent) { if (xmlNode.Name != "siteMapNode") throw new ConfigurationException ("incorrect element name", xmlNode); string attrValue = GetNonEmptyOptionalAttribute (xmlNode, "provider"); if (attrValue != null) { SiteMapProvider provider = SiteMap.Providers [attrValue]; if (provider == null) throw new ProviderException ("Provider with name [" + attrValue + "] was not found."); provider.ParentProvider = this; SiteMapNode providerRoot = provider.GetRootNodeCore(); if (parent == null) root = providerRoot; else AddNodeNoCheck (providerRoot, parent); return; } attrValue = GetNonEmptyOptionalAttribute (xmlNode, "siteMapFile"); if (attrValue != null) { var nvc = new NameValueCollection (); nvc.Add ("siteMapFile", attrValue); string description = GetOptionalAttribute (xmlNode, "description"); if (!String.IsNullOrEmpty (description)) nvc.Add ("description", description); string name = MapUrl (attrValue); var provider = new XmlSiteMapProvider (); provider.Initialize (name, nvc); SiteMapNode providerRoot = provider.GetRootNodeCore (); if (parent == null) root = providerRoot; else AddNodeNoCheck (providerRoot, parent); return; } SiteMapNode curNode = ConvertToSiteMapNode (xmlNode); if (parent == null) root = curNode; else AddNodeNoCheck (curNode, parent); XmlNodeList childNodes = xmlNode.ChildNodes; if (childNodes == null || childNodes.Count < 1) return; foreach (XmlNode child in childNodes) { if (child.NodeType != XmlNodeType.Element) continue; BuildSiteMapRecursive (child, curNode); } }
private SiteMapNode GetNodeFromSiteMapFile(XmlNode xmlNode, VirtualPath siteMapFile) { SiteMapNode node = null; // For external sitemap files, its secuity setting is inherited from parent provider bool secuityTrimmingEnabled = SecurityTrimmingEnabled; HandlerBase.GetAndRemoveBooleanAttribute(xmlNode, _securityTrimmingEnabledAttrName, ref secuityTrimmingEnabled); // No other attributes or non-comment nodes are allowed on a siteMapFile node HandlerBase.CheckForUnrecognizedAttributes(xmlNode); HandlerBase.CheckForNonCommentChildNodes(xmlNode); XmlSiteMapProvider childProvider = new XmlSiteMapProvider(); // siteMapFile was relative to the sitemap file where this xmlnode is defined, make it an application path. siteMapFile = _normalizedVirtualPath.Parent.Combine(siteMapFile); childProvider.ParentProvider = this; childProvider.Initialize(siteMapFile, secuityTrimmingEnabled); childProvider.BuildSiteMap(); node = childProvider._siteMapNode; ChildProviderTable.Add(childProvider, node); _childProviderList = null; return node; }