Host

We found 10 examples in language CSharp for this search. You will see 41 fragments of code.

		static IAsyncResult BeginAsyncCallAddresses (string host, AsyncCallback callback, object state)
		{
			SimpleResolverEventArgs e = new SimpleResolverEventArgs ();
			e.Completed += OnCompleted;
			e.HostName = host;
			DnsAsyncResult ares = new DnsAsyncResult (callback, state);
			e.UserToken = ares;
			if (resolver.GetHostAddressesAsync (e) == false)
				ares.SetCompleted (true, e.HostEntry); // Completed synchronously
			return ares;
		}

		static IAsyncResult BeginAsyncCall (string host, AsyncCallback callback, object state)
		{
			SimpleResolverEventArgs e = new SimpleResolverEventArgs ();
			e.Completed += OnCompleted;
			e.HostName = host;
			DnsAsyncResult ares = new DnsAsyncResult (callback, state);
			e.UserToken = ares;
			if (resolver.GetHostEntryAsync (e) == false)
				ares.SetCompleted (true, e.HostEntry); // Completed synchronously
			return ares;
		}


		[Test]
		[ExpectedException (typeof (InvalidOperationException))]
		public void AddServiceEndpoint1 ()
		{
			ServiceHost host = new ServiceHost (typeof (Foo), new Uri ("ftp://localhost/echo"));
			// ftp does not match BasicHttpBinding
			host.AddServiceEndpoint (typeof (Foo), new BasicHttpBinding (), "rel");
		}

		[Test]
		[ExpectedException (typeof (InvalidOperationException))]
		public void AddServiceEndpoint2 ()
		{
			ServiceHost host = new ServiceHost (typeof (Foo), new Uri ("http://localhost/echo"));
			host.AddServiceEndpoint (typeof (Foo), new BasicHttpBinding (), "rel");
			host.AddServiceEndpoint (typeof (Foo), new BasicHttpBinding (), "rel"); // duplicate URI

			host.Open ();
			host.Close (); // should not reach here. It is to make sure to close unexpectedly opened host.
		}

		[Test]
		public void AddServiceEndpoint4 ()
		{
			ServiceHost host = new ServiceHost (typeof (Baz), new Uri ("http://localhost/echo"));
			host.AddServiceEndpoint ("MonoTests.System.ServiceModel.ServiceHostTest+IBaz", new BasicHttpBinding (), "rel");
		}

		[Test]
		[ExpectedException (typeof (InvalidOperationException))]
		public void AddServiceEndpoint5 ()
		{
			ServiceHost host = new ServiceHost (typeof (Baz), new Uri ("http://localhost/echo"));

			// Full type name is expected here (see AddServiceEndpoint4).
			host.AddServiceEndpoint ("IBaz", new BasicHttpBinding (), "rel");
		}

		[Test]
		[ExpectedException (typeof (InvalidOperationException))]
		public void AddServiceEndpoint6 ()
		{
			ServiceHost host = new ServiceHost (typeof (Foo), new Uri ("http://localhost/echo"));
			host.AddServiceEndpoint ("ISuchTypeDoesNotExist", new BasicHttpBinding (), "rel");
		}

		[Test]
		public void AddServiceEndpointMetadataExchange ()
		{
			// MyMetadataExchange implements IMetadataExchange
			ServiceHost host = new ServiceHost (typeof (MyMetadataExchange));
			host.AddServiceEndpoint ("IMetadataExchange",
						 new BasicHttpBinding (),
						 "http://localhost:8080/");
		}

//
// System.Web.Hosting.ApplicationManager
// 
// Author:
//	Gonzalo Paniagua Javier ([email protected])
//
//
// 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
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
// 
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
// 
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// 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;
using System.Security.Permissions;
using System.Security.Policy;
using System.Threading;

namespace System.Web.Hosting {
	[AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
	public sealed class ApplicationManager : MarshalByRefObject {
		static ApplicationManager instance = new ApplicationManager ();
		int users;
		Dictionary <string, BareApplicationHost> id_to_host;

		ApplicationManager ()
		{
			id_to_host = new Dictionary<string, BareApplicationHost> ();
		}

		public void Close ()
		{
			if (Interlocked.Decrement (ref users) == 0)
				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)
		{
			return CreateObject (appId, type, virtualPath, physicalPath, failIfExists, true);
		}

		public IRegisteredObject CreateObject (string appId, Type type, string virtualPath,
							string physicalPath, bool failIfExists, bool throwOnError)
		{
			if (appId == null)
				throw new ArgumentNullException ("appId");

			if (!VirtualPathUtility.IsAbsolute (virtualPath))
				throw new ArgumentException ("Relative path no allowed.", "virtualPath");

			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))
				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
			// in the new application domain.
			BareApplicationHost host = null;
			if (id_to_host.ContainsKey (appId))
				host = id_to_host [appId];

			IRegisteredObject ireg = null;
			if (host != null) {
				ireg = CheckIfExists (host, type, failIfExists);
				if (ireg != null)
					return ireg;
			}

			try {
				if (host == null)
					host = CreateHost (appId, virtualPath, physicalPath);
				ireg = host.CreateInstance (type);
			} catch (Exception) {
				if (throwOnError)
					throw;
			}

			if (ireg != null && host.GetObject (type) == null) // If not registered from ctor...
				host.RegisterObject (ireg, true);

			return ireg;
		}

		// Used from ClientBuildManager
		internal BareApplicationHost CreateHostWithCheck (string appId, string vpath, string ppath)
		{
			if (id_to_host.ContainsKey (appId))
				throw new InvalidOperationException ("Already have a host with the same appId");

			return CreateHost (appId, vpath, ppath);
		}

		BareApplicationHost CreateHost (string appId, string vpath, string ppath)
		{
			BareApplicationHost host;
			host = (BareApplicationHost) ApplicationHost.CreateApplicationHost (typeof (BareApplicationHost), vpath, ppath);
			host.Manager = this;
			host.AppID = appId;
			id_to_host [appId] = host;
			return host;
		}

		internal void RemoveHost (string appId)
		{
			id_to_host.Remove (appId);
		}

		IRegisteredObject CheckIfExists (BareApplicationHost host, Type type, bool failIfExists)
		{
			IRegisteredObject ireg = host.GetObject (type);
			if (ireg == null)
				return null;

			if (failIfExists)
				throw new InvalidOperationException (String.Concat ("Well known object of type '", type.Name, "' already exists in this domain."));

			return ireg;
		}

		public static ApplicationManager GetApplicationManager ()
		{
			return instance;
		}

		public IRegisteredObject GetObject (string appId, Type type)
		{
			if (appId == null)
				throw new ArgumentNullException ("appId");

			if (type == null)
				throw new ArgumentNullException ("type");

			BareApplicationHost host = null;
			if (!id_to_host.ContainsKey (appId))
				return null;

			host = id_to_host [appId];
			return host.GetObject (type);
		}

