public XmlILStorageMethods(Type storageType)
{
// Aggregates
if (storageType == typeof(int) || storageType == typeof(long) ||
storageType == typeof(decimal) || storageType == typeof(double))
{
Type aggType = Type.GetType("System.Xml.Xsl.Runtime." + storageType.Name + "Aggregator");
AggAvg = XmlILMethods.GetMethod(aggType, "Average");
AggAvgResult = XmlILMethods.GetMethod(aggType, "get_AverageResult");
AggCreate = XmlILMethods.GetMethod(aggType, "Create");
AggIsEmpty = XmlILMethods.GetMethod(aggType, "get_IsEmpty");
AggMax = XmlILMethods.GetMethod(aggType, "Maximum");
AggMaxResult = XmlILMethods.GetMethod(aggType, "get_MaximumResult");
AggMin = XmlILMethods.GetMethod(aggType, "Minimum");
AggMinResult = XmlILMethods.GetMethod(aggType, "get_MinimumResult");
AggSum = XmlILMethods.GetMethod(aggType, "Sum");
AggSumResult = XmlILMethods.GetMethod(aggType, "get_SumResult");
}
// Sequences
if (storageType == typeof(XPathNavigator))
{
SeqType = typeof(XmlQueryNodeSequence);
SeqAdd = XmlILMethods.GetMethod(SeqType, "AddClone");
}
else if (storageType == typeof(XPathItem))
{
SeqType = typeof(XmlQueryItemSequence);
SeqAdd = XmlILMethods.GetMethod(SeqType, "AddClone");
}
else
{
SeqType = typeof(XmlQuerySequence<>).MakeGenericType(storageType);
SeqAdd = XmlILMethods.GetMethod(SeqType, "Add");
}
SeqEmpty = SeqType.GetField("Empty");
SeqReuse = XmlILMethods.GetMethod(SeqType, "CreateOrReuse", SeqType);
SeqReuseSgl = XmlILMethods.GetMethod(SeqType, "CreateOrReuse", SeqType, storageType);
SeqSortByKeys = XmlILMethods.GetMethod(SeqType, "SortByKeys");
// IList<>
IListType = typeof(IList<>).MakeGenericType(storageType);
IListItem = XmlILMethods.GetMethod(IListType, "get_Item");
IListCount = XmlILMethods.GetMethod(typeof(ICollection<>).MakeGenericType(storageType), "get_Count");
// XPathItem.ValueAsXXX
if (storageType == typeof(string))
ValueAs = XmlILMethods.GetMethod(typeof(XPathItem), "get_Value");
else if (storageType == typeof(int))
ValueAs = XmlILMethods.GetMethod(typeof(XPathItem), "get_ValueAsInt");
else if (storageType == typeof(long))
ValueAs = XmlILMethods.GetMethod(typeof(XPathItem), "get_ValueAsLong");
else if (storageType == typeof(DateTime))
ValueAs = XmlILMethods.GetMethod(typeof(XPathItem), "get_ValueAsDateTime");
else if (storageType == typeof(double))
ValueAs = XmlILMethods.GetMethod(typeof(XPathItem), "get_ValueAsDouble");
else if (storageType == typeof(bool))
ValueAs = XmlILMethods.GetMethod(typeof(XPathItem), "get_ValueAsBoolean");
// XmlILStorageConverter.XXXToAtomicValue
if (storageType == typeof(byte[]))
ToAtomicValue = XmlILMethods.GetMethod(typeof(XmlILStorageConverter), "BytesToAtomicValue");
else if (storageType != typeof(XPathItem) && storageType != typeof(XPathNavigator))
ToAtomicValue = XmlILMethods.GetMethod(typeof(XmlILStorageConverter), storageType.Name + "ToAtomicValue");
}
}