Пример #1
0
		public override void Visit(PatternRouteTreeNode node)
		{
			PatternRouteCreator routeCreator = new PatternRouteCreator(_namespace, _source, _naming, node, RouteDefinitionsType, RoutesType);
			routeCreator.Create();

			base.Visit(node);
		}
Пример #2
0
		public override object VisitMethodDeclaration(MethodDeclaration methodDeclaration, object data)
		{
			if ((methodDeclaration.Modifier & Modifiers.Public) != Modifiers.Public)
			{
				return null;
			}

			ControllerTreeNode controllerNode = (ControllerTreeNode) _treeService.Peek;

			if (controllerNode is WizardControllerTreeNode)
			{
				Type wizardControllerInterface = typeof (IWizardController);

				MethodInfo[] methodInfos = wizardControllerInterface.GetMethods(BindingFlags.Public | BindingFlags.Instance);

				if ((methodDeclaration.Name == "GetSteps") && (methodDeclaration.Body.Children.Count > 0))
				{
					(controllerNode as WizardControllerTreeNode).WizardStepPages = GetWizardStepPages(methodDeclaration.Body);

					return null;
				}
				else if (
					Array.Exists(methodInfos, delegate(MethodInfo methodInfo) { return methodInfo.Name == methodDeclaration.Name; }))
					return null;
			}

			ActionTreeNode action = new ActionTreeNode(methodDeclaration.Name);

			foreach (ParameterDeclarationExpression parameter in methodDeclaration.Parameters)
			{
				Type type = TypeResolver.Resolve(parameter.TypeReference, true);
				action.AddChild(new ParameterTreeNode(parameter.ParameterName, type));
			}

			foreach (AttributeSection attributeSection in methodDeclaration.Attributes)
			{
				List<Attribute> attributes = attributeSection.Attributes.FindAll(
					delegate(Attribute attribute) { return attribute.Name == "StaticRoute"; });

				foreach (Attribute attribute in attributes)
				{
					PrimitiveExpression name = (PrimitiveExpression) attribute.PositionalArguments[0];
					PrimitiveExpression pattern = (PrimitiveExpression) attribute.PositionalArguments[1];

					StaticRouteTreeNode routeTreeNode = new StaticRouteTreeNode((string) name.Value, (string) pattern.Value);
					action.AddChild(routeTreeNode);
				}

				attributes = attributeSection.Attributes.FindAll(
					delegate(Attribute attribute) { return attribute.Name == "PatternRoute"; });

				foreach (Attribute attribute in attributes)
				{
					PrimitiveExpression name = (PrimitiveExpression)attribute.PositionalArguments[0];
					PrimitiveExpression pattern = (PrimitiveExpression)attribute.PositionalArguments[1];
					string[] defaults = new string[attribute.PositionalArguments.Count - 2];

					for(int i = 0; i < defaults.Length; i++)
						defaults[i] = (string) ((PrimitiveExpression) attribute.PositionalArguments[2 + i]).Value;

					PatternRouteTreeNode routeTreeNode = new PatternRouteTreeNode((string)name.Value, (string)pattern.Value, defaults);
					action.AddChild(routeTreeNode);
				}
			}

			controllerNode.AddChild(action, true);

			return base.VisitMethodDeclaration(methodDeclaration, data);
		}
Пример #3
0
		public virtual void Visit(PatternRouteTreeNode node)
		{
			Accept(node.Children);
		}