// -------------------------------------------------------------------------------------------------------------------- // // Copyright (c) James South. // Licensed under the Apache License, Version 2.0. // // // Encapsulates a series of time saving extension methods to the class. // // -------------------------------------------------------------------------------------------------------------------- namespace ImageProcessor.Common.Extensions { using System.Globalization; /// /// Encapsulates a series of time saving extension methods to the class. /// public static class IntegerExtensions { /// /// Converts an value into a valid . /// /// If the value given is less than 0 or greater than 255, the value will be constrained into /// those restricted ranges. /// /// /// /// The to convert. /// /// /// The . /// public static byte ToByte(this int integer) { return ((double)integer).ToByte(); } /// /// Converts the string representation of a number in a specified culture-specific format to its /// 32-bit signed integer equivalent using invariant culture. /// /// The integer. /// A string containing a number to convert. /// A 32-bit signed integer equivalent to the number specified in s. public static int ParseInvariant(this int integer, string s) { return int.Parse(s, CultureInfo.InvariantCulture); } } }