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

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

200 Examples 7

1. 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 AgainstNullArgumentProperty<TProperty>(string parameterName, string propertyName, [ValidatedNotNull]TProperty argumentProperty)
            where TProperty : class
        {
            if (argumentProperty == null)
            {
                throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "{0}.{1} is null.", parameterName, propertyName), parameterName);
            }
        }

2. Example

Project: More
Source File: FiscalYear.cs
View license
public override string ToString()
        {
            return string.Format( CultureInfo.CurrentCulture, "FirstDay = {0:d}, LastDay = {1:d}", FirstDay, LastDay );
        }

3. Example

Project: More
Source File: FiscalWeek.cs
View license
public override string ToString()
        {
            return string.Format( CultureInfo.CurrentCulture, "FirstDay = {0:d}, LastDay = {1:d}", FirstDay, LastDay );
        }

4. Example

Project: More
Source File: FiscalMonth.cs
View license
public override string ToString()
        {
            return string.Format( CultureInfo.CurrentCulture, "FirstDay = {0:d}, LastDay = {1:d}", FirstDay, LastDay );
        }

5. Example

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

6. Example

Project: ContinuousTests
Source File: EventQueue.cs
View license
protected static Exception WrapUnserializableException(Exception ex)
        {
            string message = string.Format(
                CultureInfo.InvariantCulture,
                "(failed to serialize original Exception - original Exception follows){0}{1}",
                Environment.NewLine,
                ex);
            return new Exception(message);
        }

7. Example

Project: ControlzEx
Source File: Verify.cs
View license
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
        [DebuggerStepThrough]
        public static void BoundedInteger(int lowerBoundInclusive, int value, int upperBoundExclusive, string parameterName)
        {
            if (value < lowerBoundInclusive || value >= upperBoundExclusive)
            {
                Assert.Fail();
                throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "The integer value must be bounded with [{0}, {1})", lowerBoundInclusive, upperBoundExclusive), parameterName);
            }
        }

8. Example

Project: Veil
Source File: ComparisonContext.cs
View license
public IComparisonContext VisitingIndex(object index)
		{
			var newBreadcrumb = string.Format(CultureInfo.InvariantCulture, "{0}[{1}]", Breadcrumb, index);

			return new ComparisonContext(Differences, newBreadcrumb);
		}

9. Example

Project: LibLog
Source File: LogMessageFormatterTests.cs
View license
[Fact]
        public void When_argument_is_multiple_time_Then_should_be_replaced_with_same_value()
        {
            var date = DateTime.Today;
            Func<string> messageBuilder = () => "{date:yyyy-MM-dd} {argument1} {date:yyyy}";

            var formattedMessage = LogMessageFormatter.SimulateStructuredLogging(messageBuilder, new object[] { date, "arg0" })();

            formattedMessage.ShouldBe(
                string.Format(CultureInfo.InvariantCulture, "{0:yyyy-MM-dd} {1} {0:yyyy}", date, "arg0"));
        }

10. Example

Project: LibLog
Source File: LogMessageFormatterTests.cs
View license
[Fact]
        public void When_argument_has_format_Then_should_preserve_format()
        {
            var date = DateTime.Today;
            Func<string> messageBuilder = () => "Formatted {date1:yyyy-MM-dd} and not formatted {date2}.";

            var formattedMessage = LogMessageFormatter.SimulateStructuredLogging(messageBuilder, new object[] { date, date })();

            formattedMessage.ShouldBe(
                string.Format(CultureInfo.InvariantCulture, "Formatted {0:yyyy-MM-dd} and not formatted {1}.", date, date));
        }

11. Example

Project: storybrew
Source File: StringHelper.cs
View license
public static string ToByteSize(double byteCount, string format = "{0:0.#} {1}")
        {
            var order = 0;
            while (byteCount >= 1024 && order < sizeOrders.Length - 1)
            {
                order++;
                byteCount /= 1024;
            }
            return string.Format(CultureInfo.InvariantCulture, format, byteCount, sizeOrders[order]);
        }

12. Example

