System.Xml.Xsl.IlGen.XmlILVisitor.GetXsltConvertMethod C# (CSharp) Method

GetXsltConvertMethod() private method

Get the XsltConvert method that converts from "typSrc" to "typDst". Return false if no such method exists. This conversion matrix should match the one in XsltConvert.ExternalValueToExternalValue.
private GetXsltConvertMethod ( XmlQueryType typSrc, XmlQueryType typDst, MethodInfo &meth ) : bool
typSrc XmlQueryType
typDst XmlQueryType
meth System.Reflection.MethodInfo
return bool
        private bool GetXsltConvertMethod(XmlQueryType typSrc, XmlQueryType typDst, out MethodInfo meth) {
            meth = null;

            // Note, Ref.Equals is OK to use here, since we will always fall back to Item or Item* in the
            // case where the source or destination types do not match the static types exposed on the
            // XmlQueryTypeFactory.  This is bad for perf if it accidentally occurs, but the results
            // should still be correct.

            // => xs:boolean
            if (Ref.Equals(typDst, TypeFactory.BooleanX)) {
                if (Ref.Equals(typSrc, TypeFactory.Item))               meth = XmlILMethods.ItemToBool;
                else if (Ref.Equals(typSrc, TypeFactory.ItemS))         meth = XmlILMethods.ItemsToBool;
            }
            // => xs:dateTime
            else if (Ref.Equals(typDst, TypeFactory.DateTimeX)) {
                if (Ref.Equals(typSrc, TypeFactory.StringX))            meth = XmlILMethods.StrToDT;
            }
            // => xs:decimal
            else if (Ref.Equals(typDst, TypeFactory.DecimalX)) {
                if (Ref.Equals(typSrc, TypeFactory.DoubleX))            meth = XmlILMethods.DblToDec;
            }
            // => xs:double
            else if (Ref.Equals(typDst, TypeFactory.DoubleX)) {
                if (Ref.Equals(typSrc, TypeFactory.DecimalX))           meth = XmlILMethods.DecToDbl;
                else if (Ref.Equals(typSrc, TypeFactory.IntX))          meth = XmlILMethods.IntToDbl;
                else if (Ref.Equals(typSrc, TypeFactory.Item))          meth = XmlILMethods.ItemToDbl;
                else if (Ref.Equals(typSrc, TypeFactory.ItemS))         meth = XmlILMethods.ItemsToDbl;
                else if (Ref.Equals(typSrc, TypeFactory.LongX))         meth = XmlILMethods.LngToDbl;
                else if (Ref.Equals(typSrc, TypeFactory.StringX))       meth = XmlILMethods.StrToDbl;
            }
            // => xs:int
            else if (Ref.Equals(typDst, TypeFactory.IntX)) {
                if (Ref.Equals(typSrc, TypeFactory.DoubleX))            meth = XmlILMethods.DblToInt;
            }
            // => xs:long
            else if (Ref.Equals(typDst, TypeFactory.LongX)) {
                if (Ref.Equals(typSrc, TypeFactory.DoubleX))            meth = XmlILMethods.DblToLng;
            }
            // => node
            else if (Ref.Equals(typDst, TypeFactory.NodeNotRtf)) {
                if (Ref.Equals(typSrc, TypeFactory.Item))               meth = XmlILMethods.ItemToNode;
                else if (Ref.Equals(typSrc, TypeFactory.ItemS))         meth = XmlILMethods.ItemsToNode;
            }
            // => node*
            else if (Ref.Equals(typDst, TypeFactory.NodeDodS) ||
                     Ref.Equals(typDst, TypeFactory.NodeNotRtfS)) {
                if (Ref.Equals(typSrc, TypeFactory.Item))               meth = XmlILMethods.ItemToNodes;
                else if (Ref.Equals(typSrc, TypeFactory.ItemS))         meth = XmlILMethods.ItemsToNodes;
            }
            // => xs:string
            else if (Ref.Equals(typDst, TypeFactory.StringX)) {
                if (Ref.Equals(typSrc, TypeFactory.DateTimeX))          meth = XmlILMethods.DTToStr;
                else if (Ref.Equals(typSrc, TypeFactory.DoubleX))       meth = XmlILMethods.DblToStr;
                else if (Ref.Equals(typSrc, TypeFactory.Item))          meth = XmlILMethods.ItemToStr;
                else if (Ref.Equals(typSrc, TypeFactory.ItemS))         meth = XmlILMethods.ItemsToStr;
            }

            return meth != null ? true : false;
        }
XmlILVisitor