		public ApplicationInfo [] GetRunningApplications ()
		{
			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];
				result [i++] = new ApplicationInfo (str, host.PhysicalPath, host.VirtualPath);
			}

			return result;
		}

		public override object InitializeLifetimeService ()
		{
			return null;
		}

		public bool IsIdle ()
		{
			throw new NotImplementedException ();
		}

		public void Open ()
		{
			Interlocked.Increment (ref users);
		}

		public void ShutdownAll ()
		{
			ICollection<string> coll = id_to_host.Keys;
			string [] keys = new string [coll.Count];
			coll.CopyTo (keys, 0);
			foreach (string str in keys) {
				BareApplicationHost host = id_to_host [str];
				host.Shutdown ();
			}

			id_to_host.Clear ();
		}

		public void ShutdownApplication (string appId)
		{
			if (appId == null)
				throw new ArgumentNullException ("appId");

			BareApplicationHost host = id_to_host [appId];
			if (host == null)
				return;

			host.Shutdown ();
		}

		public void StopObject (string appId, Type type)
		{
			if (appId == null)
				throw new ArgumentNullException ("appId");

			if (type == null)
				throw new ArgumentNullException ("type");

			if (!id_to_host.ContainsKey (appId))
				return;

			BareApplicationHost host = id_to_host [appId];
			if (host == null)
				return;

			host.StopObject (type);
		}
	}
}

#endif



		[Test]
		public void Ctor () {
			Poker host = new Poker ();

			Assert.AreEqual (null, host.Description, "Description");
			Assert.AreEqual (null, host.Authorization, "Authorization");
		}

		[Test]
		public void AddBaseAddress ()
		{
			var host = new Poker ();
			Assert.AreEqual (0, host.BaseAddresses.Count, "#1");
			host.DoAddBaseAddress (new Uri ("http://localhost:37564"));
			Assert.AreEqual (1, host.BaseAddresses.Count, "#1");
			host.DoAddBaseAddress (new Uri ("net.tcp://localhost:893"));
			Assert.AreEqual (2, host.BaseAddresses.Count, "#1");
		}

		[Test]
		[ExpectedException (typeof (ArgumentException))]
		public void AddBaseAddress2 ()
		{
			var host = new Poker ();
			Assert.AreEqual (0, host.BaseAddresses.Count, "#1");
			host.DoAddBaseAddress (new Uri ("http://localhost:37564"));
			// http base address is already added.
			host.DoAddBaseAddress (new Uri ("http://localhost:893"));
		}

		[Test]
		public void AddServiceEndpointUri ()
		{
			var host = new ServiceHost (typeof (AllActions),
				new Uri ("http://localhost:37564"));
			var se = host.AddServiceEndpoint (typeof (AllActions),
				new BasicHttpBinding (), "foobar");
			Assert.AreEqual ("http://localhost:37564/foobar", se.Address.Uri.AbsoluteUri, "#1");
			Assert.AreEqual ("http://localhost:37564/foobar", se.ListenUri.AbsoluteUri, "#2");
		}

		[Test]
		public void AddServiceEndpointUri2 ()
		{
			var host = new ServiceHost (typeof (AllActions),
				new Uri ("http://localhost:37564"));
			var se = host.AddServiceEndpoint (typeof (AllActions),
				new BasicHttpBinding (), String.Empty);
			Assert.AreEqual ("http://localhost:37564/", se.Address.Uri.AbsoluteUri, "#1");
			Assert.AreEqual ("http://localhost:37564/", se.ListenUri.AbsoluteUri, "#2");
		}
		
		ServiceHost OpenHost (string address, Binding binding)
		{
			var baseAddresses = new Uri[] { new Uri(address) };

			var host = new ServiceHost (typeof (DummyService), baseAddresses);
			host.AddServiceEndpoint (typeof (IDummyService), binding, new Uri ("", UriKind.Relative));
			host.Open ();
			return host;
		}

//
// HostProtectionAttributeTest.cs - NUnit Test Cases for HostProtectionAttribute
//
// Author:
//	Sebastien Pouliot  <[email protected]>
//
// Copyright (C) 2004 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
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
// 
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
// 
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// 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 NUnit.Framework;
using System;
using System.Security;
using System.Security.Permissions;

namespace MonoTests.System.Security.Permissions {

	[TestFixture]
#if MOBILE
	[Ignore]
#endif
	public class HostProtectionAttributeTest {

		private void DefaultTests (HostProtectionAttribute hpa)
		{
			Assert.AreEqual (SecurityAction.LinkDemand, hpa.Action, "Action");
			Assert.AreEqual (HostProtectionResource.None, hpa.Resources, "Resources");
			Assert.IsFalse (hpa.ExternalProcessMgmt, "ExternalProcessMgmt");
			Assert.IsFalse (hpa.ExternalThreading, "ExternalThreading");
			Assert.IsFalse (hpa.MayLeakOnAbort, "MayLeakOnAbort");
			Assert.IsFalse (hpa.SecurityInfrastructure, "SecurityInfrastructure");
			Assert.IsFalse (hpa.SelfAffectingProcessMgmt, "SelfAffectingProcessMgmt");
			Assert.IsFalse (hpa.SelfAffectingThreading, "SelfAffectingThreading");
			Assert.IsFalse (hpa.SharedState, "SharedState");
			Assert.IsFalse (hpa.Synchronization, "Synchronization");
			Assert.IsFalse (hpa.UI, "UI");
			Assert.IsFalse (hpa.Unrestricted, "Unrestricted");
			IPermission p = hpa.CreatePermission ();
			Assert.AreEqual ("System.Security.Permissions.HostProtectionPermission", p.GetType ().ToString (), "CreatePermission");
			Assert.IsTrue ((p is IUnrestrictedPermission), "IUnrestrictedPermission");
		}

		[Test]
#if MOBILE
		[Ignore]
#endif
		public void HostProtectionAttribute_Empty ()
		{
			// note: normally security attributes don't have an empty constructor
			HostProtectionAttribute hpa = new HostProtectionAttribute ();
			DefaultTests (hpa);
		}

		[Test]
		[ExpectedException (typeof (ArgumentException))]
		public void HostProtectionAttribute_Assert ()
		{
			new HostProtectionAttribute (SecurityAction.Assert);
		}

		[Test]
		[ExpectedException (typeof (ArgumentException))]
		public void HostProtectionAttribute_Demand ()
		{
			new HostProtectionAttribute (SecurityAction.Demand);
		}

		[Test]
		[ExpectedException (typeof (ArgumentException))]
		public void HostProtectionAttribute_Deny ()
		{
			new HostProtectionAttribute (SecurityAction.Deny);
		}

		[Test]
#if MOBILE
		[Ignore]
#endif
		[ExpectedException (typeof (ArgumentException))]
		public void HostProtectionAttribute_InheritanceDemand ()
		{
			new HostProtectionAttribute (SecurityAction.InheritanceDemand);
		}

