public static List <Structure> LoadXmlFile(string filename) { XmlDocument document = new XmlDocument(); document.Load(filename); ProfileReader reader = new ProfileReader(); return(reader.Read(document)); }
public void SetUp() { var writer = new DeploymentWriter("clonewars"); var recipeDefinition = writer.RecipeFor("r1"); var host = recipeDefinition.HostFor("h1"); host.AddDirective(new SimpleSettings { One = "one", Two = "two" }); host.AddDirective(new OneSettings() { Name = "Jeremy", Age = 37 }); host.AddReference(new BottleReference() { Name = "bottle1" }); host.AddReference(new BottleReference() { Name = "bottle2" }); recipeDefinition.HostFor("h2").AddProperty <ThreeSettings>(x => x.Direction, "North"); recipeDefinition.HostFor("h3").AddProperty <TwoSettings>(x => x.City, "Austin"); writer.RecipeFor("r2").HostFor("h3").AddProperty <SimpleSettings>(x => x.One, "one"); writer.RecipeFor("r3").HostFor("h3").AddProperty <SimpleSettings>(x => x.Two, "two"); writer.RecipeFor("r4").HostFor("h4").AddProperty <SimpleSettings>(x => x.Two, "ten"); writer.RecipeFor("r4").HostFor("h5").AddProperty <SimpleSettings>(x => x.Two, "ten"); writer.RecipeFor("r4").HostFor("h5").AddProperty <SimpleSettings>(x => x.One, "*{dbName}*"); writer.AddEnvironmentSetting <SimpleSettings>(x => x.Two, "h4", "env-value"); writer.AddEnvironmentSetting("dbName", "blue"); writer.Flush(FlushOptions.Wipeout); var reader = new ProfileReader(new RecipeSorter(), new DeploymentSettings("clonewars"), new FileSystem()); theHosts = reader.Read(); }
public static void Main(string [] args) { var path = ProcessArguments(args); if (!File.Exists(path)) { Error($"'{path}' doesn't exist."); Environment.Exit(3); } if (args.Length == 1) { Modules = Types = Methods = true; } var reader = new ProfileReader(); ProfileData pd; using (var stream = new FileStream(path, FileMode.Open)) { if (Verbose) { ColorWriteLine($"Reading '{path}'...", ConsoleColor.Yellow); } pd = reader.Read(stream); } List <MethodRecord> methods = pd.Methods; ICollection <TypeRecord> types = pd.Types; ICollection <ModuleRecord> modules = pd.Modules; if (FilterMethod != null || FilterType != null || FilterModule != null) { methods = new List <MethodRecord> (); types = new HashSet <TypeRecord> (); modules = new HashSet <ModuleRecord> (); foreach (var method in pd.Methods) { var type = method.Type; var module = type.Module; if (FilterModule != null) { var match = FilterModule.Match(module.ToString()); if (!match.Success) { continue; } } if (FilterType != null) { var match = FilterType.Match(method.Type.ToString()); if (!match.Success) { continue; } } if (FilterMethod != null) { var match = FilterMethod.Match(method.ToString()); if (!match.Success) { continue; } } methods.Add(method); types.Add(type); modules.Add(module); } } if (FilterMethod == null && FilterType != null) { foreach (var type in pd.Types) { if (types.Contains(type)) { continue; } var match = FilterType.Match(type.ToString()); if (!match.Success) { continue; } types.Add(type); } } if (Modules) { ColorWriteLine($"Modules:", ConsoleColor.Green); foreach (var module in modules) { WriteLine($"\t{module.Mvid} {module}"); } } if (Types) { ColorWriteLine($"Types:", ConsoleColor.Green); foreach (var type in types) { WriteLine($"\t{type}"); } } if (Methods) { ColorWriteLine($"Methods:", ConsoleColor.Green); foreach (var method in methods) { WriteLine($"\t{method}"); } } if (Summary) { ColorWriteLine($"Summary:", ConsoleColor.Green); WriteLine($"\tModules: {modules.Count.ToString ("N0"),10}{(modules.Count != pd.Modules.Count ? $" (of {pd.Modules.Count})" : "" )}"); WriteLine($"\tTypes: {types.Count.ToString ("N0"),10}{(types.Count != pd.Types.Count ? $" (of {pd.Types.Count})" : "")}"); WriteLine($"\tMethods: {methods.Count.ToString ("N0"),10}{(methods.Count != pd.Methods.Count ? $" (of {pd.Methods.Count})" : "")}"); } if (!string.IsNullOrEmpty(Output)) { if (Verbose) { ColorWriteLine($"Going to write the profile to '{Output}'", ConsoleColor.Yellow); } var updatedPD = new ProfileData(new List <ModuleRecord>(modules), new List <TypeRecord> (types), methods); using (var stream = new FileStream(Output, FileMode.Create)) { var writer = new ProfileWriter(stream, updatedPD); writer.Write(); } } }