示例#1
0
		public void RegisterTask (string classname, AssemblyLoadInfo assemblyLoadInfo)
		{
			assemblyInformation.Add (classname, assemblyLoadInfo);
			Assembly assembly;

			if (assemblyLoadInfo.InfoType == LoadInfoType.AssemblyFilename)
				assembly = Assembly.LoadFrom (assemblyLoadInfo.Filename);
			else if (assemblyLoadInfo.InfoType == LoadInfoType.AssemblyName)
				assembly = Assembly.Load (assemblyLoadInfo.AssemblyName);
			else
				assembly = Assembly.Load (assemblyLoadInfo.AssemblyNameString);
			
			Type type = assembly.GetType (classname);
			if (type == null) {
				// search for matching class in case namespace was not used
				foreach (Type exportedType in assembly.GetExportedTypes()) {
					if (exportedType.Name == classname) {
						type = exportedType;
						break;
					}
				}
			}
			typesByFullName.Add (classname, type);
			typesByShortName [GetShortName (classname)] = type;
		}
示例#2
0
		internal void Load (TaskDatabase db)
		{
			AssemblyLoadInfo loadInfo = null;

			if (AssemblyName != null) {
				loadInfo = new AssemblyLoadInfo (AssemblyName, TaskName);
			} else if (AssemblyFile != null) {
				Expression exp = new Expression ();
				// FIXME: test it
				exp.Parse (AssemblyFile, ParseOptions.Split);
				string filename = (string) exp.ConvertTo (project, typeof (string));

				if (Path.IsPathRooted (filename) == false) {
					string ffn;
					if (importedProject != null) {
						ffn = Path.GetDirectoryName (importedProject.FullFileName);
					} else if (project.FullFileName != String.Empty) {
						ffn = Path.GetDirectoryName (project.FullFileName);
					} else {
						ffn = Environment.CurrentDirectory;
					}
					filename = Path.Combine (ffn, filename);
				}
				loadInfo = new AssemblyLoadInfo (LoadInfoType.AssemblyFilename, filename, null, null, null, null, TaskName);
			}

			db.RegisterTask (TaskName, loadInfo);
		}