本文整理汇总了C#中ConstructorDeclaration类的典型用法代码示例。如果您正苦于以下问题:C# ConstructorDeclaration类的具体用法?C# ConstructorDeclaration怎么用?C# ConstructorDeclaration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ConstructorDeclaration类属于命名空间,在下文中一共展示了ConstructorDeclaration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VisitConstructorDeclaration
public override void VisitConstructorDeclaration(ConstructorDeclaration constructorDeclaration)
{
AddMethod(true, constructorDeclaration, constructorDeclaration.Parameters);
// call base to forward execution
base.VisitConstructorDeclaration(constructorDeclaration);
}
示例2: VisitConstructorDeclaration
public override void VisitConstructorDeclaration(ConstructorDeclaration declaration)
{
Tupel t = new Tupel(declaration.StartLocation.Line, declaration.EndLocation.Line);
addToMap(declaration.Name, t);
//_methodRanges.Add(constructorDeclaration.Name, new Tupel(constructorDeclaration.StartLocation.Line,
// constructorDeclaration.EndLocation.Line));
}
示例3: VisitConstructorDeclaration
public override object VisitConstructorDeclaration(ConstructorDeclaration constructorDeclaration, object data)
{
if(constructorDeclaration.Parameters.Count > 0)
UnlockWith(constructorDeclaration);
return base.VisitConstructorDeclaration(constructorDeclaration, data);
}
示例4: VisitConstructorDeclaration
public override object VisitConstructorDeclaration(ConstructorDeclaration constructorDeclaration, object data)
{
if (!constructorDeclaration.Initializer.IsNull && constructorDeclaration.Initializer.ConstructorInitializerType == ConstructorInitializerType.Base)
UnlockWith(constructorDeclaration);
return base.VisitConstructorDeclaration(constructorDeclaration, data);
}
示例5: VisitConstructorDeclaration
public override void VisitConstructorDeclaration(ConstructorDeclaration methodDeclaration)
{
if (methodDeclaration.HasModifier(Modifiers.Static))
{
base.VisitConstructorDeclaration(methodDeclaration);
}
}
示例6: GetActions
public IEnumerable<CodeAction> GetActions(RefactoringContext context)
{
var createExpression = context.GetNode<Expression>() as ObjectCreateExpression;
if (createExpression == null)
yield break;
var resolveResult = context.Resolve(createExpression) as CSharpInvocationResolveResult;
if (resolveResult == null || !resolveResult.IsError || resolveResult.Member.DeclaringTypeDefinition == null || resolveResult.Member.DeclaringTypeDefinition.IsSealed || resolveResult.Member.DeclaringTypeDefinition.Region.IsEmpty)
yield break;
yield return new CodeAction(context.TranslateString("Create constructor"), script => {
var decl = new ConstructorDeclaration() {
Name = resolveResult.Member.DeclaringTypeDefinition.Name,
Modifiers = Modifiers.Public,
Body = new BlockStatement() {
new ThrowStatement(new ObjectCreateExpression(context.CreateShortType("System", "NotImplementedException")))
}
};
decl.Parameters.AddRange(CreateMethodDeclarationAction.GenerateParameters(context, createExpression.Arguments));
script.InsertWithCursor(
context.TranslateString("Create constructor"),
resolveResult.Member.DeclaringTypeDefinition,
decl
);
}, createExpression);
}
示例7: VisitConstructorDeclaration
public override object VisitConstructorDeclaration(ConstructorDeclaration constructorDeclaration, object data)
{
Push();
object result = base.VisitConstructorDeclaration(constructorDeclaration, data);
Pop();
return result;
}
示例8: VisitConstructorDeclaration
public override void VisitConstructorDeclaration(ConstructorDeclaration constructorDeclaration)
{
string prefix = "";
if ((constructorDeclaration.Modifiers & Modifiers.Static) == Modifiers.Static)
prefix = "static.";
VisitMember(prefix + constructorDeclaration.Name, constructorDeclaration.Parameters.Select(p => p.Type.ToString()));
base.VisitConstructorDeclaration(constructorDeclaration);
}
示例9: VisitConstructorDeclaration
public override void VisitConstructorDeclaration(ConstructorDeclaration constructorDeclaration)
{
if (isSealedType)
return;
var body = constructorDeclaration.Body;
if (body == null || body.IsNull)
return;
body.AcceptVisitor(CallFinder);
}
示例10: Create
public static OverloadsCollection Create(IEmitter emitter, ConstructorDeclaration constructorDeclaration)
{
string key = constructorDeclaration.GetHashCode().ToString();
if (emitter.OverloadsCache.ContainsKey(key))
{
return emitter.OverloadsCache[key];
}
return new OverloadsCollection(emitter, constructorDeclaration);
}
示例11: VisitConstructorDeclaration
public override void VisitConstructorDeclaration(ConstructorDeclaration constructorDeclaration)
{
if (isSealedType)
return;
var body = constructorDeclaration.Body;
if (body == null || body.IsNull)
return;
var callFinder = new VirtualCallFinderVisitor(context);
body.AcceptVisitor(callFinder);
FoundIssues.AddRange(callFinder.FoundIssues);
}
开发者ID:adisik,项目名称:simple-assembly-explorer,代码行数:11,代码来源:CallToVirtualFunctionFromConstructorIssue.cs
示例12: OverloadsCollection
private OverloadsCollection(IEmitter emitter, ConstructorDeclaration constructorDeclaration)
{
this.Emitter = emitter;
this.Name = constructorDeclaration.Name;
this.JsName = this.Emitter.GetEntityName(constructorDeclaration, false, true);
this.Inherit = false;
this.Constructor = true;
this.Static = constructorDeclaration.HasModifier(Modifiers.Static);
this.Member = this.FindMember(constructorDeclaration);
this.TypeDefinition = this.Member.DeclaringTypeDefinition;
this.Type = this.Member.DeclaringType;
this.InitMembers();
this.Emitter.OverloadsCache[constructorDeclaration.GetHashCode().ToString()] = this;
}
示例13: VisitConstructorDeclaration
public override void VisitConstructorDeclaration(ConstructorDeclaration constructorDeclaration)
{
bool isStatic = constructorDeclaration.HasModifier(Modifiers.Static);
this.FixMethodParameters(constructorDeclaration.Parameters, constructorDeclaration.Body);
if (isStatic)
{
this.CurrentType.StaticCtor = constructorDeclaration;
}
else
{
this.CurrentType.Ctors.Add(constructorDeclaration);
}
}
示例14: VisitConstructorDeclaration
public override void VisitConstructorDeclaration(ConstructorDeclaration constructorDeclaration)
{
FixAttributesAndDocComment(constructorDeclaration);
ForceSpacesBefore(constructorDeclaration.LParToken, policy.SpaceBeforeConstructorDeclarationParentheses);
if (constructorDeclaration.Parameters.Any()) {
ForceSpacesAfter(constructorDeclaration.LParToken, policy.SpaceWithinConstructorDeclarationParentheses);
FormatArguments(constructorDeclaration);
} else {
ForceSpacesAfter(constructorDeclaration.LParToken, policy.SpaceBetweenEmptyConstructorDeclarationParentheses);
ForceSpacesBefore(constructorDeclaration.RParToken, policy.SpaceBetweenEmptyConstructorDeclarationParentheses);
}
if (!constructorDeclaration.Body.IsNull) {
FixOpenBrace(policy.ConstructorBraceStyle, constructorDeclaration.Body.LBraceToken);
VisitBlockWithoutFixingBraces(constructorDeclaration.Body, policy.IndentMethodBody);
FixClosingBrace(policy.ConstructorBraceStyle, constructorDeclaration.Body.RBraceToken);
}
}
示例15: Visit
public override void Visit(Constructor c)
{
var newConstructor = new ConstructorDeclaration();
AddAttributeSection(newConstructor, c);
var location = LocationsBag.GetMemberLocation(c);
AddModifiers(newConstructor, location);
newConstructor.AddChild(Identifier.Create(c.MemberName.Name, Convert(c.MemberName.Location)), Roles.Identifier);
if (location != null && location.Count > 0)
newConstructor.AddChild(new CSharpTokenNode(Convert(location [0]), Roles.LPar), Roles.LPar);
AddParameter(newConstructor, c.ParameterInfo);
if (location != null && location.Count > 1)
newConstructor.AddChild(new CSharpTokenNode(Convert(location [1]), Roles.RPar), Roles.RPar);
if (c.Initializer != null) {
var initializer = new ConstructorInitializer();
initializer.ConstructorInitializerType = c.Initializer is ConstructorBaseInitializer ? ConstructorInitializerType.Base : ConstructorInitializerType.This;
var initializerLocation = LocationsBag.GetLocations(c.Initializer);
if (initializerLocation != null)
newConstructor.AddChild(new CSharpTokenNode(Convert(initializerLocation [0]), Roles.Colon), Roles.Colon);
if (initializerLocation != null && initializerLocation.Count > 1) {
// this and base has the same length
var r = initializer.ConstructorInitializerType == ConstructorInitializerType.This ? ConstructorInitializer.ThisKeywordRole : ConstructorInitializer.BaseKeywordRole;
initializer.AddChild(new CSharpTokenNode(Convert(c.Initializer.Location), r), r);
initializer.AddChild(new CSharpTokenNode(Convert(initializerLocation [1]), Roles.LPar), Roles.LPar);
AddArguments(initializer, c.Initializer.Arguments);
initializer.AddChild(new CSharpTokenNode(Convert(initializerLocation [2]), Roles.RPar), Roles.RPar);
newConstructor.AddChild(initializer, ConstructorDeclaration.InitializerRole);
}
}
if (c.Block != null)
newConstructor.AddChild((BlockStatement)c.Block.Accept(this), Roles.Body);
typeStack.Peek().AddChild(newConstructor, Roles.TypeMemberRole);
}