當前位置: 首頁>>代碼示例>>C#>>正文


C# Accessibility類代碼示例

本文整理匯總了C#中Accessibility的典型用法代碼示例。如果您正苦於以下問題:C# Accessibility類的具體用法?C# Accessibility怎麽用?C# Accessibility使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Accessibility類屬於命名空間,在下文中一共展示了Accessibility類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: CodeGenerationMethodSymbol

        public CodeGenerationMethodSymbol(
            INamedTypeSymbol containingType,
            IList<AttributeData> attributes,
            Accessibility declaredAccessibility,
            DeclarationModifiers modifiers,
            ITypeSymbol returnType,
            bool returnsByRef,
            IMethodSymbol explicitInterfaceSymbolOpt,
            string name,
            IList<ITypeParameterSymbol> typeParameters,
            IList<IParameterSymbol> parameters,
            IList<AttributeData> returnTypeAttributes,
            MethodKind methodKind = MethodKind.Ordinary)
            : base(containingType, attributes, declaredAccessibility, modifiers, name, returnTypeAttributes)
        {
            _returnType = returnType;
            _returnsByRef = returnsByRef;
            _typeParameters = typeParameters.AsImmutableOrEmpty();
            _parameters = parameters.AsImmutableOrEmpty();
            _explicitInterfaceImplementations = explicitInterfaceSymbolOpt == null
                ? ImmutableArray.Create<IMethodSymbol>()
                : ImmutableArray.Create(explicitInterfaceSymbolOpt);

            this.OriginalDefinition = this;
            _methodKind = methodKind;
        }
開發者ID:RoryVL,項目名稱:roslyn,代碼行數:26,代碼來源:CodeGenerationMethodSymbol.cs

示例2: DefaultResolvedAccessor

        public DefaultResolvedAccessor(Accessibility accessibility, DomRegion region = default(DomRegion), IList<IAttribute> attributes = null, IList<IAttribute> returnTypeAttributes = null)
        {
            this.accessibility = accessibility;
            this.region = region;
            this.attributes = attributes ?? EmptyList<IAttribute>.Instance;
            this.returnTypeAttributes = returnTypeAttributes ?? EmptyList<IAttribute>.Instance;
        }
開發者ID:nylen,項目名稱:SharpDevelop,代碼行數:7,代碼來源:DefaultResolvedAccessor.cs

示例3: ValidateClassType

        void ValidateClassType(Assembly assembly, string fullName, Accessibility access, bool final)
        {
            // Check that the type exists in the assembly.
            Type t = assembly.GetType(fullName);
            Assert.IsNotNull(t);

            // Check that it is a class
            Assert.IsTrue(t.IsClass);

            // Check that the full name is correct
            Assert.AreEqual(t.FullName, fullName);

            // Check that the type is final (sealed)
            Assert.AreEqual(t.IsSealed, final);

            // Check that it has the correct accessibility
            switch(access)
            {
                case Accessibility.Public:
                    Assert.IsTrue(t.IsPublic);
                    break;
                case Accessibility.Internal:
                    Assert.IsTrue(t.IsNotPublic);
                    break;
                case Accessibility.Private:
                case Accessibility.Protected:
                    Assert.Fail("Invalid accessibility for class types");
                    break;
            }
        }
開發者ID:maleficus1234,項目名稱:Pie,代碼行數:30,代碼來源:ClassCodeDomTests.cs

示例4: PrinterConfig

 public PrinterConfig(string semiColonSeparatedIncludeRegexes, string semiColonSeparatedExcludeRegexes, Accessibility minAccessibility = Accessibility.Public)
 {
     var splitters = new[] { ";" };
     m_IncludeSignatureRegexes = semiColonSeparatedIncludeRegexes.Split(splitters, StringSplitOptions.RemoveEmptyEntries);
     m_ExcludeSignatureRegexes = semiColonSeparatedExcludeRegexes.Split(splitters, StringSplitOptions.RemoveEmptyEntries);
     m_MinAccessibility = minAccessibility;
 }
開發者ID:GrahamTheCoder,項目名稱:Semver-AssemblyCompatibility,代碼行數:7,代碼來源:PrinterConfig.cs

