Summary description for Domain.
Inheritance: System.Collections.DictionaryBase
Ejemplo n.º 1
0
		public void TestBasic()
		{
			Domain domain = new Domain("default");
			AssertEquals( "default", domain.Name );
			AssertEquals( 0, domain.Count );
		}
Ejemplo n.º 2
0
		public ManagedInstance RegisterManagedObject(Object instance, ManagedObjectName name)
		{
			if (name == null)
			{
				throw new ArgumentNullException("name");
			}
			if (instance == null)
			{
				throw new ArgumentNullException("instance");
			}

			ComponentType cType = MInspector.Inspect(instance);
			MDynamicSupport dynamic = null;

			if (cType == ComponentType.None)
			{
				throw new InvalidComponentException("Component is not a managed component.");
			}
			
			if (cType == ComponentType.Standard)
			{
				dynamic = MDynamicSupportFactory.Create(instance);
			}
			else if (cType == ComponentType.Dynamic)
			{
				dynamic = (MDynamicSupport) instance;
			}

			String domainName = name.Domain;
			Domain domain = null;

			lock(domains)
			{
				domain = domains[domainName];

				if (domain == null)
				{
					domain = new Domain(domainName);
					domains.Add(domain);
				}
			}

			Entry entry = new Entry(instance, dynamic);

			try
			{
				MRegistrationListener registration = instance as MRegistrationListener;

				InvokeBeforeRegister(registration, name);

				lock(domain)
				{
					if (domain.Contains(name))
					{
						throw new InstanceAlreadyRegistredException(name.ToString());
					}

					domain.Add(name, entry);
				}

				InvokeAfterRegister(registration);
			}
			catch(Exception e)
			{
				domain.Remove(name);

				throw e;
			}

			return new ManagedInstance(instance.GetType().FullName, name);
		}