本文整理汇总了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;
}
示例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;
}
示例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;
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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));
}
示例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) });
}
示例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;
}