本文整理汇总了C#中ICSharpCode.NRefactory.Ast.AttributeSection类的典型用法代码示例。如果您正苦于以下问题:C# AttributeSection类的具体用法?C# AttributeSection怎么用?C# AttributeSection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AttributeSection类属于ICSharpCode.NRefactory.Ast命名空间,在下文中一共展示了AttributeSection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VisitAttributeSection
public virtual object VisitAttributeSection(AttributeSection attributeSection, object data) {
Debug.Assert((attributeSection != null));
Debug.Assert((attributeSection.Attributes != null));
foreach (ICSharpCode.NRefactory.Ast.Attribute o in attributeSection.Attributes) {
Debug.Assert(o != null);
o.AcceptVisitor(this, data);
}
return null;
}
示例2: CreateAttributeSection
private AttributeSection CreateAttributeSection(string attributeName, List<Expression> args)
{
Attribute attribute = new Attribute(attributeName, args, null);
List<Attribute> attributes = new List<Attribute>();
attributes.Add(attribute);
AttributeSection attributeSection = new AttributeSection("", attributes);
attribute.Parent = attributeSection;
return attributeSection;
}
示例3: TrackedVisitMethodDeclaration
public override object TrackedVisitMethodDeclaration(MethodDeclaration methodDeclaration, object data)
{
TypeDeclaration typeDeclaration = (TypeDeclaration) methodDeclaration.Parent;
string testcase = "junit.framework.TestCase";
if (typeDeclaration != null && ((IsDerivedFrom(typeDeclaration, testcase) &&
!(typeDeclaration.Name.StartsWith("Abstract"))) || IsAllTestRunner(typeDeclaration.Name)))
{
if (methodDeclaration.Name == "main" || methodDeclaration.Name == "suite")
RemoveCurrentNode();
else if (methodDeclaration.Name.StartsWith("test"))
{
MethodDeclaration replaced = methodDeclaration;
Attribute attr = new Attribute("NUnit.Framework.Test", null, null);
List<Attribute> attributes = new List<Attribute>();
attributes.Add(attr);
AttributeSection testAttribute = new AttributeSection(null, attributes);
replaced.Attributes.Add(testAttribute);
AstUtil.RemoveModifierFrom(replaced, Modifiers.Static);
ReplaceCurrentNode(replaced);
}
else if (methodDeclaration.Name == "setUp" || methodDeclaration.Name == "tearDown")
{
if (Mode == "DotNet")
{
MethodDeclaration replaced = methodDeclaration;
replaced.Modifier = Modifiers.Public;
string attributeName = "NUnit.Framework.SetUp";
if (methodDeclaration.Name == "tearDown")
attributeName = "NUnit.Framework.TearDown";
Attribute attribute = new Attribute(attributeName, null, null);
List<Attribute> attributes = new List<Attribute>();
attributes.Add(attribute);
AttributeSection attributeSection = new AttributeSection(null, attributes);
replaced.Attributes.Add(attributeSection);
ReplaceCurrentNode(replaced);
}
else if (Mode == "IKVM")
{
methodDeclaration.Modifier = Modifiers.Protected | Modifiers.Override;
}
}
}
return null;
}
示例4: TrackedVisitTypeDeclaration
public override object TrackedVisitTypeDeclaration(TypeDeclaration typeDeclaration, object data)
{
if (IsDerivedFrom(typeDeclaration, "junit.framework.TestCase"))
{
if (!(typeDeclaration.Name.StartsWith("Abstract")))
{
TypeDeclaration newType = typeDeclaration;
Attribute attr = new Attribute("NUnit.Framework.TestFixture", null, null);
List<Attribute> attributes = new List<Attribute>();
attributes.Add(attr);
AttributeSection attrSection = new AttributeSection(null, attributes);
newType.Attributes.Add(attrSection);
ReplaceCurrentNode(newType);
}
}
return base.TrackedVisitTypeDeclaration(typeDeclaration, data);
}
示例5: TrackedVisitTypeDeclaration
public override object TrackedVisitTypeDeclaration(TypeDeclaration typeDeclaration, object data)
{
int index = GetBaseTypeIndex(typeDeclaration, serializableType);
if (index != -1)
{
Removeables.Add(serializableType);
if (typeDeclaration.Type == ClassType.Class)
{
List<Attribute> attributes = new List<Attribute>();
Attribute attribute = new Attribute("System.SerializableAttribute", null, null);
attributes.Add(attribute);
AttributeSection attributeSection = new AttributeSection("", attributes);
typeDeclaration.Attributes.Add(attributeSection);
attributeSection.Parent = typeDeclaration;
}
typeDeclaration = RemoveBaseTypeFrom(typeDeclaration, (TypeReference) typeDeclaration.BaseTypes[index]);
}
return base.TrackedVisitTypeDeclaration(typeDeclaration, data);
}
示例6: CreateAreaAttributeCode
private static AttributeSection CreateAreaAttributeCode(string attributeName, string argumentName, Expression valueExpression)
{
NamedArgumentExpression argument = new NamedArgumentExpression(argumentName, valueExpression);
Attribute attribute = new Attribute(attributeName, new List<Expression>(), new List<NamedArgumentExpression>());
attribute.NamedArguments.Add(argument);
AttributeSection attributeSection = new AttributeSection("IDontKnow", new List<Attribute>());
attributeSection.Attributes.Add(attribute);
return attributeSection;
}
示例7: AttributeSection
void AttributeSection(
#line 291 "Frames/cs.ATG"
out AttributeSection section) {
#line 293 "Frames/cs.ATG"
string attributeTarget = "";
List<ASTAttribute> attributes = new List<ASTAttribute>();
ASTAttribute attribute;
Expect(18);
#line 299 "Frames/cs.ATG"
Location startPos = t.Location;
if (
#line 300 "Frames/cs.ATG"
IsLocalAttrTarget()) {
if (la.kind == 69) {
lexer.NextToken();
#line 301 "Frames/cs.ATG"
attributeTarget = "event";
} else if (la.kind == 101) {
lexer.NextToken();
#line 302 "Frames/cs.ATG"
attributeTarget = "return";
} else {
Identifier();
#line 303 "Frames/cs.ATG"
if (t.val != "field" && t.val != "method" &&
t.val != "param" &&
t.val != "property" && t.val != "type")
Error("attribute target specifier (field, event, method, param, property, return or type) expected");
attributeTarget = t.val;
}
Expect(9);
}
Attribute(
#line 312 "Frames/cs.ATG"
out attribute);
#line 312 "Frames/cs.ATG"
attributes.Add(attribute);
while (
#line 313 "Frames/cs.ATG"
NotFinalComma()) {
Expect(14);
Attribute(
#line 313 "Frames/cs.ATG"
out attribute);
#line 313 "Frames/cs.ATG"
attributes.Add(attribute);
}
if (la.kind == 14) {
lexer.NextToken();
}
Expect(19);
#line 315 "Frames/cs.ATG"
section = new AttributeSection {
AttributeTarget = attributeTarget,
Attributes = attributes,
StartLocation = startPos,
EndLocation = t.EndLocation
};
}
示例8: VisitDeclareDeclaration
public override object VisitDeclareDeclaration(DeclareDeclaration declareDeclaration, object data)
{
if (usings != null && !usings.ContainsKey("System.Runtime.InteropServices")) {
UsingDeclaration @using = new UsingDeclaration("System.Runtime.InteropServices");
addedUsings.Add(@using);
base.VisitUsingDeclaration(@using, data);
}
MethodDeclaration method = new MethodDeclaration();
method.Attributes = declareDeclaration.Attributes;
method.Parameters = declareDeclaration.Parameters;
method.TypeReference = declareDeclaration.TypeReference;
method.Modifier = declareDeclaration.Modifier;
method.Name = declareDeclaration.Name;
if ((method.Modifier & Modifiers.Visibility) == 0)
method.Modifier |= Modifiers.Public;
method.Modifier |= Modifiers.Extern | Modifiers.Static;
if (method.TypeReference.IsNull) {
method.TypeReference = new TypeReference("System.Void", true);
}
Attribute att = new Attribute("DllImport", null, null);
att.PositionalArguments.Add(CreateStringLiteral(declareDeclaration.Library));
if (declareDeclaration.Alias.Length > 0) {
att.NamedArguments.Add(new NamedArgumentExpression("EntryPoint", CreateStringLiteral(declareDeclaration.Alias)));
}
switch (declareDeclaration.Charset) {
case CharsetModifier.Auto:
att.NamedArguments.Add(new NamedArgumentExpression("CharSet",
new MemberReferenceExpression(new IdentifierExpression("CharSet"),
"Auto")));
break;
case CharsetModifier.Unicode:
att.NamedArguments.Add(new NamedArgumentExpression("CharSet",
new MemberReferenceExpression(new IdentifierExpression("CharSet"),
"Unicode")));
break;
default:
att.NamedArguments.Add(new NamedArgumentExpression("CharSet",
new MemberReferenceExpression(new IdentifierExpression("CharSet"),
"Ansi")));
break;
}
att.NamedArguments.Add(new NamedArgumentExpression("SetLastError", new PrimitiveExpression(true, true.ToString())));
att.NamedArguments.Add(new NamedArgumentExpression("ExactSpelling", new PrimitiveExpression(true, true.ToString())));
var attributeSection = new AttributeSection();
attributeSection.Attributes = new List<Attribute>().add(att);
method.Attributes.Add(attributeSection);
ReplaceCurrentNode(method);
return base.VisitMethodDeclaration(method, data);
}
示例9: VisitTypeDeclaration_AControllerWithRestRoutesAttribute_ExtractsRestRoutesData
public void VisitTypeDeclaration_AControllerWithRestRoutesAttribute_ExtractsRestRoutesData()
{
var routeName = "restController";
var routeCollection = "/part1/<key>/part2";
var routeIdentifier = "<id>";
var routeRestVerbResolverType = typeof(CustomRestVerbResolver).FullName;
var type = new TypeDeclaration(Modifiers.Public | Modifiers.Partial, new List<AttributeSection>()) { Name = ControllerName };
var attribute = new Attribute("RestRoutes", new List<Expression>(), new List<NamedArgumentExpression>());
attribute.PositionalArguments.AddRange(new Expression[]
{
new PrimitiveExpression("restController", "restController"),
new PrimitiveExpression("/part1/<key>/part2", "/part1/<key>/part2"),
new PrimitiveExpression("<id>", "<id>"),
new TypeOfExpression(new TypeReference(routeRestVerbResolverType))
});
var section = new AttributeSection();
section.Attributes.Add(attribute);
type.Attributes.Add(section);
typeResolver.Expect(r => r.Resolve(Arg<TypeReference>.Matches(t => t.Type == routeRestVerbResolverType))).Return(
routeRestVerbResolverType);
visitor.VisitTypeDeclaration(type, null);
treeService.AssertWasCalled(
s => s.PushNode(Arg<ControllerTreeNode>.Matches(
n => n.Name == ControllerName &&
n.RestRoutesDescriptor.Name == routeName &&
n.RestRoutesDescriptor.Collection == routeCollection &&
n.RestRoutesDescriptor.Identifier == routeIdentifier &&
n.RestRoutesDescriptor.RestVerbResolverType == routeRestVerbResolverType)));
treeService.AssertWasCalled(s => s.PopNode());
}
示例10: VisitAttributeSection
public virtual object VisitAttributeSection(AttributeSection attributeSection, object data) {
throw CreateException(attributeSection);
}
示例11: TrackedVisitAttributeSection
public virtual object TrackedVisitAttributeSection(AttributeSection attributeSection, object data) {
return base.VisitAttributeSection(attributeSection, data);
}
示例12: GlobalAttributeSection
void GlobalAttributeSection() {
Expect(40);
//#line 2823 "VBNET.ATG"
Location startPos = t.Location;
if (la.kind == 65) {
lexer.NextToken();
} else if (la.kind == 155) {
lexer.NextToken();
} else SynErr(243);
//#line 2825 "VBNET.ATG"
string attributeTarget = t.val != null ? t.val.ToLower(System.Globalization.CultureInfo.InvariantCulture) : null;
List<ASTAttribute> attributes = new List<ASTAttribute>();
ASTAttribute attribute;
Expect(21);
Attribute(
//#line 2829 "VBNET.ATG"
out attribute);
//#line 2829 "VBNET.ATG"
attributes.Add(attribute);
while (
//#line 2830 "VBNET.ATG"
NotFinalComma()) {
if (la.kind == 22) {
lexer.NextToken();
if (la.kind == 65) {
lexer.NextToken();
} else if (la.kind == 155) {
lexer.NextToken();
} else SynErr(244);
Expect(21);
}
Attribute(
//#line 2830 "VBNET.ATG"
out attribute);
//#line 2830 "VBNET.ATG"
attributes.Add(attribute);
}
if (la.kind == 22) {
lexer.NextToken();
}
Expect(39);
EndOfStmt();
//#line 2835 "VBNET.ATG"
AttributeSection section = new AttributeSection {
AttributeTarget = attributeTarget,
Attributes = attributes,
StartLocation = startPos,
EndLocation = t.EndLocation
};
AddChild(section);
}
示例13: GlobalAttributeSection
void GlobalAttributeSection() {
Expect(28);
#line 2521 "VBNET.ATG"
Location startPos = t.Location;
if (la.kind == 52) {
lexer.NextToken();
} else if (la.kind == 141) {
lexer.NextToken();
} else SynErr(226);
#line 2523 "VBNET.ATG"
string attributeTarget = t.val != null ? t.val.ToLower(System.Globalization.CultureInfo.InvariantCulture) : null;
List<ASTAttribute> attributes = new List<ASTAttribute>();
ASTAttribute attribute;
Expect(11);
Attribute(
#line 2527 "VBNET.ATG"
out attribute);
#line 2527 "VBNET.ATG"
attributes.Add(attribute);
while (
#line 2528 "VBNET.ATG"
NotFinalComma()) {
if (la.kind == 12) {
lexer.NextToken();
if (la.kind == 52) {
lexer.NextToken();
} else if (la.kind == 141) {
lexer.NextToken();
} else SynErr(227);
Expect(11);
}
Attribute(
#line 2528 "VBNET.ATG"
out attribute);
#line 2528 "VBNET.ATG"
attributes.Add(attribute);
}
if (la.kind == 12) {
lexer.NextToken();
}
Expect(27);
EndOfStmt();
#line 2533 "VBNET.ATG"
AttributeSection section = new AttributeSection {
AttributeTarget = attributeTarget,
Attributes = attributes,
StartLocation = startPos,
EndLocation = t.EndLocation
};
compilationUnit.AddChild(section);
}
示例14: VisitAttributeSection
public virtual object VisitAttributeSection(AttributeSection attributeSection, object data) {
throw new global::System.NotImplementedException("AttributeSection");
}
示例15: GlobalAttributeSection
void GlobalAttributeSection() {
Expect(18);
#line 222 "cs.ATG"
Location startPos = t.Location;
Identifier();
#line 223 "cs.ATG"
if (t.val != "assembly" && t.val != "module") Error("global attribute target specifier (assembly or module) expected");
string attributeTarget = t.val;
List<ASTAttribute> attributes = new List<ASTAttribute>();
ASTAttribute attribute;
Expect(9);
Attribute(
#line 228 "cs.ATG"
out attribute);
#line 228 "cs.ATG"
attributes.Add(attribute);
while (
#line 229 "cs.ATG"
NotFinalComma()) {
Expect(14);
Attribute(
#line 229 "cs.ATG"
out attribute);
#line 229 "cs.ATG"
attributes.Add(attribute);
}
if (la.kind == 14) {
lexer.NextToken();
}
Expect(19);
#line 231 "cs.ATG"
AttributeSection section = new AttributeSection {
AttributeTarget = attributeTarget,
Attributes = attributes,
StartLocation = startPos,
EndLocation = t.EndLocation
};
AddChild(section);
}