Esempio n. 1
0
 public static void Write <T>(T Value)
 {
     if (!Silent)
     {
         Out.Write(Value);
     }
 }
Esempio n. 2
0
        public void Write(char *Buffer, ref int BufferLength)
        {
            var NumberFormat = CultureInfo.CurrentCulture.NumberFormat;

            if (Value < 0)
            {
                Write(-Value, s_NumberNegativePatterns[NumberFormat.NumberNegativePattern], ref BufferLength);

                return;
            }

            Write(Value, s_NumberPositivePatterns[NumberFormat.CurrencyPositivePattern], ref BufferLength);

            void Write(float Value, string Pattern, ref int _BufferLength)
            {
                fixed(char *PatternBuffer = Pattern)
                {
                    for (int Index = 0; Index < Pattern.Length; Index++)
                    {
                        char Char = PatternBuffer[Index];

                        switch (Char)
                        {
                        case '$':
                        {
                            StringStream.Write(NumberFormat.CurrencySymbol, Buffer, ref _BufferLength);

                            break;
                        }

                        case '-':
                        {
                            StringStream.Write(NumberFormat.NegativeSign, Buffer, ref _BufferLength);

                            break;
                        }

                        case 'n':
                        {
                            int    DecimalDigits = NumberFormat.CurrencyDecimalDigits;
                            int    GroupSize     = NumberFormat.CurrencyGroupSizes[0];
                            string GroupSeprator = NumberFormat.NumberGroupSeparator;

                            StringStream.Write(Value, Buffer, ref _BufferLength, DecimalDigits, DecimalDigits, GroupSize, GroupSeprator);

                            break;
                        }

                        default:
                        {
                            Buffer[_BufferLength++] = Char;

                            break;
                        }
                        }
                    }
                }
            }
        }
Esempio n. 3
0
            // based on default .NET ToString implementation (write the full name of data type).
            static void DefaultWriter(T Value, char *Buffer, ref int BufferLength)
            {
                if (s_TypeName == null)
                {
                    var Type = typeof(T);

                    s_TypeName       = Type.Name;
                    s_TypeNamesspace = Type.Namespace;
                }
                if (!string.IsNullOrEmpty(s_TypeNamesspace))
                {
                    StringStream.Write(s_TypeNamesspace, Buffer, ref BufferLength);
                    Buffer[BufferLength++] = '.';
                }

                StringStream.Write(s_TypeName, Buffer, ref BufferLength);
            }
Esempio n. 4
0
        public static void WriteFracPart(float FracPart, char *Buffer, ref int BufferLength, int MinDecimalDigits = 0, int MaxDecimalDigits = int.MaxValue)
        {
            var NumberFormat = CultureInfo.CurrentCulture.NumberFormat;

            int DecimalDigtis = 0;

            if (FracPart > 0)
            {
                StringStream.Write(NumberFormat.NumberDecimalSeparator, Buffer, ref BufferLength);
                int DecimalSeparatorIndex = BufferLength;

                int   Exponent    = 10;
                float TmpFracPart = FracPart;

                while (TmpFracPart > 0)
                {
                    DecimalDigtis++;

                    if (DecimalDigtis > MaxDecimalDigits)
                    {
                        return;
                    }

                    TmpFracPart            = Modf(FracPart * Exponent, out int IntPart);
                    Buffer[BufferLength++] = (char)((IntPart % 10) + '0');

                    Exponent *= 10;
                }
            }

            while (DecimalDigtis < MinDecimalDigits)
            {
                DecimalDigtis++;
                Buffer[BufferLength++] = '0';
            }
        }
Esempio n. 5
0
        public static void WriteNegativeSign(char *Buffer, ref int BufferLength)
        {
            var NumberFormat = CultureInfo.CurrentCulture.NumberFormat;

            StringStream.Write(NumberFormat.NegativeSign, Buffer, ref BufferLength);
        }
Esempio n. 6
0
        // -------------------------------------------------------------------------------------------------------------
        //          String Conversion Methods
        // -------------------------------------------------------------------------------------------------------------

        public static string ToString <T>(T Value)
        {
            s_Global.Write(Value);

            return(s_Global.Flush());
        }
Esempio n. 7
0
 public void Write(char *Buffer, ref int BufferLength)
 {
     StringStream.Write(Field, Buffer, ref BufferLength);
 }