Name Tuples/Anonymous Types in F#?

后端 未结 6 1709
执笔经年
执笔经年 2021-02-03 19:46

in C# you can do stuff like :

var a = new {name = \"cow\", sound = \"moooo\", omg = \"wtfbbq\"};

and in

6条回答
  •  半阙折子戏
    2021-02-03 20:28

    Here's my take on the default web project route config:

    module RouteConfig =
    
        open System.Web.Mvc
        open System.Web.Routing
    
        let registerRoutes (routes: RouteCollection) =
    
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}")
    
            /// create a pair, boxing the second item
            let inline (=>) a b = a, box b
    
            /// set the Defaults property from a given dictionary
            let setDefaults defaultDict (route : Route) =  
                route.Defaults <- RouteValueDictionary(defaultDict)
    
            routes.MapRoute(name="Default", url="{controller}/{action}/{id}")
            |> setDefaults (dict ["controller" => "Home" 
                                  "action" => "Index" 
                                  "id" => UrlParameter.Optional])
    

提交回复
热议问题