当前位置: 首页>>代码示例>>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;未经允许,请勿转载。