コード例 #1
0
		public override void Visit(ViewTreeNode node)
		{
			if (_typeStack.Count == 0) return;

			CodeExpression[] constructionArguments = new CodeExpression[]
				{
					new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), _naming.ToMemberVariableName(_serviceIdentifier)),
					new CodeTypeOfExpression(node.Controller.FullName),
					new CodePrimitiveExpression(node.Controller.Area),
					new CodePrimitiveExpression(_naming.ToControllerName(node.Controller.Name)),
					new CodePrimitiveExpression(node.Name)
				};

			CodeExpression returnExpression =
				new CodeMethodInvokeExpression(
					new CodeMethodReferenceExpression(
						new CodePropertyReferenceExpression(
							new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), _naming.ToMemberVariableName(_serviceIdentifier)),
							"ControllerReferenceFactory"),
						"CreateViewReference"),
					constructionArguments
					);

			CodeTypeReference propertyType = new CodeTypeReference(typeof(IControllerViewReference));
			_typeStack.Peek().Members.Add(_source.CreateReadOnlyProperty(node.Name, propertyType, returnExpression));

			base.Visit(node);
		}
コード例 #2
0
    public void VisitViewNode_UnderNoController_DoesNothing()
    {
      ViewTreeNode node = new ViewTreeNode("Index");

      _mocks.ReplayAll();
      _generator.Visit(node);
      _mocks.VerifyAll();
    }
コード例 #3
0
ファイル: TreeWalker.cs プロジェクト: mgagne-atman/Projects
		public virtual void Visit(ViewTreeNode node)
		{
			Accept(node.Children);
		}
コード例 #4
0
    public void VisitViewNode_OneParameters_CreatesMethod()
    {
      ViewTreeNode node = new ViewTreeNode("Index");
      _controller.AddChild(node);
      node.AddChild(new ParameterTreeNode("id", typeof(Int32)));

      using (_mocks.Unordered())
      {
      }

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

      CodeDomAssert.AssertHasField(_source.Ccu.Namespaces[0].Types[0], "_services");
      CodeDomAssert.AssertHasProperty(_source.Ccu.Namespaces[0].Types[0], "Index");
    }
コード例 #5
0
    public void VisitViewNode_NoParameters_CreatesMethod()
    {
      ViewTreeNode node = new ViewTreeNode("Index");
      _controller.AddChild(node);

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

      CodeDomAssert.AssertHasField(_source.Ccu.Namespaces[0].Types[0], "_services");
      CodeDomAssert.AssertHasProperty(_source.Ccu.Namespaces[0].Types[0], "Index");
    }