当前位置: 首页>>代码示例>>C#>>正文


C# IVariable.GetType方法代码示例

本文整理汇总了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);
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:6,代码来源:MemoryFunctionStoreHelper.cs

示例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;
        }
开发者ID:bvssvni,项目名称:expressionlibsharp,代码行数:96,代码来源:ExpressionTreeNode.cs


注:本文中的IVariable.GetType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。