コード例 #1
0
ファイル: TaskLogger.cs プロジェクト: dougrathbone/mbunit-v3
        public TaskLogger(Task task)
        {
            if (task == null)
                throw new ArgumentNullException("task");

            this.task = task;
        }
コード例 #2
0
ファイル: XnaContentProject.cs プロジェクト: orj/xnananttasks
        public XnaContentProject(Task task, string msBuildPath, string xnaInstallPath)
        {
            m_engine = new Engine(msBuildPath);
            m_engine.RegisterLogger(new XnaContentLogger(task));
            m_project = new Project(m_engine);

            m_project.AddNewUsingTaskFromAssemblyName("BuildContent", "Microsoft.Xna.Framework.Content.Pipeline, Version=1.0.0.0, Culture=neutral, PublicKeyToken=6d5c3888ef60e27d");
            m_project.AddNewUsingTaskFromAssemblyName("BuildXact", "Microsoft.Xna.Framework.Content.Pipeline, Version=1.0.0.0, Culture=neutral, PublicKeyToken=6d5c3888ef60e27d");

            // Add our Content Pipeline Assemblies
            m_pipelineGroup = m_project.AddNewItemGroup();
            m_contentGroup = m_project.AddNewItemGroup();

            m_contentTarget = m_project.Targets.AddNewTarget("_BuildXNAContentLists");

            // Add our Build target
            m_xnaTarget = m_project.Targets.AddNewTarget("Build");
            m_xnaTarget.DependsOnTargets = "_BuildXNAContentLists";

            // Add Default Pipeline Assemblies.
            AddPilepineAssembly(xnaInstallPath + "Microsoft.Xna.Framework.Content.Pipeline.EffectImporter.dll");
            AddPilepineAssembly(xnaInstallPath + "Microsoft.Xna.Framework.Content.Pipeline.FBXImporter.dll");
            AddPilepineAssembly(xnaInstallPath + "Microsoft.Xna.Framework.Content.Pipeline.TextureImporter.dll");
            AddPilepineAssembly(xnaInstallPath + "Microsoft.Xna.Framework.Content.Pipeline.XImporter.dll");
        }
コード例 #3
0
 protected InstallerCreationCommand(MSIBase msi, NAnt.Core.Task task, Location location, XmlNode node) {
     this.msi = msi;
     this.task = task;
     this.location = location;
     this.node = node;
     guidCounter = msi.output.GetHashCode();
 }
コード例 #4
0
        public NAntRunListener(Task task)
        {
            Ensure.ArgumentIsNotNull(task, "task");
            _task = task;

            UpdateNAntProperties(_task.Properties, 0, 0, 0, 0, 0, 0);
        }
コード例 #5
0
		public TeamCityMessageProvider(TeamCityLogWriter writer, Task taskToUseForLogging)
		{
			Ensure.ArgumentIsNotNull(writer, "writer");
			Ensure.ArgumentIsNotNull(taskToUseForLogging, "taskToUseForLogging");

			_writer = writer;
			_writer.TaskToUseForLogging = taskToUseForLogging;
		}
コード例 #6
0
        public static void RenderReport(ReportResult result, Task task)
        {
            Ensure.ArgumentIsNotNull(result, "result");
            Ensure.ArgumentIsNotNull(task, "task");

            ITeamCityMessageProvider messageProvider = IoC.Resolve<ITeamCityMessageProvider>(new { taskToUseForLogging = task });

            TeamCityReportGenerator report = new TeamCityReportGenerator();
            report.Render(result, messageProvider);
        }
