AT.MIN.Tools.FormatOct C# (CSharp) Method

FormatOct() private static method

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

			if ( IsNumericType( Value ) )
			{
				w = Convert.ToString( UnboxToLong( Value, true ), 8 );

				if ( Left2Right || Padding == ' ' )
				{
					if ( Alternate && w != "0" )
						w = "0" + w;
					w = String.Format( lengthFormat, w );
				}
				else
				{
					if ( FieldLength != int.MinValue )
						w = w.PadLeft( FieldLength - ( Alternate && w != "0" ? 1 : 0 ), Padding );
					if ( Alternate && w != "0" )
						w = "0" + w;
				}
			}

			return w;
		}
		#endregion