Project: tik4net
Source File: Guard.cs
View license
public static void ArgumentOfType<TExpectedType>(object argumentValue, string argumentName)
        {
            if (argumentName is TExpectedType)
                throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, "The provided argument {0} must of '{1}' type.", argumentName, typeof(TExpectedType)), argumentName);            
        }

13. 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 AgainstNullArgumentProperty<TProperty>(string parameterName, string propertyName, [ValidatedNotNull]TProperty argumentProperty)
            where TProperty : class
        {
            if (argumentProperty == null)
            {
                throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "{0}.{1} is null.", parameterName, propertyName), parameterName);
            }
        }

14. Example

Project: WebActivator
Source File: AccountModels.cs
View license
public override string FormatErrorMessage(string name)
        {
            return String.Format(CultureInfo.CurrentCulture, ErrorMessageString,
                OriginalProperty, ConfirmProperty);
        }

15. Example

Project: WebActivator
Source File: AccountModels.cs
View license
public override string FormatErrorMessage(string name)
        {
            return String.Format(CultureInfo.CurrentCulture, ErrorMessageString,
                name, _minCharacters);
        }

16. Example

View license
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
            {
                PosDouble p = (PosDouble)value;

                if (p != null)
                    writer.WriteRawValue(String.Format(CultureInfo.InvariantCulture, "new PosD({0},{1})", p.X, p.Y));
                else
                    writer.WriteNull();
            }

17. Example

View license
private static Exception AmbiguousParameterException(string parameterMatchInfo)
        {
            return new MappingConfigurationException(string.Format(
                CultureInfo.InvariantCulture,
                "Multiple constructor parameters found {0} on type {1}",
                parameterMatchInfo,
                typeof(TTarget).GetFriendlyName()));
        }

18. Example

View license
private static Exception MissingParameterException(string parameterMatchInfo)
        {
            return new MappingConfigurationException(string.Format(
                CultureInfo.InvariantCulture,
                "No constructor parameter {0} exists on type {1}",
                parameterMatchInfo,
                typeof(TTarget).GetFriendlyName()));
        }

19. Example

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

20. Example

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

21. Example

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

22. Example

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

23. Example

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

24. Example

Project: Magick.NET
Source File: Density.cs
View license
public string ToString(DensityUnit units)
        {
            string result = string.Format(CultureInfo.InvariantCulture, "{0}x{1}", X, Y);

            switch (units)
            {
                case DensityUnit.PixelsPerCentimeter:
                    return result + " cm";
                case DensityUnit.PixelsPerInch:
                    return result + " inch";
                default:
                    return result;
            }
        }

25. Example

Project: Magick.NET
Source File: PointD.cs
View license
public override string ToString()
        {
            return string.Format(CultureInfo.InvariantCulture, "{0}x{1}", _x, _y);
        }

26. Example

Project: Magick.NET
Source File: MagickImage.cs
View license
private string FormatedFileSize()
        {
            decimal fileSize = FileSize;

            string suffix = string.Empty;
            if (fileSize > 1073741824)
            {
                fileSize /= 1073741824;
                suffix = "GB";
            }
            else if (fileSize > 1048576)
            {
                fileSize /= 1048576;
                suffix = "MB";
            }
            else if (fileSize > 1024)
            {
                fileSize /= 1024;
                suffix = "kB";
            }

            return string.Format(CultureInfo.InvariantCulture, "{0:N2}{1}", fileSize, suffix);
        }

27. Example

Project: corewf
Source File: Activity.cs
View license
public override string ToString()
        {
            return string.Format(CultureInfo.CurrentCulture, "{0}: {1}", this.Id, this.DisplayName);
        }

28. Example

Project: corewf
Source File: TestRootActivity.cs
View license
public override string ToString()
        {
            return string.Format(CultureInfo.InvariantCulture, "[{0},{1}]", _name, _action);
        }

29. Example

Project: Eddie
Source File: LinqBridge.cs
View license
public override string ToString()
    {
      return string.Format(CultureInfo.InvariantCulture, @"{{ First = {0}, Second = {1} }}", First, Second);
    }

30. Example