コード例 #7
0
        public static DefinedTaskContainer Create(Task parent, XmlNode taskNode)
        {
            DefinedTaskContainer container = new DefinedTaskContainer();
            container.Parent = parent;
            container.Project = parent.Project;
            container.NamespaceManager = parent.NamespaceManager;
            container.XmlNode = taskNode;

            return container;
        }
        protected override void Before_each_spec()
        {
            PropertyDictionary propertyDictionary = Mocks.Stub<PropertyDictionary>((Project) null);

            _task = Mocks.DynamicMock<Task>();
            SetupResult.For(_task.Properties).Return(propertyDictionary);

            Mocks.Replay(_task);

            _sut = new NAntRunListener(_task);
        }
        protected override void Before_each_spec()
        {
            _specificationInfo = new SpecificationInfo("Spec", "Type");

            PropertyDictionary propertyDictionary = Mocks.Stub<PropertyDictionary>((Project) null);

            _task = Mocks.StrictMock<Task>();
            SetupResult.For(_task.Properties).Return(propertyDictionary);

            Mocks.Replay(_task);

            _sut = new NAntRunListener(_task);
        }
        protected override void Before_each_spec()
        {
            _contextInfo = new ContextInfo("Context", "Concern", "TypeName", "Namespace", "AssemblyName");

            PropertyDictionary propertyDictionary = Mocks.Stub<PropertyDictionary>((Project) null);

            _task = Mocks.DynamicMock<Task>();
            SetupResult.For(_task.Properties).Return(propertyDictionary);

            Mocks.Replay(_task);

            _sut = new NAntRunListener(_task);
        }
コード例 #11
0
ファイル: MacroDefInvocation.cs プロジェクト: harib/macrodef
        public MacroDefInvocation(string name, Task task,
		                          XmlNode invocationXml,
		                          ArrayList attributeList,
		                          MacroDefSequential sequential,
		                          ArrayList elements)
        {
            this.name = name;
            this.task = task;
            this.invocationXml = invocationXml;
            this.attributeList = attributeList;
            this.sequential = sequential;
            this.elements = elements;
        }
コード例 #12
0
ファイル: MacroDefInvocation.cs プロジェクト: harib/macrodef
        private static void RestoreProperties(ArrayList attributeList, Task task, PropertyDictionary oldValues)
        {
            PropertyDictionary projectProperties = task.Project.Properties;
            foreach (MacroAttribute macroAttribute in attributeList)
            {
                string localPropertyName = macroAttribute.LocalPropertyName;
                string oldValue = oldValues[localPropertyName];

                if (projectProperties.Contains(localPropertyName))
                    projectProperties.Remove(localPropertyName);
                if (oldValue != null)
                    projectProperties.Add(localPropertyName, oldValue);
            }
        }
コード例 #13
0
ファイル: NAntLogger.cs プロジェクト: SteGriff/NCover
		public static void AddNAntListener(Task task)
		{
			try
			{
				if(task.Verbose)
					OutputType.Level = TraceLevel.Verbose;
			}
			catch
			{
				// Happens because NAnt throws an exception!
			}

			if(Trace.Listeners["NAnt"] != null)
				Trace.Listeners.Remove("NAnt");

			Trace.Listeners.Add(new NAntTraceListener(task));
		}
コード例 #14
0
ファイル: NAntLogger.cs プロジェクト: RoastBoy/nant
        internal static NAntLogger Create(NAnt.Core.FrameworkInfo framework, Task task, NAntLoggerVerbosity verbosity, NAnt.MSBuild.BuildEngine.Engine engine) {
            CodeDomProvider codeDomProvider = CodeDomProvider.CreateProvider("C#");
            CompilerParameters par = new CompilerParameters();
            AssemblyName msbuildFrameworkName = engine.Assembly.GetName();
            msbuildFrameworkName.Name = "Microsoft.Build.Framework";
            Assembly msbuildFramework = Assembly.Load(msbuildFrameworkName);

            par.ReferencedAssemblies.Add(msbuildFramework.Location);
            par.ReferencedAssemblies.Add(typeof(NAnt.Core.Task).Assembly.Location);
            par.ReferencedAssemblies.Add(typeof(NAntLogger).Assembly.Location);
            par.GenerateInMemory = true;
            CompilerResults res = codeDomProvider.CompileAssemblyFromSource(par, _impl);
            if (res.Errors.HasErrors) {
                return null;
            }

            Type t = res.CompiledAssembly.GetType("NAntLoggerImpl");
            return (NAntLogger)Activator.CreateInstance(t, task, verbosity);
        }
