Пример #1
0
 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);
         });
     }
 }
Пример #2
0
        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();
        }
Пример #3
0
 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();
 }
Пример #4
0
        public void Configure(TemplateChoices choices, ProjectRequest request)
        {
            choices.Options = (choices.Options ?? ((IEnumerable <string>) new string[0]));
            Option option = choices.Selections.Has(this.Name) ? this.FindOption(choices.Selections[this.Name]) : (this.Options.FirstOrDefault((Option x) => choices.Options.Any((string o) => FubuCore.StringExtensions.EqualsIgnoreCase(o, x.Name))) ?? this.Options.First <Option>());

            GenericEnumerableExtensions.AddRange <string>(request.Alterations, option.Alterations);
        }
Пример #5
0
        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);
            }
        }
Пример #6
0
 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));
 }
Пример #7
0
 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));
 }
Пример #8
0
 public void Alter(TemplatePlan plan)
 {
     plan.AlterFile(".gitignore", delegate(List <string> list)
     {
         GenericEnumerableExtensions.Each <string>(this._entries, new Action <string>(list.Fill <string>));
     });
 }
Пример #9
0
 private void applyProjectTemplates(TemplateRequest request, TemplatePlan plan)
 {
     GenericEnumerableExtensions.Each <ProjectRequest>(request.Projects, delegate(ProjectRequest proj)
     {
         this.buildProjectPlan(plan, proj);
     });
 }
Пример #10
0
 public void RegisterPostSolutionConfigurations(string projectGuid, params string[] configs)
 {
     GenericEnumerableExtensions.Each <string>(configs, delegate(string config)
     {
         this.RegisterPostSolutionConfiguration(projectGuid, config);
     });
 }
Пример #11
0
 public MissingInputException(IEnumerable <string> inputNames) : base(FubuCore.StringExtensions.ToFormat("Required inputs {0} are missing", new object[]
 {
     GenericEnumerableExtensions.Join(inputNames, ", ")
 }))
 {
     this._inputNames = inputNames;
 }
Пример #12
0
        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);
            }
        }
Пример #13
0
        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();
                });
            }
        }
Пример #14
0
        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)));
            }
        }
Пример #17
0
 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));
     });
 }
Пример #18
0
 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));
     }
 }
Пример #19
0
 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>()));
     });
 }
Пример #20
0
 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);
     });
 }
Пример #21
0
        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);
            });
        }
Пример #22
0
 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);
 }
Пример #23
0
 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");
 }
Пример #24
0
        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);
            });
        }
Пример #25
0
        public void RegisterPostSolutionConfiguration(string projectGuid, string config)
        {
            string id = "{" + projectGuid + "}";

            GenericEnumerableExtensions.Fill <string>(this._postSolution, FubuCore.StringExtensions.ToFormat("\t\t{0}.{1}", new object[]
            {
                id,
                config
            }));
        }
Пример #26
0
 public static string GetNamespace(string relativePath, string projectName)
 {
     return(GenericEnumerableExtensions.Join(relativePath.Split(new char[]
     {
         '/'
     }).Reverse <string>().Skip(1).Union(new string[]
     {
         projectName
     }).Reverse <string>(), "."));
 }
Пример #27
0
        public string ToNugetImportStatement()
        {
            string arg_4B_0 = "{0}: {1}";

            object[] array = new object[2];
            array[0] = this.ProjectName;
            array[1] = GenericEnumerableExtensions.Join(from x in this._nugetDeclarations
                                                        orderby x
                                                        select x, ", ");
            return(FubuCore.StringExtensions.ToFormat(arg_4B_0, array));
        }
Пример #28
0
        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();
        }
Пример #29
0
 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);
     });
 }
Пример #30
0
 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);
     });
 }