private object proceedHolder = new object(); //This object is placed into the parameters array as a // place holder for the proceed function. It should be swapped out when the proceed function is // provided in execute internal ReflectionLinkedStatement(ReflectionStatementDefinition definition, string statement, Match match) { Statement = statement; this.definition = definition; this.match = match; Definition = definition; PrecacheReflections(definition.ControllerType); PrecacheParameterBindings(); }
public static StatementDocumentation FromReflection(ReflectionStatementDefinition reflectionStatementDefinition, ICommentDocumentation commentDocumentation) { var methodDocs = commentDocumentation.ForMethod(reflectionStatementDefinition.MethodInfo); return new StatementDocumentation() { Parameters = (reflectionStatementDefinition.Parameters ?? Enumerable.Empty<StatementParameter>()) .Select(p => new ParameterDocumentation(){ Name = p.Name, Type = p.Type, Description = methodDocs.With(d => d.Parameters.With(p.Name)), TransformsTo = (p as ProceedParameter).With(z => z.TransformsTo) }) .ToList(), Description = methodDocs.With(x => x.Summary), ScopeType = reflectionStatementDefinition.ScopeType, Title = ExtractTitle(reflectionStatementDefinition) }; }
// place holder for the proceed function. It should be swapped out when the proceed function is // provided in execute internal ReflectionLinkedStatement(ReflectionStatementDefinition definition, string statement, Match match) { Statement = statement; this.definition = definition; this.match = match; Definition = definition; PrecacheReflections(definition.ControllerType); PrecacheParameterBindings(); }
private static string ExtractTitle(ReflectionStatementDefinition reflectionStatementDefinition) { //Use attribute if present var titleAttr = reflectionStatementDefinition .MethodInfo.GetCustomAttributes(typeof(TitleAttribute),true) .OfType<TitleAttribute>() .Select(x => x.Title) .FirstOrDefault(x => !string.IsNullOrEmpty(x)); if (titleAttr != null) return titleAttr; var expression = reflectionStatementDefinition.MatchingCriteria.ToString(); if (Regex.IsMatch(expression, @"\(\?")) return reflectionStatementDefinition.MethodInfo.Name; //Compilcated regexes just use method name return ParseTitle(expression, reflectionStatementDefinition.Parameters); }