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


C# ObjectCreateExpression.ToString方法代码示例

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


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

示例1: TrackedVisitObjectCreateExpression

            public override object TrackedVisitObjectCreateExpression(ObjectCreateExpression objectCreateExpression, object data)
            {
                if (data as bool? ?? false) {

                    #if DEBUG
                    LoggingService.Debug("ResourceToolkit: BclNRefactoryResourceResolver found object initialization: "+objectCreateExpression.ToString());
                    #endif

                    // Resolve the constructor.
                    // A type derived from the declaration type is also allowed.
                    MemberResolveResult mrr = this.Resolve(objectCreateExpression) as MemberResolveResult;

                    #if DEBUG
                    if (mrr != null) {
                        LoggingService.Debug("ResourceToolkit: BclNRefactoryResourceResolver: resolved constructor: "+mrr.ResolvedMember.ToString());
                    }
                    #endif

                    if (mrr != null &&
                        mrr.ResolvedMember is IMethod &&
                        (mrr.ResolvedMember.DeclaringType.CompareTo(this.resourceManagerMember.ReturnType.GetUnderlyingClass()) == 0 ||
                         mrr.ResolvedMember.DeclaringType.IsTypeInInheritanceTree(this.resourceManagerMember.ReturnType.GetUnderlyingClass()))
                       ) {

                        #if DEBUG
                        LoggingService.Debug("ResourceToolkit: BclNRefactoryResourceResolver: This is the correct constructor.");
                        #endif

                        // This most probably is the resource manager initialization we are looking for.
                        // Find a parameter that indicates the resources being referenced.

                        foreach (Expression param in objectCreateExpression.Parameters) {

                            PrimitiveExpression p = param as PrimitiveExpression;
                            if (p != null) {
                                string pValue = p.Value as string;
                                if (!String.IsNullOrEmpty(pValue)) {

                                    #if DEBUG
                                    LoggingService.Debug("ResourceToolkit: BclNRefactoryResourceResolver found string parameter: '"+pValue+"'");
                                    #endif

                                    this.foundResourceSet = NRefactoryResourceResolver.GetResourceSetReference(this.resourceManagerMember.DeclaringType.CompilationUnit.FileName, pValue);
                                    #if DEBUG
                                    if (this.foundResourceSet.FileName != null) {
                                        LoggingService.Debug("ResourceToolkit: BclNRefactoryResourceResolver found resource file: "+this.foundResourceSet.FileName);
                                    }
                                    #endif

                                    break;

                                }

                                continue;
                            }

                            // Support typeof(...)
                            TypeOfExpression t = param as TypeOfExpression;
                            if (t != null && this.PositionAvailable) {

                                #if DEBUG
                                LoggingService.Debug("ResourceToolkit: BclNRefactoryResourceResolver: Found TypeOfExpression in constructor call: "  + t.ToString());
                                #endif

                                ResolveResult rr = this.Resolve(new TypeReferenceExpression(t.TypeReference), ExpressionContext.Type);

                                #if DEBUG
                                if (rr == null) {
                                    LoggingService.Debug("ResourceToolkit: BclNRefactoryResourceResolver: The TypeReference of the TypeOfExpression could not be resolved.");
                                } else {
                                    LoggingService.Debug("ResourceToolkit: BclNRefactoryResourceResolver: The TypeReference resolved to: " + rr.ToString());
                                }
                                #endif

                                if (rr != null) {

                                    #if DEBUG
                                    LoggingService.Debug("ResourceToolkit: BclNRefactoryResourceResolver found typeof(...) parameter, type: '"+rr.ResolvedType.ToString()+"'");
                                    #endif

                                    this.foundResourceSet = NRefactoryResourceResolver.GetResourceSetReference(this.resourceManagerMember.DeclaringType.CompilationUnit.FileName, rr.ResolvedType.FullyQualifiedName);
                                    #if DEBUG
                                    if (this.foundResourceSet.FileName != null) {
                                        LoggingService.Debug("ResourceToolkit: BclNRefactoryResourceResolver found resource file: "+this.foundResourceSet.FileName);
                                    }
                                    #endif

                                    break;

                                }

                            }

                        }

                    }

                }

                return base.TrackedVisitObjectCreateExpression(objectCreateExpression, data);
//.........这里部分代码省略.........
开发者ID:ichengzi,项目名称:SharpDevelop,代码行数:101,代码来源:BclNRefactoryResourceResolver.cs


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