string.Format(System.IFormatProvider, string, object)

Here are the examples of the csharp api class string.Format(System.IFormatProvider, string, object) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

200 Examples 7

1. Example

View license
private static string GetStoryboardKey(string propertyPath)
        {
            return string.Format(CultureInfo.InvariantCulture, StoryboardKeyPattern, propertyPath);
        }

2. Example

Project: TraceLab
Source File: DecisionCodeParser.cs
View license
private void Assert (string expectedToken)
        {

            if (Tokenizer.Current.Equals (expectedToken, StringComparison.CurrentCulture) == false) {
                string errorMsg = String.Format (System.Globalization.CultureInfo.CurrentCulture, "Syntax Error - {0} is missing.", expectedToken);
                throw new DecisionCodeParserException (errorMsg);
            }
        }

3. Example

Project: TraceLab
Source File: StringFormatConverter.cs
View license
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value == null)
            {
                return string.Empty;
            }

            return string.Format(CultureInfo.CurrentCulture, (parameter as string) ?? "{0}", value);
        }

4. Example

Project: colored-console
Source File: Guard.cs
View license
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Justification = "Distributed as a source code package.")]
        [DebuggerStepThrough]
        public static void AgainstNullArgument<TArgument>(string parameterName, [ValidatedNotNull]TArgument argument) where TArgument : class
        {
            if (argument == null)
            {
                throw new ArgumentNullException(parameterName, string.Format(CultureInfo.InvariantCulture, "{0} is null.", parameterName));
            }
        }

5. Example

Project: config-r
Source File: Guard.cs
View license
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Justification = "Source package.")]
        [DebuggerStepThrough]
        public static void AgainstNullArgument<TArgument>(string parameterName, [ValidatedNotNull]TArgument argument)
            where TArgument : class
        {
            if (argument == null)
            {
                throw new ArgumentNullException(
                    parameterName, string.Format(CultureInfo.InvariantCulture, "{0} is null.", parameterName));
            }
        }

6. Example

Project: ContinuousTests
Source File: Constraint.cs
View license
private string _displayable(object o)
        {
            if (o == null) return "null";

            string fmt = o is string ? "\"{0}\"" : "{0}";
            return string.Format(System.Globalization.CultureInfo.InvariantCulture, fmt, o);
        }

7. Example

Project: ContinuousTests
Source File: Constraint.cs
View license
private string _displayable(object o)
        {
            if (o == null) return "null";

            string fmt = o is string ? "\"{0}\"" : "{0}";
            return string.Format(System.Globalization.CultureInfo.InvariantCulture, fmt, o);
        }

8. Example

Project: ContinuousTests
Source File: Constraint.cs
View license
private string _displayable(object o)
        {
            if (o == null) return "null";

            string fmt = o is string ? "\"{0}\"" : "{0}";
            return string.Format(System.Globalization.CultureInfo.InvariantCulture, fmt, o);
        }

9. Example

Project: ContinuousTests
Source File: Constraint.cs
View license
private string _displayable(object o)
        {
            if (o == null) return "null";

            string fmt = o is string ? "\"{0}\"" : "{0}";
            return string.Format(System.Globalization.CultureInfo.InvariantCulture, fmt, o);
        }

10. Example

Project: ControlzEx
Source File: Verify.cs
View license
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
        [DebuggerStepThrough]
        public static void PropertyIsNotNull<T>(T obj, string name) where T : class
        {
            if (null == obj)
            {
                Assert.Fail();
                throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "The property {0} cannot be null at this time.", name));
            }
        }

11. Example

Project: ControlzEx
Source File: Verify.cs
View license
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
        [DebuggerStepThrough]
        public static void PropertyIsNull<T>(T obj, string name) where T : class
        {
            if (null != obj)
            {
                Assert.Fail();
                throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "The property {0} must be null at this time.", name));
            }
        }

12. Example

View license
private static string GetCloudConfigurationSettingWithValue(string settingName)
		{
			var result = settingName.ResolveAppSetting();
			result.ThrowOnNullOrWhitespace("settingName",
				string.Format(CultureInfo.InvariantCulture,
				"Missing value for configuration setting {0}, metrics API cannot initialize.", settingName));
			return result;
		}

13. Example

Project: Cyjb.Compilers
Source File: RegexCharClass.cs
View license
private static String CategoryDescription(char ch)
		{
			short sch = (short)ch;
			if (sch == 100)
			{
				// SpaceConst = 100?
				return "\\s";
			}
			else if (sch == -100)
			{
				// NotSpaceConst = -100?
				return "\\S";
			}
			else if (sch < 0)
			{
				return string.Format(CultureInfo.InvariantCulture, "\\P{{{0}}}", Categories[-sch - 1]);
			}
			else
			{
				return string.Format(CultureInfo.InvariantCulture, "\\p{{{0}}}", Categories[ch - 1]);
			}
		}