		[Test]
		public void HostProtectionAttribute_LinkDemand ()
		{
			HostProtectionAttribute hpa = new HostProtectionAttribute (SecurityAction.LinkDemand);
			DefaultTests (hpa);
		}

		[Test]
		[ExpectedException (typeof (ArgumentException))]
		public void HostProtectionAttribute_PermitOnly ()
		{
			new HostProtectionAttribute (SecurityAction.PermitOnly);
		}

		[Test]
		[ExpectedException (typeof (ArgumentException))]
		public void HostProtectionAttribute_RequestMinimum ()
		{
			new HostProtectionAttribute (SecurityAction.RequestMinimum);
		}

		[Test]
		[ExpectedException (typeof (ArgumentException))]
		public void HostProtectionAttribute_RequestOptional ()
		{
			new HostProtectionAttribute (SecurityAction.RequestOptional);
		}

		[Test]
		[ExpectedException (typeof (ArgumentException))]
		public void HostProtectionAttribute_RequestRefuse ()
		{
			new HostProtectionAttribute (SecurityAction.RequestRefuse);
		}

		private HostProtectionAttribute Empty () 
		{
			HostProtectionAttribute a = new HostProtectionAttribute ();
			a.Synchronization = false;
			a.SharedState = false;
			a.ExternalProcessMgmt = false;
			a.SelfAffectingProcessMgmt = false;
			a.ExternalThreading = false;
			a.SelfAffectingThreading = false;
			a.SecurityInfrastructure = false;
			a.UI = false;
			a.MayLeakOnAbort = false;
			Assert.AreEqual (HostProtectionResource.None, a.Resources, "Resources=None");
			return a;
		}

		[Test]
		public void Synchronization () 
		{
			HostProtectionAttribute a = Empty ();
			a.Synchronization = true;
			Assert.AreEqual (HostProtectionResource.Synchronization, a.Resources, "Resources=Synchronization");
			a.Synchronization = false;
			Assert.AreEqual (HostProtectionResource.None, a.Resources, "Resources=None");
		}

		[Test]
		public void SharedState () 
		{
			HostProtectionAttribute a = Empty ();
			a.SharedState = true;
			Assert.AreEqual (HostProtectionResource.SharedState, a.Resources, "Resources=SharedState");
			a.SharedState = false;
			Assert.AreEqual (HostProtectionResource.None, a.Resources, "Resources=None");
		}

		[Test]
		public void ExternalProcessMgmt () 
		{
			HostProtectionAttribute a = Empty ();
			a.ExternalProcessMgmt = true;
			Assert.AreEqual (HostProtectionResource.ExternalProcessMgmt, a.Resources, "Resources=ExternalProcessMgmt");
			a.ExternalProcessMgmt = false;
			Assert.AreEqual (HostProtectionResource.None, a.Resources, "Resources=None");
		}

		[Test]
		public void SelfAffectingProcessMgmt () 
		{
			HostProtectionAttribute a = Empty ();
			a.SelfAffectingProcessMgmt = true;
			Assert.AreEqual (HostProtectionResource.SelfAffectingProcessMgmt, a.Resources, "Resources=SelfAffectingProcessMgmt");
			a.SelfAffectingProcessMgmt = false;
			Assert.AreEqual (HostProtectionResource.None, a.Resources, "Resources=None");
		}

		[Test]
		public void ExternalThreading () 
		{
			HostProtectionAttribute a = Empty ();
			a.ExternalThreading = true;
			Assert.AreEqual (HostProtectionResource.ExternalThreading, a.Resources, "Resources=ExternalThreading");
			a.ExternalThreading = false;
			Assert.AreEqual (HostProtectionResource.None, a.Resources, "Resources=None");
		}

		[Test]
		public void SelfAffectingThreading () 
		{
			HostProtectionAttribute a = Empty ();
			a.SelfAffectingThreading = true;
			Assert.AreEqual (HostProtectionResource.SelfAffectingThreading, a.Resources, "Resources=SelfAffectingThreading");
			a.SelfAffectingThreading = false;
			Assert.AreEqual (HostProtectionResource.None, a.Resources, "Resources=None");
		}

		[Test]
		public void SecurityInfrastructure () 
		{
			HostProtectionAttribute a = Empty ();
			a.SecurityInfrastructure = true;
			Assert.AreEqual (HostProtectionResource.SecurityInfrastructure, a.Resources, "Resources=SecurityInfrastructure");
			a.SecurityInfrastructure = false;
			Assert.AreEqual (HostProtectionResource.None, a.Resources, "Resources=None");
		}

		[Test]
		public void UI () 
		{
			HostProtectionAttribute a = Empty ();
			a.UI = true;
			Assert.AreEqual (HostProtectionResource.UI, a.Resources, "Resources=UI");
			a.UI = false;
			Assert.AreEqual (HostProtectionResource.None, a.Resources, "Resources=None");
		}

		[Test]
		public void MayLeakOnAbort () 
		{
			HostProtectionAttribute a = Empty ();
			a.MayLeakOnAbort = true;
			Assert.AreEqual (HostProtectionResource.MayLeakOnAbort, a.Resources, "Resources=MayLeakOnAbort");
			a.MayLeakOnAbort = false;
			Assert.AreEqual (HostProtectionResource.None, a.Resources, "Resources=None");
		}

