本文整理汇总了C#中ICSharpCode.NRefactory.Ast.ConstructorDeclaration类的典型用法代码示例。如果您正苦于以下问题:C# ConstructorDeclaration类的具体用法?C# ConstructorDeclaration怎么用?C# ConstructorDeclaration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ConstructorDeclaration类属于ICSharpCode.NRefactory.Ast命名空间,在下文中一共展示了ConstructorDeclaration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: add_Ctor_
public static CompilationUnit add_Ctor_(this CompilationUnit compilationUnit, string @namespace, string typeName, ConstructorDeclaration constructorDeclaration)
{
var myNamespace = compilationUnit.add_Namespace(@namespace);
var type = myNamespace.add_Type(typeName);
type.add_Ctor(constructorDeclaration);
return compilationUnit;
}
示例2: TrackedVisitConstructorDeclaration
public override object TrackedVisitConstructorDeclaration(ConstructorDeclaration constructorDeclaration, object data)
{
const string initializerBlock = "InitializerBlock";
if (constructorDeclaration.Name == initializerBlock)
{
TypeDeclaration type = (TypeDeclaration) constructorDeclaration.Parent;
string initName = "Init" + type.Name;
MethodDeclaration initMethod = GetInitMethod(type);
initMethod.Body.Children.AddRange(constructorDeclaration.Body.Children);
Expression initInvocation = new InvocationExpression(new IdentifierExpression(initName));
ExpressionStatement initInvocationStatement = new ExpressionStatement(initInvocation);
IList constructors = AstUtil.GetChildrenWithType(type, typeof(ConstructorDeclaration));
if (constructors.Count > 1)
{
foreach (ConstructorDeclaration constructor in constructors)
{
if (constructor.Name != initializerBlock && !HasInitInvocation(constructor))
constructor.Body.Children.Insert(0, initInvocationStatement);
}
}
else if (((ConstructorDeclaration) constructors[0]).Name == initializerBlock)
{
ConstructorDeclaration constructor = new ConstructorDeclaration(type.Name, Modifiers.Public, null, null);
constructor.Body = new BlockStatement();
constructor.Body.AddChild(initInvocationStatement);
type.AddChild(constructor);
}
RemoveCurrentNode();
}
return base.TrackedVisitConstructorDeclaration(constructorDeclaration, data);
}
示例3: VisitConstructorDeclaration
public override object VisitConstructorDeclaration(ConstructorDeclaration constructorDeclaration, object data)
{
if (this.CheckNode(constructorDeclaration)) {
return null;
}
return base.VisitConstructorDeclaration(constructorDeclaration, data);
}
示例4: TrackedVisitConstructorDeclaration
public override object TrackedVisitConstructorDeclaration(ConstructorDeclaration constructorDeclaration, object data)
{
if (ShouldStubMember(constructorDeclaration.Name))
return base.TrackedVisitConstructorDeclaration(constructorDeclaration, data);
else
return null;
}
示例5: VisitConstructorDeclaration
public override object VisitConstructorDeclaration(ConstructorDeclaration constructorDeclaration, object data)
{
if (constructorDeclaration.ConstructorInitializer.ConstructorInitializerType == ConstructorInitializerType.Base)
UnlockWith(constructorDeclaration);
return base.VisitConstructorDeclaration(constructorDeclaration, data);
}
示例6: VisitConstructorDeclaration
public override object VisitConstructorDeclaration(ConstructorDeclaration constructorDeclaration, object data)
{
Push();
object result = base.VisitConstructorDeclaration(constructorDeclaration, data);
Pop();
return result;
}
示例7: VisitConstructorDeclaration
public override object VisitConstructorDeclaration(ConstructorDeclaration constructorDeclaration, object data)
{
collectingUsedLabels = true;
base.VisitConstructorDeclaration(constructorDeclaration, data);
collectingUsedLabels = false;
base.VisitConstructorDeclaration(constructorDeclaration, data);
return null;
}
示例8: VisitConstructorDeclaration
public override object VisitConstructorDeclaration(ConstructorDeclaration constructorDeclaration, object data)
{
if (currentDependencyRelation != null)
{
currentDependencyRelation.RecordConstructor(constructorDeclaration);
}
return base.VisitConstructorDeclaration(constructorDeclaration, data);
}
示例9: TransformQueryToClass
private void TransformQueryToClass()
{
CSharpSafeName = "Index_"+ Regex.Replace(Name, @"[^\w\d]", "_");
var type = new TypeDeclaration(Modifiers.Public, new List<AttributeSection>())
{
BaseTypes =
{
new TypeReference("AbstractViewGenerator")
},
Name = CSharpSafeName,
Type = ClassType.Class
};
var ctor = new ConstructorDeclaration(CSharpSafeName,
Modifiers.Public,
new List<ParameterDeclarationExpression>(), null);
type.Children.Add(ctor);
ctor.Body = new BlockStatement();
// this.ViewText = "96E65595-1C9E-4BFB-A0E5-80BF2D6FC185"; // Will be replaced later
ctor.Body.AddChild(new ExpressionStatement(
new AssignmentExpression(
new MemberReferenceExpression(new ThisReferenceExpression(), "ViewText"),
AssignmentOperatorType.Assign,
new PrimitiveExpression(mapReduceTextToken, mapReduceTextToken))));
foreach (var map in indexDefinition.Maps)
{
HandleMapFunction(ctor, map);
}
HandleTransformResults(ctor);
HandleReduceDefintion(ctor);
AddAdditionalInformation(ctor);
CompiledQueryText = QueryParsingUtils.GenerateText(type, extensions);
var sb = new StringBuilder("@\"");
foreach (var map in indexDefinition.Maps)
{
sb.AppendLine(map.Replace("\"", "\"\""));
}
if (indexDefinition.Reduce != null)
{
sb.AppendLine(indexDefinition.Reduce.Replace("\"", "\"\"")).AppendLine();
}
if (indexDefinition.TransformResults != null)
{
sb.AppendLine(indexDefinition.TransformResults.Replace("\"", "\"\"")).AppendLine();
}
sb.Append("\"");
CompiledQueryText = CompiledQueryText.Replace("\"" + mapReduceTextToken + "\"",
sb.ToString());
}
示例10: VisitConstructorDeclaration
public override object VisitConstructorDeclaration(ConstructorDeclaration constructorDeclaration, object data)
{
if ((constructorDeclaration.Body.StartLocation < new Location(startColumn + 1, startLine + 1)) &&
(constructorDeclaration.Body.EndLocation > new Location(endColumn + 1, endLine + 1))) {
this.member = constructorDeclaration;
}
return base.VisitConstructorDeclaration(constructorDeclaration, data);
}
示例11: VisitConstructorDeclaration
public override object VisitConstructorDeclaration(ConstructorDeclaration constructorDeclaration, object data)
{
if ((constructorDeclaration.Body.StartLocation < start) &&
(constructorDeclaration.Body.EndLocation > end)) {
this.member = constructorDeclaration;
}
return base.VisitConstructorDeclaration(constructorDeclaration, data);
}
示例12: GetConstructor
private ConstructorDeclaration GetConstructor(ExpressionStatement expression, TypeDeclaration typeDeclaration)
{
ConstructorDeclaration constructorDeclaration;
constructorDeclaration = new ConstructorDeclaration(typeDeclaration.Name, Modifiers.Public, null, null);
constructorDeclaration.Body = new BlockStatement();
constructorDeclaration.Body.Children.Add(expression);
typeDeclaration.Children.Add(constructorDeclaration);
return constructorDeclaration;
}
示例13: TrackedVisitConstructorDeclaration
public override object TrackedVisitConstructorDeclaration(ConstructorDeclaration constructorDeclaration, object data)
{
TypeDeclaration typeDeclaration = (TypeDeclaration) constructorDeclaration.Parent;
if (IsDerivedFrom(typeDeclaration, "junit.framework.TestCase"))
{
if (constructorDeclaration.Parameters.Count > 0)
RemoveCurrentNode();
}
return null;
}
示例14: 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;
}
示例15: add_Ctor
public static ConstructorDeclaration add_Ctor(this TypeDeclaration typeDeclaration)
{
var name = "";
var modifier = Modifiers.Public;
var _parameters = new List<ParameterDeclarationExpression>();
var _attributes = new List<AttributeSection>();
var ctorDeclaration = new ConstructorDeclaration(name, modifier, _parameters, _attributes);
ctorDeclaration.Body = new BlockStatement();
typeDeclaration.add_Ctor(ctorDeclaration);
return ctorDeclaration;
}