protected CodeExpression CreateNewWizardStepReference(WizardControllerTreeNode node, string wizardStepPage)
		{
			CodeExpression createMethodSignature = new CodeObjectCreateExpression(
				_source[typeof (MethodSignature)],
				new CodeExpression[]
					{
						new CodeTypeOfExpression(node.FullName),
						new CodePrimitiveExpression(node.Name),
						new CodeArrayCreateExpression(_source[typeof (Type)], 0)
					}
				);

			CodeExpression[] constructionArguments = new CodeExpression[]
				{
					new CodeFieldReferenceExpression(new CodeThisReferenceExpression(),
					                                 _naming.ToMemberVariableName(_serviceIdentifier)),
					new CodeTypeOfExpression(node.FullName),
					new CodePrimitiveExpression(node.Area),
					new CodePrimitiveExpression(_naming.ToControllerName(node.Name)),
					new CodePrimitiveExpression(wizardStepPage),
					createMethodSignature,
					new CodeArrayCreateExpression(_source[typeof (ActionArgument)], 0)
				};

			return new CodeMethodInvokeExpression(
				new CodeMethodReferenceExpression(
					new CodePropertyReferenceExpression(
						new CodeFieldReferenceExpression(new CodeThisReferenceExpression(),
						                                 _naming.ToMemberVariableName(_serviceIdentifier)),
						"ControllerReferenceFactory"),
					"CreateActionReference"),
				constructionArguments
				);
		}
		public void VisitControllerNode_Always_CreatesType()
		{
			WizardControllerTreeNode node = new WizardControllerTreeNode("HomeController", "ControllerNamespace", new string[] { "Step1" });

			_mocks.ReplayAll();
			_generator.Visit(node);
			_mocks.VerifyAll();

			CodeDomAssert.AssertHasField(_source.Ccu.Namespaces[0].Types[0], "_services");
		}
		public override void Visit(WizardControllerTreeNode node)
		{
			CodeTypeDeclaration type = GenerateTypeDeclaration(_namespace, node.PathNoSlashes + _naming.ToWizardStepWrapperName(node.Name));

			foreach (string wizardStepPage in node.WizardStepPages)
			{
				CodeMemberMethod method = new CodeMemberMethod();
				method.Name = wizardStepPage;
				method.ReturnType = _source[typeof(IControllerActionReference)];
				method.Attributes = MemberAttributes.Public;
				method.CustomAttributes.Add(_source.DebuggerAttribute);
				method.Statements.Add(new CodeMethodReturnStatement(CreateNewWizardStepReference(node, wizardStepPage)));
				type.Members.Add(method);
			}

			base.Visit(node);
		}
		public override void Visit(WizardControllerTreeNode node)
		{
			Visit((ControllerTreeNode) node);

			CodeNamespace codeNamespace = _source.LookupNamespace(_namespace);

			foreach (CodeTypeDeclaration type in codeNamespace.Types)
			{
				if (type.Name == (node.PathNoSlashes + _naming.ToControllerWrapperName(node.Name)))
				{
					type.Members.Add(
						_source.CreateReadOnlyProperty("Steps",
						                               new CodeTypeReference(node.PathNoSlashes + _naming.ToWizardStepWrapperName(node.Name)),
						                               new CodeObjectCreateExpression(
						                               	new CodeTypeReference(node.PathNoSlashes + _naming.ToWizardStepWrapperName(node.Name)),
						                               	new CodeFieldReferenceExpression(_source.This, _naming.ToMemberVariableName(_serviceIdentifier)))));

					break;
				}
			}
		}
Exemplo n.º 5
0
		public override void Visit(WizardControllerTreeNode node)
		{
			Visit((ControllerTreeNode) node);
		}
Exemplo n.º 6
0
		public virtual void Visit(WizardControllerTreeNode node)
		{
			Accept(node.Children);
		}