		[Test]
		public void Properties () 
		{
			HostProtectionAttribute hpa = new HostProtectionAttribute (SecurityAction.LinkDemand);
			HostProtectionResource expected = HostProtectionResource.None;
			Assert.AreEqual (expected, hpa.Resources, "None");
			Assert.IsFalse (hpa.Unrestricted, "Unrestricted-1");

			hpa.ExternalProcessMgmt = true;
			expected |= HostProtectionResource.ExternalProcessMgmt;
			Assert.AreEqual (expected, hpa.Resources, "+ExternalProcessMgmt");
			Assert.IsFalse (hpa.Unrestricted, "Unrestricted-2");

			hpa.ExternalThreading = true;
			expected |= HostProtectionResource.ExternalThreading;
			Assert.AreEqual (expected, hpa.Resources, "+ExternalThreading");
			Assert.IsFalse (hpa.Unrestricted, "Unrestricted-3");

			hpa.MayLeakOnAbort = true;
			expected |= HostProtectionResource.MayLeakOnAbort;
			Assert.AreEqual (expected, hpa.Resources, "+MayLeakOnAbort");
			Assert.IsFalse (hpa.Unrestricted, "Unrestricted-4");

			hpa.SecurityInfrastructure = true;
			expected |= HostProtectionResource.SecurityInfrastructure;
			Assert.AreEqual (expected, hpa.Resources, "+SecurityInfrastructure");
			Assert.IsFalse (hpa.Unrestricted, "Unrestricted-5");

			hpa.SelfAffectingProcessMgmt = true;
			expected |= HostProtectionResource.SelfAffectingProcessMgmt;
			Assert.AreEqual (expected, hpa.Resources, "+SelfAffectingProcessMgmt");
			Assert.IsFalse (hpa.Unrestricted, "Unrestricted-6");

			hpa.SelfAffectingThreading = true;
			expected |= HostProtectionResource.SelfAffectingThreading;
			Assert.AreEqual (expected, hpa.Resources, "+SelfAffectingThreading");
			Assert.IsFalse (hpa.Unrestricted, "Unrestricted-7");

			hpa.SharedState = true;
			expected |= HostProtectionResource.SharedState;
			Assert.AreEqual (expected, hpa.Resources, "+SharedState");
			Assert.IsFalse (hpa.Unrestricted, "Unrestricted-8");

			hpa.Synchronization = true;
			expected |= HostProtectionResource.Synchronization;
			Assert.AreEqual (expected, hpa.Resources, "+Synchronization");
			Assert.IsFalse (hpa.Unrestricted, "Unrestricted-9");

			hpa.UI = true;
			expected |= HostProtectionResource.UI;
			Assert.AreEqual (expected, hpa.Resources, "+UI");

			Assert.IsFalse (hpa.Unrestricted, "Unrestricted");

			hpa.ExternalProcessMgmt = false;
			expected &= ~HostProtectionResource.ExternalProcessMgmt;
			Assert.AreEqual (expected, hpa.Resources, "-ExternalProcessMgmt");
			Assert.IsFalse (hpa.Unrestricted, "Unrestricted-10");

			hpa.ExternalThreading = false;
			expected &= ~HostProtectionResource.ExternalThreading;
			Assert.AreEqual (expected, hpa.Resources, "+ExternalThreading");
			Assert.IsFalse (hpa.Unrestricted, "Unrestricted-11");

			hpa.MayLeakOnAbort = false;
			expected &= ~HostProtectionResource.MayLeakOnAbort;
			Assert.AreEqual (expected, hpa.Resources, "+MayLeakOnAbort");
			Assert.IsFalse (hpa.Unrestricted, "Unrestricted-12");

			hpa.SecurityInfrastructure = false;
			expected &= ~HostProtectionResource.SecurityInfrastructure;
			Assert.AreEqual (expected, hpa.Resources, "+SecurityInfrastructure");
			Assert.IsFalse (hpa.Unrestricted, "Unrestricted-13");

			hpa.SelfAffectingProcessMgmt = false;
			expected &= ~HostProtectionResource.SelfAffectingProcessMgmt;
			Assert.AreEqual (expected, hpa.Resources, "+SelfAffectingProcessMgmt");
			Assert.IsFalse (hpa.Unrestricted, "Unrestricted-14");

			hpa.SelfAffectingThreading = false;
			expected &= ~HostProtectionResource.SelfAffectingThreading;
			Assert.AreEqual (expected, hpa.Resources, "+SelfAffectingThreading");
			Assert.IsFalse (hpa.Unrestricted, "Unrestricted-15");

			hpa.SharedState = false;
			expected &= ~HostProtectionResource.SharedState;
			Assert.AreEqual (expected, hpa.Resources, "+SharedState");
			Assert.IsFalse (hpa.Unrestricted, "Unrestricted-16");

			hpa.Synchronization = false;
			expected &= ~HostProtectionResource.Synchronization;
			Assert.AreEqual (expected, hpa.Resources, "+Synchronization");
			Assert.IsFalse (hpa.Unrestricted, "Unrestricted-17");

			hpa.UI = false;
			expected &= ~HostProtectionResource.UI;
			Assert.AreEqual (expected, hpa.Resources, "+UI");
			Assert.IsFalse (hpa.Unrestricted, "Unrestricted-18");
		}

		[Test]
		public void Attributes ()
		{
			Type t = typeof (HostProtectionAttribute);
			Assert.IsTrue (t.IsSerializable, "IsSerializable");

			object [] attrs = t.GetCustomAttributes (typeof (AttributeUsageAttribute), false);
			Assert.AreEqual (1, attrs.Length, "AttributeUsage");
			AttributeUsageAttribute aua = (AttributeUsageAttribute)attrs [0];
			Assert.IsTrue (aua.AllowMultiple, "AllowMultiple");
			Assert.IsFalse (aua.Inherited, "Inherited");
			AttributeTargets at = (AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Delegate);
			Assert.AreEqual (at, aua.ValidOn, "ValidOn");
		}
	}
}

