Loops, Functions, and Generics in .NET Console
Sunday, June 5, 2005
Fire up the latest build of WebEdit, and run the following commands in the Console window:
code: using System.Collections.Generic getPaths(history, filter){ret = new List<string>(); foreach(entry in history){if(filter(entry)){ret.Add(entry.FullPath)}} ret;} isFtp(entry){entry.FullPath.StartsWith("ftp:")} Dev.TraceCollection(getPaths(WebEditApp.HistoryManager.TotalHistory, isFtp))
You need to have Whidbey Beta 2 installed for the generics to work. Loops and user functions work with all .NET framework versions. User functions are treated like variables, and in WebEdit.NET are listed in the Console window's auto-text list. Read on here for more details on new .NET Console features.
I've also started working on better support for generic types elsewhere in the Gregor.NET framework:
- The Gregor.Core.Reflect.FindType routing will retrieve generic type definitions when given a string like "System.Collections.Generic.List<>", and closed constructed types if type arguments are provided. Note that only C# generics syntax (that is, angle brackets) is supported as of now. However, you can pass in a syntax provider for future use (already there is support for type nick names).
- The Gregor.Core.Reflect.GetTypeName routine does now produce more readable generics syntax, as does the new GetMemberName function.
- The AssemblyBrowser (Gregor.AppCore) will show generic types and methods with a better syntax.