private Func<ElementRequest, HtmlTag> resolveCreator(AccessorDef accessorDef) { TagBuilder initialCreator = null; _sources.FirstOrDefault(x => { var tagBuilder = x.CreateInitial(accessorDef); if (tagBuilder == null) { return false; } initialCreator = tagBuilder; return true; }); if (initialCreator == null) { throw new Exception(string.Format("Html Conventions have no tag builder for {0}.{1}", accessorDef.ModelType.FullName, accessorDef.Accessor.Name)); } TagModifier[] modifiers = (_modifiers).Select((x => x.CreateModifier(accessorDef))).Where((x => x != null)).ToArray(); return (request => { HtmlTag tag = initialCreator(request); foreach (TagModifier v in modifiers) { v(request, tag); } return tag; }); }
private Func<ElementRequest, HtmlTag> resolveCreator(AccessorDef accessorDef) { TagBuilder initialCreator = (_sources).FirstValue((x => x.CreateInitial(accessorDef))); if (initialCreator == null) { throw new FubuException(3000, "Html Conventions have no tag builder for {0}.{1}", new string[2] { accessorDef. ModelType. FullName, accessorDef. Accessor. Name }); } else { TagModifier[] modifiers = (_modifiers).Select((x => x.CreateModifier(accessorDef))).Where((x => x != null)).ToArray(); return (request => { HtmlTag tag = initialCreator(request); (modifiers).Each((x => x(request, tag))); return tag; }); } }
private PropertyDef ParseProperty(PropertyDeclarationSyntax propertySyntax, SemanticModel semanticModel) { var propertyDef = new PropertyDef(); propertyDef.Internal = propertySyntax; propertyDef.Name = propertySyntax.Identifier.ValueText; propertyDef.Type = ParseTypeSpecifier(propertySyntax.Type, semanticModel); propertyDef.AccessLevel = ParseAccessLevel(propertySyntax.Modifiers) ?? AccessLevel.Private; propertyDef.IsStatic = propertySyntax.Modifiers.Any(x => x.ValueText == "static"); foreach (var accessor in propertySyntax.AccessorList.Accessors) { var acc = new AccessorDef(); acc.Internal = accessor; acc.AccessLevel = ParseAccessLevel(accessor.Modifiers) ?? propertyDef.AccessLevel; if (accessor.Keyword.Text == "get") { propertyDef.Getter = acc; } else if (accessor.Keyword.Text == "set") { propertyDef.Setter = acc; } } // Summary var declaredSymbol = semanticModel.GetDeclaredSymbol(propertySyntax); var xml = declaredSymbol?.GetDocumentationCommentXml(); propertyDef.Summary = SummaryComment.Parse(xml); return(propertyDef); }
protected override bool matches(AccessorDef def) { var propertyName = def.Accessor.FieldName; var listPropertyInfo = def.ModelType.GetProperty(propertyName + "List"); return(listPropertyInfo != null && listPropertyInfo.PropertyType == typeof(IEnumerable <SelectListItem>)); }
private Func <ElementRequest, HtmlTag> resolveCreator(AccessorDef accessorDef) { TagBuilder initialCreator = null; _sources.FirstOrDefault(x => { var tagBuilder = x.CreateInitial(accessorDef); if (tagBuilder == null) { return(false); } initialCreator = tagBuilder; return(true); }); if (initialCreator == null) { throw new Exception(string.Format("Html Conventions have no tag builder for {0}.{1}", accessorDef.ModelType.FullName, accessorDef.Accessor.Name)); } TagModifier[] modifiers = (_modifiers).Select((x => x.CreateModifier(accessorDef))).Where((x => x != null)).ToArray(); return(request => { HtmlTag tag = initialCreator(request); foreach (TagModifier v in modifiers) { v(request, tag); } return tag; }); }
public TagModifier CreateModifier(AccessorDef accessorDef) { if (accessorDef.Accessor.PropertyType == typeof(Int16) || accessorDef.Accessor.PropertyType == typeof(Int32) || accessorDef.Accessor.PropertyType == typeof(Int64) || accessorDef.Accessor.PropertyType == typeof(decimal) || accessorDef.Accessor.PropertyType == typeof(float) || accessorDef.Accessor.PropertyType == typeof(double) || accessorDef.Accessor.PropertyType.IsNullableOf(typeof(Int16)) || accessorDef.Accessor.PropertyType.IsNullableOf(typeof(Int32)) || accessorDef.Accessor.PropertyType.IsNullableOf(typeof(Int64)) || accessorDef.Accessor.PropertyType.IsNullableOf(typeof(decimal)) || accessorDef.Accessor.PropertyType.IsNullableOf(typeof(float)) || accessorDef.Accessor.PropertyType.IsNullableOf(typeof(double))) { TagModifier modifier = (request, tag) => tag.AddValidationHelper(ValidationRule.Number + ":true", ValidationRule.Number + ": '" + CoreLocalizationKeys.FIELD_MUST_BE_NUMBER.ToFormat( request.Accessor.FieldName. ToSeperateWordsFromPascalCase()) + "'"); return modifier; } return null; }
public TagBuilder CreateInitial(AccessorDef accessorDef) { if (matches(accessorDef)) return Build; else return null; }
public TagModifier CreateModifier(AccessorDef accessorDef) { if (matches(accessorDef)) { return Build; } return null; }
protected override bool matches(AccessorDef def) { return def.ModelType == typeof(ProjectListModel) || def.ModelType == typeof(BoardConfigurationModel) || def.ModelType == typeof(CardListModel) || def.ModelType == typeof(TimeRecordListModel) || def.ModelType == typeof(ProjectModel); }
protected override bool matches(AccessorDef def) { var propertyName = def.Accessor.FieldName; var listPropertyInfo = def.ModelType.GetProperty("_"+propertyName + "List"); // var readOnlyListPropertyInfo = def.ModelType.GetProperty(propertyName.Replace("ReadOnly", "") + "List"); return (listPropertyInfo != null && listPropertyInfo.PropertyType == typeof(GroupedSelectViewModel)); }
public TagModifier CreateModifier(AccessorDef accessorDef) { if (matches(accessorDef)) { return(Build); } return(null); }
public TagModifier CreateModifier(AccessorDef accessorDef) { if (!accessorDef.Accessor.HasAttribute<ValidateEmailAttribute>()) return null; TagModifier modifier = (request, tag) => tag.AddValidationHelper(ValidationRule.Email + ":true", ValidationRule.Email + ": '" + CoreLocalizationKeys.VALID_EMAIL_FORMAT.ToFormat(request.Accessor.FieldName.ToSeperateWordsFromPascalCase()) + "'"); return modifier; }
public TagModifier CreateModifier(AccessorDef accessorDef) { if (!accessorDef.Accessor.HasAttribute<ValidateSameAsAttribute>()) return null; TagModifier modifier = (request, tag) => tag.AddValidationHelper("equalTo:'[name$=\"Password\"]'", "equalTo: '" + CoreLocalizationKeys.CONFIRMATION_PASSWORD_MUST_MATCH.ToString() + "'"); return modifier; }
public TagModifier CreateModifier(AccessorDef accessorDef) { if (!accessorDef.Accessor.HasAttribute<ValidateNonEmptyAttribute>()) return null; TagModifier modifier = (request, tag) => tag.AddValidationHelper(ValidationRule.Required + ":true", ValidationRule.Required + ": '" + CoreLocalizationKeys.FIELD_REQUIRED.ToFormat(request.Accessor.FieldName.ToSeperateWordsFromPascalCase()) +"'"); return modifier; }
protected override bool matches(AccessorDef accessor) { var propertyType = accessor.Accessor.PropertyType; return propertyType == typeof (DateTime) || propertyType == typeof (DateTime?) || propertyType == typeof (Date) || propertyType == typeof (Date?); }
public TagModifier CreateModifier(AccessorDef accessorDef) { if (accessorDef.Accessor.Name.EndsWith("Email")) { return (req, tag) => { tag.Attr("type", "email"); }; } return null; }
protected override bool matches(AccessorDef accessor) { var propertyType = accessor.Accessor.PropertyType; return(propertyType == typeof(DateTime) || propertyType == typeof(DateTime?) || propertyType == typeof(Date) || propertyType == typeof(Date?)); }
public TagBuilder CreateInitial(AccessorDef accessorDef) { if(accessorDef.ModelType.Equals(typeof(LoanNumber))) { return request => { var str = request.Value<LoanNumber>(); return new HtmlTag("span", tag=>tag.Text(str.ToString())); }; } return a => { return HtmlTag.Empty(); }; }
public TagModifier CreateModifier(AccessorDef accessorDef) { if (!accessorDef.Accessor.HasAttribute <ValidateNonEmptyAttribute>()) { return(null); } TagModifier modifier = (request, tag) => tag.AddValidationHelper(ValidationRule.Required + ":true", ValidationRule.Required + ": '" + CoreLocalizationKeys.FIELD_REQUIRED.ToFormat(request.Accessor.FieldName.ToSeperateWordsFromPascalCase()) + "'"); return(modifier); }
private Func<ElementRequest, HtmlTag> resolveCreator(AccessorDef accessorDef) { TagBuilder initialCreator = _sources.FirstValue(x => x.CreateInitial(accessorDef)); TagModifier[] modifiers = _modifiers.Select(x => x.CreateModifier(accessorDef)).Where(x => x != null).ToArray(); return request => { HtmlTag tag = initialCreator(request); modifiers.Each(x => x(request, tag)); return tag; }; }
public TagModifier CreateModifier(AccessorDef accessorDef) { if (accessorDef.Accessor.HasAttribute<ValidateDoubleAttribute>() || accessorDef.Accessor.HasAttribute<ValidateDecimalAttribute>() || accessorDef.Accessor.HasAttribute<ValidateIntegerAttribute>()) { TagModifier modifier = (request, tag) => tag.AddValidationHelper(ValidationRule.Number + ":true", ValidationRule.Number + ": '" + CoreLocalizationKeys.FIELD_MUST_BE_NUMBER.ToFormat( request.Accessor.FieldName. ToSeperateWordsFromPascalCase()) + "'"); return modifier; } return null; }
public TagModifier CreateModifier(AccessorDef accessorDef) { if (accessorDef.Accessor.HasAttribute <ValidateDoubleAttribute>() || accessorDef.Accessor.HasAttribute <ValidateDecimalAttribute>() || accessorDef.Accessor.HasAttribute <ValidateIntegerAttribute>()) { TagModifier modifier = (request, tag) => tag.AddValidationHelper(ValidationRule.Number + ":true", ValidationRule.Number + ": '" + CoreLocalizationKeys.FIELD_MUST_BE_NUMBER.ToFormat( request.Accessor.FieldName. ToSeperateWordsFromPascalCase()) + "'"); return(modifier); } return(null); }
protected override bool matches(AccessorDef accessor) { var propertyType = accessor.Accessor.PropertyType; return propertyType == typeof (decimal) || propertyType == typeof (decimal?) || propertyType == typeof(int) || propertyType == typeof(int?) || propertyType == typeof(short) || propertyType == typeof(short?) || propertyType == typeof (float) || propertyType == typeof (float?) || propertyType == typeof (double) || propertyType == typeof (double?) || propertyType == typeof (long) || propertyType == typeof (long?); }
public TagBuilder CreateInitial(AccessorDef accessorDef) { if (accessorDef.ModelType.Equals(typeof(LoanNumber))) { return request => { var str = request.Value<LoanNumber>().ToString(); var tag = new HtmlTag("input") .Attr("type","text") .Attr("value", str); return tag; }; } return a => { return HtmlTag.Empty(); }; }
protected override bool matches(AccessorDef accessor) { var propertyType = accessor.Accessor.PropertyType; return(propertyType == typeof(decimal) || propertyType == typeof(decimal?) || propertyType == typeof(int) || propertyType == typeof(int?) || propertyType == typeof(short) || propertyType == typeof(short?) || propertyType == typeof(float) || propertyType == typeof(float?) || propertyType == typeof(double) || propertyType == typeof(double?) || propertyType == typeof(long) || propertyType == typeof(long?)); }
private Func<ElementRequest, int, int, HtmlTag> resolveCreator(AccessorDef accessorDef) { EachPartialTagBuilder initialCreator = _sources.FirstValue(x => x.CreateInitial(accessorDef)); if (initialCreator == null) { throw new FubuException(3001, "Html Conventions have no tag builder for partials for {0}.{1}", accessorDef.ModelType.FullName, accessorDef.Accessor.Name); } EachPartialTagModifier[] modifiers = _modifiers.Select(x => x.CreateModifier(accessorDef)).Where(x => x != null).ToArray(); return (request, index, count) => { HtmlTag tag = initialCreator(request, index, count); modifiers.Each(x => x(request, tag, index, count)); return tag; }; }
private Func <ElementRequest, int, int, HtmlTag> resolveCreator(AccessorDef accessorDef) { EachPartialTagBuilder initialCreator = _sources.FirstValue(x => x.CreateInitial(accessorDef)); if (initialCreator == null) { throw new FubuException(3001, "Html Conventions have no tag builder for partials for {0}.{1}", accessorDef.ModelType.FullName, accessorDef.Accessor.Name); } EachPartialTagModifier[] modifiers = _modifiers.Select(x => x.CreateModifier(accessorDef)).Where(x => x != null).ToArray(); return((request, index, count) => { HtmlTag tag = initialCreator(request, index, count); modifiers.Each(x => x(request, tag, index, count)); return tag; }); }
private Func<ElementRequest, HtmlTag> resolveCreator(AccessorDef accessorDef) { // TODO -- going to be largely rewritten soon-ish //TagBuilder initialCreator = _sources.FirstValue(x => x.CreateInitial(accessorDef)); //if (initialCreator == null) //{ // throw new FubuException(3000, "Html Conventions have no tag builder for {0}.{1}", accessorDef.ModelType.FullName, accessorDef.Accessor.Name); //} TagModifier[] modifiers = _modifiers.Select(x => x.CreateModifier(accessorDef)).Where(x => x != null).ToArray(); return request => { //HtmlTag tag = initialCreator(request); var tag = buildTag(request); modifiers.Each(x => x(request, tag)); return tag; }; }
private Func <ElementRequest, HtmlTag> resolveCreator(AccessorDef accessorDef) { // TODO -- going to be largely rewritten soon-ish //TagBuilder initialCreator = _sources.FirstValue(x => x.CreateInitial(accessorDef)); //if (initialCreator == null) //{ // throw new FubuException(3000, "Html Conventions have no tag builder for {0}.{1}", accessorDef.ModelType.FullName, accessorDef.Accessor.Name); //} TagModifier[] modifiers = _modifiers.Select(x => x.CreateModifier(accessorDef)).Where(x => x != null).ToArray(); return(request => { //HtmlTag tag = initialCreator(request); var tag = buildTag(request); modifiers.Each(x => x(request, tag)); return tag; }); }
protected override bool matches(AccessorDef def) { return(true); }
public void return_null_if_the_filter_does_not_match_the_accessor() { AccessorDef def = AccessorDef.For <ConventionTarget>(x => x.Age); modifier.CreateModifier(def).ShouldBeNull(); }
protected override bool matches(AccessorDef accessor) { return(accessor.Accessor.HasAttribute <StringLengthAttribute>()); }
protected abstract bool matches(AccessorDef def);
protected override bool matches(AccessorDef def) { return(def.Accessor.PropertyType == typeof(string) && def.Accessor.HasAttribute <LinkDisplayAttribute>()); }
protected override bool matches(AccessorDef def) { return(def.Accessor.FieldName.ToLowerInvariant().Contains("email")); }
protected override bool matches(AccessorDef def) { return(def.Accessor.PropertyType == typeof(bool) || def.Accessor.PropertyType == typeof(bool?)); }
protected override bool matches(AccessorDef def) { return((def.Accessor.PropertyType == typeof(DateTime) || def.Accessor.PropertyType == typeof(DateTime?)) && !def.Accessor.FieldName.EndsWith("Time")); }
protected abstract bool matches(AccessorDef accessor);
protected override bool matches(AccessorDef def) { return(def.Accessor.HasAttribute <AltListValueOfAttribute>()); }
protected override bool matches(AccessorDef accessorDefinition) { return(accessorDefinition.Accessor.HasAttribute <HiddenAttribute>()); }
protected override bool matches(AccessorDef def) { return(def.Accessor.PropertyType.GetInterface("ITokenInputViewModel") != null); }
protected override bool matches(AccessorDef def) { return(def.Accessor.Name.ToLowerInvariant().Contains("password")); }
protected override bool matches(AccessorDef def) { throw new NotImplementedException(); }
public EachPartialTagBuilder CreateInitial(AccessorDef accessorDef) { if (matches(accessorDef)) return Build; return null; }
protected override bool matches(AccessorDef def) { return(def.Accessor.HasAttribute <EnumRadioButtonListAttribute>()); }
protected override bool matches(AccessorDef def) { return(def.Accessor.PropertyType == typeof(IEnumerable <string>)); }
public TagModifier CreateModifier(AccessorDef accessorDef) { return _matches(accessorDef) ? _modifierBuilder(accessorDef) : null; }
protected override bool matches(AccessorDef def) { return def.Accessor.FieldName.ToLowerInvariant().Contains("email"); }
protected override bool matches(AccessorDef def) { return(def.Accessor.PropertyType.In(typeof(DateTime), typeof(DateTime?)) && def.Accessor.HasAttribute <DateAndTimeAttribute>()); }
protected override bool matches(AccessorDef def) { return def.Accessor.HasAttribute<AjaxOptionsAttribute>(); }
protected override bool matches(AccessorDef def) { return (def.Accessor.PropertyType == typeof(DateTime) || def.Accessor.PropertyType == typeof(DateTime?)) && def.Accessor.FieldName.EndsWith("Time"); }
public TagBuilder CreateInitial(AccessorDef accessorDef) { return _matches(accessorDef) ? _builderCreator(accessorDef) : null; }
public void return_a_value_if_the_filter_matches_the_accessor() { AccessorDef def = AccessorDef.For <ConventionTarget>(x => x.Name); modifier.CreateModifier(def).ShouldBeTheSameAs(tagModifier); }
protected override bool matches(AccessorDef def) { return def.Accessor.PropertyType.Equals(typeof(PizzaType)); }
protected override bool matches(AccessorDef def) { return def.Accessor.PropertyType == typeof(string) && def.Accessor.FieldName.EndsWith("ImageUrl"); }
protected override bool matches(AccessorDef def) { return(def.Accessor.PropertyType == typeof(string) && def.Accessor.FieldName.EndsWith("ImageUrl")); }
protected override bool matches(AccessorDef accessorDefinition) { return accessorDefinition.Accessor.PropertyType.In(typeof (string)) && accessorDefinition.Accessor.HasAttribute<PasswordAttribute>(); }
protected override bool matches(AccessorDef accessor) { return(accessor.Accessor.HasAttribute <RequiredAttribute>()); }
protected override bool matches(AccessorDef def) { return(typeof(AutoCompleteInput).IsAssignableFrom(def.Accessor.PropertyType)); }