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


C# ISymbol.TypeSwitch方法代码示例

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


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

示例1: GetOverriddenMember

 private static ISymbol GetOverriddenMember(ISymbol symbol)
 {
     return symbol.TypeSwitch(
         (IMethodSymbol method) => (ISymbol)method.OverriddenMethod,
         (IPropertySymbol property) => property.OverriddenProperty,
         (IEventSymbol @event) => @event.OverriddenEvent);
 }
开发者ID:RoryVL,项目名称:roslyn,代码行数:7,代码来源:INamedTypeSymbolExtensions.cs

示例2: GetDescription

 private static string GetDescription(ISymbol throughMember)
 {
     return throughMember.TypeSwitch(
         (IFieldSymbol field) => field.Name,
         (IPropertySymbol property) => property.Name,
         _ => Contract.FailWithReturn<string>());
 }
开发者ID:noahfalk,项目名称:roslyn,代码行数:7,代码来源:AbstractImplementInterfaceService.CodeAction.cs

示例3: GetDescription

 private static string GetDescription(ISymbol throughMember)
 {
     return throughMember.TypeSwitch(
         (IFieldSymbol field) => field.Name,
         (IPropertySymbol property) => property.Name);
 }
开发者ID:sushihangover,项目名称:monodevelop,代码行数:6,代码来源:AbstractImplementInterfaceService.CodeAction.cs

示例4: GetType

 private static ITypeSymbol GetType(Compilation compilation, ISymbol symbol)
 {
     return symbol.TypeSwitch(
         (IFieldSymbol field) => field.Type,
         (IPropertySymbol property) => property.Type,
         (ISymbol _) => compilation.GetSpecialType(SpecialType.System_Object));
 }
开发者ID:RoryVL,项目名称:roslyn,代码行数:7,代码来源:ICodeDefinitionFactoryExtensions_CreateEqualsMethod.cs

示例5: GetType

 private static ITypeSymbol GetType(ISymbol symbol)
 {
     return symbol.TypeSwitch(
         (IEventSymbol f) => f.Type,
         (IFieldSymbol f) => f.ContainingType.TypeKind == TypeKind.Enum ? null : f.Type,
         (IMethodSymbol m) => IncludeReturnType(m) ? m.ReturnType : null,
         (IPropertySymbol p) => p.Type,
         (INamedTypeSymbol n) => n.IsDelegateType() ? n.DelegateInvokeMethod.ReturnType : null,
         _ => null);
 }
开发者ID:Rickinio,项目名称:roslyn,代码行数:10,代码来源:CSharpProgressionLanguageService.cs

示例6: IsApplicable

        /// <summary>
        /// Is this method or property a valid place to set a breakpoint and does it match the expected parameter count?
        /// </summary>
        private bool IsApplicable(ISymbol methodOrProperty, int? parameterCount, CancellationToken cancellationToken)
        {
            // You can only set a breakpoint on methods (including constructors/destructors) and properties.
            var kind = methodOrProperty.Kind;
            if (!(kind == SymbolKind.Method || kind == SymbolKind.Property))
            {
                return false;
            }

            // You can't set a breakpoint on an abstract method or property.
            if (methodOrProperty.IsAbstract)
            {
                return false;
            }

            // If parameters were provided, check to make sure the method or property has the expected number
            // of parameters (but we don't actually validate the type or name of the supplied parameters).
            if (parameterCount != null)
            {
                if (methodOrProperty.TypeSwitch(
                        (IMethodSymbol method) => method.Parameters.Length != parameterCount,
                        (IPropertySymbol property) => property.Parameters.Length != parameterCount))
                {
                    return false;
                }
            }

            // Finally, check to make sure we have source, and if we've got a method symbol, make sure it
            // has a body to set a breakpoint on.
            if ((methodOrProperty.Language == _language) && methodOrProperty.Locations.Any(location => location.IsInSource))
            {
                if (methodOrProperty.IsKind(SymbolKind.Method))
                {
                    return HasMethodBody((IMethodSymbol)methodOrProperty, cancellationToken);
                }

                // Non-abstract properties are always applicable, because you can set a breakpoint on the
                // accessor methods (get and/or set).
                return true;
            }

            return false;
        }
开发者ID:GloryChou,项目名称:roslyn,代码行数:46,代码来源:AbstractBreakpointResolver.cs


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