本文整理汇总了C#中DelegateDeclaration类的典型用法代码示例。如果您正苦于以下问题:C# DelegateDeclaration类的具体用法?C# DelegateDeclaration怎么用?C# DelegateDeclaration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DelegateDeclaration类属于命名空间,在下文中一共展示了DelegateDeclaration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestParameters
void TestParameters(DelegateDeclaration dd)
{
Assert.AreEqual(3, dd.Parameters.Count());
Assert.AreEqual("a", ((ParameterDeclaration)dd.Parameters.ElementAt(0)).Name);
//Assert.AreEqual("System.Int32", ((ParameterDeclaration)dd.Parameters.ElementAt(0)).TypeReference.Type);
Assert.Ignore("check types"); // TODO
Assert.AreEqual("secondParam", ((ParameterDeclaration)dd.Parameters.ElementAt(1)).Name);
//Assert.AreEqual("System.Int32", ((ParameterDeclaration)dd.Parameters.ElementAt(1)).TypeReference.Type);
Assert.AreEqual("lastParam", ((ParameterDeclaration)dd.Parameters.ElementAt(2)).Name);
//Assert.AreEqual("MyObj", ((ParameterDeclaration)dd.Parameters.ElementAt(2)).TypeReference.Type);
}
示例2: CreateType
static DelegateDeclaration CreateType(RefactoringContext context, SimpleType simpleType)
{
var result = new DelegateDeclaration() {
Name = simpleType.Identifier,
Modifiers = ((EntityDeclaration)simpleType.Parent).Modifiers,
ReturnType = new PrimitiveType("void"),
Parameters = {
new ParameterDeclaration(new PrimitiveType("object"), "sender"),
new ParameterDeclaration(context.CreateShortType("System", "EventArgs"), "e")
}
};
return result;
}
示例3: VisitDelegateDeclaration
public override void VisitDelegateDeclaration(DelegateDeclaration delegateDeclaration)
{
ForceSpacesBefore(delegateDeclaration.LParToken, policy.SpaceBeforeDelegateDeclarationParentheses);
if (delegateDeclaration.Parameters.Any()) {
ForceSpacesAfter(delegateDeclaration.LParToken, policy.SpaceWithinDelegateDeclarationParentheses);
ForceSpacesBefore(delegateDeclaration.RParToken, policy.SpaceWithinDelegateDeclarationParentheses);
} else {
ForceSpacesAfter(delegateDeclaration.LParToken, policy.SpaceBetweenEmptyDelegateDeclarationParentheses);
ForceSpacesBefore(delegateDeclaration.RParToken, policy.SpaceBetweenEmptyDelegateDeclarationParentheses);
}
FormatCommas(delegateDeclaration, policy.SpaceBeforeDelegateDeclarationParameterComma, policy.SpaceAfterDelegateDeclarationParameterComma);
base.VisitDelegateDeclaration(delegateDeclaration);
}
示例4: 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", true);
dd.Parent = eventDeclaration.Parent;
eventDeclaration.Parameters = null;
InsertAfterSibling(eventDeclaration, dd);
eventDeclaration.TypeReference = new TypeReference(dd.Name);
}
}
return base.VisitEventDeclaration(eventDeclaration, data);
}
示例5: Process_Delegate_Declaration
private void Process_Delegate_Declaration(DelegateDeclaration node)
{
if (node == null) throw new ArgumentNullException("node");
var dele = new Delegate(controller);
dele.Name = node.Name.Text;
dele.Modifiers.AddRange(FormatterUtility.GetModifiersFromEnum(node.Modifiers));
dele.ReturnType = FormatterUtility.GetDataTypeFromTypeReference(node.ReturnType, document, controller);
foreach (ParameterDeclaration paramNode in node.Parameters)
{
Parameter param = GetParameterFromParameterDeclaration(document, controller, paramNode);
param.ParentObject = dele;
dele.Parameters.Add(param);
}
SetupBaseConstruct(node, dele);
}
示例6: Visit
public override void Visit (Mono.CSharp.Delegate d)
{
DelegateDeclaration newDelegate = new DelegateDeclaration ();
var location = LocationsBag.GetMemberLocation (d);
AddModifiers (newDelegate, location);
if (location != null)
newDelegate.AddChild (new CSharpTokenNode (Convert (location[0]), "delegate".Length), TypeDeclaration.TypeKeyword);
newDelegate.AddChild ((INode)d.ReturnType.Accept (this), AbstractNode.Roles.ReturnType);
newDelegate.AddChild (new Identifier (d.Name, Convert (d.MemberName.Location)), AbstractNode.Roles.Identifier);
if (d.MemberName.TypeArguments != null) {
var typeArgLocation = LocationsBag.GetLocations (d.MemberName);
if (typeArgLocation != null)
newDelegate.AddChild (new CSharpTokenNode (Convert (typeArgLocation[0]), 1), MemberReferenceExpression.Roles.LChevron);
// AddTypeArguments (newDelegate, typeArgLocation, d.MemberName.TypeArguments);
if (typeArgLocation != null)
newDelegate.AddChild (new CSharpTokenNode (Convert (typeArgLocation[1]), 1), MemberReferenceExpression.Roles.RChevron);
AddConstraints (newDelegate, d);
}
if (location != null) {
newDelegate.AddChild (new CSharpTokenNode (Convert (location[1]), 1), DelegateDeclaration.Roles.LPar);
newDelegate.AddChild (new CSharpTokenNode (Convert (location[2]), 1), DelegateDeclaration.Roles.RPar);
newDelegate.AddChild (new CSharpTokenNode (Convert (location[3]), 1), DelegateDeclaration.Roles.Semicolon);
}
AddType (newDelegate);
}
示例7: Visit
public override void Visit(Mono.CSharp.Delegate d)
{
var newDelegate = new DelegateDeclaration();
var location = LocationsBag.GetMemberLocation(d);
AddAttributeSection(newDelegate, d);
AddModifiers(newDelegate, location);
if (location != null && location.Count > 0) {
newDelegate.AddChild(new CSharpTokenNode(Convert(location [0]), Roles.DelegateKeyword), Roles.DelegateKeyword);
}
if (d.ReturnType != null)
newDelegate.AddChild(ConvertToType(d.ReturnType), Roles.Type);
newDelegate.AddChild(Identifier.Create(d.MemberName.Name, Convert(d.MemberName.Location)), Roles.Identifier);
AddTypeParameters(newDelegate, d.MemberName);
if (location != null && location.Count > 1)
newDelegate.AddChild(new CSharpTokenNode(Convert(location [1]), Roles.LPar), Roles.LPar);
AddParameter(newDelegate, d.Parameters);
if (location != null && location.Count > 2) {
newDelegate.AddChild(new CSharpTokenNode(Convert(location [2]), Roles.RPar), Roles.RPar);
}
AddConstraints(newDelegate, d.CurrentTypeParameters);
if (location != null && location.Count > 3) {
newDelegate.AddChild(new CSharpTokenNode(Convert(location [3]), Roles.Semicolon), Roles.Semicolon);
}
AddType(newDelegate);
}
示例8: Visit
public override void Visit (Mono.CSharp.Delegate d)
{
DelegateDeclaration newDelegate = new DelegateDeclaration ();
var location = LocationsBag.GetMemberLocation (d);
AddAttributeSection (newDelegate, d);
AddModifiers (newDelegate, location);
if (location != null)
newDelegate.AddChild (new CSharpTokenNode (Convert (location[0]), "delegate".Length), TypeDeclaration.Roles.Keyword);
newDelegate.AddChild (ConvertToType (d.ReturnType), AstNode.Roles.Type);
newDelegate.AddChild (Identifier.Create (d.MemberName.Name, Convert (d.MemberName.Location)), AstNode.Roles.Identifier);
if (d.MemberName.TypeArguments != null) {
AddTypeParameters (newDelegate, d.MemberName.TypeArguments);
}
if (location != null)
newDelegate.AddChild (new CSharpTokenNode (Convert (location[1]), 1), DelegateDeclaration.Roles.LPar);
AddParameter (newDelegate, d.Parameters);
if (location != null) {
newDelegate.AddChild (new CSharpTokenNode (Convert (location[2]), 1), DelegateDeclaration.Roles.RPar);
}
AddConstraints (newDelegate, d);
if (location != null) {
newDelegate.AddChild (new CSharpTokenNode (Convert (location[3]), 1), DelegateDeclaration.Roles.Semicolon);
}
AddType (newDelegate);
}
示例9: DelegateType
public DelegateType(AbstractType ReturnType,DelegateDeclaration Declaration, IEnumerable<AbstractType> Parameters = null) : base(ReturnType, Declaration)
{
this.IsFunction = Declaration.IsFunction;
if (Parameters is AbstractType[])
this.Parameters = (AbstractType[])Parameters;
else if(Parameters!=null)
this.Parameters = Parameters.ToArray();
}
示例10: VisitDelegateDeclaration
public override void VisitDelegateDeclaration(DelegateDeclaration delegateDeclaration)
{
}
示例11: NonModuleDeclaration
//.........这里部分代码省略.........
Identifier();
#line 514 "VBNET.ATG"
newType.Name = t.val;
TypeParameterList(
#line 515 "VBNET.ATG"
newType.Templates);
EndOfStmt();
#line 517 "VBNET.ATG"
newType.BodyStartLocation = t.Location;
while (la.kind == 127) {
InterfaceBase(
#line 518 "VBNET.ATG"
out baseInterfaces);
#line 518 "VBNET.ATG"
newType.BaseTypes.AddRange(baseInterfaces);
}
InterfaceBody(
#line 519 "VBNET.ATG"
newType);
#line 521 "VBNET.ATG"
compilationUnit.BlockEnd();
break;
}
case 90: {
lexer.NextToken();
#line 526 "VBNET.ATG"
m.Check(Modifiers.VBDelegates);
DelegateDeclaration delegateDeclr = new DelegateDeclaration(m.Modifier, attributes);
delegateDeclr.ReturnType = new TypeReference("System.Void", true);
delegateDeclr.StartLocation = m.GetDeclarationLocation(t.Location);
List<ParameterDeclarationExpression> p = new List<ParameterDeclarationExpression>();
if (la.kind == 195) {
lexer.NextToken();
Identifier();
#line 533 "VBNET.ATG"
delegateDeclr.Name = t.val;
TypeParameterList(
#line 534 "VBNET.ATG"
delegateDeclr.Templates);
if (la.kind == 25) {
lexer.NextToken();
if (StartOf(4)) {
FormalParameterList(
#line 535 "VBNET.ATG"
p);
}
Expect(26);
#line 535 "VBNET.ATG"
delegateDeclr.Parameters = p;
}
} else if (la.kind == 114) {
lexer.NextToken();
Identifier();
#line 537 "VBNET.ATG"
delegateDeclr.Name = t.val;
TypeParameterList(
示例12: ConvertDelegate
DelegateDeclaration ConvertDelegate(IMethod invokeMethod, Modifiers modifiers)
{
ITypeDefinition d = invokeMethod.DeclaringTypeDefinition;
DelegateDeclaration decl = new DelegateDeclaration();
decl.Modifiers = modifiers & ~Modifiers.Sealed;
if (ShowAttributes) {
decl.Attributes.AddRange (d.Attributes.Select (a => new AttributeSection (ConvertAttribute (a))));
decl.Attributes.AddRange (invokeMethod.ReturnTypeAttributes.Select ((a) => new AttributeSection (ConvertAttribute (a)) {
AttributeTarget = "return"
}));
}
decl.ReturnType = ConvertType(invokeMethod.ReturnType);
decl.Name = d.Name;
int outerTypeParameterCount = (d.DeclaringTypeDefinition == null) ? 0 : d.DeclaringTypeDefinition.TypeParameterCount;
if (this.ShowTypeParameters) {
foreach (ITypeParameter tp in d.TypeParameters.Skip(outerTypeParameterCount)) {
decl.TypeParameters.Add(ConvertTypeParameter(tp));
}
}
foreach (IParameter p in invokeMethod.Parameters) {
decl.Parameters.Add(ConvertParameter(p));
}
if (this.ShowTypeParameters && this.ShowTypeParameterConstraints) {
foreach (ITypeParameter tp in d.TypeParameters.Skip(outerTypeParameterCount)) {
var constraint = ConvertTypeParameterConstraint(tp);
if (constraint != null)
decl.Constraints.Add(constraint);
}
}
return decl;
}
示例13: VisitDelegateDeclaration
public virtual void VisitDelegateDeclaration(DelegateDeclaration delegateDeclaration)
{
StartNode(delegateDeclaration);
WriteAttributes(delegateDeclaration.Attributes);
WriteModifiers(delegateDeclaration.ModifierTokens);
WriteKeyword(Roles.DelegateKeyword);
delegateDeclaration.ReturnType.AcceptVisitor(this);
Space();
WriteIdentifier(delegateDeclaration.NameToken);
WriteTypeParameters(delegateDeclaration.TypeParameters, CodeBracesRangeFlags.AngleBrackets);
Space(policy.SpaceBeforeDelegateDeclarationParentheses);
WriteCommaSeparatedListInParenthesis(delegateDeclaration.Parameters, policy.SpaceWithinMethodDeclarationParentheses, CodeBracesRangeFlags.Parentheses);
int count = 0;
foreach (Constraint constraint in delegateDeclaration.Constraints) {
if (count-- <= 0) {
cancellationToken.ThrowIfCancellationRequested();
count = CANCEL_CHECK_LOOP_COUNT;
}
constraint.AcceptVisitor(this);
}
SaveDeclarationOffset();
Semicolon();
EndNode(delegateDeclaration);
}
示例14: TypeDecl
//.........这里部分代码省略.........
InterfaceBody();
if (la.kind == 11) {
lexer.NextToken();
}
#line 437 "cs.ATG"
newType.EndLocation = t.Location;
compilationUnit.BlockEnd();
} else if (la.kind == 68) {
lexer.NextToken();
#line 441 "cs.ATG"
TypeDeclaration newType = new TypeDeclaration(m.Modifier, attributes);
compilationUnit.AddChild(newType);
compilationUnit.BlockStart(newType);
newType.StartLocation = m.GetDeclarationLocation(t.Location);
newType.Type = Types.Enum;
Identifier();
#line 447 "cs.ATG"
newType.Name = t.val;
if (la.kind == 9) {
lexer.NextToken();
IntegralType(
#line 448 "cs.ATG"
out name);
#line 448 "cs.ATG"
newType.BaseTypes.Add(new TypeReference(name, true));
}
#line 450 "cs.ATG"
newType.BodyStartLocation = t.EndLocation;
EnumBody();
if (la.kind == 11) {
lexer.NextToken();
}
#line 452 "cs.ATG"
newType.EndLocation = t.Location;
compilationUnit.BlockEnd();
} else {
lexer.NextToken();
#line 456 "cs.ATG"
DelegateDeclaration delegateDeclr = new DelegateDeclaration(m.Modifier, attributes);
templates = delegateDeclr.Templates;
delegateDeclr.StartLocation = m.GetDeclarationLocation(t.Location);
if (
#line 460 "cs.ATG"
NotVoidPointer()) {
Expect(123);
#line 460 "cs.ATG"
delegateDeclr.ReturnType = new TypeReference("System.Void", true);
} else if (StartOf(10)) {
Type(
#line 461 "cs.ATG"
out type);
#line 461 "cs.ATG"
delegateDeclr.ReturnType = type;
} else SynErr(152);
Identifier();
#line 463 "cs.ATG"
delegateDeclr.Name = t.val;
if (la.kind == 23) {
TypeParameterList(
#line 466 "cs.ATG"
templates);
}
Expect(20);
if (StartOf(11)) {
FormalParameterList(
#line 468 "cs.ATG"
p);
#line 468 "cs.ATG"
delegateDeclr.Parameters = p;
}
Expect(21);
while (la.kind == 127) {
TypeParameterConstraintsClause(
#line 472 "cs.ATG"
templates);
}
Expect(11);
#line 474 "cs.ATG"
delegateDeclr.EndLocation = t.Location;
compilationUnit.AddChild(delegateDeclr);
}
} else SynErr(153);
}
示例15: VisitDelegateDeclaration
public override object VisitDelegateDeclaration(DelegateDeclaration delegateDeclaration, object data)
{
// fix default inner type visibility
if (currentType != null && (delegateDeclaration.Modifier & Modifiers.Visibility) == 0)
delegateDeclaration.Modifier |= Modifiers.Private;
return base.VisitDelegateDeclaration(delegateDeclaration, data);
}