/// <summary>
 /// Configures <see cref="GlobalizationConfiguration"/>
 /// </summary>
 /// <param name="environment">An <see cref="INancyEnvironment"/> that should be configured.</param>
 /// <param name="supportedCultureNames">Cultures that the application can accept</param>
 /// <param name="defaultCulture">Used to set a default culture for the application</param>
 /// <param name="dateTimeStyles">The <see cref="DateTimeStyles"/> that should be used for date parsing.</param>
 /// <remarks>If defaultCulture not specified the first supported culture is used</remarks>
 public static void Globalization(this INancyEnvironment environment, IEnumerable <string> supportedCultureNames, string defaultCulture = null, DateTimeStyles?dateTimeStyles = null)
 {
     environment.AddValue(new GlobalizationConfiguration(
                              supportedCultureNames: supportedCultureNames,
                              defaultCulture: defaultCulture,
                              dateTimeStyles: dateTimeStyles));
 }
Exemplo n.º 2
0
 /// <summary>
 /// Configures JSON serialization.
 /// </summary>
 /// <param name="environment"><see cref="INancyEnvironment"/> that should be configured.</param>
 /// <param name="maxJsonLength">Max length of JSON output.</param>
 /// <param name="defaultEncoding">The <see cref="Encoding"/> that should be as a default.</param>
 /// <param name="converters">List of <see cref="JavaScriptConverter"/> that should be used.</param>
 /// <param name="primitiveConverters">List of <see cref="JavaScriptPrimitiveConverter"/> that should be used.</param>
 /// <param name="retainCasing"><see langword="true" /> if C# casing should be retained, otherwise <see langword="false" /> to use camel-casing.</param>
 public static void Json(this INancyEnvironment environment, int?maxJsonLength = null, Encoding defaultEncoding = null, IList <JavaScriptConverter> converters = null, IList <JavaScriptPrimitiveConverter> primitiveConverters = null, bool?retainCasing = null)
 {
     environment.AddValue(new JsonConfiguration(
                              defaultEncoding ?? JsonConfiguration.Default.DefaultEncoding,
                              converters ?? JsonConfiguration.Default.Converters,
                              primitiveConverters ?? JsonConfiguration.Default.PrimitiveConverters,
                              retainCasing ?? JsonConfiguration.Default.RetainCasing));
 }
Exemplo n.º 3
0
        public override void Configure(INancyEnvironment environment)
        {
            base.Configure(environment);

            environment.AddValue("AssetServer", this.assetServer);

            environment.Tracing(enabled: true, displayErrorTraces: true);
        }
Exemplo n.º 4
0
 /// <summary>
 /// Configures diagnostics.
 /// </summary>
 /// <param name="environment"><see cref="INancyEnvironment"/> that should be configured.</param>
 /// <param name="password">Password used to secure the dashboard.</param>
 /// <param name="path">Relative path of the dashboard.</param>
 /// <param name="cookieName">Name of the cookie to store diagnostics information.</param>
 /// <param name="slidingTimeout">Number of minutes that expiry of the diagnostics dashboard.</param>
 /// <param name="cryptographyConfiguration">Cryptography config to use for securing the dashboard.</param>
 public static void Diagnostics(this INancyEnvironment environment, string password, string path = null, string cookieName = null, int slidingTimeout = 15, CryptographyConfiguration cryptographyConfiguration = null)
 {
     environment.AddValue(new DiagnosticsConfiguration(
                              password,
                              path,
                              cookieName,
                              slidingTimeout,
                              cryptographyConfiguration));
 }
Exemplo n.º 5
0
 /// <summary>
 /// Configures JSON serialization.
 /// </summary>
 /// <param name="environment"><see cref="INancyEnvironment"/> that should be configured.</param>
 /// <param name="defaultEncoding">The <see cref="Encoding"/> that should be as a default.</param>
 /// <param name="converters">List of <see cref="JavaScriptConverter"/> that should be used.</param>
 /// <param name="primitiveConverters">List of <see cref="JavaScriptPrimitiveConverter"/> that should be used.</param>
 /// <param name="retainCasing"><see langword="true" /> if C# casing should be retained, otherwise <see langword="false" /> to use camel-casing.</param>
 /// <param name="serializeEnumToString"><see langword="true"/> if enums should be represented as string otherwise <see langword="false"/>.</param>
 /// <param name="excludeNullValues"><see langword="true" /> if the serializer should exclude null values for properties on objects otherwise <see langword="false" />.</param>
 public static void Json(this INancyEnvironment environment, Encoding defaultEncoding = null, IList <JavaScriptConverter> converters = null, IList <JavaScriptPrimitiveConverter> primitiveConverters = null, bool?retainCasing = null, bool?serializeEnumToString = null, bool?excludeNullValues = false)
 {
     environment.AddValue(new JsonConfiguration(
                              defaultEncoding ?? JsonConfiguration.Default.DefaultEncoding,
                              converters ?? JsonConfiguration.Default.Converters,
                              primitiveConverters ?? JsonConfiguration.Default.PrimitiveConverters,
                              retainCasing ?? JsonConfiguration.Default.RetainCasing,
                              serializeEnumToString ?? JsonConfiguration.Default.SerializeEnumToString,
                              excludeNullValues ?? JsonConfiguration.Default.ExcludeNullValues));
 }
