public void WritePreview() { this.Logger.Starting(this._steps.Count); this._substitutions.Trace(this.Logger); GenericEnumerableExtensions.Each <ITemplateStep>(this._steps, delegate(ITemplateStep x) { this.Logger.TraceStep(x); ProjectPlan project = x as ProjectPlan; if (project != null) { this.Logger.StartProject(project.Alterations.Count); project.Substitutions.Trace(this.Logger); GenericEnumerableExtensions.Each <IProjectAlteration>(project.Alterations, delegate(IProjectAlteration alteration) { this.Logger.TraceAlteration(this.ApplySubstitutions(alteration.ToString())); }); this.Logger.EndProject(); } }); string[] projectsWithNugets = this.determineProjectsWithNugets(); if (projectsWithNugets.Any <string>()) { Console.WriteLine(); Console.WriteLine("Nuget imports:"); GenericEnumerableExtensions.Each <string>(projectsWithNugets, delegate(string x) { Console.WriteLine(x); }); } }
public void Save(string fileName) { if (!this.Settings.MaintainOriginalItemOrder) { GenericEnumerableExtensions.Each <MSBuildItemGroup>(this.ItemGroups, delegate(MSBuildItemGroup group) { XmlElement[] elements = (from x in @group.Items select x.Element into x orderby x.GetAttribute("Include") select x).ToArray <XmlElement>(); group.Element.RemoveAll(); GenericEnumerableExtensions.Each <XmlElement>(elements, delegate(XmlElement x) { group.Element.AppendChild(x); }); }); } MSBuildProject.ProjectWriter sw = new MSBuildProject.ProjectWriter(this.bom); sw.NewLine = this.newLine; this.doc.Save(sw); string content = sw.ToString(); if (this.endsWithEmptyLine && !content.EndsWith(this.newLine)) { content += this.newLine; } bool shouldSave = !this.Settings.OnlySaveIfChanged || (File.Exists(fileName) && !File.ReadAllText(fileName).Equals(content)); if (shouldSave) { new FileSystem().WriteStringToFile(fileName, content); } }
public void Alter(List <string> contents, ProjectPlan plan) { GenericEnumerableExtensions.Each <string>(from x in this._additions select plan.ApplySubstitutionsRaw(x, null) into x where !contents.Contains(x) select x, new Action <string>(contents.Add)); }
public void Alter(TemplatePlan plan) { plan.AlterFile(".gitignore", delegate(List <string> list) { GenericEnumerableExtensions.Each <string>(this._entries, new Action <string>(list.Fill <string>)); }); }
public void WriteInstructions() { if (FubuCore.StringExtensions.IsEmpty(this._instructions.ToString())) { return; } string instructionText = this.GetInstructions(); string[] contents = instructionText.SplitOnNewLine(); this.FileSystem.AlterFlatFile(FubuCore.StringExtensions.AppendPath(this.Root, new string[] { TemplatePlan.InstructionsFile }), delegate(List <string> list) { list.AddRange(contents); }); Console.WriteLine(); Console.WriteLine(); Console.ForegroundColor = ConsoleColor.Cyan; GenericEnumerableExtensions.Each <string>(contents, delegate(string x) { Console.WriteLine(x); }); Console.ResetColor(); }
public void Save(string filename, bool saveProjects = true) { this.CalculateProjectConfigurationPlatforms(); StringWriter writer = new StringWriter(); this.EnsureHeaders(); GenericEnumerableExtensions.Each <string>(this._header, delegate(string x) { writer.WriteLine(x); }); GenericEnumerableExtensions.Each <SolutionProject>(this._projects, delegate(SolutionProject x) { x.Write(writer); }); writer.WriteLine("Global"); GenericEnumerableExtensions.Each <GlobalSection>(this._sections, delegate(GlobalSection x) { x.Write(writer); }); writer.WriteLine("EndGlobal"); new FileSystem().WriteStringToFile(filename, writer.ToString()); if (saveProjects) { GenericEnumerableExtensions.Each <SolutionProject>(this._projects, delegate(SolutionProject x) { x.Project.Save(); }); } }
private Solution(string filename, string text) { this._filename = filename; string[] items = text.SplitOnNewLine(); Solution.SolutionReader reader = new Solution.SolutionReader(this); GenericEnumerableExtensions.Each <string>(items, new Action <string>(reader.Read)); }
public TemplateLibrary(string templatesRoot) { this._templatesRoot = templatesRoot; this._templateDirectories = new Cache <TemplateType, string>(delegate(TemplateType type) { string directory = FubuCore.StringExtensions.AppendPath(this._templatesRoot, new string[] { type.ToString().ToLowerInvariant() }); TemplateLibrary.FileSystem.CreateDirectory(directory); return(directory); }); GenericEnumerableExtensions.Each <TemplateType>(Enum.GetValues(typeof(TemplateType)).OfType <TemplateType>(), delegate(TemplateType x) { this._templateDirectories.FillDefault(x); }); string graphFile = FubuCore.StringExtensions.AppendPath(templatesRoot, new string[] { TemplateGraph.FILE }); if (File.Exists(graphFile)) { this.Graph = TemplateGraph.Read(graphFile); } }
private void CalculateProjectConfigurationPlatforms() { GlobalSection section = this.FindSection("ProjectConfigurationPlatforms"); if (section == null) { section = new GlobalSection("GlobalSection(ProjectConfigurationPlatforms) = postSolution"); this._sections.Add(section); } section.Properties.Clear(); BuildConfiguration[] configurations = this.Configurations().ToArray <BuildConfiguration>(); GenericEnumerableExtensions.Each <SolutionProject>(from x in this._projects where x.ProjectName != "Solution Items" select x, delegate(SolutionProject proj) { GenericEnumerableExtensions.Each <BuildConfiguration>(configurations, delegate(BuildConfiguration config) { config.WriteProjectConfiguration(proj, section); }); }); if (section.Empty) { this._sections.Remove(section); } }
capture_events_to_a_new_stream_and_fetch_the_events_back_with_stream_id_provided_in_another_database_schema( DocumentTracking sessionType) { var store = InitStore("event_store"); using (var session = store.OpenSession(sessionType)) { var joined = new MembersJoined { Members = new[] { "Rand", "Matt", "Perrin", "Thom" } }; var departed = new MembersDeparted { Members = new[] { "Thom" } }; var id = Guid.NewGuid(); session.Events.StartStream(id, joined, departed); session.SaveChanges(); var streamEvents = session.Events.FetchStream(id); Enumerable.Count <IEvent>(streamEvents).ShouldBe(2); Enumerable.ElementAt <IEvent>(streamEvents, 0).Data.ShouldBeOfType <MembersJoined>(); Enumerable.ElementAt <IEvent>(streamEvents, 0).Version.ShouldBe(1); Enumerable.ElementAt <IEvent>(streamEvents, 1).Data.ShouldBeOfType <MembersDeparted>(); Enumerable.ElementAt <IEvent>(streamEvents, 1).Version.ShouldBe(2); GenericEnumerableExtensions.Each <IEvent>(streamEvents, x => SpecificationExtensions.ShouldBeGreaterThan(x.Sequence, 0L)); } }
public async Task capture_events_to_a_new_stream_and_fetch_the_events_back_async(DocumentTracking sessionType) { var store = InitStore(); using (var session = store.OpenSession(sessionType)) { // SAMPLE: start-stream-with-aggregate-type var joined = new MembersJoined { Members = new[] { "Rand", "Matt", "Perrin", "Thom" } }; var departed = new MembersDeparted { Members = new[] { "Thom" } }; var id = session.Events.StartStream(joined, departed).Id; await session.SaveChangesAsync(); // ENDSAMPLE var streamEvents = await session.Events.FetchStreamAsync(id); Enumerable.Count <IEvent>(streamEvents).ShouldBe(2); Enumerable.ElementAt <IEvent>(streamEvents, 0).Data.ShouldBeOfType <MembersJoined>(); Enumerable.ElementAt <IEvent>(streamEvents, 0).Version.ShouldBe(1); Enumerable.ElementAt <IEvent>(streamEvents, 1).Data.ShouldBeOfType <MembersDeparted>(); Enumerable.ElementAt <IEvent>(streamEvents, 1).Version.ShouldBe(2); GenericEnumerableExtensions.Each <IEvent>(streamEvents, e => ShouldBeTestExtensions.ShouldNotBe(e.Timestamp, default(DateTimeOffset))); } }
public void RegisterPostSolutionConfigurations(string projectGuid, params string[] configs) { GenericEnumerableExtensions.Each <string>(configs, delegate(string config) { this.RegisterPostSolutionConfiguration(projectGuid, config); }); }
public void Execute() { if (this._missingInputs.Any <string>()) { this.Logger.Trace("Missing Inputs:", new object[0]); this.Logger.Trace("---------------", new object[0]); GenericEnumerableExtensions.Each <string>(this._missingInputs, delegate(string x) { Console.WriteLine(x); }); throw new MissingInputException(this._missingInputs.ToArray <string>()); } this.Logger.Starting(this._steps.Count); this._substitutions.Trace(this.Logger); this._substitutions.Set("%INSTRUCTIONS%", this.GetInstructions().Replace("\"", "'")); GenericEnumerableExtensions.Each <ITemplateStep>(this._steps, delegate(ITemplateStep x) { this.Logger.TraceStep(x); x.Alter(this); }); if (this.Solution != null) { this.Logger.Trace("Saving solution to {0}", new object[] { this.Solution.Filename }); this.Solution.Save(true); } this.Substitutions.WriteTo(FubuCore.StringExtensions.AppendPath(this.Root, new string[] { Substitutions.ConfigFile })); this.WriteNugetImports(); this.Logger.Finish(); }
private void applyProjectTemplates(TemplateRequest request, TemplatePlan plan) { GenericEnumerableExtensions.Each <ProjectRequest>(request.Projects, delegate(ProjectRequest proj) { this.buildProjectPlan(plan, proj); }); }
private void applyTestingTemplates(TemplateRequest request, TemplatePlan plan) { GenericEnumerableExtensions.Each <ProjectRequest>(request.TestingProjects, delegate(ProjectRequest proj) { this.buildProjectPlan(plan, proj); plan.Add(new CopyProjectReferences(proj.OriginalProject)); }); }
private void EnsureHeaders() { if (this._header.Count == 0) { this._header.Add(string.Empty); GenericEnumerableExtensions.Each <string>(Solution._versionLines.ToDictionary()[this.Version ?? Solution.DefaultVersion], new Action <string>(this._header.Add)); } }
public static void ConfigurePlan(TextFile textFile, TemplatePlan plan) { GenericEnumerableExtensions.Each <string>(textFile.ReadLines(), delegate(string line) { string[] parts = FubuCore.StringExtensions.ToDelimitedArray(line); plan.Add(new GemReference(parts.First <string>(), parts.Last <string>())); }); }
protected override void configurePlan(string directory, TemplatePlan plan) { ProjectPlan current = plan.Steps.OfType <ProjectPlan>().LastOrDefault <ProjectPlan>(); GenericEnumerableExtensions.Each <ProjectDirectory>(ProjectDirectory.PlanForDirectory(directory), delegate(ProjectDirectory x) { current.Add(x); }); }
public void CreatePlan(Template template, TemplatePlan plan) { this.configurePlan(template.Path, plan); GenericEnumerableExtensions.Each <ITemplatePlanner>(this._planners, delegate(ITemplatePlanner x) { x.DetermineSteps(template.Path, plan); }); plan.CopyUnhandledFiles(template.Path); }
public void DetermineSteps(string directory, TemplatePlan plan) { GenericEnumerableExtensions.Each <TextFile>(from x in TextFile.FileSystem.FindFiles(directory, this._matching) select new TextFile(x, FubuCore.StringExtensions.PathRelativeTo(x, directory)), delegate(TextFile file) { this._action(file, plan); plan.MarkHandled(file.Path); }); }
private void applySolutionTemplates(TemplateRequest request, TemplatePlan plan) { SolutionPlanner planner = new SolutionPlanner(); GenericEnumerableExtensions.Each <Template>(this._library.Find(TemplateType.Solution, request.Templates), delegate(Template template) { planner.CreatePlan(template, plan); }); }
public void Write(StringWriter writer) { writer.WriteLine("\t" + this._declaration); GenericEnumerableExtensions.Each <string>(this._properties, delegate(string x) { writer.WriteLine("\t\t" + x); }); writer.WriteLine("\tEndGlobalSection"); }
public void Alter(TemplatePlan plan) { this._substitutions.Set("%INSTRUCTIONS%", plan.GetInstructions()); plan.Logger.StartProject(this._alterations.Count); plan.StartProject(this); this._substitutions.Trace(plan.Logger); SolutionProject reference = plan.Solution.FindProject(this._projectName); if (reference == null) { if (FubuCore.StringExtensions.IsEmpty(this.ProjectTemplateFile)) { plan.Logger.Trace("Creating project {0} from the default template", new object[] { this._projectName }); reference = plan.Solution.AddProject(this._projectName); } else { plan.Logger.Trace("Creating project {0} from template at {1}", new object[] { this._projectName, this.ProjectTemplateFile }); reference = plan.Solution.AddProjectFromTemplate(this._projectName, this.ProjectTemplateFile); } reference.Project.AssemblyName = (reference.Project.RootNamespace = this.ProjectName); if (this.DotNetVersion != null) { reference.Project.DotNetVersion = this.DotNetVersion; } } string projectDirectory = reference.Project.ProjectDirectory; plan.FileSystem.CreateDirectory(projectDirectory); this._relativePath = FubuCore.StringExtensions.PathRelativeTo(reference.Project.FileName, plan.Root).Replace("\\", "/"); this._substitutions.Set("%PROJECT_PATH%", this._relativePath); this._substitutions.Set("%PROJECT_FOLDER%", GenericEnumerableExtensions.Join(this._relativePath.Split(new char[] { '/' }).Reverse <string>().Skip(1).Reverse <string>(), "/")); GenericEnumerableExtensions.Each <IProjectAlteration>(this._alterations, delegate(IProjectAlteration x) { plan.Logger.TraceAlteration(this.ApplySubstitutionsRaw(x.ToString(), null)); x.Alter(reference.Project, this); }); this.Substitutions.WriteTo(FubuCore.StringExtensions.AppendPath(projectDirectory, new string[] { Substitutions.ConfigFile })); plan.Logger.EndProject(); }
public void ReadInputs(IEnumerable <Input> inputs, Action <string> markMissing) { GenericEnumerableExtensions.Each <Input>(inputs, delegate(Input x) { if (!this._values.Has(x.Name) && FubuCore.StringExtensions.IsEmpty(x.Default)) { markMissing(x.Name); } string resolved = this.ApplySubstitutions(x.Default ?? string.Empty, null); this.SetIfNone(x.Name, resolved); }); }
private static void copyNugetDeclarations(ProjectPlan originalPlan, ProjectPlan testPlan, CsProjFile original, CsProjFile testProject) { GenericEnumerableExtensions.Each <string>(originalPlan.NugetDeclarations, delegate(string x) { GenericEnumerableExtensions.Fill <string>(testPlan.NugetDeclarations, x); }); GenericEnumerableExtensions.Each <AssemblyReference>(from x in original.All <AssemblyReference>() where FubuCore.StringExtensions.IsEmpty(x.HintPath) select x, delegate(AssemblyReference x) { testProject.Add <AssemblyReference>(x.Include); }); }
public ProjectPlanner() { base.ShallowMatch(Substitutions.ConfigFile).Do = delegate(TextFile file, TemplatePlan plan) { plan.CurrentProject.Substitutions.ReadFrom(file.Path); }; base.ShallowMatch(Input.File).Do = delegate(TextFile file, TemplatePlan plan) { IEnumerable <Input> inputs = Input.ReadFromFile(file.Path); plan.CurrentProject.Substitutions.ReadInputs(inputs, new Action <string>(plan.MissingInputs.Add)); }; base.Matching(FileSet.Shallow(ProjectPlan.TemplateFile, null)).Do = delegate(TextFile file, TemplatePlan plan) { plan.CurrentProject.ProjectTemplateFile = file.Path; }; base.Matching(FileSet.Shallow(ProjectPlanner.NugetFile, null)).Do = delegate(TextFile file, TemplatePlan plan) { GenericEnumerableExtensions.Each <string>(from x in file.ReadLines() where FubuCore.StringExtensions.IsNotEmpty(x) select x, delegate(string line) { plan.CurrentProject.NugetDeclarations.Add(line.Trim()); }); }; base.Matching(FileSet.Shallow("assembly-info.txt", null)).Do = delegate(TextFile file, TemplatePlan plan) { string[] additions = (from x in file.ReadLines() where FubuCore.StringExtensions.IsNotEmpty(x) select x).ToArray <string>(); plan.CurrentProject.Add(new AssemblyInfoAlteration(additions)); }; base.Matching(FileSet.Shallow("references.txt", null)).Do = delegate(TextFile file, TemplatePlan plan) { GenericEnumerableExtensions.Each <string>(from x in file.ReadLines() where FubuCore.StringExtensions.IsNotEmpty(x) select x, delegate(string assem) { plan.CurrentProject.Add(new SystemReference(assem)); }); }; base.Matching(FileSet.Deep("*.cs", null)).Do = delegate(TextFile file, TemplatePlan plan) { CodeFileTemplate template = new CodeFileTemplate(file.RelativePath, file.ReadAll()); plan.CurrentProject.Add(template); }; base.ShallowMatch(TemplatePlan.InstructionsFile).Do = delegate(TextFile file, TemplatePlan plan) { string instructions = file.ReadAll(); plan.AddInstructions(plan.ApplySubstitutions(instructions)); }; }
public void AssertHasFile(string relativeName) { relativeName = relativeName.Replace("\\", "/"); var file = findFile(relativeName); if (file == null) { var files = FindFiles(FileSet.Deep("*")).Select(x => x.Path); var description = "Could not find " + relativeName; GenericEnumerableExtensions.Each(files, x => description += "\n" + x); throw new Exception(description); } }
public void CopyUnhandledFiles(string directory) { IEnumerable <string> unhandledFiles = this._fileSystem.FindFiles(directory, FileSet.Everything()).Where(new Func <string, bool>(this.FileIsUnhandled)); if (this.CurrentProject == null) { GenericEnumerableExtensions.Each <string>(unhandledFiles, delegate(string file) { this.Add(new CopyFileToSolution(FubuCore.StringExtensions.PathRelativeTo(file, directory), file)); }); return; } GenericEnumerableExtensions.Each <string>(unhandledFiles, delegate(string file) { this.CurrentProject.Add(new CopyFileToProject(FubuCore.StringExtensions.PathRelativeTo(file, directory), file)); }); }
public ProjectRequest BuildProjectRequest(TemplateChoices choices) { ProjectRequest request = new ProjectRequest(choices.ProjectName, this.Template); GenericEnumerableExtensions.AddRange <string>(request.Alterations, this.Alterations); if (FubuCore.StringExtensions.IsNotEmpty(this.DotNetVersion)) { request.Version = this.DotNetVersion; } if (choices.Options != null) { GenericEnumerableExtensions.Each <string>(choices.Options, delegate(string o) { Option opt = this.FindOption(o); if (opt == null) { if (!this.tryResolveSelection(o, choices) && opt == null) { throw new Exception(FubuCore.StringExtensions.ToFormat("Unknown option '{0}' for project type {1}", new object[] { o, this.Name })); } } else { GenericEnumerableExtensions.AddRange <string>(request.Alterations, opt.Alterations); } }); } if (this.Selections != null) { GenericEnumerableExtensions.Each <OptionSelection>(this.Selections, delegate(OptionSelection selection) { selection.Configure(choices, request); }); } choices.Inputs.Each(delegate(string key, string value) { request.Substitutions.Set(key, value); }); return(request); }
public void Write(StringWriter writer) { writer.WriteLine(SolutionProject.ProjectLineTemplate, new object[] { this._projectType.ToString().ToUpper(), this._projectName, this._relativePath.Replace('/', Path.DirectorySeparatorChar), this._projectGuid.ToString().ToUpper() }); GenericEnumerableExtensions.Each <string>(this._directives, delegate(string x) { writer.WriteLine(x); }); GenericEnumerableExtensions.Each <ProjectSection>(this._projectSections, delegate(ProjectSection x) { x.Write(writer); }); writer.WriteLine("EndProject"); }