#endif


		[TestFixtureSetUp]
		public void FixtureSetUp ()
		{
			reset = new ManualResetEvent (false);
			hostname = Dns.GetHostName ();
			ip = Dns.Resolve (site).AddressList[0];
		}

		[TestFixtureTearDown]
		public void FixtureTearDown ()
		{
			reset.Close ();
		}

		[SetUp]
		public void SetUp ()
		{
			if (!SecurityManager.SecurityEnabled)
				Assert.Ignore ("SecurityManager.SecurityEnabled is OFF");
		}

		// test Demand by denying it's caller from the required permission

		[Test]
		[DnsPermission (SecurityAction.Deny, Unrestricted = true)]
		[ExpectedException (typeof (SecurityException))]
		public void Deny_BeginGetHostName ()
		{
			Dns.BeginGetHostByName (null, null, null);
		}

		[Test]
		[DnsPermission (SecurityAction.Deny, Unrestricted = true)]
		[ExpectedException (typeof (ArgumentNullException))]
		public void Deny_EndGetHostByName ()
		{
			Dns.EndGetHostByName (null);
		}

		[Test]
		[DnsPermission (SecurityAction.Deny, Unrestricted = true)]
		[ExpectedException (typeof (SecurityException))]
		public void Deny_BeginResolve ()
		{
			Dns.BeginResolve (null, null, null);
		}


		public static void Throws<TException> (TestCode code, string message) where TException : Exception
		{
			Throws (code, typeof (TException), null, message);
		}

		public static void Throws (TestCode code, Type expected_exception, Type expected_inner_exception, string message)
		{
			bool failed = false;
			try {
				code ();
				failed = true;
			}
			catch (Exception ex) {
				if (!(ex.GetType () == expected_exception))
					throw new AssertionException (string.Format ("Expected '{0}', got '{1}'. {2}", expected_exception.FullName, ex.GetType ().FullName, message));
				//System.Diagnostics.Debug.WriteLine (ex.ToString ());
				if (expected_inner_exception != null) {
					// we only check if the inner exception was supplied
					if (ex.InnerException.GetType () != expected_inner_exception)
						throw new AssertionException (string.Format ("Expected InnerException '{0}', got '{1}'. {2}", expected_inner_exception.FullName, ex.InnerException.GetType ().FullName, message));
				}
			}
			if (failed)
				throw new AssertionException (string.Format ("Expected '{0}', but got no exception. {1}", expected_exception.FullName, message));
		}
		
		[SetUp]
		public void SetUp ()
		{
			isWin32 = (Path.DirectorySeparatorChar == '\\');
		}

		// Segments cannot be validated here...
		public void AssertUri (string relsrc, Uri uri,
			string toString,
			string absoluteUri,
			string scheme,
			string host,
			string localPath,
			string query,
			int port,
			bool isFile,
			bool isUnc,
			bool isLoopback,
			bool userEscaped,
			UriHostNameType hostNameType,
			string absolutePath,
			string pathAndQuery,
			string authority,
			string fragment,
			string userInfo)
		{
			Assert.AreEqual (absoluteUri, uri.AbsoluteUri, relsrc + " AbsoluteUri");
			Assert.AreEqual (scheme, uri.Scheme, relsrc + " Scheme");
			Assert.AreEqual (host, uri.Host, relsrc + " Host");
			Assert.AreEqual (port, uri.Port, relsrc + " Port");
			// Windows UNC path is not automatically testable on *nix environment,
			if (relsrc.StartsWith ("\\\\") && Path.DirectorySeparatorChar == '\\')
				Assert.AreEqual (localPath, uri.LocalPath, relsrc + " LocalPath");
			Assert.AreEqual (query, uri.Query, relsrc + " Query");
			Assert.AreEqual (fragment, uri.Fragment, relsrc + " Fragment");
			Assert.AreEqual (isFile, uri.IsFile, relsrc + " IsFile");
			Assert.AreEqual (isUnc, uri.IsUnc, relsrc + " IsUnc");
			Assert.AreEqual (isLoopback, uri.IsLoopback, relsrc + " IsLoopback");
			Assert.AreEqual (authority, uri.Authority, relsrc + " Authority");
			Assert.AreEqual (userEscaped, uri.UserEscaped, relsrc + " UserEscaped");
			Assert.AreEqual (userInfo, uri.UserInfo, relsrc + " UserInfo");
			Assert.AreEqual (hostNameType, uri.HostNameType, relsrc + " HostNameType");
			Assert.AreEqual (absolutePath, uri.AbsolutePath, relsrc + " AbsolutePath");
			Assert.AreEqual (pathAndQuery, uri.PathAndQuery, relsrc + " PathAndQuery");
			Assert.AreEqual (toString, uri.ToString (), relsrc + " ToString()");
		}

		[Test]
		[Ignore ("Tests needs to be updated for 2.0")]
		public void AbsoluteUriFromFile ()
		{
			FromResource ("test-uri-props.txt", null);
		}
		
		[Test]
		[Category("NotDotNet")]
		[Ignore ("Tests needs to be updated for 2.0")]
		public void AbsoluteUriFromFileManual ()
		{
			if (Path.DirectorySeparatorChar == '\\')
				return;
			FromResource ("test-uri-props-manual.txt", null);
		}

        #region Address
        /// <summary>
        /// Gets the address types.
        /// </summary>
        /// <param name="oHostSecurityToken">HostSecurityToken obtained when security provider of IWS is called</param>
        /// <param name="collectionRequest">Information about the collection being requested.</param>
        /// <param name="criteria">Address Type search criteria.</param>
        /// <returns></returns>
        public AddressTypeReturnValue GetAddressTypes(HostSecurityToken oHostSecurityToken, CollectionRequest collectionRequest,
                AddressTypeSearchCriteria criteria)
        {
            AddressTypeReturnValue returnValue = null;
            if (Functions.ValidateIWSToken(oHostSecurityToken))
            {
                oContactService = new ContactService();
                returnValue = oContactService.GetAddressTypes(Functions.GetLogonIdFromToken(oHostSecurityToken), collectionRequest, criteria);
            }
            else
            {
                returnValue = new AddressTypeReturnValue();
                returnValue.Success = false;
                returnValue.Message = "Invalid Token";
            }
            return returnValue;
        }

        /// <summary>
        /// Saves the address for the contact.
        /// </summary>
        /// <param name="oHostSecurityToken">HostSecurityToken obtained when security provider of IWS is called</param>
        /// <param name="address">The address.</param>
        /// <returns></returns>
        public AddressReturnValue SaveAddress(HostSecurityToken oHostSecurityToken, Address address)
        {
            AddressReturnValue returnValue = null;
            if (Functions.ValidateIWSToken(oHostSecurityToken))
            {
                oContactService = new ContactService();
                returnValue = oContactService.SaveAddress(Functions.GetLogonIdFromToken(oHostSecurityToken), address);
            }
            else
            {
                returnValue = new AddressReturnValue();
                returnValue.Success = false;
                returnValue.Message = "Invalid Token";
            }
            return returnValue;
        }

        /// <summary>
        /// Saves the additional address element.
        /// </summary>
        /// <param name="oHostSecurityToken">HostSecurityToken obtained when security provider of IWS is called</param>
        /// <param name="additionalElement">The additional element.</param>
        /// <returns></returns>
        public ReturnValue SaveAdditionalAddressElement(HostSecurityToken oHostSecurityToken,
                                        AdditionalAddressElement additionalElement)
        {
            ReturnValue returnValue = null;
            if (Functions.ValidateIWSToken(oHostSecurityToken))
            {
                oContactService = new ContactService();
                returnValue = oContactService.SaveAdditionalAddressElement(Functions.GetLogonIdFromToken(oHostSecurityToken), additionalElement);
            }
            else
            {
                returnValue = new ReturnValue();
                returnValue.Success = false;
                returnValue.Message = "Invalid Token";
            }
            return returnValue;
        }

        #endregion

        #region AssociationRole

        /// <summary>
        /// Get a list of partners that match the search criteria
        /// </summary>
        /// <param name="oHostSecurityToken">HostSecurityToken obtained when security provider of IWS is called</param>
        /// <param name="collectionRequest">Information about the collection being requested.</param>
        /// <param name="criteria">Association Roles search criteria</param>
        /// <returns></returns>
        public AssociationRoleSearchReturnValue AssociationRoleSearch(HostSecurityToken oHostSecurityToken, CollectionRequest collectionRequest,
            AssociationRoleSearchCriteria criteria)
        {
            AssociationRoleSearchReturnValue returnValue = null;
            if (Functions.ValidateIWSToken(oHostSecurityToken))
            {
                oContactService = new ContactService();
                returnValue = oContactService.AssociationRoleSearch(Functions.GetLogonIdFromToken(oHostSecurityToken), collectionRequest, criteria);
            }
            else
            {
                returnValue = new AssociationRoleSearchReturnValue();
                returnValue.Success = false;
                returnValue.Message = "Invalid Token";
            }
            return returnValue;
        }
        #endregion

        #region BusinessSource

        /// <summary>
        /// Businesses the source search.
        /// </summary>
        /// <param name="oHostSecurityToken">HostSecurityToken obtained when security provider of IWS is called</param>
        /// <param name="collectionRequest">Information about the collection being requested.</param>
        /// <param name="criteria">Business Source search criteria</param>
        /// <returns></returns>
        public BusinessSourceReturnValue BusinessSourceSearch(HostSecurityToken oHostSecurityToken, CollectionRequest collectionRequest,
                                BusinessSourceSearchCriteria criteria)
        {
            BusinessSourceReturnValue returnValue = null;
            if (Functions.ValidateIWSToken(oHostSecurityToken))
            {
                oContactService = new ContactService();
                returnValue = oContactService.BusinessSourceSearch(Functions.GetLogonIdFromToken(oHostSecurityToken), collectionRequest, criteria);
            }
            else
            {
                returnValue = new BusinessSourceReturnValue();
                returnValue.Success = false;
                returnValue.Message = "Invalid Token";
            }
            return returnValue;
        }

        #endregion

        #region Campaign

        /// <summary>
        /// Campaigns the search.
        /// </summary>
        /// <param name="oHostSecurityToken">HostSecurityToken obtained when security provider of IWS is called</param>
        /// <param name="collectionRequest">Information about the collection being requested.</param>
        /// <param name="criteria">Campaign search criteria.</param>
        /// <returns></returns>
        public CampaignSearchReturnValue CampaignSearch(HostSecurityToken oHostSecurityToken, CollectionRequest collectionRequest, CampaignSearchCriteria criteria)
        {
            CampaignSearchReturnValue returnValue = null;
            if (Functions.ValidateIWSToken(oHostSecurityToken))
            {
                oContactService = new ContactService();
                returnValue = oContactService.CampaignSearch(Functions.GetLogonIdFromToken(oHostSecurityToken), collectionRequest, criteria);
            }
            else
            {
                returnValue = new CampaignSearchReturnValue();
                returnValue.Success = false;
                returnValue.Message = "Invalid Token";
            }
            return returnValue;
        }