Exemplo n.º 6
0
 /// <summary>
 /// Configures JSON serialization.
 /// </summary>
 /// <param name="environment"><see cref="INancyEnvironment"/> that should be configured.</param>
 /// <param name="useIso8601DateFormat"><see langword="true" /> if ISO-860 date formats should be used, otherwise <see langword="false" />.</param>
 /// <param name="maxJsonLength">Max length of JSON output.</param>
 /// <param name="maxRecursions">Maximum number of recursions.</param>
 /// <param name="defaultEncoding">The <see cref="Encoding"/> that should be as a default.</param>
 /// <param name="converters">List of <see cref="JavaScriptConverter"/> that should be used.</param>
 /// <param name="primitiveConverters">List of <see cref="JavaScriptPrimitiveConverter"/> that should be used.</param>
 /// <param name="retainCasing"><see langword="true" /> if C# casing should be retained, otherwise <see langword="false" /> to use camel-casing.</param>
 public static void Json(this INancyEnvironment environment, bool?useIso8601DateFormat = null, int?maxJsonLength = null, int?maxRecursions = null, Encoding defaultEncoding = null, IList <JavaScriptConverter> converters = null, IList <JavaScriptPrimitiveConverter> primitiveConverters = null, bool?retainCasing = null)
 {
     environment.AddValue(new JsonConfiguration(
                              useIso8601DateFormat ?? JsonConfiguration.Default.UseISO8601DateFormat,
                              maxJsonLength ?? JsonConfiguration.Default.MaxJsonLength,
                              maxRecursions ?? JsonConfiguration.Default.MaxRecursions,
                              defaultEncoding ?? JsonConfiguration.Default.DefaultEncoding,
                              converters ?? JsonConfiguration.Default.Converters,
                              primitiveConverters ?? JsonConfiguration.Default.PrimitiveConverters,
                              retainCasing ?? JsonConfiguration.Default.RetainCasing));
 }
Exemplo n.º 7
0
        public override void Configure(INancyEnvironment environment)
        {
            var config = JObject.Parse(File.ReadAllText(_configurationFile));

            foreach(var element in config)
            {
                environment.AddValue<string>(element.Key, element.Value.Value<string>());
            }

            environment.Diagnostics(
                enabled: true,
                password: config["GTDPad.DiagnosticsPassword"].Value<string>()
            );

            environment.Tracing(
                enabled: false,
                displayErrorTraces: true
            );
        }
 /// <summary>
 /// Configures <see cref="GlobalizationConfiguration"/>
 /// </summary>
 /// <param name="environment">An <see cref="INancyEnvironment"/> that should be configured.</param>
 /// <param name="supportedCultureNames">Cultures that the application can accept</param>
 /// <param name="defaultCulture">Used to set a default culture for the application</param>
 /// <remarks>If defaultCulture not specified the first supported culture is used</remarks>
 public static void Cultures(this INancyEnvironment environment, IEnumerable <string> supportedCultureNames, string defaultCulture = null)
 {
     environment.AddValue(new GlobalizationConfiguration(
                              supportedCultureNames: supportedCultureNames,
                              defaultCulture: defaultCulture));
 }
Exemplo n.º 9
0
        public override void Configure(INancyEnvironment environment)
        {
            var config = new TraceConfiguration(enabled: false, displayErrorTraces: true);

            environment.AddValue(config);
        }
        public override void Configure(INancyEnvironment environment)
        {
            var config = new TraceConfiguration(true, true);

            environment.AddValue(config);
        }
 public static void MyConfig(this INancyEnvironment environment, string value)
 {
     environment.AddValue(
         typeof(MyConfig).FullName, // Using the full type name of the type to avoid collisions
         new MyConfig(value));
 }