示例5: Minimum

        public static Accessibility Minimum(Accessibility accessibility1, Accessibility accessibility2)
        {
            if (accessibility1 == Accessibility.Private || accessibility2 == Accessibility.Private)
            {
                return Accessibility.Private;
            }

            if (accessibility1 == Accessibility.ProtectedAndInternal || accessibility2 == Accessibility.ProtectedAndInternal)
            {
                return Accessibility.ProtectedAndInternal;
            }

            if (accessibility1 == Accessibility.Protected || accessibility2 == Accessibility.Protected)
            {
                return Accessibility.Protected;
            }

            if (accessibility1 == Accessibility.Internal || accessibility2 == Accessibility.Internal)
            {
                return Accessibility.Internal;
            }

            if (accessibility1 == Accessibility.ProtectedOrInternal || accessibility2 == Accessibility.ProtectedOrInternal)
            {
                return Accessibility.ProtectedOrInternal;
            }

            return Accessibility.Public;
        }
開發者ID:pabloescribanoloza,項目名稱:monodevelop,代碼行數:29,代碼來源:AccessibilityUtilities.cs

示例6: CodeGenerationNamedTypeSymbol

        public CodeGenerationNamedTypeSymbol(
            INamedTypeSymbol containingType,
            IList<AttributeData> attributes,
            Accessibility declaredAccessibility,
            DeclarationModifiers modifiers,
            TypeKind typeKind,
            string name,
            IList<ITypeParameterSymbol> typeParameters,
            INamedTypeSymbol baseType,
            IList<INamedTypeSymbol> interfaces,
            SpecialType specialType,
            IList<ISymbol> members,
            IList<CodeGenerationAbstractNamedTypeSymbol> typeMembers,
            INamedTypeSymbol enumUnderlyingType)
            : base(containingType, attributes, declaredAccessibility, modifiers, name, specialType, typeMembers)
        {
            _typeKind = typeKind;
            _typeParameters = typeParameters ?? SpecializedCollections.EmptyList<ITypeParameterSymbol>();
            _baseType = baseType;
            _interfaces = interfaces ?? SpecializedCollections.EmptyList<INamedTypeSymbol>();
            _members = members ?? SpecializedCollections.EmptyList<ISymbol>();
            _enumUnderlyingType = enumUnderlyingType;

            this.OriginalDefinition = this;
        }
開發者ID:RoryVL,項目名稱:roslyn,代碼行數:25,代碼來源:CodeGenerationNamedTypeSymbol.cs

示例7: AdjustAccessibility

        static void AdjustAccessibility (SyntaxTokenList modifiers, ref Accessibility acc, ref bool isStatic, ref bool result)
        {
            isStatic = modifiers.Any (mod => mod.Kind () == Microsoft.CodeAnalysis.CSharp.SyntaxKind.StaticKeyword);
            if (modifiers.Any (mod => mod.Kind () == Microsoft.CodeAnalysis.CSharp.SyntaxKind.ProtectedKeyword) &&
                modifiers.Any (mod => mod.Kind () == Microsoft.CodeAnalysis.CSharp.SyntaxKind.InternalKeyword)) {
                acc = Accessibility.ProtectedOrInternal;
                result = true;
                return;
            }

            foreach (var mod in modifiers) {
                if (mod.Kind () == Microsoft.CodeAnalysis.CSharp.SyntaxKind.PublicKeyword) {
                    acc = Accessibility.Public;
                    result = true;
                    return;
                }
                if (mod.Kind () == Microsoft.CodeAnalysis.CSharp.SyntaxKind.PrivateKeyword) {
                    acc = Accessibility.Private;
                    result = true;
                    return;
                }
                if (mod.Kind () == Microsoft.CodeAnalysis.CSharp.SyntaxKind.ProtectedKeyword) {
                    acc = Accessibility.Protected;
                    result = true;
                    return;
                }
                if (mod.Kind () == Microsoft.CodeAnalysis.CSharp.SyntaxKind.InternalKeyword) {
                    acc = Accessibility.Internal;
                    result = true;
                    return;
                }
            }
        }
開發者ID:FreeBSD-DotNet,項目名稱:monodevelop,代碼行數:33,代碼來源:AstStockIcons.cs