14. Example

Project: Wexflow
Source File: Now.cs
View license
public override TaskStatus Run()
        {
            Info("Getting current date...");
            string value = string.Empty;
            bool succeeded = false;
            try
            {
                value = string.Format(new CultureInfo(Cultre), "{0:"+Format+"}", DateTime.Now);
                InfoFormat("The value is: {0}", value);
                succeeded = true;
            }
            catch (ThreadAbortException)
            {
                throw;
            }
            catch (Exception e)
            {
                ErrorFormat("An error occured while retrieving current date. Error: {0}", e.Message);
            }
            Info("Task finished.");
            return new TaskStatus(succeeded ? Status.Success : Status.Error, value);
        }

15. Example

Project: ArcGIS.PCL
Source File: Guard.cs
View license
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Justification = "Distributed as a source code package.")]
        [DebuggerStepThrough]
        public static void AgainstNullArgument<TArgument>(string parameterName, [ValidatedNotNull]TArgument argument) where TArgument : class
        {
            if (argument == null)
            {
                throw new ArgumentNullException(parameterName, string.Format(CultureInfo.InvariantCulture, "{0} is null.", parameterName));
            }
        }

16. Example

View license
protected virtual string FormatErrorMessage(string error, string name) {
            return string.Format(CultureInfo.CurrentCulture, error, name);
        }

17. Example

Project: Unity3dTools
Source File: Notification.cs
View license
public override string ToString()
            {
                return String.Format(CultureInfo.CurrentCulture, "OnNext({0})", Value);
            }

18. Example

Project: Magick.NET
Source File: Percentage.cs
View license
public override string ToString()
        {
            return string.Format(CultureInfo.InvariantCulture, "{0:0.##}%", _value);
        }

19. Example

Project: Dnn.Platform
Source File: NativeError.cs
View license
public override string ToString() 
		{
			return string.Format(CultureInfo.InvariantCulture, "0x{0:x8}", this.Number) + (this.Message != null ? ": " + this.Message : "");
		}

20. Example

Project: bio
Source File: SparseSequenceP2TestCases.cs
View license
[Test]
        [Category("Priority2")]
        public void ValidateSparseSequenceNullException()
        {
            // Try Creating sparse sequence by passing null value.
            IAlphabet alphabet = null;
            Assert.Throws<ArgumentNullException>(() => new SparseSequence(alphabet));

            // Log to GUI.
            ApplicationLog.WriteLine(string.Format(null,
                                            "SparseSequence P2: SparseSequence Exception was validated successfully {0}",
                                            "Null Exception"));
        }

21. Example

Project: bio
Source File: IEnumerableExtensions.cs
View license
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0")]
        public static T Single<T>(this IList<T> list)
        {
            Helper.CheckCondition(list.Count == 1, () => string.Format(CultureInfo.InvariantCulture, "Expected list to contain 1 element, but it has {0}.", list.Count));
            return list[0];
        }

22. Example

Project: bio
Source File: SparseSequenceP2TestCases.cs
View license
private static void LogMessage(string message)
        {
            ApplicationLog.WriteLine(string.Format(null, "SparseSequence P2: SparseSequence Exception was validated successfully {0}", message));
        }

23. Example

Project: bio
Source File: SparseSequenceP2TestCases.cs
View license
[Test]
        [Category("Priority2")]
        public void ValidateSparseListSeqItemsAlphabetNullException()
        {
            IEnumerable<byte> byteArray = new List<byte> {Alphabets.DNA.A, Alphabets.DNA.C};

            // Try Creating sparse sequence by passing null value as alphabet.
            Assert.Throws<ArgumentNullException> ( () => new SparseSequence(null, 2, byteArray));

            // Log to GUI.
            ApplicationLog.WriteLine(string.Format(null,
                                            "SparseSequence P2: SparseSequence Exception was validated successfully {0}",
                                            "NullException"));
        }

24. Example

View license
public void ValidateFormatterExceptions(ISequenceFormatter formatter)
        {
            try
            {
                var formatterTypes = formatter.GetType();
                Assert.IsNotNull(formatterTypes);
            }
            catch (NullReferenceException exception)
            {
                // Log to VSTest GUI.
                ApplicationLog.WriteLine(string.Format((IFormatProvider) null,
                                                       "Sequence Formatter P2 : Validated Exception {0} successfully",
                                                       exception.Message));
            }
        }

25. Example

