Esempio n. 1
0
        public void Seed(IContext context)
        {
            var factory = new DataDictionaryFactory(_reflectionHelper, _assemblyName);
            var seeders = factory.CreateDataDictionarySeederDataBuilder();

            seeders.ForEach(o => o.Seed(context));
        }
        public bool IsRequiredField <TModel, TValue>(string dictionaryAssemblyName, HtmlHelper <TModel> htmlHelper, Expression <Func <TModel, TValue> > fieldExpression)
        {
            if (!_dataDictionaries.Any())
            {
                var dataDictionaryFactory = new DataDictionaryFactory(ReflectionHelper.Instance, dictionaryAssemblyName);
                var dictionaries          = dataDictionaryFactory.CreateDataDictionarySeederDataBuilder();
                dictionaries.ForEach(o => _dataDictionaries.AddRange(o.Container));
            }

            var metadata       = ModelMetadata.FromLambdaExpression(fieldExpression, htmlHelper.ViewData);
            var dataDictionary = _dataDictionaries.FirstOrDefault(o => o.Model.ToLower() == metadata.ContainerType.Name.ToLower() &&
                                                                  o.FieldName == metadata.PropertyName);

            return(dataDictionary != null && dataDictionary.IsRequired);
        }