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


C# CodeActivityContext.Dispose方法代码示例

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


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

示例1: EvaluateExpression

        internal object EvaluateExpression(string expressionString)
        {
            // This is to shortcircuit a common case where 
            // internally, vsdebugger calls our EE with literal "0"            
            int intResult;
            if (int.TryParse(expressionString, out intResult))
            {
                return intResult;
            }

            // At refresh, Expression Evaluator may re-evaluate locals/arguments.
            // To speed up the process, locals/arguments are cached.
            LocalInfo cachedLocalInfo = null;
            if (this.cachedLocalInfos != null && this.cachedLocalInfos.TryGetValue(expressionString, out cachedLocalInfo))
            {
                return cachedLocalInfo;
            }

            Activity activity = activityInstance.Activity;
            LocationReferenceEnvironment locationReferenceEnvironment = activity.PublicEnvironment;

            // a temporary context for EvaluateExpression
            // We're not using the executor so it's ok that it's null
            CodeActivityContext context = new CodeActivityContext(activityInstance, null);

            object result;
            try
            {
                // First try as R-Value
                if (!TryEvaluateExpression(expressionString, null, locationReferenceEnvironment, context, out result))
                {
                    return SR.DebugInfoCannotEvaluateExpression(expressionString);
                }
            }
            catch (Exception ex)
            {
                // ---- all exceptions, this exception is generated by user typing input in either
                // Watch window or Immediate windows.  Exception should not affect the current runtime.
                // Except for fatal exception.
                if (Fx.IsFatal(ex))
                {
                    throw;
                }
                context.Dispose();
                return SR.DebugInfoCannotEvaluateExpression(expressionString);
            }

            // Now try expression as an L-Value if possible.
            try
            {
                object resultLocation;
                if (TryEvaluateExpression(expressionString, result.GetType(), locationReferenceEnvironment, context, out resultLocation))
                {
                    LocalInfo localInfo = new LocalInfo()
                                            {
                                                Name = expressionString,
                                                Location = resultLocation as Location
                                            };
                    this.cachedLocalInfos[expressionString] = localInfo;
                    return localInfo;
                }
            }
            catch (Exception ex)
            {
                // ---- all exceptions, this exception is generated by user typing input in either
                // Watch window or Immediate windows.  Exception should not affect the current runtime.
                // Except for fatal exception.
                if (Fx.IsFatal(ex))
                {
                    throw;
                }
            }
            finally
            {
                context.Dispose();
            }
            return result;
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:78,代码来源:DebugInfo.cs


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