Project: bio
Source File: GenBankFeaturesP1TestCases.cs
View license
private void ValidateGenBankLocationResolver(string nodeName,
                                      /n ..... /n //View Source file for more details /n }

26. Example

Project: bio
Source File: ValueConverter.cs
View license
static public ValueConverter<char, T> GetCharToGeneric<T>()
        {
            if (typeof(T) == typeof(string))
            {
                return (ValueConverter<char, T>)(object)CharToString;
            }
            if (typeof(T) == typeof(int))
            {
                return (ValueConverter<char, T>)(object)CharToInt;
            }
            if (typeof(T) == typeof(double))
            {
                return (ValueConverter<char, T>)(object)CharToDouble;
            }

            throw new ArgumentOutOfRangeException(string.Format(CultureInfo.InvariantCulture, "Don't have a predefined converter for char to {0}.", typeof(T)));
        }

27. Example

Project: bio
Source File: BAMP2TestCases.cs
View license
[Test]
        [Category("Priority1"), Category("BAM")]
        public void InvalidateSetAlphabet()
        {
            // Create BAM Parser object
            using (var bamParserObj = new BAMParser())
            {
                // TO cover code coverage.
                try
                {
                    bamParserObj.Alphabet = Alphabets.DNA;
                    Assert.Fail();
                }
                catch (NotSupportedException ex)
                {
                    string exceptionMessage = ex.Message;
                    ApplicationLog.WriteLine(string.Format(null,
                                                           "BAM Parser P2 : Validated Exception {0} successfully",
                                                           exceptionMessage));
                }
            }
        }

28. Example

View license
public void ValidateParserExceptions(ISequenceParser parser)
        {
            try
            {
                var parserTypes = parser.GetType();
                Assert.IsNotNull(parserTypes);
            }
            catch (NullReferenceException exception)
            {
                // Log to VSTest GUI.
                ApplicationLog.WriteLine(string.Format((IFormatProvider) null,
                                                       "Sequence Parser P2 : Validated Exception {0} successfully",
                                                       exception.Message));
            }
        }

29. Example

Project: bio
Source File: BAMP2TestCases.cs
View license
[Test]
        [Category("Priority1"), Category("BAM")]
        public void InvalidateGetIndexFromBAMFileUsingStream()
        {
            // Create BAM Parser object
            using (var bamParserObj = new BAMParser())
            {
                try
                {
                    bamParserObj.GetIndexFromBAMStorage(null);
                    Assert.Fail();
                }
                catch (ArgumentNullException ex)
                {
                    string exceptionMessage = ex.Message;
                    ApplicationLog.WriteLine(string.Format(null,
                                                           "BAM Parser P2 : Validated Exception {0} successfully",
                                                           exceptionMessage));
                }
            }
        }

30. Example

Project: DotSpatial
Source File: NumberConverter.cs
View license
private char[] ToCharInternal(object number)
        {
            char[] c = new char[Length];
            string str = string.Format(NumberConversionFormatProvider, DecimalFormatString, number);
            if (str.Length >= Length)
            {
                for (int i = 0; i < Length; i++)
                {
                    c[i] = str[i]; // keep the left characters, and chop off lesser characters
                }
            }
            else
            {
                for (int i = 0; i < Length; i++)
                {
                    int ci = i - (Length - str.Length);
                    c[i] = ci < 0 ? ' ' : str[ci];
                }
            }

            return c;
        }

31. Example

View license
public override string ToString()
		{
			return String.Format(CultureInfo.InvariantCulture, "BitmapIndex['{0}']", this.Name);
		}

32. Example

Project: Akavache
Source File: ExceptionHelper.cs
View license
public static IObservable<T> ObservableThrowKeyNotFoundException<T>(string key, Exception innerException = null)
        {
            return Observable.Throw<T>(
                new KeyNotFoundException(String.Format(CultureInfo.InvariantCulture,
                "The given key '{0}' was not present in the cache.", key), innerException));
        }

33. Example

Project: Akavache
Source File: ExceptionHelper.cs
View license
public static IObservable<T> ObservableThrowObjectDisposedException<T>(string obj, Exception innerException = null)
        {
            return Observable.Throw<T>(
                new ObjectDisposedException(String.Format(CultureInfo.InvariantCulture,
                "The cache '{0}' was disposed.", obj), innerException));
        }

34. Example

Project: hourglass
Source File: SpecialTimeToken.cs
View license
public string GetName(IFormatProvider provider)
            {
                string resourceName = string.Format(
                    CultureInfo.InvariantCulture,
                    "SpecialTimeToken{0}Name",
                    this.SpecialTime);

                return Resources.ResourceManager.GetString(resourceName, provider);
            }

35. Example

Project: hourglass
Source File: SpecialDateToken.cs
View license
public string GetName(IFormatProvider provider)
            {
                string resourceName = string.Format(
                    CultureInfo.InvariantCulture,
                    "SpecialDateToken{0}Name",
                    this.SpecialDate);

                return Resources.ResourceManager.GetString(resourceName, provider);
            }

36. Example

Project: hourglass
Source File: RelativeDateToken.cs
View license
public string GetName(IFormatProvider provider)
            {
                string resourceName = string.Format(
                    CultureInfo.InvariantCulture,
                    "RelativeDateToken{0}Name",
                    this.RelativeDate);

                return Resources.ResourceManager.GetString(resourceName, provider);
            }

37. Example

Project: BehaviorIsManaged
Source File: Verify.cs
View license
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
        [DebuggerStepThrough]
        public static void PropertyIsNull<T>(T obj, string name) where T : class
        {
            if (null != obj)
            {
                throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "The property {0} must be null at this time.", name));
            }
        }