Project: Eddie
Source File: JsonSerializerTest.cs
View license
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
            {
                PosDouble p = (PosDouble)value;

                if (p != null)
                {
                    writer.WriteRawValue(String.Format(CultureInfo.InvariantCulture, "new PosD({0},{1})", p.X, p.Y));
                }
                else
                {
                    writer.WriteNull();
                }
            }

31. Example

Project: spectnetide
Source File: EditorPaneBase.cs
View license
int IPersistFileFormat.GetFormatList(out string ppszFormatList)
        {
            string formatList =
                string.Format(CultureInfo.CurrentCulture,
                    "Editor Files (*{0}){1}*{0}{1}{1}",
                    FileExtensionUsed, END_LINE_CHAR);
            ppszFormatList = formatList;
            return VSConstants.S_OK;
        }

32. Example

View license
[NotNull]
		private FormatException SyntaxError(string msg)
		{
			return new FormatException(String.Format(CultureInfo.InvariantCulture, "Invalid JSON Syntax: {0} at {1}", msg, m_cursor));
		}

33. Example

View license
public override string ToString()
			{
				return String.Format(CultureInfo.InvariantCulture, "[{0}, {1})", this.Begin, this.End);
			}

34. Example

Project: Xamaridea
Source File: MenuItemTest.cs
View license
[TestMethod()]
        [HostType("VS IDE")]
        public void LaunchCommand()
        {
            UIThreadInvoker.Invoke((ThreadInvoker)delegate()
            {
                CommandID menuItemCmd = new CommandID(EgorBo.Xamaridea_VisualStudioPlugin.GuidList.guidXamaridea_VisualStudioPluginCmdSet, (int)EgorBo.Xamaridea_VisualStudioPlugin.PkgCmdIDList.cmdidOpenInIdeaCommand);

                // Create the DialogBoxListener Thread.
                string expectedDialogBoxText = string.Format(CultureInfo.CurrentCulture, "{0}\n\nInside {1}.MenuItemCallback()", "Xamaridea.VisualStudioPlugin", "EgorBo.Xamaridea_VisualStudioPlugin.Xamaridea_VisualStudioPluginPackage");
                DialogBoxPurger purger = new DialogBoxPurger(NativeMethods.IDOK, expectedDialogBoxText);

                try
                {
                    purger.Start();

                    TestUtils testUtils = new TestUtils();
                    testUtils.ExecuteCommand(menuItemCmd);
                }
                finally
                {
                    Assert.IsTrue(purger.WaitForDialogThreadToTerminate(), "The dialog box has not shown");
                }
            });
        }

35. Example

Project: MBINCompiler
Source File: Half.cs
View license
DateTime IConvertible.ToDateTime(IFormatProvider provider)
        {
            throw new InvalidCastException(string.Format(CultureInfo.CurrentCulture, "Invalid cast from '{0}' to '{1}'.", "Half", "DateTime"));
        }

36. Example

Project: MBINCompiler
Source File: Half.cs
View license
char IConvertible.ToChar(IFormatProvider provider)
        {
            throw new InvalidCastException(string.Format(CultureInfo.CurrentCulture, "Invalid cast from '{0}' to '{1}'.", "Half", "Char"));
        }

37. Example

Project: BehaviorIsManaged
Source File: Verify.cs
View license
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
        [DebuggerStepThrough]
        public static void BoundedInteger(int lowerBoundInclusive, int value, int upperBoundExclusive, string parameterName)
        {
            if (value < lowerBoundInclusive || value >= upperBoundExclusive)
            {
                throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "The integer value must be bounded with [{0}, {1})", lowerBoundInclusive, upperBoundExclusive), parameterName);
            }
        }

38. Example

View license
public static string EncodeError(string message)
        {
            return string.Format(CultureInfo.InvariantCulture, "{0}|{1}", ErrorType, message);
        }

39. Example

View license
public static string EncodeInfo(string message)
        {
            return string.Format(CultureInfo.InvariantCulture, "{0}|{1}", DebugType, message);
        }

40. Example

Project: mptanks2d
Source File: HalfFloat.cs
View license
char IConvertible.ToChar(IFormatProvider provider)
        {
            throw new InvalidCastException(string.Format(CultureInfo.CurrentCulture, "Invalid cast from '{0}' to '{1}'.", "Half", "Char"));
        }

