本文整理汇总了C#中TypeDeclaration类的典型用法代码示例。如果您正苦于以下问题:C# TypeDeclaration类的具体用法?C# TypeDeclaration怎么用?C# TypeDeclaration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TypeDeclaration类属于命名空间,在下文中一共展示了TypeDeclaration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VisitTypeDeclaration
public override void VisitTypeDeclaration(TypeDeclaration typeDeclaration)
{
bool oldIsSealedType = isSealedType;
isSealedType = typeDeclaration.Modifiers.HasFlag(Modifiers.Sealed);
base.VisitTypeDeclaration(typeDeclaration);
isSealedType = oldIsSealedType;
}
示例2: VisitTypeDeclaration
public override void VisitTypeDeclaration(TypeDeclaration typeDeclaration)
{
if (!typeDeclaration.HasModifier(Modifiers.Public))
{
base.VisitTypeDeclaration(typeDeclaration);
return;
}
this.m_TotalClasses++;
if (this.m_TotalClasses > 1)
{
this.Results.Issues.Add(new LintIssue(typeDeclaration)
{
Index = LintIssueIndex.MoreThanOneClassInFile,
Parameters = new[]
{
typeDeclaration.Name,
this.m_FirstClassName
}
});
}
else
{
this.m_FirstClassName = typeDeclaration.Name;
}
base.VisitTypeDeclaration(typeDeclaration);
}
示例3: GetAllPMixinAttributes
public static IEnumerable<pMixinAttributeResolvedResult> GetAllPMixinAttributes(
this ICreateCodeGenerationPlanPipelineState manager,
TypeDeclaration target)
{
return manager.ResolveAttributesPipeline.PartialClassLevelResolvedPMixinAttributes[target]
.OfType<pMixinAttributeResolvedResult>();
}
示例4: VisitTypeDeclaration
public override object VisitTypeDeclaration(TypeDeclaration typeDeclaration, object data)
{
Push();
object result = base.VisitTypeDeclaration(typeDeclaration, data);
Pop();
return result;
}
示例5: CheckName
void CheckName(TypeDeclaration node, AffectedEntity entity, Identifier identifier, Modifiers accessibilty)
{
TypeResolveResult resolveResult = ctx.Resolve(node) as TypeResolveResult;
if (resolveResult == null)
return;
var type = resolveResult.Type;
if (type.DirectBaseTypes.Any(t => t.FullName == "System.Attribute")) {
if (CheckNamedResolveResult(resolveResult, node, AffectedEntity.CustomAttributes, identifier, accessibilty)) {
return;
}
} else if (type.DirectBaseTypes.Any(t => t.FullName == "System.EventArgs")) {
if (CheckNamedResolveResult(resolveResult, node, AffectedEntity.CustomEventArgs, identifier, accessibilty)) {
return;
}
} else if (type.DirectBaseTypes.Any(t => t.FullName == "System.Exception")) {
if (CheckNamedResolveResult(resolveResult, node, AffectedEntity.CustomExceptions, identifier, accessibilty)) {
return;
}
}
var typeDef = type.GetDefinition();
if (typeDef != null && typeDef.Attributes.Any(attr => attr.AttributeType.FullName == "NUnit.Framework.TestFixtureAttribute")) {
if (CheckNamedResolveResult(resolveResult, node, AffectedEntity.TestType, identifier, accessibilty)) {
return;
}
}
CheckNamedResolveResult(resolveResult, node, entity, identifier, accessibilty);
}
示例6: VisitTypeDeclaration
public override object VisitTypeDeclaration(TypeDeclaration typeDeclaration, object data)
{
if(typeDeclaration.ClassType == ClassType.Class && typeDeclaration.Name != "Program")
UnlockWith(typeDeclaration);
return base.VisitTypeDeclaration(typeDeclaration, data);
}
示例7: AddSerializibility
/// <summary>
/// Makes sure that the PHP-visible type is serializable.
/// </summary>
private void AddSerializibility(TypeDeclaration type, TypeDeclaration outType)
{
// make the type serializable
if (!Utility.IsDecoratedByAttribute(type, "System.SerializableAttribute"))
{
AttributeSection section = new AttributeSection();
section.Attributes.Add(new ICSharpCode.NRefactory.Parser.AST.Attribute("Serializable", null, null));
outType.Attributes.Add(section);
ConstructorDeclaration ctor = new ConstructorDeclaration(type.Name,
((type.Modifier & Modifier.Sealed) == Modifier.Sealed ? Modifier.Private : Modifier.Protected),
new List<ParameterDeclarationExpression>(), null);
ctor.Parameters.Add(
new ParameterDeclarationExpression(new TypeReference("System.Runtime.Serialization.SerializationInfo"), "info"));
ctor.Parameters.Add(
new ParameterDeclarationExpression(new TypeReference("System.Runtime.Serialization.StreamingContext"), "context"));
ctor.ConstructorInitializer = new ConstructorInitializer();
ctor.ConstructorInitializer.ConstructorInitializerType = ConstructorInitializerType.Base;
ctor.ConstructorInitializer.Arguments.Add(new IdentifierExpression("info"));
ctor.ConstructorInitializer.Arguments.Add(new IdentifierExpression("context"));
ctor.Body = new BlockStatement();
outType.AddChild(ctor);
}
}
示例8: VisitTypeDeclaration
public override object VisitTypeDeclaration(TypeDeclaration typeDeclaration, object data)
{
if(typeDeclaration.ClassType == ClassType.Interface)
UnlockWith(typeDeclaration);
return base.VisitTypeDeclaration(typeDeclaration, data);
}
示例9: VisitTypeDeclaration
public override object VisitTypeDeclaration(TypeDeclaration typeDeclaration, object data)
{
if (typeDeclaration.ClassType == ClassType.Class && typeDeclaration.Modifiers.HasFlag(Modifiers.Abstract))
UnlockWith(typeDeclaration);
return base.VisitTypeDeclaration(typeDeclaration, data);
}
示例10: VisitTypeDeclaration
public override void VisitTypeDeclaration(TypeDeclaration typeDeclaration)
{
if (!typeDeclaration.HasModifier(Modifiers.Public))
{
base.VisitTypeDeclaration(typeDeclaration);
return;
}
var idx = this.Results.BaseName.LastIndexOf('.');
var filename = this.Results.BaseName;
if (idx != -1)
filename = filename.Substring(0, idx);
if (typeDeclaration.Name != filename)
{
this.Results.Issues.Add(new LintIssue(typeDeclaration)
{
Index = LintIssueIndex.ClassNameDoesNotMatchFileName,
Parameters = new[]
{
typeDeclaration.Name,
filename
}
});
}
base.VisitTypeDeclaration(typeDeclaration);
}
示例11: TypeDeclaration
public TypeDeclaration(Position pos, Symbol name, Type type, TypeDeclaration next)
{
Pos = pos;
Name = name;
Type = type;
Next = next;
}
示例12: VisitTypeDeclaration
public override void VisitTypeDeclaration(TypeDeclaration typeDeclaration)
{
if (typeDeclaration.TypeKeyword.ToString() == "enum")
{
_currentEnumMembers = new List<NameNode>();
EnumMembers.Add(typeDeclaration, _currentEnumMembers);
}
base.VisitTypeDeclaration(typeDeclaration);
}
示例13: CreateTypeSignature
public static string CreateTypeSignature(TypeDeclaration type)
{
var @namespace = type.GetParent<NamespaceDeclaration>();
var builder = new StringBuilder();
builder.Append(@namespace.FullName.ToJavaNamespace());
builder.Append("/");
builder.Append(type.Name);
return builder.ToString();
}
示例14: VisitTypeDeclaration
public override void VisitTypeDeclaration(TypeDeclaration typeDeclaration)
{
var oldGenericStatus = isInGenericType;
isInGenericType = typeDeclaration.TypeParameters.Count > 0;
base.VisitTypeDeclaration(typeDeclaration);
isInGenericType = oldGenericStatus;
}
示例15: AddImplementation
static void AddImplementation(RefactoringContext context, TypeDeclaration result, ICSharpCode.NRefactory.TypeSystem.IType guessedType)
{
foreach (var property in guessedType.GetProperties ()) {
if (!property.IsAbstract)
continue;
if (property.IsIndexer) {
var indexerDecl = new IndexerDeclaration() {
ReturnType = context.CreateShortType(property.ReturnType),
Modifiers = GetModifiers(property),
Name = property.Name
};
indexerDecl.Parameters.AddRange(ConvertParameters(context, property.Parameters));
if (property.CanGet)
indexerDecl.Getter = new Accessor();
if (property.CanSet)
indexerDecl.Setter = new Accessor();
result.AddChild(indexerDecl, Roles.TypeMemberRole);
continue;
}
var propDecl = new PropertyDeclaration() {
ReturnType = context.CreateShortType(property.ReturnType),
Modifiers = GetModifiers (property),
Name = property.Name
};
if (property.CanGet)
propDecl.Getter = new Accessor();
if (property.CanSet)
propDecl.Setter = new Accessor();
result.AddChild(propDecl, Roles.TypeMemberRole);
}
foreach (var method in guessedType.GetMethods ()) {
if (!method.IsAbstract)
continue;
var decl = new MethodDeclaration() {
ReturnType = context.CreateShortType(method.ReturnType),
Modifiers = GetModifiers (method),
Name = method.Name,
Body = new BlockStatement() {
new ThrowStatement(new ObjectCreateExpression(context.CreateShortType("System", "NotImplementedException")))
}
};
decl.Parameters.AddRange(ConvertParameters(context, method.Parameters));
result.AddChild(decl, Roles.TypeMemberRole);
}
foreach (var evt in guessedType.GetEvents ()) {
if (!evt.IsAbstract)
continue;
var decl = new EventDeclaration() {
ReturnType = context.CreateShortType(evt.ReturnType),
Modifiers = GetModifiers (evt),
Name = evt.Name
};
result.AddChild(decl, Roles.TypeMemberRole);
}
}