AT.MIN.Tools.FormatNumber C# (CSharp) 메소드

FormatNumber() 개인적인 정적인 메소드

private static FormatNumber ( string NativeFormat, bool Alternate, int FieldLength, int FieldPrecision, bool Left2Right, bool PositiveSign, bool PositiveSpace, char Padding, object Value ) : string
NativeFormat string
Alternate bool
FieldLength int
FieldPrecision int
Left2Right bool
PositiveSign bool
PositiveSpace bool
Padding char
Value object
리턴 string
		private static string FormatNumber( string NativeFormat, bool Alternate,
											int FieldLength, int FieldPrecision,
											bool Left2Right,
											bool PositiveSign, bool PositiveSpace,
											char Padding, object Value )
		{
			string w = String.Empty;
			string lengthFormat = "{0" + ( FieldLength != int.MinValue ?
											"," + ( Left2Right ?
													"-" :
													String.Empty ) + FieldLength.ToString() :
											String.Empty ) + "}";
			string numberFormat = "{0:" + NativeFormat + ( FieldPrecision != int.MinValue ?
											FieldPrecision.ToString() :
											"0" ) + "}";

			if ( IsNumericType( Value ) )
			{
				w = String.Format(CultureInfo.InvariantCulture, numberFormat, Value );

				if ( Left2Right || Padding == ' ' )
				{
					if ( IsPositive( Value, true ) )
						w = ( PositiveSign ?
								"+" : ( PositiveSpace ? " " : String.Empty ) ) + w;
					w = String.Format( lengthFormat, w );
				}
				else
				{
					if ( w.StartsWith( "-" ) )
						w = w.Substring( 1 );
					if ( FieldLength != int.MinValue )
						w = w.PadLeft( FieldLength - 1, Padding );
					if ( IsPositive( Value, true ) )
						w = ( PositiveSign ?
								"+" : ( PositiveSpace ? " " : String.Empty ) ) + w;
					else
						w = "-" + w;
				}
			}

			return w;
		}
		#endregion