本文整理汇总了C#中ICSharpCode.NRefactory.Ast.EventDeclaration类的典型用法代码示例。如果您正苦于以下问题:C# EventDeclaration类的具体用法?C# EventDeclaration怎么用?C# EventDeclaration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EventDeclaration类属于ICSharpCode.NRefactory.Ast命名空间,在下文中一共展示了EventDeclaration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VisitEventDeclaration
public override object VisitEventDeclaration(EventDeclaration eventDeclaration, object data)
{
if (!eventDeclaration.HasAddRegion && !eventDeclaration.HasRaiseRegion && !eventDeclaration.HasRemoveRegion) {
if (eventDeclaration.TypeReference.IsNull) {
DelegateDeclaration dd = new DelegateDeclaration(eventDeclaration.Modifier, null);
dd.Name = eventDeclaration.Name + "EventHandler";
dd.Parameters = eventDeclaration.Parameters;
dd.ReturnType = new TypeReference("System.Void");
dd.Parent = eventDeclaration.Parent;
eventDeclaration.Parameters = null;
InsertAfterSibling(eventDeclaration, dd);
eventDeclaration.TypeReference = new TypeReference(dd.Name);
}
}
return base.VisitEventDeclaration(eventDeclaration, data);
}
示例2: VisitEventDeclaration
// The following conversions are implemented:
// Public Event EventName(param As String) -> automatic delegate declaration
// static variables inside methods become fields
public override object VisitEventDeclaration(EventDeclaration eventDeclaration, object data)
{
if (!eventDeclaration.HasAddRegion && !eventDeclaration.HasRaiseRegion && !eventDeclaration.HasRemoveRegion) {
if (eventDeclaration.TypeReference.IsNull) {
DelegateDeclaration dd = new DelegateDeclaration(eventDeclaration.Modifier, null);
dd.Name = eventDeclaration.Name + "EventHandler";
dd.Parameters = eventDeclaration.Parameters;
dd.ReturnType = new TypeReference("System.Void");
dd.Parent = eventDeclaration.Parent;
eventDeclaration.Parameters = null;
int index = eventDeclaration.Parent.Children.IndexOf(eventDeclaration);
// inserting before current position is not allowed in a Transformer
eventDeclaration.Parent.Children.Insert(index + 1, dd);
eventDeclaration.TypeReference = new TypeReference(dd.Name);
}
}
return base.VisitEventDeclaration(eventDeclaration, data);
}
示例3: InterfaceMemberDecl
void InterfaceMemberDecl() {
#line 596 "VBNET.ATG"
TypeReference type =null;
List<ParameterDeclarationExpression> p = new List<ParameterDeclarationExpression>();
List<TemplateDefinition> templates = new List<TemplateDefinition>();
AttributeSection section, returnTypeAttributeSection = null;
ModifierList mod = new ModifierList();
List<AttributeSection> attributes = new List<AttributeSection>();
string name;
if (StartOf(18)) {
while (la.kind == 27) {
AttributeSection(
#line 604 "VBNET.ATG"
out section);
#line 604 "VBNET.ATG"
attributes.Add(section);
}
while (StartOf(8)) {
MemberModifier(
#line 607 "VBNET.ATG"
mod);
}
if (la.kind == 93) {
lexer.NextToken();
#line 611 "VBNET.ATG"
mod.Check(Modifiers.VBInterfaceEvents);
Location startLocation = t.Location;
Identifier();
#line 614 "VBNET.ATG"
name = t.val;
if (la.kind == 24) {
lexer.NextToken();
if (StartOf(4)) {
FormalParameterList(
#line 615 "VBNET.ATG"
p);
}
Expect(25);
}
if (la.kind == 48) {
lexer.NextToken();
TypeName(
#line 616 "VBNET.ATG"
out type);
}
Expect(1);
#line 619 "VBNET.ATG"
EventDeclaration ed = new EventDeclaration {
Name = name, TypeReference = type, Modifier = mod.Modifier,
Parameters = p, Attributes = attributes,
StartLocation = startLocation, EndLocation = t.EndLocation
};
compilationUnit.AddChild(ed);
} else if (la.kind == 167) {
lexer.NextToken();
#line 629 "VBNET.ATG"
Location startLocation = t.Location;
mod.Check(Modifiers.VBInterfaceMethods);
Identifier();
#line 632 "VBNET.ATG"
name = t.val;
TypeParameterList(
#line 633 "VBNET.ATG"
templates);
if (la.kind == 24) {
lexer.NextToken();
if (StartOf(4)) {
FormalParameterList(
#line 634 "VBNET.ATG"
p);
}
Expect(25);
}
Expect(1);
#line 637 "VBNET.ATG"
MethodDeclaration md = new MethodDeclaration {
Name = name,
Modifier = mod.Modifier,
Parameters = p,
Attributes = attributes,
TypeReference = new TypeReference("", "System.Void"),
StartLocation = startLocation,
EndLocation = t.EndLocation,
Templates = templates
};
compilationUnit.AddChild(md);
} else if (la.kind == 100) {
//.........这里部分代码省略.........
示例4: VisitEventDeclaration
public override object VisitEventDeclaration(EventDeclaration eventDeclaration, object data)
{
return base.VisitEventDeclaration(eventDeclaration, data);
}
示例5: StructureMemberDecl
//.........这里部分代码省略.........
}
if (la.kind == 24) {
lexer.NextToken();
if (StartOf(4)) {
FormalParameterList(
#line 946 "VBNET.ATG"
p);
}
Expect(25);
}
if (la.kind == 48) {
lexer.NextToken();
TypeName(
#line 947 "VBNET.ATG"
out type);
}
Expect(1);
#line 950 "VBNET.ATG"
DeclareDeclaration declareDeclaration = new DeclareDeclaration(name, m.Modifier, type, p, attributes, library, alias, charsetModifer);
declareDeclaration.StartLocation = m.GetDeclarationLocation(startPos);
declareDeclaration.EndLocation = t.EndLocation;
compilationUnit.AddChild(declareDeclaration);
} else SynErr(225);
break;
}
case 93: {
lexer.NextToken();
#line 960 "VBNET.ATG"
m.Check(Modifiers.VBEvents);
Location startPos = t.Location;
EventDeclaration eventDeclaration;
string name = String.Empty;
List<InterfaceImplementation> implementsClause = null;
Identifier();
#line 966 "VBNET.ATG"
name= t.val;
if (la.kind == 48) {
lexer.NextToken();
TypeName(
#line 968 "VBNET.ATG"
out type);
} else if (la.kind == 1 || la.kind == 24 || la.kind == 107) {
if (la.kind == 24) {
lexer.NextToken();
if (StartOf(4)) {
FormalParameterList(
#line 970 "VBNET.ATG"
p);
}
Expect(25);
}
} else SynErr(226);
if (la.kind == 107) {
ImplementsClause(
#line 972 "VBNET.ATG"
out implementsClause);
}
#line 974 "VBNET.ATG"
eventDeclaration = new EventDeclaration {
Name = name, TypeReference = type, Modifier = m.Modifier,
示例6: VisitEventDeclaration
public virtual object VisitEventDeclaration(EventDeclaration eventDeclaration, object data) {
throw new global::System.NotImplementedException("EventDeclaration");
}
示例7: StructMemberDecl
//.........这里部分代码省略.........
EndLocation = t.EndLocation,
Templates = templates,
IsExtensionMethod = isExtensionMethod
};
if (explicitInterface != null)
SafeAdd(methodDeclaration, methodDeclaration.InterfaceImplementations, new InterfaceImplementation(explicitInterface, qualident));
compilationUnit.AddChild(methodDeclaration);
compilationUnit.BlockStart(methodDeclaration);
while (la.kind == 127) {
TypeParameterConstraintsClause(
#line 800 "cs.ATG"
templates);
}
if (la.kind == 16) {
Block(
#line 802 "cs.ATG"
out stmt);
} else if (la.kind == 11) {
lexer.NextToken();
} else SynErr(163);
#line 802 "cs.ATG"
compilationUnit.BlockEnd();
methodDeclaration.Body = (BlockStatement)stmt;
} else if (la.kind == 69) {
#line 806 "cs.ATG"
m.Check(Modifiers.PropertysEventsMethods);
lexer.NextToken();
#line 808 "cs.ATG"
EventDeclaration eventDecl = new EventDeclaration {
Modifier = m.Modifier,
Attributes = attributes,
StartLocation = t.Location
};
compilationUnit.AddChild(eventDecl);
compilationUnit.BlockStart(eventDecl);
EventAddRegion addBlock = null;
EventRemoveRegion removeBlock = null;
Type(
#line 818 "cs.ATG"
out type);
#line 818 "cs.ATG"
eventDecl.TypeReference = type;
if (
#line 819 "cs.ATG"
IsExplicitInterfaceImplementation()) {
TypeName(
#line 820 "cs.ATG"
out explicitInterface, false);
#line 821 "cs.ATG"
qualident = TypeReference.StripLastIdentifierFromType(ref explicitInterface);
#line 822 "cs.ATG"
eventDecl.InterfaceImplementations.Add(new InterfaceImplementation(explicitInterface, qualident));
} else if (StartOf(19)) {
Identifier();
#line 824 "cs.ATG"
qualident = t.val;
示例8: VisitEventDeclaration
public override object VisitEventDeclaration(EventDeclaration eventDeclaration, object data)
{
if (this.CheckNode(eventDeclaration)) {
return null;
}
return base.VisitEventDeclaration(eventDeclaration, data);
}
示例9: StructureMemberDecl
//.........这里部分代码省略.........
}
if (la.kind == 25) {
lexer.NextToken();
if (StartOf(4)) {
FormalParameterList(
#line 988 "VBNET.ATG"
p);
}
Expect(26);
}
if (la.kind == 50) {
lexer.NextToken();
TypeName(
#line 989 "VBNET.ATG"
out type);
}
EndOfStmt();
#line 992 "VBNET.ATG"
DeclareDeclaration declareDeclaration = new DeclareDeclaration(name, m.Modifier, type, p, attributes, library, alias, charsetModifer);
declareDeclaration.StartLocation = m.GetDeclarationLocation(startPos);
declareDeclaration.EndLocation = t.EndLocation;
compilationUnit.AddChild(declareDeclaration);
} else SynErr(241);
break;
}
case 106: {
lexer.NextToken();
#line 1002 "VBNET.ATG"
m.Check(Modifiers.VBEvents);
Location startPos = t.Location;
EventDeclaration eventDeclaration;
string name = String.Empty;
List<InterfaceImplementation> implementsClause = null;
Identifier();
#line 1008 "VBNET.ATG"
name= t.val;
if (la.kind == 50) {
lexer.NextToken();
TypeName(
#line 1010 "VBNET.ATG"
out type);
} else if (StartOf(16)) {
if (la.kind == 25) {
lexer.NextToken();
if (StartOf(4)) {
FormalParameterList(
#line 1012 "VBNET.ATG"
p);
}
Expect(26);
}
} else SynErr(242);
if (la.kind == 123) {
ImplementsClause(
#line 1014 "VBNET.ATG"
out implementsClause);
}
#line 1016 "VBNET.ATG"
eventDeclaration = new EventDeclaration {
Name = name, TypeReference = type, Modifier = m.Modifier,
示例10: InterfaceMemberDecl
//.........这里部分代码省略.........
if (la.kind == 23) {
TypeParameterList(
#line 1109 "cs.ATG"
templates);
}
Expect(20);
if (StartOf(11)) {
FormalParameterList(
#line 1110 "cs.ATG"
parameters);
}
Expect(21);
while (la.kind == 127) {
TypeParameterConstraintsClause(
#line 1112 "cs.ATG"
templates);
}
Expect(11);
#line 1113 "cs.ATG"
MethodDeclaration md = new MethodDeclaration();
md.EndLocation = t.EndLocation;
md.StartLocation = startLocation;
md.Templates = templates;
md.Attributes = attributes;
md.Parameters = parameters;
md.TypeReference = type;
md.Modifier = mod;
md.Name = name;
compilationUnit.AddChild(md);
} else if (la.kind == 16) {
#line 1122 "cs.ATG"
PropertyDeclaration pd = new PropertyDeclaration(name, type, mod, attributes);
compilationUnit.AddChild(pd);
lexer.NextToken();
#line 1125 "cs.ATG"
Location bodyStart = t.Location;
InterfaceAccessors(
#line 1126 "cs.ATG"
out getBlock, out setBlock);
Expect(17);
#line 1127 "cs.ATG"
pd.GetRegion = getBlock; pd.SetRegion = setBlock; pd.StartLocation = startLocation; pd.EndLocation = qualIdentEndLocation; pd.BodyStart = bodyStart; pd.BodyEnd = t.EndLocation;
} else SynErr(175);
} else if (la.kind == 111) {
lexer.NextToken();
Expect(18);
FormalParameterList(
#line 1130 "cs.ATG"
parameters);
Expect(19);
#line 1131 "cs.ATG"
Location bracketEndLocation = t.EndLocation;
#line 1132 "cs.ATG"
IndexerDeclaration id = new IndexerDeclaration(type, parameters, mod, attributes);
compilationUnit.AddChild(id);
Expect(16);
#line 1134 "cs.ATG"
Location bodyStart = t.Location;
InterfaceAccessors(
#line 1135 "cs.ATG"
out getBlock, out setBlock);
Expect(17);
#line 1137 "cs.ATG"
id.GetRegion = getBlock; id.SetRegion = setBlock; id.StartLocation = startLocation; id.EndLocation = bracketEndLocation; id.BodyStart = bodyStart; id.BodyEnd = t.EndLocation;
} else SynErr(176);
} else {
lexer.NextToken();
#line 1140 "cs.ATG"
if (startLocation.IsEmpty) startLocation = t.Location;
Type(
#line 1141 "cs.ATG"
out type);
Identifier();
#line 1142 "cs.ATG"
EventDeclaration ed = new EventDeclaration();
ed.Attributes = attributes;
ed.Modifier = mod;
ed.Name = t.val;
ed.TypeReference = type;
compilationUnit.AddChild(ed);
Expect(11);
#line 1148 "cs.ATG"
ed.StartLocation = startLocation; ed.EndLocation = t.EndLocation;
}
} else SynErr(177);
}
示例11: VisitEventDeclaration
public virtual object VisitEventDeclaration(EventDeclaration eventDeclaration, object data) {
Debug.Assert((eventDeclaration != null));
Debug.Assert((eventDeclaration.Attributes != null));
Debug.Assert((eventDeclaration.Parameters != null));
Debug.Assert((eventDeclaration.InterfaceImplementations != null));
Debug.Assert((eventDeclaration.TypeReference != null));
Debug.Assert((eventDeclaration.AddRegion != null));
Debug.Assert((eventDeclaration.RemoveRegion != null));
Debug.Assert((eventDeclaration.RaiseRegion != null));
Debug.Assert((eventDeclaration.Initializer != null));
for (int i = 0; i < eventDeclaration.Attributes.Count; i++) {
AttributeSection o = eventDeclaration.Attributes[i];
Debug.Assert(o != null);
nodeStack.Push(o);
o.AcceptVisitor(this, data);
o = (AttributeSection)nodeStack.Pop();
if (o == null)
eventDeclaration.Attributes.RemoveAt(i--);
else
eventDeclaration.Attributes[i] = o;
}
for (int i = 0; i < eventDeclaration.Parameters.Count; i++) {
ParameterDeclarationExpression o = eventDeclaration.Parameters[i];
Debug.Assert(o != null);
nodeStack.Push(o);
o.AcceptVisitor(this, data);
o = (ParameterDeclarationExpression)nodeStack.Pop();
if (o == null)
eventDeclaration.Parameters.RemoveAt(i--);
else
eventDeclaration.Parameters[i] = o;
}
for (int i = 0; i < eventDeclaration.InterfaceImplementations.Count; i++) {
InterfaceImplementation o = eventDeclaration.InterfaceImplementations[i];
Debug.Assert(o != null);
nodeStack.Push(o);
o.AcceptVisitor(this, data);
o = (InterfaceImplementation)nodeStack.Pop();
if (o == null)
eventDeclaration.InterfaceImplementations.RemoveAt(i--);
else
eventDeclaration.InterfaceImplementations[i] = o;
}
nodeStack.Push(eventDeclaration.TypeReference);
eventDeclaration.TypeReference.AcceptVisitor(this, data);
eventDeclaration.TypeReference = ((TypeReference)(nodeStack.Pop()));
nodeStack.Push(eventDeclaration.AddRegion);
eventDeclaration.AddRegion.AcceptVisitor(this, data);
eventDeclaration.AddRegion = ((EventAddRegion)(nodeStack.Pop()));
nodeStack.Push(eventDeclaration.RemoveRegion);
eventDeclaration.RemoveRegion.AcceptVisitor(this, data);
eventDeclaration.RemoveRegion = ((EventRemoveRegion)(nodeStack.Pop()));
nodeStack.Push(eventDeclaration.RaiseRegion);
eventDeclaration.RaiseRegion.AcceptVisitor(this, data);
eventDeclaration.RaiseRegion = ((EventRaiseRegion)(nodeStack.Pop()));
nodeStack.Push(eventDeclaration.Initializer);
eventDeclaration.Initializer.AcceptVisitor(this, data);
eventDeclaration.Initializer = ((Expression)(nodeStack.Pop()));
return null;
}
示例12: VisitEventDeclaration
public object VisitEventDeclaration(EventDeclaration eventDeclaration, object data)
{
throw new NotImplementedException ();
}
示例13: VisitEventDeclaration
public virtual object VisitEventDeclaration(EventDeclaration eventDeclaration, object data)
{
Debug.Assert((eventDeclaration != null));
Debug.Assert((eventDeclaration.Attributes != null));
Debug.Assert((eventDeclaration.Parameters != null));
Debug.Assert((eventDeclaration.InterfaceImplementations != null));
Debug.Assert((eventDeclaration.TypeReference != null));
Debug.Assert((eventDeclaration.AddRegion != null));
Debug.Assert((eventDeclaration.RemoveRegion != null));
Debug.Assert((eventDeclaration.RaiseRegion != null));
Debug.Assert((eventDeclaration.Initializer != null));
foreach (AttributeSection o in eventDeclaration.Attributes) {
Debug.Assert(o != null);
o.AcceptVisitor(this, data);
}
foreach (ParameterDeclarationExpression o in eventDeclaration.Parameters) {
Debug.Assert(o != null);
o.AcceptVisitor(this, data);
}
foreach (InterfaceImplementation o in eventDeclaration.InterfaceImplementations) {
Debug.Assert(o != null);
o.AcceptVisitor(this, data);
}
eventDeclaration.TypeReference.AcceptVisitor(this, data);
eventDeclaration.AddRegion.AcceptVisitor(this, data);
eventDeclaration.RemoveRegion.AcceptVisitor(this, data);
eventDeclaration.RaiseRegion.AcceptVisitor(this, data);
return eventDeclaration.Initializer.AcceptVisitor(this, data);
}
示例14: VisitEventDeclaration
public object VisitEventDeclaration(EventDeclaration eventDeclaration, object data)
{
B.Event m = new B.Event(GetLexicalInfo(eventDeclaration));
m.Name = eventDeclaration.Name;
m.Modifiers = ConvertModifier(eventDeclaration, B.TypeMemberModifiers.Private);
ConvertAttributes(eventDeclaration.Attributes, m.Attributes);
if (currentType != null) currentType.Members.Add(m);
m.EndSourceLocation = GetLocation(eventDeclaration.EndLocation);
m.Type = ConvertTypeReference(eventDeclaration.TypeReference);
if (eventDeclaration.InterfaceImplementations.Count > 0) {
AddError(eventDeclaration, "Explicit interface implementation is not supported for events.");
}
if (eventDeclaration.Parameters.Count > 0) {
AddError(eventDeclaration, "Events with parameters are not supported.");
}
if (eventDeclaration.HasAddRegion) {
m.Add = new B.Method(GetLexicalInfo(eventDeclaration.AddRegion));
ConvertAttributes(eventDeclaration.AddRegion.Attributes, m.Add.Attributes);
m.Modifiers = ConvertModifier(eventDeclaration.AddRegion, m.Visibility);
m.Add.Body = ConvertMethodBlock(eventDeclaration.AddRegion.Block);
}
if (eventDeclaration.HasRemoveRegion) {
m.Remove = new B.Method(GetLexicalInfo(eventDeclaration.RemoveRegion));
ConvertAttributes(eventDeclaration.RemoveRegion.Attributes, m.Remove.Attributes);
m.Modifiers = ConvertModifier(eventDeclaration.RemoveRegion, m.Visibility);
m.Remove.Body = ConvertMethodBlock(eventDeclaration.RemoveRegion.Block);
}
if (eventDeclaration.HasRaiseRegion) {
m.Raise = new B.Method(GetLexicalInfo(eventDeclaration.RaiseRegion));
ConvertAttributes(eventDeclaration.RaiseRegion.Attributes, m.Raise.Attributes);
m.Modifiers = ConvertModifier(eventDeclaration.RaiseRegion, m.Visibility);
m.Raise.Body = ConvertMethodBlock(eventDeclaration.RaiseRegion.Block);
}
return m;
}
示例15: VisitEventDeclaration
public virtual bool VisitEventDeclaration(EventDeclaration eventDeclaration, object d)
{
if ((eventDeclaration == null)) {
return SetFailure();
}
if ((d == null)) {
return SetFailure();
}
if ((eventDeclaration.Attributes == null)) {
return SetFailure();
}
if ((eventDeclaration.Parameters == null)) {
return SetFailure();
}
if ((eventDeclaration.InterfaceImplementations == null)) {
return SetFailure();
}
if ((eventDeclaration.TypeReference == null)) {
return SetFailure();
}
if ((eventDeclaration.AddRegion == null)) {
return SetFailure();
}
if ((eventDeclaration.RemoveRegion == null)) {
return SetFailure();
}
if ((eventDeclaration.RaiseRegion == null)) {
return SetFailure();
}
if ((eventDeclaration.Initializer == null)) {
return SetFailure();
}
if(eventDeclaration.GetType() != d.GetType()) {return SetFailure();}
var data = (EventDeclaration)d;
if (!IsMatch(eventDeclaration, data)) {
return SetFailure();
}
if (eventDeclaration.Attributes.Count == data.Attributes.Count) {
for (int i=0; i<eventDeclaration.Attributes.Count;i++) {
AttributeSection o = eventDeclaration.Attributes[i];
if(o == null){return SetFailure();}
if((bool)o.AcceptVisitor(this, data.Attributes[i]) == false) return SetFailure();
} } else { return SetFailure(); }
if (eventDeclaration.Parameters.Count == data.Parameters.Count) {
for (int i=0; i<eventDeclaration.Parameters.Count;i++) {
ParameterDeclarationExpression o = eventDeclaration.Parameters[i];
if(o == null){return SetFailure();}
if((bool)o.AcceptVisitor(this, data.Parameters[i]) == false) return SetFailure();
} } else { return SetFailure(); }
if (eventDeclaration.InterfaceImplementations.Count == data.InterfaceImplementations.Count) {
for (int i=0; i<eventDeclaration.InterfaceImplementations.Count;i++) {
InterfaceImplementation o = eventDeclaration.InterfaceImplementations[i];
if(o == null){return SetFailure();}
if((bool)o.AcceptVisitor(this, data.InterfaceImplementations[i]) == false) return SetFailure();
} } else { return SetFailure(); }
eventDeclaration.TypeReference.AcceptVisitor(this, data.TypeReference);
eventDeclaration.AddRegion.AcceptVisitor(this, data.AddRegion);
eventDeclaration.RemoveRegion.AcceptVisitor(this, data.RemoveRegion);
eventDeclaration.RaiseRegion.AcceptVisitor(this, data.RaiseRegion);
return eventDeclaration.Initializer.AcceptVisitor(this, data.Initializer);
}