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


C# ISymbol.IsNew方法代码示例

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


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

示例1: GetMethodName


//.........这里部分代码省略.........
            (isinterfacemethod && methodSymbol.IsOverride))
            {
                /* name = Regex.Replace(
                    TypeProcessor.ConvertType(methodSymbol.ContainingType.ConstructedFrom) + "_" + name,
                    @" ?!\(.*?\)", String.Empty);*/

                interfaceImplemented = methodSymbol.ContainingType.ConstructedFrom;

                if (methodSymbol.ContainingType.ContainingType != null)
                    name = name.RemoveFromStartOfString(methodSymbol.ContainingType.ContainingType.Name + ".");
            }

            if (name.Contains(".")) // Explicit Interface method
            {
                //              
                name = name.SubstringAfterLast('.');
                name = name.Replace('.', '_');
            }

            var name1 = name;

            IEnumerable<ISymbol> interfaceMethods = null;
            if (methodSymbol.IsOverride && (interfaceMethods == null || !interfaceMethods.Any()))
            {
                interfaceMethods =
                    methodSymbol.ContainingType.BaseType.AllInterfaces.SelectMany(
                    u =>
                        u.GetMembers(name1));

                if ((interfaceMethods == null || !interfaceMethods.Any()))
                {
                    interfaceMethods =
                    interfaceMethods.Where(
                        o => Equals(methodSymbol.ContainingType.BaseType.FindImplementationForInterfaceMember(o), methodSymbol));
                }
            }
            else
            {
                interfaceMethods =
                    methodSymbol.ContainingType.AllInterfaces.SelectMany(
                    u =>
                        u.GetMembers(name1));
                interfaceMethods =
                interfaceMethods.Where(
                    o => Equals(methodSymbol.ContainingType.FindImplementationForInterfaceMember(o), methodSymbol));
            }

            var enumerable = interfaceMethods as ISymbol[] ?? interfaceMethods.ToArray();
            var interfaceMethod = enumerable.FirstOrDefault();

            if (interfaceMethods.Count() > 1)
                proxies = interfaceMethods.ToArray();

            if (interfaceMethod != null)
            {
                //TODO: fix this for virtual method test 7, seems roslyn cannot deal with virtual 
                // overrides of interface methods ... so i'll provide a kludge
                //                if (!member.GetModifiers().Any(SyntaxKind.NewKeyword) && methodSymbol is IMethodSymbol) // This is not neccessary for properties
                //                {
                //                    interfaceMethod =
                //                        enumerable.FirstOrDefault(k => CompareMethods(k as IMethodSymbol, (IMethodSymbol) methodSymbol));
                //                }
            }

            if (interfaceMethod != null)
            {
                //This is an interface method/property //TO
                if (methodSymbol.ContainingType.SpecialType == SpecialType.System_Array)
                    name += ("");
                else
                {
                    /*   var typenameI =
                        Regex.Replace(TypeProcessor.ConvertType(interfaceMethod.ContainingType.ConstructedFrom),
                            @" ?!\(.*?\)", String.Empty);*/
                    //TODO: we should be able to get the original interface name, or just remove all generics from this
                    interfaceImplemented = interfaceMethod.ContainingType;//.ConstructedFrom;

                    /*  if (typenameI.Contains('.'))
                        typenameI = typenameI.SubstringAfterLast('.');
                    name = (typenameI + "_") + name;*/
                }
            }

            /*  if (
                  //member.GetModifiers().Any(SyntaxKind.NewKeyword) && 
                  methodSymbol.OriginalDefinition.ContainingType.TypeKind != TypeKind.Interface) //Take care of new
                  name += "_";*/
            if (methodSymbol.IsNew())
            {
                // name += "_";
                interfaceImplemented = methodSymbol.OriginalDefinition.ContainingType;
            }

            GetExplicitInterface(ref interfaceImplemented, methodSymbol);

            //            if (interfaceMethods.Count() >= 1 && interfaceMethod!=null)
            //                proxies = interfaceMethods.ToArray();

            return name;
        }
开发者ID:mortezabarzkar,项目名称:SharpNative,代码行数:101,代码来源:MemberUtilities.cs


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