Exemplo n.º 12
0
 /// <summary>
 /// Configures <see cref="StaticContentConfiguration"/>
 /// </summary>
 /// <param name="environment">An <see cref="INancyEnvironment"/> that should be configured.</param>
 /// <param name="safepaths">Paths that the application consider safe to return static content from</param>
 public static void StaticContent(this INancyEnvironment environment, params string[] safepaths)
 {
     environment.AddValue(new StaticContentConfiguration(
                              safePaths: safepaths));
 }
Exemplo n.º 13
0
 /// <summary>
 /// Configures <see cref="RouteConfiguration"/>.
 /// </summary>
 /// <param name="environment"><see cref="INancyEnvironment"/> that should be configured.</param>
 /// <param name="disableMethodNotAllowedResponses"><see langword="true"/>If 405 responses are allowed, otherwise <see langword="false"/>.</param>
 /// <param name="explicitHeadRouting"><see langword="true"/>If explicit HEAD route requests are allowed, otherwise <see langword="false"/>.</param>
 public static void Routing(this INancyEnvironment environment, bool?disableMethodNotAllowedResponses = false, bool?explicitHeadRouting = false)
 {
     environment.AddValue(new RouteConfiguration(
                              disableMethodNotAllowedResponses: disableMethodNotAllowedResponses ?? RouteConfiguration.Default.DisableMethodNotAllowedResponses,
                              explicitHeadRouting: explicitHeadRouting ?? RouteConfiguration.Default.ExplicitHeadRouting));
 }
 /// <summary>
 /// Configures <see cref="XmlConfiguration"/>.
 /// </summary>
 /// <param name="environment"><see cref="INancyEnvironment"/> that should be configured.</param>
 /// <param name="enableEncoding"><see langword="true"/> if encoding should be enabled, otherwise <see langword="false"/>.</param>
 /// <param name="defaultEncoding">The default <see cref="Encoding"/>.</param>
 public static void Xml(this INancyEnvironment environment, bool enableEncoding, Encoding defaultEncoding = null)
 {
     environment.AddValue(new XmlConfiguration(
                              enableEncoding,
                              defaultEncoding));
 }
Exemplo n.º 15
0
 /// <summary>
 /// Configures <see cref="TraceConfiguration"/>.
 /// </summary>
 /// <param name="environment">An <see cref="INancyEnvironment"/> that should be configured.</param>
 /// <param name="enabled"><see langword="true"/> if tracing should be enabled, otherwise <see langword="false"/>.</param>
 /// <param name="displayErrorTraces"><see langword="true"/> traces should be displayed in error messages, otherwise <see langword="false"/>.</param>
 public static void Tracing(this INancyEnvironment environment, bool enabled, bool displayErrorTraces)
 {
     environment.AddValue(new TraceConfiguration(
                              enabled: enabled,
                              displayErrorTraces: displayErrorTraces));
 }
Exemplo n.º 16
0
 /// <summary>
 /// Configures <see cref="ViewConfiguration"/>.
 /// </summary>
 /// <param name="environment"><see cref="INancyEnvironment"/> that should be configured.</param>
 /// <param name="runtimeViewDiscovery"><see langword="true"/> if views can be discovered during runtime, otherwise <see langword="false"/>.</param>
 /// <param name="runtimeViewUpdates"><see langword="true"/> if views can be updated during runtime, otherwise <see langword="false"/>.</param>
 public static void Views(this INancyEnvironment environment, bool?runtimeViewDiscovery = false, bool?runtimeViewUpdates = false)
 {
     environment.AddValue(new ViewConfiguration(
                              runtimeViewDiscovery: runtimeViewDiscovery ?? ViewConfiguration.Default.RuntimeViewDiscovery,
                              runtimeViewUpdates: runtimeViewUpdates ?? ViewConfiguration.Default.RuntimeViewUpdates));
 }
 /// <summary>
 /// Adds a value to the environment, using the full name of the type defined by <typeparamref name="T"/> as the key.
 /// </summary>
 /// <param name="environment">The <see cref="INancyEnvironment"/> instance.</param>
 /// <param name="value">The value to store in the environment.</param>
 /// <typeparam name="T">The <see cref="Type"/> of the value to store in the environment.</typeparam>
 public static void AddValue <T>(this INancyEnvironment environment, T value)
 {
     environment.AddValue(typeof(T).FullName, value);
 }
Exemplo n.º 18
0
 public override void Configure(INancyEnvironment environment)
 {
     base.Configure(environment);
     environment.AddValue(spotifySecrets);
 }