本文整理汇总了C#中ICSharpCode.NRefactory.Ast.ConstructorDeclaration类的典型用法代码示例。如果您正苦于以下问题:C# ConstructorDeclaration类的具体用法?C# ConstructorDeclaration怎么用?C# ConstructorDeclaration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ConstructorDeclaration类属于ICSharpCode.NRefactory.Ast命名空间,在下文中一共展示了ConstructorDeclaration类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:pusp,项目名称:o2platform,代码行数:7,代码来源:ConstructorDeclaration_ExtensionMethods.cs
示例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);
}
开发者ID:sourcewarehouse,项目名称:janett,代码行数:32,代码来源:InitializerBlockTransformer.cs
示例3: VisitConstructorDeclaration
public override object VisitConstructorDeclaration(ConstructorDeclaration constructorDeclaration, object data)
{
if (this.CheckNode(constructorDeclaration)) {
return null;
}
return base.VisitConstructorDeclaration(constructorDeclaration, data);
}
开发者ID:2594636985,项目名称:SharpDevelop,代码行数:7,代码来源:MemberFindAstVisitor.cs
示例4: TrackedVisitConstructorDeclaration
public override object TrackedVisitConstructorDeclaration(ConstructorDeclaration constructorDeclaration, object data)
{
if (ShouldStubMember(constructorDeclaration.Name))
return base.TrackedVisitConstructorDeclaration(constructorDeclaration, data);
else
return null;
}
开发者ID:sourcewarehouse,项目名称:janett,代码行数:7,代码来源:StubTransformer.cs
示例5: VisitConstructorDeclaration
public override object VisitConstructorDeclaration(ConstructorDeclaration constructorDeclaration, object data)
{
if (constructorDeclaration.ConstructorInitializer.ConstructorInitializerType == ConstructorInitializerType.Base)
UnlockWith(constructorDeclaration);
return base.VisitConstructorDeclaration(constructorDeclaration, data);
}
开发者ID:timdams,项目名称:strokes,代码行数:7,代码来源:CreateBaseConstructorInitAchievement.cs
示例6: VisitConstructorDeclaration
public override object VisitConstructorDeclaration(ConstructorDeclaration constructorDeclaration, object data)
{
Push();
object result = base.VisitConstructorDeclaration(constructorDeclaration, data);
Pop();
return result;
}
开发者ID:Adam-Fogle,项目名称:agentralphplugin,代码行数:7,代码来源:PrefixFieldsVisitor.cs
示例7: VisitConstructorDeclaration
public override object VisitConstructorDeclaration(ConstructorDeclaration constructorDeclaration, object data)
{
collectingUsedLabels = true;
base.VisitConstructorDeclaration(constructorDeclaration, data);
collectingUsedLabels = false;
base.VisitConstructorDeclaration(constructorDeclaration, data);
return null;
}
开发者ID:almazik,项目名称:ILSpy,代码行数:8,代码来源:RemoveDeadLabels.cs
示例8: VisitConstructorDeclaration
public override object VisitConstructorDeclaration(ConstructorDeclaration constructorDeclaration, object data)
{
if (currentDependencyRelation != null)
{
currentDependencyRelation.RecordConstructor(constructorDeclaration);
}
return base.VisitConstructorDeclaration(constructorDeclaration, data);
}
开发者ID:modulexcite,项目名称:magic-1,代码行数:8,代码来源:DependencyFinder.cs
示例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());
}
开发者ID:neiz,项目名称:ravendb,代码行数:58,代码来源:DynamicViewCompiler.cs
示例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);
}
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:9,代码来源:FindMemberVisitor.cs
示例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);
}
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:9,代码来源:FindMemberVisitor.cs
示例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;
}
开发者ID:sourcewarehouse,项目名称:janett,代码行数:9,代码来源:FieldInitializerTransformer.cs
示例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;
}
开发者ID:sourcewarehouse,项目名称:janett,代码行数:10,代码来源:TestCaseTransformer.cs
示例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;
}
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:55,代码来源:WrapperGeneratorVisitor.cs
示例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;
}
开发者ID:njmube,项目名称:FluentSharp,代码行数:12,代码来源:ConstructorDeclaration_ExtensionMethods.cs
示例16: HasInitInvocation
private bool HasInitInvocation(ConstructorDeclaration constructor)
{
IList stms = AstUtil.GetChildrenWithType(constructor.Body, typeof(ExpressionStatement));
foreach (ExpressionStatement statement in stms)
{
Expression expression = statement.Expression;
if (expression is InvocationExpression && ((InvocationExpression) expression).TargetObject is IdentifierExpression)
{
IdentifierExpression identifierExpression = (IdentifierExpression) ((InvocationExpression) expression).TargetObject;
return identifierExpression.Identifier == "Init" + constructor.Name;
}
}
return false;
}
开发者ID:sourcewarehouse,项目名称:janett,代码行数:14,代码来源:InitializerBlockTransformer.cs
示例17: GenerateCode
public override void GenerateCode(List<AbstractNode> nodes, IList items)
{
ConstructorDeclaration ctor = new ConstructorDeclaration(currentClass.Name, Modifiers.Public, null, null);
ctor.Body = new BlockStatement();
foreach (FieldWrapper w in items) {
string parameterName = codeGen.GetParameterName(w.Field.Name);
ctor.Parameters.Add(new ParameterDeclarationExpression(ConvertType(w.Field.ReturnType),
parameterName));
Expression left = new MemberReferenceExpression(new ThisReferenceExpression(), w.Field.Name);
Expression right = new IdentifierExpression(parameterName);
Expression expr = new AssignmentExpression(left, AssignmentOperatorType.Assign, right);
ctor.Body.AddChild(new ExpressionStatement(expr));
}
nodes.Add(ctor);
}
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:15,代码来源:ConstructorCodeGenerator.cs
示例18: GetConstructorInfo
/// <summary>
/// Gets the constructor information from a type declaration. Returns null if there is no
/// constructor defined or if there are no fields defined.
/// </summary>
public static RubyConstructorInfo GetConstructorInfo(TypeDeclaration type)
{
List<FieldDeclaration> fields = new List<FieldDeclaration>();
ConstructorDeclaration constructor = null;
foreach (INode node in type.Children) {
ConstructorDeclaration currentConstructor = node as ConstructorDeclaration;
FieldDeclaration field = node as FieldDeclaration;
if (currentConstructor != null) {
constructor = currentConstructor;
} else if (field != null) {
fields.Add(field);
}
}
if ((fields.Count > 0) || (constructor != null)) {
return new RubyConstructorInfo(constructor, fields);
}
return null;
}
开发者ID:Rpinski,项目名称:SharpDevelop,代码行数:23,代码来源:RubyConstructorInfo.cs
示例19: IsEmptyConstructor
private static bool IsEmptyConstructor(ConstructorDeclaration constructor)
{
bool flag;
flag = (constructor == null ? true : constructor.Body.Children.Count == 0);
return flag;
}
开发者ID:L3tum,项目名称:BesiegeScriptingMod,代码行数:6,代码来源:NRefactoryToPythonConverter.cs
示例20: TrackedVisitConstructorDeclaration
public virtual object TrackedVisitConstructorDeclaration(ConstructorDeclaration constructorDeclaration, object data) {
return base.VisitConstructorDeclaration(constructorDeclaration, data);
}
开发者ID:transformersprimeabcxyz,项目名称:monodevelop-1,代码行数:3,代码来源:NodeTrackingAstVisitor.cs
注:本文中的ICSharpCode.NRefactory.Ast.ConstructorDeclaration类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论