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


C# Aplus.GetMemberBinder方法代码示例

本文整理汇总了C#中Aplus.GetMemberBinder方法的典型用法代码示例。如果您正苦于以下问题:C# Aplus.GetMemberBinder方法的具体用法?C# Aplus.GetMemberBinder怎么用?C# Aplus.GetMemberBinder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Aplus的用法示例。


在下文中一共展示了Aplus.GetMemberBinder方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SetVariable

        /// <summary>
        /// Constructs a DLR Expression tree representing setting a variable inside a context.
        /// </summary>
        /// <param name="runtime"></param>
        /// <param name="variableContainer">The container where the lookup should be performed</param>
        /// <param name="contextParts">
        /// Contains 2 strings:
        ///  1. The name of the context
        ///  2. The name of the variable inside the context
        /// </param>
        /// <param name="value">Expression containing the value of the variable</param>
        /// <remarks>
        /// The returned DLR Expression tree will try to fetch the context inside the container.
        /// If the context does not exists, this will result an exception.
        /// If the exception occured, the context will be created inside the catch block.
        /// After this the context surely exists, so we can simply set the variable to the provided value.
        /// 
        /// </remarks>
        /// <returns>>Expression tree for setting a value for the given context parts</returns>
        internal static DLR.Expression SetVariable(Aplus runtime, DLR.Expression variableContainer, string[] contextParts, DLR.Expression value)
        {
            // Get the context
            DLR.Expression getContext =
                DLR.Expression.TryCatch(
                    DLR.Expression.Dynamic(
                        runtime.GetMemberBinder(contextParts[0]),
                        typeof(object),
                        variableContainer
                    ),
                    DLR.Expression.Catch(
                // Context not found, create one!
                        typeof(Error.Value),
                        DLR.Expression.Dynamic(
                            runtime.SetMemberBinder(contextParts[0]),
                            typeof(object),
                            variableContainer,
                            DLR.Expression.Constant(new ScopeStorage())
                        )
                    )
                );

            DLR.Expression setVariable = DLR.Expression.Dynamic(
                runtime.SetMemberBinder(contextParts[1]),
                typeof(object),
                getContext,
                value
            );
            return setVariable;
        }
开发者ID:sammoorhouse,项目名称:aplusdotnet,代码行数:49,代码来源:VariableHelper.cs

示例2: GetVariable

        /// <summary>
        /// Constructs a DLR Expression tree representing accessing a variable inside a context
        /// </summary>
        /// <param name="runtime"></param>
        /// <param name="variableContainer">The container where the lookup should be performed</param>
        /// <param name="contextParts">
        /// Contains 2 strings:
        ///  1. The name of the context
        ///  2. The name of the variable inside the context
        /// </param>
        /// <returns>Expression tree for retrieving a value for the given context parts</returns>
        internal static DLR.Expression GetVariable(Aplus runtime, DLR.Expression variableContainer, string[] contextParts)
        {
            // Get the context
            DLR.Expression contextAccess = DLR.Expression.Dynamic(
                runtime.GetMemberBinder(contextParts[0]),
                typeof(object),
                variableContainer
            );

            // Get the variable from the context
            DLR.Expression variableAccess = DLR.Expression.Dynamic(
                runtime.GetMemberBinder(contextParts[1]),
                typeof(object),
                contextAccess
            );
            return variableAccess;
        }
开发者ID:sammoorhouse,项目名称:aplusdotnet,代码行数:28,代码来源:VariableHelper.cs


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