//
// System.Configuration.Internal.IConfigErrorInfo.cs
//
// Authors:
//  Lluis Sanchez Gual ([email protected])
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
// 
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
// 
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
//

#if NET_2_0

using System;
using System.IO;
using System.Security;

namespace System.Configuration.Internal
{
	public class DelegatingConfigHost: IInternalConfigHost
	{
		IInternalConfigHost host;
		
		protected DelegatingConfigHost ()
		{
		}
		
		protected IInternalConfigHost Host {
			get { return host; }
			set { host = value; }
		}
		
		public virtual object CreateConfigurationContext (string configPath, string locationSubPath)
		{
			return host.CreateConfigurationContext (configPath, locationSubPath);
		}
		
		public virtual object CreateDeprecatedConfigContext (string configPath)
		{
			return host.CreateDeprecatedConfigContext (configPath);
		}
		
		public virtual string DecryptSection (string encryptedXml, ProtectedConfigurationProvider protectionProvider, ProtectedConfigurationSection protectedSection)
		{
			return host.DecryptSection (encryptedXml, protectionProvider, protectedSection);
		}
		
		public virtual void DeleteStream (string streamName)
		{
			host.DeleteStream (streamName);
		}
		
		public virtual string EncryptSection (string encryptedXml, ProtectedConfigurationProvider protectionProvider, ProtectedConfigurationSection protectedSection)
		{
			return host.EncryptSection (encryptedXml, protectionProvider, protectedSection);
		}
		
		public virtual string GetConfigPathFromLocationSubPath (string configPath, string locatinSubPath)
		{
			return host.GetConfigPathFromLocationSubPath (configPath, locatinSubPath);
		}
		
		public virtual Type GetConfigType (string typeName, bool throwOnError)
		{
			return host.GetConfigType (typeName, throwOnError);
		}
		
		public virtual string GetConfigTypeName (Type t)
		{
			return host.GetConfigTypeName (t);
		}
		
		public virtual void GetRestrictedPermissions (IInternalConfigRecord configRecord, out PermissionSet permissionSet, out bool isHostReady)
		{
			host.GetRestrictedPermissions (configRecord, out permissionSet, out isHostReady);
		}
		
		public virtual string GetStreamName (string configPath)
		{
			return host.GetStreamName (configPath);
		}
		
		public virtual string GetStreamNameForConfigSource (string streamName, string configSource)
		{
			return host.GetStreamNameForConfigSource (streamName, configSource);
		}
		
		public virtual object GetStreamVersion (string streamName)
		{
			return host.GetStreamVersion (streamName);
		}
		
		public virtual IDisposable Impersonate ()
		{
			return host.Impersonate ();
		}
		
		public virtual void Init (IInternalConfigRoot root, params object[] hostInitParams)
		{
			host.Init (root, hostInitParams);
		}
		
		public virtual void InitForConfiguration (ref string locationSubPath, out string configPath, out string locationConfigPath, IInternalConfigRoot root, params object[] hostInitConfigurationParams)
		{
			host.InitForConfiguration (ref locationSubPath, out configPath, out locationConfigPath, root, hostInitConfigurationParams);
		}
		
		public virtual bool IsAboveApplication (string configPath)
		{
			return host.IsAboveApplication (configPath);
		}
		
		public virtual bool IsConfigRecordRequired (string configPath)
		{
			return host.IsConfigRecordRequired (configPath);
		}
		
		public virtual bool IsDefinitionAllowed (string configPath, ConfigurationAllowDefinition allowDefinition, ConfigurationAllowExeDefinition allowExeDefinition)
		{
			return host.IsDefinitionAllowed (configPath, allowDefinition, allowExeDefinition);
		}

		public virtual bool IsInitDelayed (IInternalConfigRecord configRecord)
		{
			return host.IsInitDelayed (configRecord);
		}
		
		public virtual bool IsFile (string streamName)
		{
			return host.IsFile (streamName);
		}
		
		public virtual bool IsFullTrustSectionWithoutAptcaAllowed (IInternalConfigRecord configRecord)
		{
			return host.IsFullTrustSectionWithoutAptcaAllowed (configRecord);
		}

		public virtual bool IsLocationApplicable (string configPath)
		{
			return host.IsLocationApplicable (configPath);
		}

		public virtual bool IsRemote {
			get { return host.IsRemote; }
		}

		public virtual bool IsSecondaryRoot (string configPath)
		{
			return host.IsSecondaryRoot (configPath);
		}

		public virtual bool IsTrustedConfigPath (string configPath)
		{
			return host.IsTrustedConfigPath (configPath);
		}
		
		public virtual Stream OpenStreamForRead (string streamName)
		{
			return host.OpenStreamForRead (streamName);
		}

		public virtual Stream OpenStreamForRead (string streamName, bool assertPermissions)
		{
			return host.OpenStreamForRead (streamName, assertPermissions);
		}
		
