AddDecimalFormat() private method

private AddDecimalFormat ( XmlQualifiedName name, DecimalFormat formatinfo ) : void
name System.Xml.XmlQualifiedName
formatinfo System.Xml.Xsl.Runtime.DecimalFormat
return void
示例#1
0
        protected void CompileDecimalFormat(Compiler compiler)
        {
            NumberFormatInfo info   = new NumberFormatInfo();
            DecimalFormat    format = new DecimalFormat(info, '#', '0', ';');
            XmlQualifiedName?Name   = null;
            NavigatorInput   input  = compiler.Input;

            if (input.MoveToFirstAttribute())
            {
                do
                {
                    if (input.Prefix.Length != 0)
                    {
                        continue;
                    }

                    string name  = input.LocalName;
                    string value = input.Value;

                    if (Ref.Equal(name, input.Atoms.Name))
                    {
                        Name = compiler.CreateXPathQName(value);
                    }
                    else if (Ref.Equal(name, input.Atoms.DecimalSeparator))
                    {
                        info.NumberDecimalSeparator = value;
                    }
                    else if (Ref.Equal(name, input.Atoms.GroupingSeparator))
                    {
                        info.NumberGroupSeparator = value;
                    }
                    else if (Ref.Equal(name, input.Atoms.Infinity))
                    {
                        info.PositiveInfinitySymbol = value;
                    }
                    else if (Ref.Equal(name, input.Atoms.MinusSign))
                    {
                        info.NegativeSign = value;
                    }
                    else if (Ref.Equal(name, input.Atoms.NaN))
                    {
                        info.NaNSymbol = value;
                    }
                    else if (Ref.Equal(name, input.Atoms.Percent))
                    {
                        info.PercentSymbol = value;
                    }
                    else if (Ref.Equal(name, input.Atoms.PerMille))
                    {
                        info.PerMilleSymbol = value;
                    }
                    else if (Ref.Equal(name, input.Atoms.Digit))
                    {
                        if (CheckAttribute(value.Length == 1, compiler))
                        {
                            format.digit = value[0];
                        }
                    }
                    else if (Ref.Equal(name, input.Atoms.ZeroDigit))
                    {
                        if (CheckAttribute(value.Length == 1, compiler))
                        {
                            format.zeroDigit = value[0];
                        }
                    }
                    else if (Ref.Equal(name, input.Atoms.PatternSeparator))
                    {
                        if (CheckAttribute(value.Length == 1, compiler))
                        {
                            format.patternSeparator = value[0];
                        }
                    }
                }while (input.MoveToNextAttribute());
                input.ToParent();
            }
            info.NegativeInfinitySymbol = string.Concat(info.NegativeSign, info.PositiveInfinitySymbol);
            if (Name == null)
            {
                Name = new XmlQualifiedName();
            }
            compiler.AddDecimalFormat(Name, format);
            CheckEmpty(compiler);
        }
        protected void CompileDecimalFormat(Compiler compiler){
            NumberFormatInfo info   = new NumberFormatInfo();
            DecimalFormat    format = new DecimalFormat(info, '#', '0', ';');
            XmlQualifiedName  Name  = null;
            NavigatorInput   input  = compiler.Input;
            if (input.MoveToFirstAttribute()) {
                do {
                    if (input.Prefix.Length != 0) continue;

                    string name   = input.LocalName;
                    string value  = input.Value;

                    if (Ref.Equal(name, input.Atoms.Name)) {
                        Name = compiler.CreateXPathQName(value);
                    }
                    else if (Ref.Equal(name, input.Atoms.DecimalSeparator)) {
                        info.NumberDecimalSeparator = value;
                    }
                    else if (Ref.Equal(name, input.Atoms.GroupingSeparator)) {
                        info.NumberGroupSeparator = value;
                    }
                    else if (Ref.Equal(name, input.Atoms.Infinity)) {
                        info.PositiveInfinitySymbol = value;
                    }
                    else if (Ref.Equal(name, input.Atoms.MinusSign)) {
                        info.NegativeSign = value;
                    }
                    else if (Ref.Equal(name, input.Atoms.NaN)) {
                        info.NaNSymbol = value;
                    }
                    else if (Ref.Equal(name, input.Atoms.Percent)) {
                        info.PercentSymbol = value;
                    }
                    else if (Ref.Equal(name, input.Atoms.PerMille)) {
                        info.PerMilleSymbol = value;
                    }
                    else if (Ref.Equal(name, input.Atoms.Digit)) {
                        if (CheckAttribute(value.Length == 1, compiler)) {
                            format.digit = value[0];
                        }
                    }
                    else if (Ref.Equal(name, input.Atoms.ZeroDigit)) {
                        if (CheckAttribute(value.Length == 1, compiler)) {
                            format.zeroDigit = value[0];
                        }
                    }
                    else if (Ref.Equal(name, input.Atoms.PatternSeparator)) {
                        if (CheckAttribute(value.Length == 1, compiler)) {
                            format.patternSeparator = value[0];
                        }
                    }
                }
                while(input.MoveToNextAttribute());
                input.ToParent();
            }
            info.NegativeInfinitySymbol = String.Concat(info.NegativeSign, info.PositiveInfinitySymbol);
            if (Name == null) {
                Name = new XmlQualifiedName();
            }
            compiler.AddDecimalFormat(Name, format);
            CheckEmpty(compiler);
        }