示例8: CreatePropertySymbol

 internal static IPropertySymbol CreatePropertySymbol(
     INamedTypeSymbol containingType,
     IList<AttributeData> attributes,
     Accessibility accessibility,
     DeclarationModifiers modifiers,
     ITypeSymbol type,
     IPropertySymbol explicitInterfaceSymbol,
     string name,
     IList<IParameterSymbol> parameters,
     IMethodSymbol getMethod,
     IMethodSymbol setMethod,
     bool isIndexer = false,
     SyntaxNode initializer = null)
 {
     var result = new CodeGenerationPropertySymbol(
         containingType,
         attributes,
         accessibility,
         modifiers,
         type,
         explicitInterfaceSymbol,
         name,
         isIndexer,
         parameters,
         getMethod,
         setMethod);
     CodeGenerationPropertyInfo.Attach(result, modifiers.IsNew, modifiers.IsUnsafe, initializer);
     return result;
 }
開發者ID:RoryVL,項目名稱:roslyn,代碼行數:29,代碼來源:CodeGenerationSymbolFactory.cs

示例9: SetGenerateTypeOptions

 public void SetGenerateTypeOptions(
     Accessibility accessibility = Accessibility.NotApplicable,
     TypeKind typeKind = TypeKind.Class,
     string typeName = null,
     Project project = null,
     bool isNewFile = false,
     string newFileName = null,
     IList<string> folders = null,
     string fullFilePath = null,
     Document existingDocument = null,
     bool areFoldersValidIdentifiers = true,
     string defaultNamespace = null,
     bool isCancelled = false)
 {
     Accessibility = accessibility;
     TypeKind = typeKind;
     TypeName = typeName;
     Project = project;
     IsNewFile = isNewFile;
     NewFileName = newFileName;
     Folders = folders;
     FullFilePath = fullFilePath;
     ExistingDocument = existingDocument;
     AreFoldersValidIdentifiers = areFoldersValidIdentifiers;
     DefaultNamespace = defaultNamespace;
     IsCancelled = isCancelled;
 }
開發者ID:Rickinio,項目名稱:roslyn,代碼行數:27,代碼來源:TestGenerateTypeOptionsService.cs

示例10: GenerateTypeOptionsResult

 public GenerateTypeOptionsResult(
     Accessibility accessibility,
     TypeKind typeKind,
     string typeName,
     Project project,
     bool isNewFile,
     string newFileName,
     IList<string> folders,
     string fullFilePath,
     Document existingDocument,
     bool areFoldersValidIdentifiers,
     bool isCancelled = false)
 {
     this.Accessibility = accessibility;
     this.TypeKind = typeKind;
     this.TypeName = typeName;
     this.Project = project;
     this.IsNewFile = isNewFile;
     this.NewFileName = newFileName;
     this.Folders = folders;
     this.FullFilePath = fullFilePath;
     this.ExistingDocument = existingDocument;
     this.AreFoldersValidIdentifiers = areFoldersValidIdentifiers;
     this.IsCancelled = isCancelled;
 }
開發者ID:ehsansajjad465,項目名稱:roslyn,代碼行數:25,代碼來源:GenerateTypeOptionsResult.cs

示例11: ValuedDeclaration

 public ValuedDeclaration(QualifiedMemberName qualifiedName, string parentScope,
     string asTypeName, Accessibility accessibility, DeclarationType declarationType, string value, 
     ParserRuleContext context, Selection selection, bool isBuiltIn = false)
     :base(qualifiedName, parentScope, asTypeName, true, false, accessibility, declarationType, context, selection, isBuiltIn)
 {
     _value = value;
 }
開發者ID:ThunderFrame,項目名稱:Rubberduck,代碼行數:7,代碼來源:ValuedDeclaration.cs

