本文整理汇总了C#中IVariable.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# IVariable.GetType方法的具体用法?C# IVariable.GetType怎么用?C# IVariable.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IVariable
的用法示例。
在下文中一共展示了IVariable.GetType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateEmptyValuesArray
public static IMultiDimensionalArray CreateEmptyValuesArray(IVariable variable)
{
Type valueType = variable.GetType().GetGenericArguments()[0];
return (MultiDimensionalArray)TypeUtils.CreateGeneric(typeof(MultiDimensionalArray<>), valueType);
}
示例2: Calc
//Calculates the value by expression tree.
//Calculator - The object that contains functions, variables and expressions.
//Relative - The relative variable.
public object Calc(ICalculator calculator, IVariable relative, IFunction callFunction)
{
try
{
if (m_type == NODE_TYPE.FUNCTION || m_type == NODE_TYPE.OPERATOR)
{
//Run function.
IFunction func;
//(14.11.2006 11:50)
//Point directly to the function to increase speed.
if (m_function != null)
{
func = m_function;
}
else
{
string val = (string)m_value;
FunctionSet functions = calculator.Functions;
if (functions.Contains(val))
{
func = functions.Item(val);
m_function = func;
}
else
{
throw new Exception("Unknown function :" + val);
}
}
if (func is IIntelligenceFunction)
{
return ((IIntelligenceFunction)func).Run(m_subNodes, calculator, relative);
}
object[] @params = new object[this.m_subNodes.Length];
//The argument position.
int i = 0;
while (i < @params.Length)
{
object obj = m_subNodes[i].Calc(calculator, relative, func);
@params[i] = obj;
i += 1;
}
return func.Run(@params);
}
else if (m_type == NODE_TYPE.TEXT)
return m_value;
else if (m_type == NODE_TYPE.NUMBER)
return (float)m_value;
else if (m_type == NODE_TYPE.VARIABLE)
{
string val = (string)m_value;
int propIndex = val.IndexOf('.');
#region "Sub Expression Updating"
// Update sub expressions before calculating the value to make sure
// the computation will be correct.
if (calculator.RunExpressions && relative != null)
{
if (this.m_subExpressionUpdate == null)
this.m_subExpressionUpdate = new SubExpressionUpdate(calculator, callFunction, val, propIndex, relative);
this.m_subExpressionUpdate.UpdateSubExpressions(calculator);
if (propIndex == 0)
return relative.GetType().InvokeMember(val.Substring(propIndex + 1), System.Reflection.BindingFlags.GetProperty, null, relative, new object[] {});
else
return calculator.ComputeVariable(val, null);
}
#endregion
// Don't use relative if there is none.
if (relative == null || propIndex != 0 && (propIndex == -1 || val.Substring(0, propIndex) != relative.Name))
{
return calculator.ComputeVariable(val, relative);
}
// Get value directly from variable if relative is the variable.
return relative.GetType().InvokeMember(val.Substring(propIndex + 1), System.Reflection.BindingFlags.GetProperty, null, relative, new object[] {});
}
}
catch (Exception ex)
{
if (!(ex is ExpressionException))
{
throw new ExpressionException(ex.Message, m_column, m_length);
}
else
{
throw ex;
}
}
return null;
}