static string applicationID = null;
static string applicationName = null;
static string configFile = "";
- static MiniParser parser = null;
+ static SmallXmlParser parser = null;
static string processGuid = null;
static bool defaultConfigRead = false;
static bool defaultDelayedConfigRead = false;
public static string ApplicationId
{
get
- {
- applicationID = AppDomain.CurrentDomain.SetupInformation.ApplicationName;
+ {
+ applicationID = ApplicationName;
return applicationID;
}
}
public static string ApplicationName
{
- get {
- try {
- applicationName = AppDomain.CurrentDomain.SetupInformation.ApplicationName;
- }
- catch (Exception e) {
- throw e;
- }
- // We return null if the application name has not been set.
- return null;
- }
+ get { return applicationName; }
set { applicationName = value; }
}
// public methods
- public static void Configure (string filename)
+#if NET_2_0
+ [MonoTODO ("Implement ensureSecurity")]
+ public
+#else
+ internal
+#endif
+ static void Configure (string filename, bool ensureSecurity)
{
- lock (channelTemplates)
- {
- if (!defaultConfigRead)
- {
+ lock (channelTemplates) {
+ if (!defaultConfigRead) {
ReadConfigFile (Environment.GetMachineConfigPath ());
defaultConfigRead = true;
}
-
+
if (filename != null)
ReadConfigFile (filename);
}
}
+
+ public static void Configure (string filename)
+ {
+ Configure (filename, false);
+ }
private static void ReadConfigFile (string filename)
{
try
{
- MiniParser parser = new MiniParser ();
- RReader rreader = new RReader (filename);
- ConfigHandler handler = new ConfigHandler (false);
- parser.Parse (rreader, handler);
+ SmallXmlParser parser = new SmallXmlParser ();
+ using (TextReader rreader = new StreamReader (filename)) {
+ ConfigHandler handler = new ConfigHandler (false);
+ parser.Parse (rreader, handler);
+ }
}
catch (Exception ex)
{
- throw new RemotingException ("Configuration file '" + filename + "' could not be loaded: " + ex.Message);
+ throw new RemotingException ("Configuration file '" + filename + "' could not be loaded: " + ex.Message, ex);
}
}
{
if (defaultDelayedConfigRead || defaultConfigRead) return;
- MiniParser parser = new MiniParser ();
- RReader rreader = new RReader (Environment.GetMachineConfigPath ());
- ConfigHandler handler = new ConfigHandler (true);
- parser.Parse (rreader, handler);
+ SmallXmlParser parser = new SmallXmlParser ();
+ using (TextReader rreader = new StreamReader (Environment.GetMachineConfigPath ())) {
+ ConfigHandler handler = new ConfigHandler (true);
+ parser.Parse (rreader, handler);
+ }
defaultDelayedConfigRead = true;
}
}
internal static void SetCustomErrorsMode (string mode)
{
- if (mode != "on" && mode != "off" && mode != "remoteOnly")
+ if (mode == null)
+ throw new RemotingException ("mode attribute is required");
+
+ // the mode is case insensitive
+ string m = mode.ToLower ();
+
+ if (m != "on" && m != "off" && m != "remoteonly")
throw new RemotingException ("Invalid custom error mode: " + mode);
- _errorMode = mode;
+ _errorMode = m;
}
}
* Internal classes used by RemotingConfiguration.Configure () *
***************************************************************/
- internal class RReader : MiniParser.IReader {
- private string xml; // custom remoting config file
- private int pos;
-
- public RReader (string filename)
- {
- try {
- StreamReader sr = new StreamReader (filename);
- xml = sr.ReadToEnd ();
- sr.Close ();
- }
- catch {
- xml = null;
- }
- }
-
- public int Read () {
- try {
- return (int) xml[pos++];
- }
- catch {
- return -1;
- }
- }
- }
-
- internal class ConfigHandler : MiniParser.IHandler
+ internal class ConfigHandler : SmallXmlParser.IContentHandler
{
ArrayList typeEntries = new ArrayList ();
ArrayList channelInstances = new ArrayList ();
return currentXmlPath.EndsWith (path);
}
- public void OnStartParsing (MiniParser parser) {}
+ public void OnStartParsing (SmallXmlParser parser) {}
- public void OnStartElement (string name, MiniParser.IAttrList attrs)
+ public void OnProcessingInstruction (string name, string text) {}
+
+ public void OnIgnorableWhitespace (string s) {}
+
+ public void OnStartElement (string name, SmallXmlParser.IAttrList attrs)
{
try
{
}
catch (Exception ex)
{
- throw new RemotingException ("Error in element " + name + ": " + ex.Message);
+ throw new RemotingException ("Error in element " + name + ": " + ex.Message, ex);
}
}
- public void ParseElement (string name, MiniParser.IAttrList attrs)
+ public void ParseElement (string name, SmallXmlParser.IAttrList attrs)
{
if (currentProviderData != null)
{
if (currentProviderData != null)
{
currentProviderData.Pop ();
- if (currentProviderData.Count > 0) return;
- currentProviderData = null;
+ if (currentProviderData.Count == 0)
+ currentProviderData = null;
}
currentXmlPath = currentXmlPath.Substring (0, currentXmlPath.Length - name.Length - 1);
}
- void ReadCustomProviderData (string name, MiniParser.IAttrList attrs)
+ void ReadCustomProviderData (string name, SmallXmlParser.IAttrList attrs)
{
SinkProviderData parent = (SinkProviderData) currentProviderData.Peek ();
currentProviderData.Push (data);
}
- void ReadLifetine (MiniParser.IAttrList attrs)
+ void ReadLifetine (SmallXmlParser.IAttrList attrs)
{
for (int i=0; i < attrs.Names.Length; ++i) {
switch (attrs.Names[i]) {
throw new RemotingException ("Invalid time unit: " + unit);
}
- void ReadChannel (MiniParser.IAttrList attrs, bool isTemplate)
+ void ReadChannel (SmallXmlParser.IAttrList attrs, bool isTemplate)
{
ChannelData channel = new ChannelData ();
currentChannel = channel;
}
- ProviderData ReadProvider (string name, MiniParser.IAttrList attrs, bool isTemplate)
+ ProviderData ReadProvider (string name, SmallXmlParser.IAttrList attrs, bool isTemplate)
{
ProviderData prov = (name == "provider") ? new ProviderData () : new FormatterData ();
SinkProviderData data = new SinkProviderData ("root");
if (at == "id" && isTemplate)
prov.Id = val;
- if (at == "type")
+ else if (at == "type")
prov.Type = val;
- if (at == "ref" && !isTemplate)
+ else if (at == "ref" && !isTemplate)
prov.Ref = val;
else
prov.CustomProperties.Add (at, val);
return prov;
}
- void ReadClientActivated (MiniParser.IAttrList attrs)
+ void ReadClientActivated (SmallXmlParser.IAttrList attrs)
{
string type = GetNotNull (attrs, "type");
string assm = ExtractAssembly (ref type);
typeEntries.Add (new ActivatedClientTypeEntry (type, assm, currentClientUrl));
}
- void ReadServiceActivated (MiniParser.IAttrList attrs)
+ void ReadServiceActivated (SmallXmlParser.IAttrList attrs)
{
string type = GetNotNull (attrs, "type");
string assm = ExtractAssembly (ref type);
typeEntries.Add (new ActivatedServiceTypeEntry (type, assm));
}
- void ReadClientWellKnown (MiniParser.IAttrList attrs)
+ void ReadClientWellKnown (SmallXmlParser.IAttrList attrs)
{
string url = GetNotNull (attrs, "url");
string type = GetNotNull (attrs, "type");
typeEntries.Add (new WellKnownClientTypeEntry (type, assm, url));
}
- void ReadServiceWellKnown (MiniParser.IAttrList attrs)
+ void ReadServiceWellKnown (SmallXmlParser.IAttrList attrs)
{
string objectUri = GetNotNull (attrs, "objectUri");
string smode = GetNotNull (attrs, "mode");
typeEntries.Add (new WellKnownServiceTypeEntry (type, assm, objectUri, mode));
}
- void ReadInteropXml (MiniParser.IAttrList attrs, bool isElement)
+ void ReadInteropXml (SmallXmlParser.IAttrList attrs, bool isElement)
{
Type t = Type.GetType (GetNotNull (attrs, "clr"));
string[] xmlName = GetNotNull (attrs, "xml").Split (',');
else SoapServices.RegisterInteropXmlType (localName, ns, t);
}
- void ReadPreload (MiniParser.IAttrList attrs)
+ void ReadPreload (SmallXmlParser.IAttrList attrs)
{
string type = attrs.GetValue ("type");
string assm = attrs.GetValue ("assembly");
throw new RemotingException ("Either type or assembly attributes must be specified");
}
- string GetNotNull (MiniParser.IAttrList attrs, string name)
+ string GetNotNull (SmallXmlParser.IAttrList attrs, string name)
{
string value = attrs.GetValue (name);
if (value == null || value == "")
public void OnChars (string ch) {}
- public void OnEndParsing (MiniParser parser)
+ public void OnEndParsing (SmallXmlParser parser)
{
RemotingConfiguration.RegisterChannels (channelInstances, onlyDelayedChannels);
if (appName != null) RemotingConfiguration.ApplicationName = appName;