コード例 #1
0
ファイル: TagFactory.cs プロジェクト: reharik/CCHtmlHelpers
        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;
                });
        }
コード例 #2
0
 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
ファイル: Parser.cs プロジェクト: altseed/LanguageTranslator
        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);
        }
コード例 #4
0
        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
ファイル: TagFactory.cs プロジェクト: reharik/CCHtmlHelpers
        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;
 }
コード例 #8
0
 public TagModifier CreateModifier(AccessorDef accessorDef)
 {
     if (matches(accessorDef))
     {
         return Build;
     }
     return null;
 }
コード例 #9
0
 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));
 }
コード例 #11
0
 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;
 }
コード例 #15
0
        protected override bool matches(AccessorDef accessor)
        {
            var propertyType = accessor.Accessor.PropertyType;

            return propertyType == typeof (DateTime)
                   || propertyType == typeof (DateTime?)
                   || propertyType == typeof (Date)
                   || propertyType == typeof (Date?);
        }
コード例 #16
0
	public TagModifier CreateModifier(AccessorDef accessorDef)
	{
		if (accessorDef.Accessor.Name.EndsWith("Email"))
		{
			return (req, tag) => { tag.Attr("type", "email"); };
		}

		return null;
	}
コード例 #17
0
        protected override bool matches(AccessorDef accessor)
        {
            var propertyType = accessor.Accessor.PropertyType;

            return(propertyType == typeof(DateTime) ||
                   propertyType == typeof(DateTime?) ||
                   propertyType == typeof(Date) ||
                   propertyType == typeof(Date?));
        }
コード例 #18
0
        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
ファイル: TagFactory.cs プロジェクト: bbehrens/fubumvc
        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);
 }
コード例 #23
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?);
        }
コード例 #24
0
        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
ファイル: PartialTagFactory.cs プロジェクト: roend83/fubumvc
        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
ファイル: TagFactory.cs プロジェクト: roend83/fubumvc
        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
ファイル: TagFactory.cs プロジェクト: rmueller/fubumvc
        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);
 }
コード例 #31
0
        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
ファイル: Interfaces.cs プロジェクト: jemacom/fubumvc
 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"));
 }
コード例 #38
0
 protected abstract bool matches(AccessorDef accessor);
コード例 #39
0
 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);
 }
コード例 #42
0
 protected abstract bool matches(AccessorDef accessor);
コード例 #43
0
 protected override bool matches(AccessorDef def)
 {
     return(def.Accessor.Name.ToLowerInvariant().Contains("password"));
 }
コード例 #44
0
 protected override bool matches(AccessorDef def)
 {
     throw new NotImplementedException();
 }
コード例 #45
0
ファイル: Interfaces.cs プロジェクト: jemacom/fubumvc
 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>());
 }
コード例 #51
0
 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;
 }
コード例 #54
0
        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"));
 }
コード例 #58
0
		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));
 }