public StObjEngine(IActivityMonitor monitor, StObjEngineConfiguration config) { Throw.CheckNotNullArgument(monitor); Throw.CheckNotNullArgument(config); _monitor = monitor; _config = new RunningStObjEngineConfiguration(config); }
/// <summary> /// Creates a xml element from this <see cref="BinPathConfiguration"/>. /// <see cref="AspectConfigurations"/> are cloned. /// </summary> /// <returns>A new element.</returns> public XElement ToXml() { return(new XElement(StObjEngineConfiguration.xBinPath, String.IsNullOrWhiteSpace(Name) ? null : new XAttribute(StObjEngineConfiguration.xName, Name), new XAttribute(StObjEngineConfiguration.xPath, Path), !OutputPath.IsEmptyPath ? new XElement(StObjEngineConfiguration.xOutputPath, OutputPath) : null, !ProjectPath.IsEmptyPath ? new XElement(StObjEngineConfiguration.xProjectPath, ProjectPath) : null, new XElement(StObjEngineConfiguration.xCompileOption, CompileOption.ToString()), GenerateSourceFiles ? null : new XElement(StObjEngineConfiguration.xGenerateSourceFiles, false), StObjEngineConfiguration.ToXml(StObjEngineConfiguration.xAssemblies, StObjEngineConfiguration.xAssembly, Assemblies), StObjEngineConfiguration.ToXml(StObjEngineConfiguration.xExcludedTypes, StObjEngineConfiguration.xType, ExcludedTypes), new XElement(StObjEngineConfiguration.xTypes, Types.Select(t => new XElement(StObjEngineConfiguration.xType, new XAttribute(StObjEngineConfiguration.xName, t.Name), t.Kind != AutoServiceKind.None ? new XAttribute(StObjEngineConfiguration.xKind, t.Kind) : null, t.Optional ? new XAttribute(StObjEngineConfiguration.xOptional, true) : null))), AspectConfigurations.Select(e => new XElement(e)))); }
/// <summary> /// Initializes a new <see cref="BinPathConfiguration"/> from a Xml element. /// All <see cref="AspectConfigurations"/> (extra elements) are cloned. /// </summary> /// <param name="e">The Xml element.</param> public BinPathConfiguration(XElement e) { Name = (string?)e.Attribute(StObjEngineConfiguration.xName); Path = (string?)e.Attribute(StObjEngineConfiguration.xPath); OutputPath = (string?)e.Element(StObjEngineConfiguration.xOutputPath); ProjectPath = (string?)e.Element(StObjEngineConfiguration.xProjectPath); if (e.Element("SkipCompilation") != null) { throw new XmlException(@"Element SkipCompilation must be replaced with CompileOption that can be be ""None"", ""Parse"" or ""Compile"". It defaults to ""None""."); } CompileOption = e.Element(StObjEngineConfiguration.xCompileOption)?.Value.ToUpperInvariant() switch { null => CompileOption.None, "NONE" => CompileOption.None, "PARSE" => CompileOption.Parse, "COMPILE" => CompileOption.Compile, _ => throw new XmlException(@"Expected CompileOption to be ""None"", ""Parse"" or ""Compile"".") }; GenerateSourceFiles = (bool?)e.Element(StObjEngineConfiguration.xGenerateSourceFiles) ?? true; Assemblies = new HashSet <string>(StObjEngineConfiguration.FromXml(e, StObjEngineConfiguration.xAssemblies, StObjEngineConfiguration.xAssembly)); ExcludedTypes = new HashSet <string>(StObjEngineConfiguration.FromXml(e, StObjEngineConfiguration.xExcludedTypes, StObjEngineConfiguration.xType)); Types = e.Elements(StObjEngineConfiguration.xTypes).Elements(StObjEngineConfiguration.xType).Select(c => new TypeConfiguration(c)).ToList(); AspectConfigurations = e.Elements().Where(e => e.Name != StObjEngineConfiguration.xTypes && e.Name != StObjEngineConfiguration.xExcludedTypes && e.Name != StObjEngineConfiguration.xAssemblies && e.Name != StObjEngineConfiguration.xGenerateSourceFiles && e.Name != StObjEngineConfiguration.xCompileOption && e.Name != StObjEngineConfiguration.xProjectPath && e.Name != StObjEngineConfiguration.xOutputPath && e.Name != StObjEngineConfiguration.xPath && e.Name != StObjEngineConfiguration.xName) .Select(e => new XElement(e)) .ToList(); }
public static StObjEngineResult Run(IActivityMonitor monitor, StObjCollectorResult result, StObjEngineConfiguration config) { Throw.CheckNotNullArgument(monitor); Throw.CheckNotNullArgument(result); Throw.CheckNotNullArgument(config); Throw.CheckArgument(config.BinPaths.Select(b => b.Path).Distinct().Count() == 1); var e = new StObjEngine(monitor, config); return(e.Run(new MonoResolver(result))); }
internal RunningStObjEngineConfiguration(StObjEngineConfiguration configuration) { _binPathGroups = new List <RunningBinPathGroup>(); Configuration = configuration; }