本文整理汇总了C#中ConstructorDeclaration类的典型用法代码示例。如果您正苦于以下问题:C# ConstructorDeclaration类的具体用法?C# ConstructorDeclaration怎么用?C# ConstructorDeclaration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ConstructorDeclaration类属于命名空间,在下文中一共展示了ConstructorDeclaration类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: VisitConstructorDeclaration
public override void VisitConstructorDeclaration(ConstructorDeclaration constructorDeclaration)
{
AddMethod(true, constructorDeclaration, constructorDeclaration.Parameters);
// call base to forward execution
base.VisitConstructorDeclaration(constructorDeclaration);
}
开发者ID:goncalod,项目名称:csharp,代码行数:7,代码来源:NRefactoryVisitor.cs
示例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));
}
开发者ID:kourzanov,项目名称:101repo,代码行数:7,代码来源:LocatorCSharpParser.cs
示例3: VisitConstructorDeclaration
public override object VisitConstructorDeclaration(ConstructorDeclaration constructorDeclaration, object data)
{
if(constructorDeclaration.Parameters.Count > 0)
UnlockWith(constructorDeclaration);
return base.VisitConstructorDeclaration(constructorDeclaration, data);
}
开发者ID:clausjoergensen,项目名称:strokes,代码行数:7,代码来源:CreateOverloadedConstructorAchievement.cs
示例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);
}
开发者ID:vlad2135,项目名称:strokes,代码行数:7,代码来源:CreateBaseConstructorInitAchievement.cs
示例5: VisitConstructorDeclaration
public override void VisitConstructorDeclaration(ConstructorDeclaration methodDeclaration)
{
if (methodDeclaration.HasModifier(Modifiers.Static))
{
base.VisitConstructorDeclaration(methodDeclaration);
}
}
开发者ID:TinkerWorX,项目名称:Bridge,代码行数:7,代码来源:DependencyFinderVisitor.cs
示例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);
}
开发者ID:segaman,项目名称:NRefactory,代码行数:27,代码来源:CreateConstructorDeclarationAction.cs
示例7: VisitConstructorDeclaration
public override object VisitConstructorDeclaration(ConstructorDeclaration constructorDeclaration, object data)
{
Push();
object result = base.VisitConstructorDeclaration(constructorDeclaration, data);
Pop();
return result;
}
开发者ID:mgagne-atman,项目名称:Projects,代码行数:7,代码来源:PrefixFieldsVisitor.cs
示例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);
}
开发者ID:KvanTTT,项目名称:CSharp-Minifier,代码行数:8,代码来源:MinifyLocalsAstVisitor.cs
示例9: VisitConstructorDeclaration
public override void VisitConstructorDeclaration(ConstructorDeclaration constructorDeclaration)
{
if (isSealedType)
return;
var body = constructorDeclaration.Body;
if (body == null || body.IsNull)
return;
body.AcceptVisitor(CallFinder);
}
开发者ID:kaagati,项目名称:NRefactory,代码行数:9,代码来源:CallToVirtualFunctionFromConstructorIssue.cs
示例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);
}
开发者ID:yindongfei,项目名称:bridge.lua,代码行数:10,代码来源:OverloadsCollection.cs
示例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;
}
开发者ID:GavinHwa,项目名称:Bridge,代码行数:14,代码来源:OverloadsCollection.cs
示例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);
}
}
开发者ID:Oaz,项目名称:bridgedotnet_Builder,代码行数:15,代码来源:Inspector.Visitor.cs
示例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);
}
}
开发者ID:porcus,项目名称:NRefactory,代码行数:19,代码来源:FormattingVisitor_TypeMembers.cs
示例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);
}
开发者ID:0xb1dd1e,项目名称:NRefactory,代码行数:37,代码来源:CSharpParser.cs
示例16: VisitConstructorDeclaration
public override void VisitConstructorDeclaration(ConstructorDeclaration constructorDeclaration)
{
FormatAttributedNode(constructorDeclaration);
ForceSpacesBefore(constructorDeclaration.LParToken, policy.SpaceBeforeConstructorDeclarationParentheses);
if (constructorDeclaration.Parameters.Any()) {
ForceSpacesAfter(constructorDeclaration.LParToken, policy.SpaceWithinConstructorDeclarationParentheses);
ForceSpacesBefore(constructorDeclaration.RParToken, policy.SpaceWithinConstructorDeclarationParentheses);
} else {
ForceSpacesAfter(constructorDeclaration.LParToken, policy.SpaceBetweenEmptyConstructorDeclarationParentheses);
ForceSpacesBefore(constructorDeclaration.RParToken, policy.SpaceBetweenEmptyConstructorDeclarationParentheses);
}
FormatCommas(constructorDeclaration, policy.SpaceBeforeConstructorDeclarationParameterComma, policy.SpaceAfterConstructorDeclarationParameterComma);
if (!constructorDeclaration.Body.IsNull) {
EnforceBraceStyle(policy.ConstructorBraceStyle, constructorDeclaration.Body.LBraceToken, constructorDeclaration.Body.RBraceToken);
VisitBlockWithoutFixingBraces(constructorDeclaration.Body, policy.IndentMethodBody);
}
if (IsMember(constructorDeclaration.NextSibling)) {
EnsureBlankLinesAfter(constructorDeclaration, policy.BlankLinesBetweenMembers);
}
}
开发者ID:txdv,项目名称:monodevelop,代码行数:22,代码来源:AstFormattingVisitor.cs
示例17: VisitConstructorDeclaration
public override void VisitConstructorDeclaration(ConstructorDeclaration constructorDeclaration)
{
currentMethodName = constructorDeclaration.Name;
base.VisitConstructorDeclaration(constructorDeclaration);
}
开发者ID:RainsSoft,项目名称:playscript-monodevelop,代码行数:5,代码来源:CS0127ReturnMustNotBeFollowedByAnyExpression.cs
示例18: ConvertConstructor
ConstructorDeclaration ConvertConstructor(IMethod ctor)
{
ConstructorDeclaration decl = new ConstructorDeclaration();
decl.Modifiers = GetMemberModifiers(ctor);
if (ctor.DeclaringTypeDefinition != null)
decl.Name = ctor.DeclaringTypeDefinition.Name;
foreach (IParameter p in ctor.Parameters) {
decl.Parameters.Add(ConvertParameter(p));
}
decl.Body = GenerateBodyBlock();
return decl;
}
开发者ID:0xb1dd1e,项目名称:NRefactory,代码行数:12,代码来源:TypeSystemAstBuilder.cs
示例19: MaybeCompileAndAddConstructorToType
private void MaybeCompileAndAddConstructorToType(JsClass jsClass, ConstructorDeclaration node, IMethod constructor, ConstructorScriptSemantics options)
{
if (options.GenerateCode) {
var mc = CreateMethodCompiler();
var compiled = mc.CompileConstructor(node, constructor, TryGetInstanceInitStatements(jsClass), options);
OnMethodCompiled(constructor, compiled, mc);
AddCompiledConstructorToType(jsClass, constructor, options, compiled);
}
}
开发者ID:jack128,项目名称:SaltarelleCompiler,代码行数:9,代码来源:Compiler.cs
示例20: HandleConstructorDeclaration
private void HandleConstructorDeclaration(ConstructorDeclaration constructorDeclaration)
{
var resolveResult = _resolver.Resolve(constructorDeclaration);
if (!(resolveResult is MemberResolveResult)) {
_errorReporter.Region = constructorDeclaration.GetRegion();
_errorReporter.InternalError("Method declaration " + constructorDeclaration.Name + " does not resolve to a member.");
return;
}
var method = ((MemberResolveResult)resolveResult).Member as IMethod;
if (method == null) {
_errorReporter.Region = constructorDeclaration.GetRegion();
_errorReporter.InternalError("Method declaration " + constructorDeclaration.Name + " does not resolve to a method (resolves to " + resolveResult.ToString() + ")");
return;
}
var jsClass = GetJsClass(method.DeclaringTypeDefinition);
if (jsClass == null)
return;
if (method.IsStatic) {
jsClass.StaticInitStatements.AddRange(CompileMethod(constructorDeclaration, constructorDeclaration.Body, method, MethodScriptSemantics.NormalMethod("X")).Body.Statements);
}
else {
MaybeCompileAndAddConstructorToType(jsClass, constructorDeclaration, method, _metadataImporter.GetConstructorSemantics(method));
}
}
开发者ID:jack128,项目名称:SaltarelleCompiler,代码行数:26,代码来源:Compiler.cs
注:本文中的ConstructorDeclaration类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论