public IComponentAdapter RegisterComponentImplementation(ObjectTypeSettings componentImplementationClassName,
		                                                         string[] parameterTypesAsString,
		                                                         string[] parameterValuesAsString)
		{
			Type type = TypeLoader.GetType(componentImplementationClassName);
			return RegisterComponentImplementation(parameterTypesAsString, parameterValuesAsString, type, type);
		}
		public IComponentAdapter RegisterComponentImplementation(object key, ObjectTypeSettings componentImplementationClassName)
		{
			return picoContainer.RegisterComponentImplementation(key, TypeLoader.GetType(componentImplementationClassName));
		}
		public IComponentAdapter RegisterComponentImplementation(ObjectTypeSettings typeSettings)
		{
			return picoContainer.RegisterComponentImplementation(TypeLoader.GetType(typeSettings));
		}
Exemple #4
0
		public static Type GetType(ObjectTypeSettings typeSettings)
		{
			Type type = TypeMap[typeSettings.Name] as Type;
			if (type != null)
			{
				return type;
			}

			Assembly assemblyInstance = null;

			try
			{
				if (typeSettings.Assembly != null)
				{
					assemblyInstance = Assembly.Load(typeSettings.Assembly);
				}
				else
				{
					assemblyInstance = Assembly.GetExecutingAssembly();
				}
			}
			catch (FileNotFoundException e)
			{
				// Maybe it is a in memory assembly try it
				foreach (Assembly a in AppDomain.CurrentDomain.GetAssemblies())
				{
					if (a.FullName.Replace(" ", "") == typeSettings.Assembly)
					{
						assemblyInstance = a;
						break;
					}
				}

				if (assemblyInstance == null)
				{
					throw new TypeLoadException("Can not load the assembly " + typeSettings.Assembly + " needed for the type: " + typeSettings.Type, e);
				}
			}

			try
			{
				type = assemblyInstance.GetType(typeSettings.Type, true, false);
				TypeMap.Add(typeSettings.Name, type);

				return type;
			}
			catch (Exception ex)
			{
				Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
				foreach (Assembly assembly in assemblies)
				{
					try
					{
						type = assembly.GetType(typeSettings.Type, true, false);
						TypeMap.Add(typeSettings.Name, type);

						return type;
					}
					catch (Exception)
					{
					}
				}
				throw ex;
			}

		}
		public void FiveQualifiers()
		{
			ObjectTypeSettings ot = new ObjectTypeSettings("Test, aassd,fdf,aaa,ads");
			Assert.IsNotNull(ot.Name);
			Assert.AreEqual("aassd,fdf,aaa,ads", ot.Assembly);
		}
		public void TwoQualifiers()
		{
			ObjectTypeSettings ot = new ObjectTypeSettings("Test, aassd");
			Assert.IsNotNull(ot.Name);
			Assert.AreEqual("aassd", ot.Assembly);
		}
		public void OneQualifier()
		{
			ObjectTypeSettings ot = new ObjectTypeSettings("Test");
			Assert.IsNotNull(ot.Name);
			Assert.IsNull(ot.Assembly);
		}