Beispiel #1
0
 public static void AddValueWithType(this SerializationInfo Info, String Name, Object Object)
 {
     if (Object == null)
     {
         Info.AddValue(Name + ".Type", "Nothing");
     }
     else
     {
         Info.AddValue(Name + ".Type", Object.GetType().FullName);
         Info.AddValue(Name, Object, Object.GetType());
     }
 }
Beispiel #2
0
 /// <summary>
 /// Checks if a value exists for a node, if not, it adds one.
 /// </summary>
 public static void TryAddValue(this ConfigNode node, string name, string value)
 {
     if (!node.HasValue(name))
     {
         node.AddValue(name, value);
     }
 }
 /// <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));
 }
 /// <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));
 }
 /// <summary>SqlParameterCollection に連番のパラメタとその値を設定する。
 /// </summary>
 /// <param name="parameters"></param>
 /// <param name="parameternamePrefix"></param>
 /// <param name="values"></param>
 public static void AddValue(this SqlParameterCollection parameters, string parameternamePrefix, IEnumerable<int> values)
 {
     int i = -1;
     foreach (var value in values)
     {
         parameters.AddValue(parameternamePrefix + (++i), value);
     }
 }
 /// <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));
 }
Beispiel #7
0
 /// <summary>
 /// Gets a value if available, otherwise adds the value and then returns the defaultValue
 /// </summary>
 public static string GetAddValue(this ConfigNode node, string name, string defaultValue)
 {
     if (node.HasValue(name))
     {
         return node.GetValue(name);
     }
     node.AddValue(name, defaultValue);
     return defaultValue;
 }
 /// <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));
 }
 /// <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));
 }
        /// <summary>
        /// Add a new <see cref="T:System.String"/> XML value to the current <see cref="T:Tridion.ContentManager.Templating.Package" />
        /// </summary>
        /// <param name="package"><see cref="T:Tridion.ContentManager.Templating.Package" /></param>
        /// <param name="name">Name.</param>
        /// <param name="value">Value.</param>
        /// <remarks>An XML processing instruction is automatically added if required.</remarks>
        public static void AddXml(this Package package, String name, String value)
        {
            if (package != null)
            {
                String packageValue = value;

                // Add an XML prolog to ensure a valid XML snippet
                if (!packageValue.StartsWith("<?xml", StringComparison.OrdinalIgnoreCase))
                    packageValue = String.Format("<?xml version=\"1.0\" encoding=\"{0}\"?>\n", Encoding.UTF8.HeaderName) + packageValue;

                package.AddValue(ContentType.Xml, name, packageValue);
            }
        }
 /// <summary>
 /// Add a new <see cref="T:System.DateTime"/> value to the current <see cref="T:Tridion.ContentManager.Templating.Package" />
 /// </summary>
 /// <param name="package"><see cref="T:Tridion.ContentManager.Templating.Package" /></param>
 /// <param name="name">Name.</param>
 /// <param name="value">Value.</param>
 public static void AddDateTime(this Package package, String name, DateTime value)
 {
     if (package != null)
         package.AddValue(ContentType.DateTime, name, value.ToString());
 }
 /// <summary>
 /// Add a new <see cref="T:System.Double"/> value to the current <see cref="T:Tridion.ContentManager.Templating.Package" />
 /// </summary>
 /// <param name="package"><see cref="T:Tridion.ContentManager.Templating.Package" /></param>
 /// <param name="name">Name.</param>
 /// <param name="value">Value.</param>
 public static void AddNumber(this Package package, String name, double value)
 {
     if (package != null)
         package.AddValue(ContentType.Number, name, value.ToString());
 }
 /// <summary>
 /// Add a new <see cref="T:System.String"/> XHTML value to the current <see cref="T:Tridion.ContentManager.Templating.Package" />
 /// </summary>
 /// <param name="package"><see cref="T:Tridion.ContentManager.Templating.Package" /></param>
 /// <param name="name">Name.</param>
 /// <param name="value">Value.</param>
 public static void AddXhtml(this Package package, String name, String value)
 {
     if (package != null)
         package.AddValue(ContentType.Xhtml, name, value);
 }
		internal static void SetOptionsSyntheticMargin(this Security security, decimal value)
		{
			security.AddValue(SecurityOptionsSyntheticMargin, value);
		}