コード例 #15
0
ファイル: Project.cs プロジェクト: skolima/NAnt
        /// <summary>
        /// Writes a <see cref="Task" /> task level message to the build log 
        /// with the given <see cref="Level" />.
        /// </summary>
        /// <param name="task">The <see cref="Task" /> from which the message originated.</param>
        /// <param name="messageLevel">The <see cref="Level" /> to log at.</param>
        /// <param name="message">The message to log.</param>
        public void Log(Task task, Level messageLevel, string message)
        {
            BuildEventArgs eventArgs = new BuildEventArgs(task);

            eventArgs.Message = message;
            eventArgs.MessageLevel = messageLevel;
            OnMessageLogged(eventArgs);
        }
コード例 #16
0
ファイル: TypeFactory.cs プロジェクト: julianhaslinger/nant
        /// <summary>
        /// Scans a given <see cref="Type" /> for tasks.
        /// </summary>
        /// <param name="extensionAssembly">The <see cref="ExtensionAssembly" /> containing the <see cref="Type" /> to scan.</param>
        /// <param name="type">The <see cref="Type" /> to scan.</param>
        /// <param name="task">The <see cref="Task" /> which will be used to output messages to the build log.</param>
        /// <returns>
        /// <see langword="true" /> if <paramref name="type" /> represents a
        /// <see cref="Task" />; otherwise, <see langword="false" />.
        /// </returns>
        private static bool ScanTypeForTasks(ExtensionAssembly extensionAssembly, Type type, Task task)
        {
            try {
                TaskNameAttribute taskNameAttribute = (TaskNameAttribute)
                    Attribute.GetCustomAttribute(type, typeof(TaskNameAttribute));

                if (type.IsSubclassOf(typeof(Task)) && !type.IsAbstract && taskNameAttribute != null) {
                    task.Log(Level.Debug, string.Format(CultureInfo.InvariantCulture,
                        ResourceUtils.GetString("String_CreatingTaskBuilder"),
                        type.Name));

                    TaskBuilder tb = new TaskBuilder(extensionAssembly, type.FullName);
                    if (TaskBuilders[tb.TaskName] == null) {
                        task.Log(Level.Debug, string.Format(CultureInfo.InvariantCulture,
                            ResourceUtils.GetString("String_AddingTask"), tb.TaskName,
                            GetAssemblyLocation(tb.Assembly), tb.ClassName));

                        TaskBuilders.Add(tb);
                    }

                    // specified type represents a task
                    return true;
                } else {
                    // specified type does not represent valid task
                    return false;
                }
            } catch {
                task.Log(Level.Error, "Failure scanning \"{0}\" for tasks.",
                    type.AssemblyQualifiedName);
                throw;
            }
        }
