public string Format( string format, object arg, IFormatProvider formatProvider) { if (!this.Equals(formatProvider)) { return(null); } if (!(arg is WrappedArgument wrappedArgument)) { throw new FormatException("This formatter is not meant for public use."); } var guid = Guid.NewGuid(); // ReSharper disable FormatStringProblem var formattedValue = string.IsNullOrWhiteSpace(format) ? $"{wrappedArgument.Value}" : string.Format("{0:" + format + "}", wrappedArgument.Value); // ReSharper restore FormatStringProblem var guidAsString = guid.ToString("N"); var argumentReferenceInformation = new ArgumentReferenceInformation( wrappedArgument.ArgumentIndex, guidAsString, formattedValue); this.ArgumentReferences.Add(argumentReferenceInformation); return(guidAsString); }
public FormatSlice(string formatString, ArgumentReferenceInformation argumentReferenceInformation) { this.FormatString = formatString; this.ArgumentReferenceInformation = argumentReferenceInformation; }