<commit_before>#region usings
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using Signum.Engine;
using Signum.Engine.Maps;
using Signum.Utilities;
using Signum.Entities;
using Signum.Utilities.DataStructures;
using System.Reflection;
using Signum.Utilities.Reflection;
using System.Collections.Specialized;
using Signum.Entities.Reflection;
using Signum.Entities.DynamicQuery;
using Signum.Engine.DynamicQuery;
using System.Configuration;
using Signum.Utilities.ExpressionTrees;
using Signum.Web.Controllers;
using System.Web.Hosting;
using System.Web.Compilation;
using Signum.Web.PortableAreas;
using Signum.Entities.Basics;
using Signum.Engine.Basics;
using Signum.Engine.Operations;
using System.Runtime.Serialization.Formatters.Binary;
using System.Web.UI;
using Signum.Services;
using System.IO;
using System.IO.Compression;
using System.Security.Cryptography;
using System.Text;
using System.Runtime.Serialization;
using Microsoft.SqlServer.Types;
using Newtonsoft.Json;
using System.Globalization;
#endregion

namespace Signum.Web
{
    public static class Navigator
    {
        public static NavigationManager Manager;

        public static void Start(NavigationManager manager)
        {
            Manager = manager;
        }

        public const string ViewRouteName = "sfView";
        public const string CreateRouteName = "sfCreate";

        public static string NavigateRoute(Type type, int? id)
        {
            var entitySettings = EntitySettings(type);
            if (entitySettings.ViewRoute != null)
                return entitySettings.ViewRoute(new UrlHelper(HttpContext.Current.Request.RequestContext), type, id);

            return new UrlHelper(HttpContext.Current.Request.RequestContext).RouteUrl(id == null ? CreateRouteName : ViewRouteName, new
            {
                webTypeName = EntitySettings(type).WebTypeName,
                id = id.TryToString()
            });
        }

        public static string NavigateRoute(IIdentifiable ie)
        {
            return NavigateRoute(ie.GetType(), ie.Id);
        }

        public static string NavigateRoute(Lite<IIdentifiable> lite)
        {
            return NavigateRoute(lite.EntityType, lite.Id);
        }

        public const string FindRouteName = "sfFind";

        public static string FindRoute(object queryName)
        {
            return new UrlHelper(HttpContext.Current.Request.RequestContext).RouteUrl(FindRouteName, new
            {
                webQueryName = ResolveWebQueryName(queryName)
            });
        }

        public static JsonNetResult JsonNet(this ControllerBase controller, object data)
        {
            return new JsonNetResult { Data = data }; 
        }

        public static ViewResult NormalPage(this ControllerBase controller, IRootEntity entity)
        {
            return Manager.NormalPage(controller, new NavigateOptions(entity));
        }

        public static ViewResult NormalPage(this ControllerBase controller, NavigateOptions options)
        {
            return Manager.NormalPage(controller, options);
        }

        public static PartialViewResult NormalControl(this ControllerBase controller, IRootEntity entity)
        {
            return Manager.NormalControl(controller, new NavigateOptions(entity));
        }

        public static PartialViewResult NormalControl(this ControllerBase controller, NavigateOptions options)<commit_msg>JsonNet with optional settings<commit_after>#region usings
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using Signum.Engine;
using Signum.Engine.Maps;
using Signum.Utilities;
using Signum.Entities;
using Signum.Utilities.DataStructures;
using System.Reflection;
using Signum.Utilities.Reflection;
using System.Collections.Specialized;
using Signum.Entities.Reflection;
using Signum.Entities.DynamicQuery;
using Signum.Engine.DynamicQuery;
using System.Configuration;
using Signum.Utilities.ExpressionTrees;
using Signum.Web.Controllers;
using System.Web.Hosting;
using System.Web.Compilation;
using Signum.Web.PortableAreas;
using Signum.Entities.Basics;
using Signum.Engine.Basics;
using Signum.Engine.Operations;
using System.Runtime.Serialization.Formatters.Binary;
using System.Web.UI;
using Signum.Services;
using System.IO;
using System.IO.Compression;
using System.Security.Cryptography;
using System.Text;
using System.Runtime.Serialization;
using Microsoft.SqlServer.Types;
using Newtonsoft.Json;
using System.Globalization;
#endregion

namespace Signum.Web
{
    public static class Navigator
    {
        public static NavigationManager Manager;

        public static void Start(NavigationManager manager)
        {
            Manager = manager;
        }

        public const string ViewRouteName = "sfView";
        public const string CreateRouteName = "sfCreate";

        public static string NavigateRoute(Type type, int? id)
        {
            var entitySettings = EntitySettings(type);
            if (entitySettings.ViewRoute != null)
                return entitySettings.ViewRoute(new UrlHelper(HttpContext.Current.Request.RequestContext), type, id);

            return new UrlHelper(HttpContext.Current.Request.RequestContext).RouteUrl(id == null ? CreateRouteName : ViewRouteName, new
            {
                webTypeName = EntitySettings(type).WebTypeName,
                id = id.TryToString()
            });
        }

        public static string NavigateRoute(IIdentifiable ie)
        {
            return NavigateRoute(ie.GetType(), ie.Id);
        }

        public static string NavigateRoute(Lite<IIdentifiable> lite)
        {
            return NavigateRoute(lite.EntityType, lite.Id);
        }

        public const string FindRouteName = "sfFind";

        public static string FindRoute(object queryName)
        {
            return new UrlHelper(HttpContext.Current.Request.RequestContext).RouteUrl(FindRouteName, new
            {
                webQueryName = ResolveWebQueryName(queryName)
            });
        }

        public static JsonNetResult JsonNet(this ControllerBase controller, object data, JsonSerializerSettings settings = null)
        {
            var result = new JsonNetResult { Data = data };

            if (settings != null)
                result.SerializerSettings = settings;

            return result;
        }

        public static ViewResult NormalPage(this ControllerBase controller, IRootEntity entity)
        {
            return Manager.NormalPage(controller, new NavigateOptions(entity));
        }

        public static ViewResult NormalPage(this ControllerBase controller, NavigateOptions options)
        {
            return Manager.NormalPage(controller, options);
        }

        public static PartialViewResult NormalControl(this ControllerBase controller, IRootEntity entity)
        {
            return Manager.NormalControl(controller, new NavigateOptions(entity));
        }

        public static PartialViewResult NormalControl(this ControllerBase controller, NavigateOptions options)
{'fraction_non_alphanumeric': 0.07538525614327364, 'fraction_numerical': 0.0, 'mean_word_length': 3.0133704735376043, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6177441', 'n_tokens_mistral': 1822, 'n_tokens_neox': 1810, 'n_words': 455}