		public virtual Stream OpenStreamForWrite (string streamName, string templateStreamName, ref object writeContext)
		{
			return host.OpenStreamForWrite (streamName, templateStreamName, ref writeContext);
		}
		
		public virtual Stream OpenStreamForWrite (string streamName, string templateStreamName, ref object writeContext, bool assertPermissions)
		{
			return host.OpenStreamForWrite (streamName, templateStreamName, ref writeContext, assertPermissions);
		}

		public virtual bool PrefetchAll (string configPath, string streamName)
		{
			return host.PrefetchAll (configPath, streamName);
		}
		
		public virtual bool PrefetchSection (string sectionGroupName, string sectionName)
		{
			return host.PrefetchSection (sectionGroupName, sectionName);
		}

		public virtual void RequireCompleteInit (IInternalConfigRecord configRecord)
		{
			host.RequireCompleteInit (configRecord);
		}
		
		public virtual object StartMonitoringStreamForChanges (string streamName, StreamChangeCallback callback)
		{
			return host.StartMonitoringStreamForChanges (streamName, callback);
		}
		
		public virtual void StopMonitoringStreamForChanges (string streamName, StreamChangeCallback callback)
		{
			host.StopMonitoringStreamForChanges (streamName, callback);
		}
		
		public virtual void VerifyDefinitionAllowed (string configPath, ConfigurationAllowDefinition allowDefinition, ConfigurationAllowExeDefinition allowExeDefinition, IConfigErrorInfo errorInfo)
		{
			host.VerifyDefinitionAllowed (configPath, allowDefinition, allowExeDefinition, errorInfo);
		}
		
		public virtual void WriteCompleted (string streamName, bool success, object writeContext)
		{
			host.WriteCompleted (streamName, success, writeContext);
		}
		
		public virtual void WriteCompleted (string streamName, bool success, object writeContext, bool assertPermissions)
		{
			host.WriteCompleted (streamName, success, writeContext, assertPermissions);
		}
		
		public virtual bool SupportsChangeNotifications {
			get { return host.SupportsChangeNotifications; }
		}
		
		public virtual bool SupportsLocation {
			get { return host.SupportsLocation; }
		}
		
		public virtual bool SupportsPath {
			get { return host.SupportsPath; }
		}
		
		public virtual bool SupportsRefresh {
			get { return host.SupportsRefresh; }
		}
	}
}

