System.Xml.Xsl.XsltOld.NumberAction.SimplifyValue C# (CSharp) Method

SimplifyValue() private static method

private static SimplifyValue ( object value ) : object
value object
return object
        private static object SimplifyValue(object value) {
            // If result of xsl:number is not in correct range it should be returned as is.
            // so we need intermidiate string value.
            // If it's already a double we would like to keep it as double.
            // So this function converts to string only if if result is nodeset or RTF
            Debug.Assert(!(value is int));
            if (Type.GetTypeCode(value.GetType()) == TypeCode.Object) {
                XPathNodeIterator nodeset = value as XPathNodeIterator;
                if (nodeset != null) {
                    if (nodeset.MoveNext()) {
                        return nodeset.Current.Value;
                    }
                    return string.Empty;
                }
                XPathNavigator nav = value as XPathNavigator;
                if (nav != null) {
                    return nav.Value;
                }
            }
            return value;
        }