Click here to Skip to main content
15,894,646 members
Articles / Web Development / IIS

BooProd.Core - Context sensitive URL

Rate me:
Please Sign up or sign in to vote.
3.80/5 (3 votes)
22 Dec 20047 min read 47.7K   22  
Helps you create context sensitive dynamic URLs: dynamically computed URLs, depending on which server the page is generated on.
using System;
using System.Xml;
using System.Xml.Schema;
using System.Collections;

namespace BooProd.Core
{
	/// <summary>
	/// v1.2	/ 2004-12-06 / CB => Exception if ExeConfig is empty.
	/// v1.1	/ 2004-11-19 / CB => Modification of ExeDB. XML file is now in version 1.2
	/// v1.0	/ 2004-08-21 / CB => Creation
	/// </summary>

	public class ExeConfig {

		#region ACCESS
		/// <summary>
		/// CurrentVersion:
		/// Current Version of the XML File.
		/// </summary>
		public static string CurrentVersion =	"1.2";

		/// <summary>
		/// Version:
		/// Version of the XML File
		/// </summary>
		private string _Version;
		public string Version {
			get { return _Version; }
		}

		/// <summary>
		/// LocalIP:
		/// LocalIP starting string. ie: If "10.1.", then all IP starting with "10.1" are considered al local.
		/// </summary>
		private string _LocalIP;
		public string LocalIP {
			get { return _LocalIP; }
		}

		/// <summary>
		/// Return true if the IP is a local IP adress, using the LocalIP "mask" for testing.
		/// </summary>
		/// <param name="pIPToCheck"></param>
		/// <returns></returns>
		public bool isLocalIP(string pIPToCheck) {
			return (pIPToCheck.Substring(0,LocalIP.Length) == LocalIP);
		}

		#endregion

		#region CREATION

		/// <summary>
		/// Create a new instance from the XML node.
		/// </summary>
		/// <param name="reader"></param>
		/// <returns></returns>
		public static ExeConfig newFromXML(XmlNodeReader reader) {
			// If wrong elem, or none, get out of here.
			if (reader.IsStartElement("ExeConfig")==false)
				return null;
			if (reader.IsEmptyElement)
				throw new Exception("ExeConfig can't be empty.");

			ExeConfig vElem= new ExeConfig();
			reader.ReadStartElement("ExeConfig");
			vElem._Version= reader.ReadElementString("version");
			if (vElem._Version!=CurrentVersion)
				throw new Exception("Wrong ExeConfig version.");
			vElem._LocalIP= reader.ReadElementString("local_ip");
			reader.ReadEndElement();

			return vElem;
		}
		#endregion

		public ExeConfig() {
		}
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
France France
I work on a leading European telecom provider regarding on-line real time account management for B2B and B2C customers. Before this position, I worked in one of the leading European council providers of economic forecasts analyses.

I jump into software development in 1985 and never stop! I work with a lot of systems like Apple, NeXT, Unix, Windows. I develop with a lot of languages like Assembler, Pascal, C, C++, Java and C#. I play with databases like Oracle and SQL Server. I love networks and like to make systems working and cooperate themselves.

I'm very interested in MAS: Multi Agent System and really hope that computer will be human in the future. I work on BDI architecture extensions on this purpose, but this is the project of my life!

Comments and Discussions