#endif

			[OperationContract]
			string GetData ();

		[Test]
		public void InitializeRuntime1 () {
			using (ServiceHost host = new ServiceHost (typeof (MyService), new Uri ("http://localhost:8080"))) {
				host.AddServiceEndpoint (typeof (IMyContract), new BasicHttpBinding (), "e1");
				host.Description.Behaviors.Add (new ServiceMetadataBehavior () { HttpGetEnabled = true });

				Assert.AreEqual (0, host.ChannelDispatchers.Count, "ChannelDispatchers.Count #1");

				host.Open ();

				Assert.AreEqual (2, host.ChannelDispatchers.Count, "ChannelDispatchers.Count #2");

				ChannelDispatcher cd = (ChannelDispatcher) host.ChannelDispatchers [1];
				Assert.AreEqual (1, cd.Endpoints.Count, "Endpoints.Count");
				Assert.AreEqual ("ServiceMetadataBehaviorHttpGetBinding", cd.BindingName, "BindingName");
				Assert.AreEqual (host, cd.Host, "Host");
				//Assert.AreEqual (false, cd.IsTransactedAccept, "IsTransactedAccept");
				//Assert.AreEqual (false, cd.IsTransactedReceive, "IsTransactedReceive");

				EndpointDispatcher ed = cd.Endpoints [0];
				Assert.AreEqual (typeof (EndpointAddressMessageFilter), ed.AddressFilter.GetType (), "AddressFilter");
				Assert.AreEqual (cd, ed.ChannelDispatcher, "ChannelDispatcher");
				Assert.AreEqual (typeof (MatchAllMessageFilter), ed.ContractFilter.GetType (), "ContractFilter");
				Assert.AreEqual ("IHttpGetHelpPageAndMetadataContract", ed.ContractName, "ContractName");
				Assert.AreEqual ("http://schemas.microsoft.com/2006/04/http/metadata", ed.ContractNamespace, "ContractNamespace");
				Assert.AreEqual (0, ed.FilterPriority, "FilterPriority");

				EndpointAddress ea = ed.EndpointAddress;
				// TODO

				DispatchRuntime dr = ed.DispatchRuntime;
				// TODO

				host.Close ();
			}
		}

		[Test]
		public void InitializeRuntime2 () {
			using (ServiceHost host = new ServiceHost (typeof (MyService), new Uri ("http://localhost:8080"))) {
				host.AddServiceEndpoint (typeof (IMyContract), new BasicHttpBinding (), "");
				host.Description.Behaviors.Add (new ServiceMetadataBehavior () { HttpGetEnabled = true, HttpGetUrl = new Uri ("http://localhost:8080/mex_and_help") });
				host.Description.Behaviors.Find<ServiceDebugBehavior> ().HttpHelpPageUrl = new Uri ("http://localhost:8080/mex_and_help");

				Assert.AreEqual (0, host.ChannelDispatchers.Count, "ChannelDispatchers.Count #1");

				host.Open ();

				Assert.AreEqual (2, host.ChannelDispatchers.Count, "ChannelDispatchers.Count #2");

				ChannelDispatcher cd = (ChannelDispatcher) host.ChannelDispatchers [1];
				Assert.AreEqual (1, cd.Endpoints.Count, "Endpoints.Count");
				Assert.AreEqual ("ServiceMetadataBehaviorHttpGetBinding", cd.BindingName, "BindingName");
				Assert.AreEqual (host, cd.Host, "Host");
				//Assert.AreEqual (false, cd.IsTransactedAccept, "IsTransactedAccept");
				//Assert.AreEqual (false, cd.IsTransactedReceive, "IsTransactedReceive");

				EndpointDispatcher ed = cd.Endpoints [0];
				Assert.AreEqual (typeof (EndpointAddressMessageFilter), ed.AddressFilter.GetType (), "AddressFilter");
				Assert.AreEqual (cd, ed.ChannelDispatcher, "ChannelDispatcher");
				Assert.AreEqual (typeof (MatchAllMessageFilter), ed.ContractFilter.GetType (), "ContractFilter");
				Assert.AreEqual ("IHttpGetHelpPageAndMetadataContract", ed.ContractName, "ContractName");
				Assert.AreEqual ("http://schemas.microsoft.com/2006/04/http/metadata", ed.ContractNamespace, "ContractNamespace");
				Assert.AreEqual (0, ed.FilterPriority, "FilterPriority");

				host.Close ();
			}
		}

		[Test]
		public void InitializeRuntime3 () {
			using (ServiceHost host = new ServiceHost (typeof (MyService), new Uri ("http://localhost:8080"))) {
				host.AddServiceEndpoint (typeof (IMyContract), new BasicHttpBinding (), "");
				host.Description.Behaviors.Add (new ServiceMetadataBehavior () { HttpGetEnabled = true, HttpGetUrl = new Uri ("http://localhost:8080/mex") });
				host.Description.Behaviors.Find<ServiceDebugBehavior> ().HttpHelpPageUrl = new Uri ("http://localhost:8080/help");

				Assert.AreEqual (0, host.ChannelDispatchers.Count, "ChannelDispatchers.Count #1");

				host.Open ();

				Assert.AreEqual (3, host.ChannelDispatchers.Count, "ChannelDispatchers.Count #2");

				ChannelDispatcher cd = (ChannelDispatcher) host.ChannelDispatchers [1];
				Assert.AreEqual (1, cd.Endpoints.Count, "Endpoints.Count");

				EndpointDispatcher ed = cd.Endpoints [0];
				Assert.AreEqual (typeof (EndpointAddressMessageFilter), ed.AddressFilter.GetType (), "AddressFilter #1");
				Assert.AreEqual (cd, ed.ChannelDispatcher, "ChannelDispatcher #1");
				Assert.AreEqual (typeof (MatchAllMessageFilter), ed.ContractFilter.GetType (), "ContractFilter #1");
				Assert.AreEqual ("IHttpGetHelpPageAndMetadataContract", ed.ContractName, "ContractName #1");
				Assert.AreEqual ("http://schemas.microsoft.com/2006/04/http/metadata", ed.ContractNamespace, "ContractNamespace #1");
				Assert.AreEqual (0, ed.FilterPriority, "FilterPriority #1");

				EndpointAddress ea = ed.EndpointAddress;
				// TODO

				DispatchRuntime dr = ed.DispatchRuntime;
				// TODO

				cd = (ChannelDispatcher) host.ChannelDispatchers [2];
				Assert.AreEqual (1, cd.Endpoints.Count, "Endpoints.Count");

				ed = cd.Endpoints [0];
				Assert.AreEqual (typeof (EndpointAddressMessageFilter), ed.AddressFilter.GetType (), "AddressFilter #2");
				Assert.AreEqual (cd, ed.ChannelDispatcher, "ChannelDispatcher #2");
				Assert.AreEqual (typeof (MatchAllMessageFilter), ed.ContractFilter.GetType (), "ContractFilter #2");
				Assert.AreEqual ("IHttpGetHelpPageAndMetadataContract", ed.ContractName, "ContractName #2");
				Assert.AreEqual ("http://schemas.microsoft.com/2006/04/http/metadata", ed.ContractNamespace, "ContractNamespace #2");
				Assert.AreEqual (0, ed.FilterPriority, "FilterPriority #2");

				ea = ed.EndpointAddress;
				// TODO

				dr = ed.DispatchRuntime;
				// TODO

				host.Close ();
			}
		}

		[Test]
		public void InitializeRuntime4 () {
			using (ServiceHost host = new ServiceHost (typeof (MyService), new Uri ("http://localhost:8080"))) {
				host.AddServiceEndpoint (typeof (IMyContract), new BasicHttpBinding (), "");
				host.Description.Behaviors.Add (new ServiceMetadataBehavior () { HttpGetEnabled = true, HttpGetUrl = new Uri ("http://localhost:8080/mex") });
				host.Description.Behaviors.Remove<ServiceDebugBehavior> ();

				Assert.AreEqual (0, host.ChannelDispatchers.Count, "ChannelDispatchers.Count #1");

				host.Open ();

				Assert.AreEqual (2, host.ChannelDispatchers.Count, "ChannelDispatchers.Count #2");

				ChannelDispatcher cd = (ChannelDispatcher) host.ChannelDispatchers [1];
				Assert.AreEqual (1, cd.Endpoints.Count, "Endpoints.Count");
				Assert.AreEqual ("ServiceMetadataBehaviorHttpGetBinding", cd.BindingName, "BindingName");
				Assert.AreEqual (host, cd.Host, "Host");
				//Assert.AreEqual (false, cd.IsTransactedAccept, "IsTransactedAccept");
				//Assert.AreEqual (false, cd.IsTransactedReceive, "IsTransactedReceive");
				Assert.AreEqual (MessageVersion.None, cd.MessageVersion, "MessageVersion");

				EndpointDispatcher ed = cd.Endpoints [0];
				Assert.AreEqual (typeof (EndpointAddressMessageFilter), ed.AddressFilter.GetType (), "AddressFilter");
				Assert.AreEqual (cd, ed.ChannelDispatcher, "ChannelDispatcher");
				Assert.AreEqual (typeof (MatchAllMessageFilter), ed.ContractFilter.GetType (), "ContractFilter");
				Assert.AreEqual ("IHttpGetHelpPageAndMetadataContract", ed.ContractName, "ContractName");
				Assert.AreEqual ("http://schemas.microsoft.com/2006/04/http/metadata", ed.ContractNamespace, "ContractNamespace");
				Assert.AreEqual (0, ed.FilterPriority, "FilterPriority");

				EndpointAddress ea = ed.EndpointAddress;
				Assert.AreEqual (new Uri ("http://localhost:8080/mex"), ea.Uri, "Uri");

				DispatchRuntime dr = ed.DispatchRuntime;
				Assert.AreEqual (1, dr.Operations.Count, "Operations.Count");

				DispatchOperation dispOp = dr.Operations [0];
				Assert.AreEqual ("*", dispOp.Action, "Operation.Action");
				Assert.AreEqual ("*", dispOp.ReplyAction, "Operation.ReplyAction");
				Assert.AreEqual ("Get", dispOp.Name, "Operation.Name");
				//Assert.IsNotNull (dispOp.Invoker, "Operation.Invoker");

				host.Close ();
			}
		}

		[Test]
		public void ServiceMetadataExtension1 () {
			using (ServiceHost host = new ServiceHost (typeof (MyService), new Uri ("http://localhost:8080"))) {
				host.AddServiceEndpoint (typeof (IMyContract), new BasicHttpBinding (), "");
				host.Description.Behaviors.Add (new ServiceMetadataBehavior () { HttpGetEnabled = true, HttpGetUrl = new Uri ("http://localhost:8080/mex") });
				host.Description.Behaviors.Remove<ServiceDebugBehavior> ();

				host.Open ();

				Assert.IsNotNull (host.Extensions.Find<ServiceMetadataExtension> (), "ServiceMetadataExtension #1");
				Assert.AreEqual (1, host.Extensions.FindAll<ServiceMetadataExtension> ().Count, "ServiceMetadataExtension #2");

				host.Close ();
			}
		}

Amazon.CDK.AWS.ECS.Host : IHost

Constructors :

public Host()

Methods :

public String get_SourcePath()
public Void set_SourcePath(String value = )
public Type GetType()
public String ToString()
public Boolean Equals(Object obj = )
public Int32 GetHashCode()