示例12: GetAccessibility

        static bool GetAccessibility (SyntaxNode element, out Accessibility acc, out bool isStatic)
        {
            isStatic = false;
            if (element.Parent is TypeDeclarationSyntax && element.Parent is InterfaceDeclarationSyntax) {
                acc = Accessibility.Public;
                return true;
            }
            bool result = false;
            acc = Accessibility.Private;
            if (element is TypeDeclarationSyntax && !(element.Parent is TypeDeclarationSyntax))
                acc = Accessibility.Internal;

            if (element is VariableDeclaratorSyntax)
                element = element.Parent.Parent;
            
            if (element is TypeDeclarationSyntax)
                AdjustAccessibility (((TypeDeclarationSyntax)element).Modifiers, ref acc, ref isStatic, ref result);
            if (element is BaseFieldDeclarationSyntax)
                AdjustAccessibility (((BaseFieldDeclarationSyntax)element).Modifiers, ref acc, ref isStatic, ref result);
            if (element is BasePropertyDeclarationSyntax)
                AdjustAccessibility (((BasePropertyDeclarationSyntax)element).Modifiers, ref acc, ref isStatic, ref result);
            if (element is BaseMethodDeclarationSyntax)
                AdjustAccessibility (((BaseMethodDeclarationSyntax)element).Modifiers, ref acc, ref isStatic, ref result);
            return result;
        }
開發者ID:pabloescribanoloza,項目名稱:monodevelop,代碼行數:25,代碼來源:AstStockIcons.cs

示例13: Declare

 public void Declare(Accessibility accessibility, String name, Exp value = null)
 {
     if (dict.ContainsKey(name))
         validations.GenericWarning("variable '" + name + "' is already declared",
                                    Void.Instance);
     dict.Add(name, new EnvItem(accessibility, value));
 }
開發者ID:michal-minich,項目名稱:Efekt-CS,代碼行數:7,代碼來源:Env.cs

示例14: GenerateMethod

            private ISymbol GenerateMethod(
                Compilation compilation,
                IMethodSymbol method,
                Accessibility accessibility,
                DeclarationModifiers modifiers,
                bool generateAbstractly,
                bool useExplicitInterfaceSymbol,
                string memberName,
                CancellationToken cancellationToken)
            {
                var syntaxFacts = this.Document.GetLanguageService<ISyntaxFactsService>();

                var updatedMethod = method.EnsureNonConflictingNames(
                    this.State.ClassOrStructType, syntaxFacts, cancellationToken);

                updatedMethod = updatedMethod.RemoveInaccessibleAttributesAndAttributesOfTypes(
                    this.State.ClassOrStructType,
                    AttributesToRemove(compilation));

                return CodeGenerationSymbolFactory.CreateMethodSymbol(
                    updatedMethod,
                    accessibility: accessibility,
                    modifiers: modifiers,
                    explicitInterfaceSymbol: useExplicitInterfaceSymbol ? updatedMethod : null,
                    name: memberName,
                    statements: generateAbstractly ? null : new[] { CreateStatement(compilation, updatedMethod, cancellationToken) });
            }
開發者ID:XieShuquan,項目名稱:roslyn,代碼行數:27,代碼來源:AbstractImplementInterfaceService.CodeAction_Method.cs

示例15: TryDetermineOverridableMembers

        static bool TryDetermineOverridableMembers(SemanticModel semanticModel, SyntaxToken startToken, Accessibility seenAccessibility, out ISet<ISymbol> overridableMembers, CancellationToken cancellationToken)
        {
            var result = new HashSet<ISymbol>();
            var containingType = semanticModel.GetEnclosingSymbol<INamedTypeSymbol>(startToken.SpanStart, cancellationToken);
            if (containingType != null && !containingType.IsScriptClass && !containingType.IsImplicitClass)
            {
                if (containingType.TypeKind == TypeKind.Class || containingType.TypeKind == TypeKind.Struct)
                {
                    var baseTypes = containingType.GetBaseTypes().Reverse();
                    foreach (var type in baseTypes)
                    {
                        cancellationToken.ThrowIfCancellationRequested();

                        // Prefer overrides in derived classes
                        RemoveOverriddenMembers(result, type, cancellationToken);

                        // Retain overridable methods
                        AddProtocolMembers(semanticModel, result, containingType, type, cancellationToken);
                    }
                    // Don't suggest already overridden members
                    RemoveOverriddenMembers(result, containingType, cancellationToken);
                }
            }

            // Filter based on accessibility
            if (seenAccessibility != Accessibility.NotApplicable)
            {
                result.RemoveWhere(m => m.DeclaredAccessibility != seenAccessibility);
            }

            overridableMembers = result;
            return overridableMembers.Count > 0;
        }
開發者ID:pabloescribanoloza,項目名稱:monodevelop,代碼行數:33,代碼來源:ProtocolMemberContextHandler.cs


注:本文中的Accessibility類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。