本文整理汇总了C#中ICSharpCode.NRefactory.Ast.PropertyDeclaration类的典型用法代码示例。如果您正苦于以下问题:C# PropertyDeclaration类的具体用法?C# PropertyDeclaration怎么用?C# PropertyDeclaration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PropertyDeclaration类属于ICSharpCode.NRefactory.Ast命名空间,在下文中一共展示了PropertyDeclaration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VisitPropertyDeclaration
public override object VisitPropertyDeclaration(PropertyDeclaration propertyDeclaration, object data)
{
if (propertyDeclaration.GetRegion.Block.IsNull && propertyDeclaration.SetRegion.Block.IsNull)
UnlockWith(propertyDeclaration);
return base.VisitPropertyDeclaration(propertyDeclaration, data);
}
示例2: VisitPropertyDeclaration
public override object VisitPropertyDeclaration(PropertyDeclaration propertyDeclaration, object data)
{
Push();
object result = base.VisitPropertyDeclaration(propertyDeclaration, data);
Pop();
return result;
}
示例3: VisitPropertyDeclaration
public override object VisitPropertyDeclaration(PropertyDeclaration propertyDeclaration, object data)
{
if ((propertyDeclaration.BodyStart < start) &&
(propertyDeclaration.BodyEnd > end)) {
this.member = propertyDeclaration;
}
return base.VisitPropertyDeclaration(propertyDeclaration, data);
}
示例4: VisitPropertyDeclaration
public override object VisitPropertyDeclaration(PropertyDeclaration propertyDeclaration, object data)
{
if ((propertyDeclaration.BodyStart < new Location(startColumn + 1, startLine + 1)) &&
(propertyDeclaration.BodyEnd > new Location(endColumn + 1, endLine + 1))) {
this.member = propertyDeclaration;
}
return base.VisitPropertyDeclaration(propertyDeclaration, data);
}
示例5: VisitPropertyDeclaration
public override object VisitPropertyDeclaration(PropertyDeclaration propertyDeclaration, object data)
{
if ((propertyDeclaration.SetRegion.Modifier & Modifiers.Private) == Modifiers.Private)
{
UnlockWith(propertyDeclaration.SetRegion);
}
return base.VisitPropertyDeclaration(propertyDeclaration, data);
}
示例6: add_Property
public static PropertyDeclaration add_Property(this TypeDeclaration typeDeclaration, PropertyDeclaration propertyDeclaration)
{
if (typeDeclaration.notNull() && propertyDeclaration.notNull() && typeDeclaration.Children.notNull())
{
var insertPosition = typeDeclaration.Children.Count;
typeDeclaration.Children.Insert(insertPosition, propertyDeclaration);
}
return propertyDeclaration;
}
示例7: VisitTypeDeclaration
public override object VisitTypeDeclaration(TypeDeclaration typeDeclaration, object data)
{
base.VisitTypeDeclaration(typeDeclaration, data); // visit methods
typeDeclaration.Attributes.Clear();
typeDeclaration.BaseTypes.Clear();
// add constructor accepting the wrapped object and the field holding the object
FieldDeclaration fd = new FieldDeclaration(null, // no attributes
new TypeReference(typeDeclaration.Name),
Modifiers.Private);
fd.Fields.Add(new VariableDeclaration("wrappedObject"));
typeDeclaration.AddChild(fd);
typeDeclaration.Name += "Wrapper";
if (typeDeclaration.Type == ClassType.Interface) {
typeDeclaration.Type = ClassType.Class;
typeDeclaration.Name = typeDeclaration.Name.Substring(1);
}
ConstructorDeclaration cd = new ConstructorDeclaration(typeDeclaration.Name,
Modifiers.Public,
new List<ParameterDeclarationExpression>(),
null);
cd.Parameters.Add(new ParameterDeclarationExpression(fd.TypeReference,
"wrappedObject"));
// this.wrappedObject = wrappedObject;
Expression fieldReference = new MemberReferenceExpression(new ThisReferenceExpression(),
"wrappedObject");
Expression assignment = new AssignmentExpression(fieldReference,
AssignmentOperatorType.Assign,
new IdentifierExpression("wrappedObject"));
cd.Body = new BlockStatement();
cd.Body.AddChild(new ExpressionStatement(assignment));
typeDeclaration.AddChild(cd);
for (int i = 0; i < typeDeclaration.Children.Count; i++) {
object child = typeDeclaration.Children[i];
if (child is MethodDeclaration) {
MethodDeclaration method = (MethodDeclaration)child;
if (method.Parameters.Count == 0 &&
(method.Name.StartsWith("Is") || method.Name.StartsWith("Get")))
{
// replace the method with a property
PropertyDeclaration prop = new PropertyDeclaration(method.Modifier,
method.Attributes,
method.Name,
null);
prop.TypeReference = method.TypeReference;
prop.GetRegion = new PropertyGetRegion(method.Body, null);
typeDeclaration.Children[i] = prop;
}
}
}
return null;
}
示例8: ast_Property
public static PropertyDeclaration ast_Property(this string propertyName, string propertyType)
{
var modifier = Modifiers.Public;
var attributes = new List<AttributeSection>();
var parameters = new List<ParameterDeclarationExpression>() { };
var propertyDeclaration = new PropertyDeclaration(modifier, attributes, propertyName, parameters);
propertyDeclaration.TypeReference = propertyType.ast_TypeReference();
propertyDeclaration.GetRegion = new PropertyGetRegion(null, null);
propertyDeclaration.SetRegion = new PropertySetRegion(null, null);
return propertyDeclaration;
}
示例9: AddGetSet
private void AddGetSet(PropertyDeclaration propertyDeclaration, MethodDeclaration accessorMethod, IList fields)
{
BlockStatement block;
string fieldName = accessorMethod.Name.Substring(3);
TypeDeclaration typeDeclaration = (TypeDeclaration) accessorMethod.Parent;
if (IsInterface(typeDeclaration) || (IsAbstractClass(typeDeclaration) && !HasField(fields, fieldName) && accessorMethod.Body == BlockStatement.Null))
block = BlockStatement.Null;
else
{
block = new BlockStatement();
block.Children.AddRange(accessorMethod.Body.Children);
}
if (accessorMethod.Name.StartsWith("get"))
propertyDeclaration.GetRegion = new PropertyGetRegion(block, null);
else if (accessorMethod.Name.StartsWith("set"))
propertyDeclaration.SetRegion = new PropertySetRegion(block, null);
}
示例10: CallInternalMethod
public void CallInternalMethod()
{
string program = TestUtil.GetInput();
string expected = TestUtil.GetExpected();
CompilationUnit cu = TestUtil.ParseProgram(program);
NamespaceDeclaration ns = (NamespaceDeclaration) cu.Children[0];
TypeDeclaration ty = (TypeDeclaration) ns.Children[0];
PropertyDeclaration property = new PropertyDeclaration(Modifiers.Public, null, "Name", null);
property.TypeReference = new TypeReference("String");
property.SetRegion = new PropertySetRegion(new BlockStatement(), null);
ty.AddChild(property);
TypesVisitor typesVisitor = new TypesVisitor();
typesVisitor.CodeBase = CodeBase;
typesVisitor.VisitCompilationUnit(cu, null);
VisitCompilationUnit(cu, null);
TestUtil.CodeEqual(expected, TestUtil.GenerateCode(cu));
}
示例11: TrackedVisitPropertyDeclaration
public override object TrackedVisitPropertyDeclaration(PropertyDeclaration propertyDeclaration, object data)
{
if (this.memberToFind is IProperty) {
// If we are looking for a specified property:
// find out if this is the one by comparing the location.
if (propertyDeclaration.StartLocation.X == this.memberToFind.Region.BeginColumn &&
propertyDeclaration.StartLocation.Y == this.memberToFind.Region.BeginLine) {
data = true;
}
} else if (this.memberToFind is IField) {
// If we are looking for a specifield field:
// store the property info for future reference.
data = propertyDeclaration;
}
return base.TrackedVisitPropertyDeclaration(propertyDeclaration, data);
}
示例12: VisitPropertyDeclaration
public override object VisitPropertyDeclaration(PropertyDeclaration propertyDeclaration, object data)
{
if (!IsClassType(ClassType.Interface) && (propertyDeclaration.Modifier & Modifiers.Visibility) == 0)
propertyDeclaration.Modifier |= Modifiers.Private;
base.VisitPropertyDeclaration(propertyDeclaration, data);
ToVBNetRenameConflictingVariablesVisitor.RenameConflicting(propertyDeclaration);
if (!IsClassType(ClassType.Interface) && (propertyDeclaration.Modifier & Modifiers.Abstract) == 0) {
if (propertyDeclaration.HasGetRegion && propertyDeclaration.HasSetRegion) {
if (propertyDeclaration.GetRegion.Block.IsNull && propertyDeclaration.SetRegion.Block.IsNull) {
// automatically implemented property
string fieldName = "m_" + propertyDeclaration.Name;
Modifiers fieldModifier = propertyDeclaration.Modifier & ~(Modifiers.Visibility) | Modifiers.Private;
FieldDeclaration newField = new FieldDeclaration(null, propertyDeclaration.TypeReference, fieldModifier);
newField.Fields.Add(new VariableDeclaration(fieldName));
InsertAfterSibling(propertyDeclaration, newField);
propertyDeclaration.GetRegion.Block = new BlockStatement();
propertyDeclaration.GetRegion.Block.Return(ExpressionBuilder.Identifier(fieldName));
propertyDeclaration.SetRegion.Block = new BlockStatement();
propertyDeclaration.SetRegion.Block.Assign(ExpressionBuilder.Identifier(fieldName), ExpressionBuilder.Identifier("Value"));
}
}
}
return null;
}
示例13: VisitPropertyDeclaration
public override object VisitPropertyDeclaration(PropertyDeclaration propertyDeclaration, object data)
{
if (this.CheckNode(propertyDeclaration)) {
return null;
}
return base.VisitPropertyDeclaration(propertyDeclaration, data);
}
示例14: InterfaceMemberDecl
//.........这里部分代码省略.........
if (StartOf(18)) {
Identifier();
#line 1134 "cs.ATG"
name = t.val; Location qualIdentEndLocation = t.EndLocation;
if (la.kind == 20 || la.kind == 23) {
if (la.kind == 23) {
TypeParameterList(
#line 1138 "cs.ATG"
templates);
}
Expect(20);
if (StartOf(11)) {
FormalParameterList(
#line 1139 "cs.ATG"
parameters);
}
Expect(21);
while (la.kind == 127) {
TypeParameterConstraintsClause(
#line 1141 "cs.ATG"
templates);
}
Expect(11);
#line 1142 "cs.ATG"
MethodDeclaration md = new MethodDeclaration {
Name = name, Modifier = mod, TypeReference = type,
Parameters = parameters, Attributes = attributes, Templates = templates,
StartLocation = startLocation, EndLocation = t.EndLocation
};
AddChild(md);
} else if (la.kind == 16) {
#line 1151 "cs.ATG"
PropertyDeclaration pd = new PropertyDeclaration(name, type, mod, attributes);
AddChild(pd);
lexer.NextToken();
#line 1154 "cs.ATG"
Location bodyStart = t.Location;
InterfaceAccessors(
#line 1155 "cs.ATG"
out getBlock, out setBlock);
Expect(17);
#line 1156 "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 1159 "cs.ATG"
parameters);
Expect(19);
#line 1160 "cs.ATG"
Location bracketEndLocation = t.EndLocation;
#line 1161 "cs.ATG"
PropertyDeclaration id = new PropertyDeclaration(mod | Modifiers.Default, attributes, "Item", parameters);
id.TypeReference = type;
AddChild(id);
Expect(16);
#line 1164 "cs.ATG"
Location bodyStart = t.Location;
InterfaceAccessors(
#line 1165 "cs.ATG"
out getBlock, out setBlock);
Expect(17);
#line 1167 "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 1170 "cs.ATG"
if (startLocation.IsEmpty) startLocation = t.Location;
Type(
#line 1171 "cs.ATG"
out type);
Identifier();
#line 1172 "cs.ATG"
EventDeclaration ed = new EventDeclaration {
TypeReference = type, Name = t.val, Modifier = mod, Attributes = attributes
};
AddChild(ed);
Expect(11);
#line 1178 "cs.ATG"
ed.StartLocation = startLocation; ed.EndLocation = t.EndLocation;
}
} else SynErr(177);
}
示例15: StructMemberDecl
//.........这里部分代码省略.........
Expect(19);
}
} else if (StartOf(18)) {
VariableDeclarator(
#line 982 "cs.ATG"
fd);
while (la.kind == 14) {
lexer.NextToken();
VariableDeclarator(
#line 983 "cs.ATG"
fd);
}
} else SynErr(169);
Expect(11);
#line 985 "cs.ATG"
fd.EndLocation = t.EndLocation; AddChild(fd);
} else if (la.kind == 111) {
#line 988 "cs.ATG"
m.Check(Modifiers.Indexers);
lexer.NextToken();
Expect(18);
FormalParameterList(
#line 989 "cs.ATG"
p);
Expect(19);
#line 989 "cs.ATG"
Location endLocation = t.EndLocation;
Expect(16);
#line 990 "cs.ATG"
PropertyDeclaration indexer = new PropertyDeclaration(m.Modifier | Modifiers.Default, attributes, "Item", p);
indexer.StartLocation = startPos;
indexer.EndLocation = endLocation;
indexer.BodyStart = t.Location;
indexer.TypeReference = type;
PropertyGetRegion getRegion;
PropertySetRegion setRegion;
AccessorDecls(
#line 998 "cs.ATG"
out getRegion, out setRegion);
Expect(17);
#line 999 "cs.ATG"
indexer.BodyEnd = t.EndLocation;
indexer.GetRegion = getRegion;
indexer.SetRegion = setRegion;
AddChild(indexer);
} else if (
#line 1004 "cs.ATG"
IsIdentifierToken(la)) {
if (
#line 1005 "cs.ATG"
IsExplicitInterfaceImplementation()) {
TypeName(
#line 1006 "cs.ATG"
out explicitInterface, false);
#line 1007 "cs.ATG"
if (la.kind != Tokens.Dot || Peek(1).kind != Tokens.This) {
qualident = TypeReference.StripLastIdentifierFromType(ref explicitInterface);
}