コード例 #17
0
ファイル: TypeFactory.cs プロジェクト: julianhaslinger/nant
        /// <summary>
        /// Scans a given <see cref="Type" /> for functions.
        /// </summary>
        /// <param name="type">The <see cref="Type" /> to scan.</param>
        /// <param name="task">The <see cref="Task" /> which will be used to output messages to the build log.</param>
        /// <returns>
        /// <see langword="true" /> if <paramref name="type" /> represents a
        /// valid set of funtions; otherwise, <see langword="false" />.
        /// </returns>
        private static bool ScanTypeForFunctions(Type type, Task task)
        {
            try {
                FunctionSetAttribute functionSetAttribute = (FunctionSetAttribute)
                    Attribute.GetCustomAttribute(type, typeof(FunctionSetAttribute));
                if (functionSetAttribute == null) {
                    // specified type does not represent a valid functionset
                    return false;
                }

                bool acceptType = (type == typeof(ExpressionEvaluator));

                if (type.IsSubclassOf(typeof(FunctionSetBase)) && !type.IsAbstract) {
                    acceptType = true;
                }

                if (acceptType) {
                    string prefix = functionSetAttribute.Prefix;
                    if (prefix != null && prefix != String.Empty) {
                        prefix += "::";
                    } else {
                        task.Log(Level.Warning, "Ignoring functions in type \"{0}\":"
                            + " no prefix was set.", type.AssemblyQualifiedName);

                        // specified type does not represent a valid functionset
                        return false;
                    }

                    //
                    // add public static/instance methods
                    //
                    foreach (MethodInfo info in type.GetMethods(BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static)) {
                        FunctionAttribute functionAttribute = (FunctionAttribute)
                            Attribute.GetCustomAttribute(info, typeof(FunctionAttribute));
                        if (functionAttribute != null)
                            RegisterFunction(prefix + functionAttribute.Name, info);
                    }

                    // specified type represents a valid functionset
                    return true;
                } else {
                    // specified type does not represent a valid functionset
                    return false;
                }
            } catch {
                task.Log(Level.Error, "Failure scanning \"{0}\" for functions.",
                    type.AssemblyQualifiedName);
                throw;
            }
        }
コード例 #18
0
ファイル: VcProject.cs プロジェクト: TheGreatMasterG/nant
        private void ExecuteInProjectDirectory(Task task)
        {
            string oldBaseDir = SolutionTask.Project.BaseDirectory;
            SolutionTask.Project.BaseDirectory = ProjectDirectory.FullName;

            try {
                // increment indentation level
                task.Project.Indent();

                // execute task
                task.Execute();
            } finally {
                // restore original base directory
                SolutionTask.Project.BaseDirectory = oldBaseDir;

                // restore indentation level
                task.Project.Unindent();
            }
        }
コード例 #19
0
ファイル: Log.cs プロジェクト: anthonyheckmann/NAnt-cvsclone
 /// <summary>
 /// Initializes a new instance of the <see cref="BuildEventArgs" />
 /// class for a <see cref="Task" /> level event.
 /// </summary>
 /// <param name="task">The <see cref="Task" /> that emitted the event.</param>
 public BuildEventArgs(Task task)
 {
     _project = task.Project;
     _target = task.Parent as Target;
     _task = task;
 }
コード例 #20
0
ファイル: TypeFactory.cs プロジェクト: julianhaslinger/nant
        public static bool ScanAssembly(Assembly assembly, Task task)
        {
            task.Log(Level.Verbose, "Scanning assembly \"{0}\" for extensions.",
                assembly.GetName().Name);

            foreach (Type type in assembly.GetExportedTypes()) {
                foreach (MethodInfo methodInfo in type.GetMethods()) {
                    if (methodInfo.IsStatic) {
                        task.Log(Level.Verbose, "Found method {0}.",
                            methodInfo.Name);
                    }
                }
            }

            bool isExtensionAssembly = false;

            ExtensionAssembly extensionAssembly = new ExtensionAssembly (
                assembly);

            Type[] types;

            try {
                types = assembly.GetTypes();
            }
            catch(ReflectionTypeLoadException ex) {
                if(ex.LoaderExceptions != null && ex.LoaderExceptions.Length > 0) {
                    throw ex.LoaderExceptions[0];
                }

                throw;
            }

            foreach (Type type in types) {
                //
                // each extension type is exclusive, meaning a given type
                // cannot be both a task and data type
                //
                // so it doesn't make sense to scan a type for, for example,
                // data types if the type has already been positively
                // identified as a task
                //

                bool extensionFound = ScanTypeForTasks(extensionAssembly,
                    type, task);

                if (!extensionFound) {
                    extensionFound = ScanTypeForDataTypes(extensionAssembly,
                        type, task);
                }

                if (!extensionFound) {
                    extensionFound = ScanTypeForFunctions(type, task);
                }

                if (!extensionFound) {
                    extensionFound = ScanTypeForFilters(extensionAssembly,
                        type, task);
                }

                if (!extensionFound) {
                    extensionFound = _pluginScanner.ScanTypeForPlugins(
                        extensionAssembly, type, task);
                }

                // if extension is found in type, then mark assembly as
                // extension assembly
                isExtensionAssembly = isExtensionAssembly || extensionFound;
            }

            // if no extension could be found at all, then we might be dealing
            // with an extension assembly that was built using an older version
            // of NAnt(.Core)
            if (!isExtensionAssembly) {
                AssemblyName coreAssemblyName = Assembly.GetExecutingAssembly().
                    GetName(false);

                foreach (AssemblyName assemblyName in assembly.GetReferencedAssemblies()) {
                    if (assemblyName.Name == coreAssemblyName.Name) {
                        // the given assembly references NAnt.Core, so check whether
                        // it doesn't reference an older version of NAnt.Core
                        if (assemblyName.Version != coreAssemblyName.Version) {
                            task.Log(Level.Warning, "Assembly \"{0}\" is built"
                                + " using version {1} of NAnt. If any problems"
                                + " arise, then try using a version that is built"
                                + " for NAnt version {2}.", assembly.GetName().Name,
                                assemblyName.Version, coreAssemblyName.Version);
                        }
                    }
                }
            }

            return isExtensionAssembly;
        }
