public static void OnEntry(MethodArguments args) { if (DefaultTarget == null) { return; } DefaultTarget.Log(OnEntryLevel, Formatter.Format(Events.OnEnter, args, null)); }
public void IInstanceProviderImplementationShouldReturnCorrectDefault(Type expectedType) { Output.WriteLine($"Expected type is { expectedType }"); object expected = GetDefault(expectedType); IInstanceProvider toTest = new DefaultTarget(expectedType); //shouldn't need a ResolveContext Assert.Equal(expected, toTest.GetInstance(default));
public static void OnException(MethodArguments args, Exception e) { if (DefaultTarget == null) { return; } DefaultTarget.Log(OnExceptionLevel, Formatter.Format(Events.OnException, args, e)); }
public static T GetObject <T>(List <Object> options, DefaultTarget defaultTarget) { for (int i = options.Count - 1; i >= 0; --i) { object option = options[i]; if (option is T) { return((T)option); } } // no found, return the default Type optionType = typeof(T); // for class type , default value is NULL; if (optionType.IsClass) { return(default(T)); } // find the default options FieldInfo[] optionTypeFields = optionType.GetFields(); foreach (FieldInfo field in optionTypeFields) { object[] attributes = s_cachedDefaultAttributes.GetOrAdd(field, fi => fi.GetCustomAttributes(typeof(Options.Default), true)); foreach (Default defaultOption in attributes) { if (Util.FlagsTest(defaultOption.DefaultTarget, defaultTarget)) { object fieldValue = field.GetValue(optionType); return((T)fieldValue); } } } throw new Error("Not default value found for options: " + optionType.Name + " Default Options is " + options); }
public Default(DefaultTarget defaultValue) { DefaultTarget = defaultValue; }
public Default() { DefaultTarget = DefaultTarget.All; }
private void RunBuild(FileInfo buildFile) { Log(Level.Info, "{0} {1}", buildFile.FullName, DefaultTarget); // create new project with same threshold as current project and // increased indentation level, and initialize it using the same // configuration node Project project = new Project(buildFile.FullName, Project); // have the new project inherit properties from the current project if (InheritAll) { StringCollection excludes = new StringCollection(); excludes.Add(Project.NAntPropertyFileName); excludes.Add(Project.NAntPropertyLocation); excludes.Add(Project.NAntPropertyOnSuccess); excludes.Add(Project.NAntPropertyOnFailure); excludes.Add(Project.NAntPropertyProjectBaseDir); excludes.Add(Project.NAntPropertyProjectBuildFile); excludes.Add(Project.NAntPropertyProjectDefault); excludes.Add(Project.NAntPropertyProjectName); excludes.Add(Project.NAntPropertyVersion); this.PropertyAccessor.MergeInto(project, excludes); } // add/overwrite properties foreach (PropertyTask property in OverrideProperties) { // expand properties in context of current project for non-dynamic // properties if (!property.Dynamic) { property.Value = this.PropertyAccessor.ExpandProperties(property.Value, Location); } property.Project = project; property.CallStack = this.CallStack; property.Execute(); } if (InheritRefs) { // pass datatypes thru to the child project project.DataTypeReferences.Inherit(Project.DataTypeReferences); } // handle multiple targets if (DefaultTarget != null) { foreach (string t in DefaultTarget.Split(' ')) { string target = t.Trim(); if (target.Length > 0) { project.BuildTargets.Add(target); } } } Project.ProjectRunResult result; if (this.InheritAll) { result = project.Run(this.CallStack.Clone() as TargetCallStack); } else { result = project.Run(project.RootTargetCallStack); } // run the given build if (!result.Success) { throw new BuildException(string.Concat("Nested build failed: ", result.Exception.Message), result.Exception); } }
private void RunBuild(FileInfo buildFile) { Log(Level.Info, "{0} {1}", buildFile.FullName, DefaultTarget); // create new project with same threshold as current project and // increased indentation level, and initialize it using the same // configuration node Project project = new Project(buildFile.FullName, Project.Threshold, Project.IndentationLevel + 1, Project.ConfigurationNode); // add listeners of current project to new project project.AttachBuildListeners(Project.BuildListeners); // have the new project inherit the runtime framework from the // current project if (Project.RuntimeFramework != null && project.Frameworks.Contains(Project.RuntimeFramework.Name)) { project.RuntimeFramework = project.Frameworks[Project.RuntimeFramework.Name]; } // have the new project inherit the current framework from the // current project if (Project.TargetFramework != null && project.Frameworks.Contains(Project.TargetFramework.Name)) { project.TargetFramework = project.Frameworks[Project.TargetFramework.Name]; } // have the new project inherit properties from the current project if (InheritAll) { StringCollection excludes = new StringCollection(); excludes.Add(Project.NAntPropertyFileName); excludes.Add(Project.NAntPropertyLocation); excludes.Add(Project.NAntPropertyOnSuccess); excludes.Add(Project.NAntPropertyOnFailure); excludes.Add(Project.NAntPropertyProjectBaseDir); excludes.Add(Project.NAntPropertyProjectBuildFile); excludes.Add(Project.NAntPropertyProjectDefault); excludes.Add(Project.NAntPropertyProjectName); excludes.Add(Project.NAntPropertyVersion); project.Properties.Inherit(Properties, excludes); } // add/overwrite properties foreach (PropertyTask property in OverrideProperties) { // expand properties in context of current project for non-dynamic // properties if (!property.Dynamic) { property.Value = Project.ExpandProperties(property.Value, Location); } property.Project = project; property.Execute(); } if (InheritRefs) { // pass datatypes thru to the child project project.DataTypeReferences.Inherit(Project.DataTypeReferences); } // handle multiple targets if (DefaultTarget != null) { foreach (string t in DefaultTarget.Split(' ')) { string target = t.Trim(); if (target.Length > 0) { project.BuildTargets.Add(target); } } } // run the given build if (!project.Run()) { throw new BuildException("Nested build failed. Refer to build log for exact reason."); } }