} // public static string DecimalNumber /// <summary> /// Format any floating point number per the Regional Settings, /// overriding the digits past the decimal point to render a specified /// number of significant digits to the right of the decimal point. /// </summary> /// <param name="pfltDecimalNumber"> /// Floating point value to be formatted /// </param> /// <param name="pintSignificantDigits"> /// Number of significant digits to display /// </param> /// <returns> /// Floating point value, ready to display /// </returns> public static string DecimalNumber(float pfltDecimalNumber, int pintSignificantDigits) { return(pfltDecimalNumber.ToString(NumericFormats.NumberPerRegSettings(pintSignificantDigits))); } // public static string DecimalNumber
} // public static string Integer /// <summary> /// Format any long integer per the Regional Settings, overriding the /// digits past the decimal point to render an long integer. /// </summary> /// <param name="plngAnyInteger"> /// Integer to be formatted /// </param> /// <returns> /// Formatted integer, ready to display /// </returns> public static string Integer(long plngAnyInteger) { return(plngAnyInteger.ToString(NumericFormats.IntegerPerRegSettings( ))); } // public static string Integer
} // void ListObjectProperties /// <summary> /// Enumerate the properties of an object, showing for each its type and /// value, as a formatted listing. /// </summary> /// <param name="pstrNameOfObject"> /// Name of object as it appears in the calling routine /// </param> /// <param name="pObjThisOne"> /// Reference to the object from which to enumerate properties /// </param> /// <param name="pintLeftPadding"> /// Optional left padding for the report /// </param> /// <param name="pstrObjectLabelSuffix"> /// Optional supplementary label information for the object /// </param> /// <param name="penmBindingFlags"> /// Binding flags mask, which determines which properties are enumerated /// </param> public static void ListObjectPropertyTypesAndValues ( string pstrNameOfObject, object pObjThisOne, int pintLeftPadding = ListInfo.EMPTY_STRING_LENGTH, string pstrObjectLabelSuffix = null, BindingFlags penmBindingFlags = DEFAULT_BINDING_FLAGS ) { string strIndentation = pintLeftPadding > ListInfo.EMPTY_STRING_LENGTH ? StringTricks.StrFill ( SpecialCharacters.SPACE_CHAR , pintLeftPadding ) : SpecialStrings.EMPTY_STRING; PropertyInfo [ ] apropertyInfos = pObjThisOne.GetType ( ).GetProperties ( penmBindingFlags ); int intMaxDigits = apropertyInfos.Length.ToString ( ).Length; // Compute the width of the largest possible ordinal. Console.WriteLine ( Properties.Resources.MSG_PROPERTY_LIST_HEADER , // Format Control String strIndentation , // Format Item 0: {0}Object pstrNameOfObject , // Format Item 1: Object {1} pstrObjectLabelSuffix == null // Format Item 2: {2} exposes the ? SpecialStrings.EMPTY_STRING // when pstrObjectLabelSuffix == null : $" ({pstrObjectLabelSuffix})" , // when pstrObjectLabelSuffix != null apropertyInfos.Length , // Format Item 3: exposes the following {2} Environment.NewLine ); // Format Item 4: public properties:{4} for ( int intPropertyIndex = ArrayInfo.ARRAY_FIRST_ELEMENT ; intPropertyIndex < apropertyInfos.Length ; intPropertyIndex++ ) { try { Console.WriteLine ( Properties.Resources.MSG_PROP_TYPE_AND_VALUE_DETAIL , // Format Control String strIndentation , // Format Item 0: {0}Property NumericFormats.FormatIntegerLeftPadded ( // Format Item 1: Property {1}: ArrayInfo.OrdinalFromIndex ( // Get the ordinal equivalent to array subscript. intPropertyIndex ) , // Array subscript for which to get the corresponding ordinal. intMaxDigits ) , // Right align to this width. apropertyInfos [ intPropertyIndex ].Name , // Format Item 2: : {2} apropertyInfos[intPropertyIndex].PropertyType.FullName ,// Format Item 3: ({3}) = StringTricks.TruncateValueToOneLine ( // Format Item 4: = {4} apropertyInfos [ intPropertyIndex ].GetValue ( // Get value from the apropertyInfos in array slot intPropertyIndex. pObjThisOne , // Object from which to get property value. null ) ) ); // The null CultureInfo causes the method to infer the culture of the calling thread. } catch ( TargetInvocationException ex ) { Console.WriteLine ( Properties.Resources.ERRMSG_PROPERTY_LIST , // Format Control String strIndentation , // Format Item 0: {0}Property ArrayInfo.OrdinalFromIndex ( intPropertyIndex ) , // Format Item 1: Property {1}: apropertyInfos [ intPropertyIndex ].Name , // Format Item 2: : {2} = ex.Message ); // Format Item 3: = {3} } } // for ( int intPropertyIndex = ArrayInfo.ARRAY_FIRST_ELEMENT ; intPropertyIndex < apropertyInfos.Length ; intPropertyIndex++ ) Console.WriteLine ( Properties.Resources.MSG_PROPERTY_LIST_FOOTER , // Format Control String strIndentation , // Format Item 0 Environment.NewLine ); // Format Item 1 } // void ListObjectPropertyTypesAndValues