コード例 #21
0
ファイル: TypeFactory.cs プロジェクト: julianhaslinger/nant
 public static bool ScanAssembly(string assemblyFile, Task task)
 {
     Assembly assembly = Assembly.LoadFrom(assemblyFile);
     return ScanAssembly(assembly, task);
 }
コード例 #22
0
 public NAntLogger(Task task)
 {
     this.task = task;
 }
コード例 #23
0
ファイル: XnaContentLogger.cs プロジェクト: orj/xnananttasks
 public XnaContentLogger(Task task)
 {
     m_task = task;
 }
コード例 #24
0
ファイル: TypeFactory.cs プロジェクト: vardars/ci-factory
        /// <summary>
        /// Scans a given <see cref="Type" /> for tasks.
        /// </summary>
        /// <param name="type">The <see cref="Type" /> to scan.</param>
        /// <param name="task">The <see cref="Task" /> which will be used to output messages to the build log.</param>
        /// <returns>
        /// <see langword="true" /> if <paramref name="type" /> represents a
        /// <see cref="Task" />; otherwise, <see langword="false" />.
        /// </returns>
        private static bool ScanTypeForTasks(Type type, Task task)
        {
            try {
                TaskNameAttribute taskNameAttribute = (TaskNameAttribute)
                    Attribute.GetCustomAttribute(type, typeof(TaskNameAttribute));

                if (type.IsSubclassOf(typeof(Task)) && !type.IsAbstract && taskNameAttribute != null) {
                    task.Log(Level.Debug, "Creating TaskBuilder for \"{0}\".",
                        type.Name);
                    TaskBuilder tb = new TaskBuilder(type.FullName, type.Assembly.Location);
                    if (TaskBuilders[tb.TaskName] == null) {
                        task.Log(Level.Debug, "Adding \"{0}\" from {1}:{2}.",
                            tb.TaskName, tb.AssemblyFileName, tb.ClassName);

                        TaskBuilders.Add(tb);
                        foreach(WeakReference wr in _projects) {
                            if (!wr.IsAlive) {
                                task.Log(Level.Debug, "WeakReference for project is dead.");
                                continue;
                            }
                            Project p = wr.Target as Project;
                            if (p == null) {
                                task.Log(Level.Debug, "WeakReference is not a"
                                    + " project! This should not be possible.");
                                continue;
                            }
                            UpdateProjectWithBuilder(p, tb);
                        }
                    }

                    // specified type represents a task
                    return true;
                } else {
                    // specified type does not represent valid task
                    return false;
                }
            } catch {
                task.Log(Level.Error, "Failure scanning \"{0}\" for tasks.",
                    type.AssemblyQualifiedName);
                throw;
            }
        }