Beispiel #15
0
		internal static void SetEvMultiplier(this ExecutionMessage trade, decimal multiplier)
		{
			trade.AddValue(_evMultiplier, multiplier);
		}
 /// <summary>
 /// Returns true if the ConfigNode has the given value, and stores it in the ref value
 /// </summary>
 /// <param name="name">Name of the value to find</param>
 /// <param name="value">Value to store the result in</param>
 /*public static bool TryGetValue(this ConfigNode node, string name, ref Vector3 value)
 {
     if (node.HasValue(name) && RCUtils.TryParseVector3(node.GetValue(name), ref value)) { return true; }
     return false;
 }*/
 /// <summary>
 /// Sees if the ConfigNode has the given value and sets it, else it creates a new value for it.
 /// </summary>
 /// <param name="name">Name of the value to look for</param>
 /// <param name="value">Value to set</param>
 public static void SetAddValue(this ConfigNode node, string name, string value)
 {
     if (node.HasValue(name)) { node.SetValue(name, value); }
     else { node.AddValue(name, value); }
 }
Beispiel #17
0
		internal static void SetOrderRef(this ExecutionMessage trade, string orderRef)
		{
			trade.AddValue(_orderRef, orderRef);
		}
Beispiel #18
0
		internal static void SetWhyHeld(this ExecutionMessage order, string whyHeld)
		{
			order.AddValue(_whyHeld, whyHeld);
		}
Beispiel #19
0
		internal static void SetLastTradePrice(this ExecutionMessage order, decimal price)
		{
			order.AddValue(_lastTradePrice, price);
		}
Beispiel #20
0
		//public static int GetPermId(this Order order)
		//{
		//	return order.GetValue<int>(_permId);
		//}

		internal static void SetPermId(this Order order, int permId)
		{
			order.AddValue(_permId, permId);
		}
Beispiel #21
0
 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));
 }
Beispiel #22
0
		internal static void SetAveragePrice(this ExecutionMessage trade, decimal price)
		{
			trade.AddValue(_averagePrice, price);
		}
 /// <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));
 }
Beispiel #24
0
		internal static void SetEvRule(this ExecutionMessage trade, string rule)
		{
			trade.AddValue(_evRule, rule);
		}
Beispiel #25
0
 public static void AddColor(this SerializationInfo Info, String Name, Color Color)
 {
     Info.AddValue(Name, Convert.ToString(Color.ToArgb(), 16));
 }
 /// <summary>
 /// Add a new <see cref="T:System.String"/> ExternalLink value to the current <see cref="T:Tridion.ContentManager.Templating.Package" />
 /// </summary>
 /// <param name="package"><see cref="T:Tridion.ContentManager.Templating.Package" /></param>
 /// <param name="name">Name.</param>
 /// <param name="value">Value.</param>
 public static void AddExternalLink(this Package package, String name, String value)
 {
     if (package != null)
         package.AddValue(ContentType.ExternalLink, name, value);
 }
Beispiel #27
0
		public static Message InitRequestId(this Message message, long requestId)
		{
			if (requestId > 0)
				message.AddValue("RequestId", requestId);

			return message;
		}
 /// <summary>
 /// Add a new <see cref="T:Tridion.ContentManager.TcmUri"/> Link value to the current <see cref="T:Tridion.ContentManager.Templating.Package" />
 /// </summary>
 /// <param name="package"><see cref="T:Tridion.ContentManager.Templating.Package" /></param>
 /// <param name="name">Name.</param>
 /// <param name="value">Value.</param>
 public static void AddLink(this Package package, String name, TcmUri value)
 {
     if (package != null)
         package.AddValue(ContentType.ItemLink, name, value != null ? value : TcmUri.UriNull);
 }
		internal static void SetSmartStatus(this Portfolio portfolio, SmartPortfolioStatus value)
		{
			portfolio.AddValue(PortfolioStatus, value);
		}
 /// <summary>
 /// Add a new <see cref="T:Tridion.ContentManager.IdentifiableOject"/> Link value to the current <see cref="T:Tridion.ContentManager.Templating.Package" />
 /// </summary>
 /// <param name="package"><see cref="T:Tridion.ContentManager.Templating.Package" /></param>
 /// <param name="name">Name.</param>
 /// <param name="value">Value.</param>
 public static void AddLink(this Package package, String name, IdentifiableObject value)
 {
     if (package != null)
         package.AddValue(ContentType.ItemLink, name, value != null ? value.Id : TcmUri.UriNull);
 }