This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <# | |
| PowerShell script to rename C# Project step-by-step: | |
| * Copying project folder to folder with new project name | |
| * Renaming .csproj file and other files with project name | |
| * Changing project name reference in .sln solution file | |
| * Changing RootNamespace and AssemblyName in .csproj file | |
| * Renaming project inside AssemblyInfo.cs | |
| #> | |
| param( | |
| [parameter( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Option Strict Off | |
| Option Explicit Off | |
| Imports System | |
| Imports EnvDTE | |
| Imports EnvDTE80 | |
| Imports EnvDTE90 | |
| Imports EnvDTE90a | |
| Imports EnvDTE100 | |
| Imports System.Diagnostics |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let rules = [(3, "Fizz"); (5, "Buzz")] | |
| let translate x = | |
| None |> List.foldBack (fun (i, word) say -> | |
| if x % i = 0 then Some <| Option.fold (+) word say | |
| else say) rules | |
| for n in 1..100 do | |
| printfn "%s" <| match translate n with | Some s -> s | _ -> string n |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [Test] | |
| public void FizzBuzz() | |
| { | |
| var rules = new Dictionary<int, string> { { 3, "Fizz" }, { 5, "Buzz" } }; | |
| Func<int, string> translate = i => | |
| rules.Aggregate((string)null, (s, x) => i % x.Key == 0 ? (s == null ? x.Value : s + x.Value) : s) | |
| ?? i.ToString(); | |
| var words = Enumerable.Range(9, 7).Select(translate).ToArray(); | |
| CollectionAssert.AreEqual(new[] { "Fizz", "Buzz", "11", "Fizz", "13", "14", "FizzBuzz" }, words); |
NewerOlder