38. Example

Project: BehaviorIsManaged
Source File: Verify.cs
View license
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
        [DebuggerStepThrough]
        public static void PropertyIsNotNull<T>(T obj, string name) where T : class
        {
            if (null == obj)
            {
                throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "The property {0} cannot be null at this time.", name));
            }
        }

39. Example

View license
public static string EncodePingData()
        {
            return string.Format(CultureInfo.InvariantCulture, "{0}|", PingType);
        }

40. Example

Project: NosDB
Source File: Resources.Designer.cs
View license
public static string InvalidFileExtension(string ext)
        {
            return String.Format(resourceCulture, CSharpTest.Net.Resources.FormatStrings.InvalidFileExtension_string_ext_, ext);
        }

41. Example

Project: NosDB
Source File: Resources.Designer.cs
View license
public static string FailedToConstructSingleton(System.Type type)
        {
            return String.Format(resourceCulture, CSharpTest.Net.Resources.FormatStrings.FailedToConstructSingleton_System_Type_type_, type);
        }

42. Example

Project: NosDB
Source File: Resources.Designer.cs
View license
public static string StringConverterTryParse(System.Type type)
        {
            return String.Format(resourceCulture, CSharpTest.Net.Resources.FormatStrings.StringConverterTryParse_System_Type_type_, type);
        }

43. Example

Project: Banzai
Source File: Guard.cs
View license
public static void AgainstNullProperty<TProperty>(string propertyName, TProperty property) where TProperty : class
        {
            if (property == null)
            {
                throw new NullReferenceException(string.Format(CultureInfo.InvariantCulture, "{0} is null.", propertyName));
            }
        }

44. Example

Project: Banzai
Source File: Guard.cs
View license
public static void AgainstNullArgument<TArgument>(string parameterName, TArgument argument)
        {
            if (argument == null)
            {
                throw new ArgumentNullException(parameterName, string.Format(CultureInfo.InvariantCulture, "{0} is null.", parameterName));
            }
        }

45. Example

Project: TQVaultAE
Source File: CommandLineArgs.cs
View license
private static void Usage(string error)
		{
			string message = string.Format(CultureInfo.InvariantCulture, "Error parsing command-line arguments: {0}\n\nUsage: TQVault [playername] [/mod:<mod name>]", error);
			throw new ArgumentException(message);
		}

46. Example

Project: kafka-net
Source File: CompressionCodec.cs
View license
public static CompressionCodecs GetCompressionCodec(int codec)
        {
            switch (codec)
            {
                case 0:
                    return CompressionCodecs.NoCompressionCodec;
                case 1:
                    return CompressionCodecs.GZIPCompressionCodec;
                case 2:
                    return CompressionCodecs.SnappyCompressionCodec;
                default:
                    throw new UnknownCodecException(string.Format(
                        CultureInfo.CurrentCulture,
                        "{0} is an unknown compression codec",
                        codec));
            }
        }

47. Example

Project: Espera
Source File: DeprecatedBlobCache.cs
View license
public static IObservable<T> ObservableThrowObjectDisposedException<T>(string obj, Exception innerException = null)
        {
            return Observable.Throw<T>(
                new ObjectDisposedException(String.Format(CultureInfo.InvariantCulture,
                "The cache '{0}' was disposed.", obj), innerException));
        }

48. Example

Project: Espera
Source File: DeprecatedBlobCache.cs
View license
public static IObservable<T> ObservableThrowKeyNotFoundException<T>(string key, Exception innerException = null)
        {
            return Observable.Throw<T>(
                new KeyNotFoundException(String.Format(CultureInfo.InvariantCulture,
                "The given key '{0}' was not present in the cache.", key), innerException));
        }

49. Example

View license
static string FormatArgumentValue(object value)
    {
        if (value == null)
        {
            return "null";
        }

        return string.Format(CultureInfo.InvariantCulture, "{0}", value);
    }

50. Example

Project: Knifer
Source File: CommandLineUsageEventArgs.cs
View license
public override string ToString()
        {
            return string.Format(CultureInfo.CurrentCulture, "Usage : {0}", Usage);
        }