41. Example

Project: mptanks2d
Source File: HalfFloat.cs
View license
DateTime IConvertible.ToDateTime(IFormatProvider provider)
        {
            throw new InvalidCastException(string.Format(CultureInfo.CurrentCulture, "Invalid cast from '{0}' to '{1}'.", "Half", "DateTime"));
        }

42. Example

Project: InnovatorAdmin
Source File: TextLocation.cs
View license
public override string ToString()
		{
			return string.Format(CultureInfo.InvariantCulture, "(Line {1}, Col {0})", this.column, this.line);
		}

43. Example

Project: Banzai
Source File: Guard.cs
View license
public static void AgainstNullArgumentProperty<TProperty>(string parameterName, string propertyName, TProperty argumentProperty)
        {
            if (argumentProperty == null)
            {
                throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "{0}.{1} is null.", parameterName, propertyName), parameterName);
            }
        }

44. Example

Project: TQVaultAE
Source File: ItemProperties.cs
View license
private void LoadProperties()
		{
			string[] bareAttr;
			bareAttr = this.item.GetBareAttributes(this.filterExtra);
			string bgcolor = "#2e1f15";

			// Base Item Attributes
			if (bareAttr[0].Length == 0)
			{
				this.webBrowser1.Hide();
				this.label2.Hide();
			}
			else
			{
				this.webBrowser1.DocumentText = string.Format(CultureInfo.InvariantCulture, "<body bgcolor={0} text=white><font face=\"Albertus MT\" size=1>{1}", bgcolor, bareAttr[0]);
				this.webBrowser1.Show();
				this.label2.Show();
			}

			// Prefix Attributes
			if (bareAttr[2].Length == 0)
			{
				this.webBrowser2.Hide();
				this.label1.Hide();
			}
			else
			{
				this.webBrowser2.DocumentText = string.Format(CultureInfo.InvariantCulture, "<body bgcolor={0} text=white><font face=\"Albertus MT\" size=1>{1}", bgcolor, bareAttr[2]);
				this.webBrowser2.Show();
				this.label1.Show();
			}

			// Suffix Attributes
			if (bareAttr[3].Length == 0)
			{
				this.webBrowser3.Hide();
				this.label3.Hide();
			}
			else
			{
				this.webBrowser3.DocumentText = string.Format(CultureInfo.InvariantCulture, "<body bgcolor={0} text=white><font face=\"Albertus MT\" size=1>{1}", bgcolor, bareAttr[3]);
				this.webBrowser3.Show();
				this.label3.Show();
			}
		}

45. Example

Project: Albedo
Source File: ParameterInfoElement.cs
View license
public override string ToString()
        {
            return string.Format(
                CultureInfo.CurrentCulture, "[[{0}]] ({1})", this.ParameterInfo, "parameter");
        }

46. Example

Project: Albedo
Source File: LocalVariableInfoElement.cs
View license
public override string ToString()
        {
            return string.Format(
                CultureInfo.CurrentCulture, "[[{0}]] ({1})", this.LocalVariableInfo, "local");
        }

47. Example

Project: Albedo
Source File: PropertyInfoElement.cs
View license
public override string ToString()
        {
            return string.Format(
                CultureInfo.CurrentCulture, "[[{0}]] ({1})", this.PropertyInfo, "property");
        }

48. Example

Project: Albedo
Source File: MethodInfoElement.cs
View license
public override string ToString()
        {
            return string.Format(
                CultureInfo.CurrentCulture, "[[{0}]] ({1})", this.MethodInfo, "method");
        }

49. Example

Project: Albedo
Source File: FieldInfoElement.cs
View license
public override string ToString()
        {
            return string.Format(
                CultureInfo.CurrentCulture, "[[{0}]] ({1})", this.FieldInfo, "field");
        }

50. Example

Project: Albedo
Source File: TypeElement.cs
View license
public override string ToString()
        {
            return string.Format(
                CultureInfo.CurrentCulture, "[[{0}]] ({1})", this.Type, "type");
        }