コード例 #25
0
ファイル: ProjectBase.cs プロジェクト: smaclell/NAnt
        /// <summary>
        /// Copies the specified file if the destination file does not exist, or
        /// the source file has been modified since it was previously copied.
        /// </summary>
        /// <param name="srcFile">The file to copy.</param>
        /// <param name="destFile">The destination file.</param>
        /// <param name="parent">The <see cref="Task" /> in which context the operation will be performed.</param>
        protected void CopyFile(FileInfo srcFile, FileInfo destFile, Task parent)
        {
            // create instance of Copy task
            CopyTask ct = new CopyTask();

            // parent is solution task
            ct.Parent = parent;

            // inherit project from parent task
            ct.Project = parent.Project;

            // inherit namespace manager from parent task
            ct.NamespaceManager = parent.NamespaceManager;

            // inherit verbose setting from parent task
            ct.Verbose = parent.Verbose;

            // only output warning messages or higher, unless
            // we're running in verbose mode
            if (!ct.Verbose) {
                ct.Threshold = Level.Warning;
            }

            // make sure framework specific information is set
            ct.InitializeTaskConfiguration();

            // set parent of child elements
            ct.CopyFileSet.Parent = ct;

            // inherit project for child elements from containing task
            ct.CopyFileSet.Project = ct.Project;

            // inherit namespace manager from containing task
            ct.CopyFileSet.NamespaceManager = ct.NamespaceManager;

            // set file to copy
            ct.SourceFile = srcFile;

            // set file
            ct.ToFile = destFile;

            // increment indentation level
            ct.Project.Indent();

            try {
                // execute task
                ct.Execute();
            } finally {
                // restore indentation level
                ct.Project.Unindent();
            }
        }
コード例 #26
0
ファイル: Log.cs プロジェクト: anthonyheckmann/NAnt-cvsclone
 /// <summary>
 /// Initializes a new instance of the <see cref="LogWriter" /> class 
 /// for the specified <see cref="Task" /> with the specified output 
 /// level and format provider.
 /// </summary>
 /// <param name="task">Determines the indentation level.</param>
 /// <param name="outputLevel">The <see cref="Level" /> with which messages will be output to the build log.</param>
 /// <param name="formatProvider">An <see cref="IFormatProvider" /> object that controls formatting.</param>
 public LogWriter(Task task, Level outputLevel, IFormatProvider formatProvider)
     : base(formatProvider)
 {
     _task = task;
     _outputLevel = outputLevel;
 }
コード例 #27
0
ファイル: TypeFactory.cs プロジェクト: julianhaslinger/nant
        public static void ScanDir(string path, Task task, bool failOnError)
        {
            // don't do anything if we don't have a valid directory path
            if (String.IsNullOrEmpty(path)) {
                return;
            }

            task.Log(Level.Info, "Scanning directory \"{0}\" for extension"
                + " assemblies.", path);

            // scan all dll's for tasks, types and functions
            DirectoryScanner scanner = new DirectoryScanner();
            scanner.BaseDirectory = new DirectoryInfo(path);
            scanner.Includes.Add("*.dll");

            foreach (string assemblyFile in scanner.FileNames) {
                try {
                    TypeFactory.ScanAssembly(assemblyFile, task);
                } catch (Exception ex) {
                    string msg = string.Format(CultureInfo.InvariantCulture,
                        "Failure scanning \"{0}\" for extensions", assemblyFile);

                    if (failOnError) {
                        throw new BuildException(msg + ".",
                            Location.UnknownLocation, ex);
                    }

                    task.Log(Level.Error, msg + ": " + assemblyFile, ex.Message);
                }
            }
        }
コード例 #28
0
ファイル: NAntLogger.cs プロジェクト: jgsteeler/roundhouse
 public NAntLogger(ConfigurationPropertyHolder configuration)
 {
     nant_task = configuration.NAntTask;
 }
