// Gonzalo Paniagua Javier (gonzalo@novell.com)
//
//
-// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
+// Copyright (C) 2006-2010 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-#if NET_2_0
using System;
using System.Collections.Generic;
using System.IO;
int users;
Dictionary <string, BareApplicationHost> id_to_host;
- private ApplicationManager ()
+ ApplicationManager ()
{
id_to_host = new Dictionary<string, BareApplicationHost> ();
}
ShutdownAll ();
}
+ [MonoTODO ("Need to take advantage of the configuration mapping capabilities of IApplicationHost")]
+ [SecurityPermissionAttribute(SecurityAction.Demand, Unrestricted = true)]
+ public IRegisteredObject CreateObject (IApplicationHost appHost, Type type)
+ {
+ if (appHost == null)
+ throw new ArgumentNullException ("appHost");
+ if (type == null)
+ throw new ArgumentNullException ("type");
+
+ return CreateObject (appHost.GetSiteID (),
+ type,
+ appHost.GetVirtualPath (),
+ appHost.GetPhysicalPath (),
+ true,
+ true);
+ }
+
public IRegisteredObject CreateObject (string appId, Type type, string virtualPath,
string physicalPath, bool failIfExists)
{
if (!VirtualPathUtility.IsAbsolute (virtualPath))
throw new ArgumentException ("Relative path no allowed.", "virtualPath");
- if (physicalPath == null || physicalPath == "")
+ if (String.IsNullOrEmpty (physicalPath))
throw new ArgumentException ("Cannot be null or empty", "physicalPath");
// 'type' is not checked. If it's null, we'll throw a NullReferenceException
- if (!typeof (IRegisteredObject).IsAssignableFrom (type)) {
- string msg = String.Format ("Type '{0}' does not implement IRegisteredObject.", type.Name);
- throw new ArgumentException (msg, "type");
- }
+ if (!typeof (IRegisteredObject).IsAssignableFrom (type))
+ throw new ArgumentException (String.Concat ("Type '", type.Name, "' does not implement IRegisteredObject."), "type");
//
// ArgumentException is thrown for the physical path from the internal object created
if (host == null)
host = CreateHost (appId, virtualPath, physicalPath);
ireg = host.CreateInstance (type);
- } catch (Exception e) {
+ } catch (Exception) {
if (throwOnError)
throw;
}
if (ireg == null)
return null;
- if (failIfExists) {
- string msg = String.Format ("Well known object of type '{0}' already " +
- "exists in this domain.", type.Name);
- throw new InvalidOperationException (msg);
- }
+ if (failIfExists)
+ throw new InvalidOperationException (String.Concat ("Well known object of type '", type.Name, "' already exists in this domain."));
return ireg;
}
ICollection<string> coll = id_to_host.Keys;
string [] keys = new string [coll.Count];
coll.CopyTo (keys, 0);
- ApplicationInfo [] result = new ApplicationInfo [coll.Count];
- int i = 0;
foreach (string str in keys) {
BareApplicationHost host = id_to_host [str];
host.Shutdown ();
}
}
-#endif