예제 #1
0
        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;
                     });
     }
 }
예제 #3
0
        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>));
        }
예제 #5
0
        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;
            });
        }
예제 #6
0
 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;
 }
예제 #7
0
 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);
 }
예제 #10
0
 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);
 }
예제 #12
0
 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;
 }
예제 #13
0
 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;
 }
예제 #14
0
 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(); };
        }
예제 #19
0
        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);
        }
예제 #20
0
        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;
            };
        }
예제 #21
0
 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;
 }
예제 #22
0
 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(); };
        }
예제 #25
0
        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?));
        }
예제 #26
0
        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;
            };
        }
예제 #27
0
        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;
            });
        }
예제 #28
0
        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;
            };
        }
예제 #29
0
        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;
            });
        }
예제 #30
0
 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>());
 }
예제 #33
0
 protected abstract bool matches(AccessorDef def);
예제 #34
0
 protected override bool matches(AccessorDef def)
 {
     return(def.Accessor.PropertyType == typeof(string) &&
            def.Accessor.HasAttribute <LinkDisplayAttribute>());
 }
예제 #35
0
 protected override bool matches(AccessorDef def)
 {
     return(def.Accessor.FieldName.ToLowerInvariant().Contains("email"));
 }
예제 #36
0
 protected override bool matches(AccessorDef def)
 {
     return(def.Accessor.PropertyType == typeof(bool) ||
            def.Accessor.PropertyType == typeof(bool?));
 }
예제 #37
0
 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>());
 }
예제 #40
0
 protected override bool matches(AccessorDef accessorDefinition)
 {
     return(accessorDefinition.Accessor.HasAttribute <HiddenAttribute>());
 }
예제 #41
0
 protected override bool matches(AccessorDef def)
 {
     return(def.Accessor.PropertyType.GetInterface("ITokenInputViewModel") != null);
 }
 protected abstract bool matches(AccessorDef accessor);
예제 #43
0
 protected override bool matches(AccessorDef def)
 {
     return(def.Accessor.Name.ToLowerInvariant().Contains("password"));
 }
 protected override bool matches(AccessorDef def)
 {
     throw new NotImplementedException();
 }
예제 #45
0
 public EachPartialTagBuilder CreateInitial(AccessorDef accessorDef)
 {
     if (matches(accessorDef)) return Build;
     return null;
 }
예제 #46
0
 protected override bool matches(AccessorDef def)
 {
     return(def.Accessor.HasAttribute <EnumRadioButtonListAttribute>());
 }
예제 #47
0
 protected override bool matches(AccessorDef def)
 {
     return(def.Accessor.PropertyType == typeof(IEnumerable <string>));
 }
예제 #48
0
 public TagModifier CreateModifier(AccessorDef accessorDef)
 {
     return _matches(accessorDef) ? _modifierBuilder(accessorDef) : null;
 }
예제 #49
0
 protected override bool matches(AccessorDef def)
 {
     return def.Accessor.FieldName.ToLowerInvariant().Contains("email");
 }
예제 #50
0
 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>();
 }
예제 #52
0
 protected override bool matches(AccessorDef def)
 {
     return (def.Accessor.PropertyType == typeof(DateTime)
         || def.Accessor.PropertyType == typeof(DateTime?))
         && def.Accessor.FieldName.EndsWith("Time");
 }
예제 #53
0
 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);
        }
예제 #55
0
 protected override bool matches(AccessorDef def)
 {
     return def.Accessor.PropertyType.Equals(typeof(PizzaType));
 }
예제 #56
0
 protected override bool matches(AccessorDef def)
 {
     return def.Accessor.PropertyType == typeof(string)
         && def.Accessor.FieldName.EndsWith("ImageUrl");
 }
예제 #57
0
 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>();
		}
예제 #59
0
 protected override bool matches(AccessorDef accessor)
 {
     return(accessor.Accessor.HasAttribute <RequiredAttribute>());
 }
예제 #60
0
 protected override bool matches(AccessorDef def)
 {
     return(typeof(AutoCompleteInput).IsAssignableFrom(def.Accessor.PropertyType));
 }