コード例 #29
0
ファイル: TypeFactory.cs プロジェクト: julianhaslinger/nant
        /// <summary>
        /// Scans a given <see cref="Type" /> for data type.
        /// </summary>
        /// <param name="extensionAssembly">The <see cref="ExtensionAssembly" /> containing the <see cref="Type" /> to scan.</param>
        /// <param name="type">The <see cref="Type" /> to scan.</param>
        /// <param name="task">The <see cref="Task" /> which will be used to output messages to the build log.</param>
        /// <returns>
        /// <see langword="true" /> if <paramref name="type" /> represents a
        /// data type; otherwise, <see langword="false" />.
        /// </returns>
        private static bool ScanTypeForDataTypes(ExtensionAssembly extensionAssembly, Type type, Task task)
        {
            try {
                ElementNameAttribute elementNameAttribute = (ElementNameAttribute)
                    Attribute.GetCustomAttribute(type, typeof(ElementNameAttribute));

                if (type.IsSubclassOf(typeof(DataTypeBase)) && !type.IsAbstract && elementNameAttribute != null) {
                    logger.Info(string.Format(CultureInfo.InvariantCulture,
                        ResourceUtils.GetString("String_CreatingDataTypeBaseBuilder"), type.Name));
                    DataTypeBaseBuilder dtb = new DataTypeBaseBuilder(extensionAssembly, type.FullName);
                    if (DataTypeBuilders[dtb.DataTypeName] == null) {
                        logger.Debug(string.Format(CultureInfo.InvariantCulture,
                            ResourceUtils.GetString("String_AddingDataType"), dtb.DataTypeName,
                            GetAssemblyLocation(dtb.Assembly), dtb.ClassName));

                        DataTypeBuilders.Add(dtb);
                    }

                    // specified type represents a data type
                    return true;
                } else {
                    // specified type does not represent valid data type
                    return false;
                }
            } catch {
                task.Log(Level.Error, "Failure scanning \"{0}\" for data types.",
                    type.AssemblyQualifiedName);
                throw;
            }
        }
コード例 #30
0
ファイル: TypeFactory.cs プロジェクト: julianhaslinger/nant
        /// <summary>
        /// Scans a given <see cref="Type" /> for filters.
        /// </summary>
        /// <param name="extensionAssembly">The <see cref="ExtensionAssembly" /> containing the <see cref="Type" /> to scan.</param>
        /// <param name="type">The <see cref="Type" /> to scan.</param>
        /// <param name="task">The <see cref="Task" /> which will be used to output messages to the build log.</param>
        /// <returns>
        /// <see langword="true" /> if <paramref name="type" /> represents a
        /// <see cref="Filter" />; otherwise, <see langword="false" />.
        /// </returns>
        private static bool ScanTypeForFilters(ExtensionAssembly extensionAssembly, Type type, Task task)
        {
            try {
                ElementNameAttribute elementNameAttribute = (ElementNameAttribute)
                    Attribute.GetCustomAttribute(type, typeof(ElementNameAttribute));

                if (type.IsSubclassOf(typeof(Filter)) && !type.IsAbstract && elementNameAttribute != null) {
                    task.Log(Level.Debug, "Creating FilterBuilder for \"{0}\".",
                        type.Name);
                    FilterBuilder builder = new FilterBuilder(extensionAssembly, type.FullName);
                    if (FilterBuilders[builder.FilterName] == null) {
                        FilterBuilders.Add(builder);

                        task.Log(Level.Debug, "Adding filter \"{0}\" from {1}:{2}.",
                            builder.FilterName, GetAssemblyLocation(builder.Assembly),
                            builder.ClassName);
                    }

                    // specified type represents a filter
                    return true;
                }

                // specified type does not represent a valid filter
                return false;
            } catch {
                task.Log(Level.Error, "Failure scanning \"{0}\" for filters.",
                    type.AssemblyQualifiedName);
                throw;
            }
        }
コード例 #31
0
 public XnaContentLogger(Task task)
 {
     m_task = task;
 }