コード例 #1
0
            protected override IEnumerable <string> GenerateCode(List <object> includedMembers)
            {
                var constructorDeclaration = new ConstructorDeclaration()
                {
                    Name      = Options.EnclosingType.Name,
                    Modifiers = ICSharpCode.NRefactory.PlayScript.Modifiers.Public,
                    Body      = new BlockStatement()
                };

                foreach (IMember member in includedMembers)
                {
                    constructorDeclaration.Parameters.Add(new ParameterDeclaration(Options.CreateShortType(member.ReturnType), CreateParameterName(member)));

                    var memberReference = new MemberReferenceExpression(new ThisReferenceExpression(), member.Name);
                    var assign          = new AssignmentExpression(memberReference, AssignmentOperatorType.Assign, new IdentifierExpression(CreateParameterName(member)));
                    constructorDeclaration.Body.Statements.Add(new ExpressionStatement(assign));
                }

                yield return(constructorDeclaration.GetText(Options.FormattingOptions));
            }
コード例 #2
0
			protected override IEnumerable<string> GenerateCode (List<object> includedMembers)
			{
				var constructorDeclaration = new ConstructorDeclaration () {
					Name = Options.EnclosingType.Name,
					Modifiers = ICSharpCode.NRefactory.PlayScript.Modifiers.Public,
					Body = new BlockStatement ()
				};
				
				foreach (IMember member in includedMembers) {
					constructorDeclaration.Parameters.Add (new ParameterDeclaration (Options.CreateShortType (member.ReturnType), CreateParameterName (member)));
					
					var memberReference = new MemberReferenceExpression (new ThisReferenceExpression (), member.Name);
					var assign = new AssignmentExpression (memberReference, AssignmentOperatorType.Assign, new IdentifierExpression (CreateParameterName (member)));
					constructorDeclaration.Body.Statements.Add (new ExpressionStatement (assign));
				}
				
				yield return constructorDeclaration.GetText (Options.FormattingOptions);
			}