public override void Fill(DateTimePropertyBag propertyBag, FillerParams fillerParams) { if (fillerParams.SkipBehaviourFill == false) { IModelPropertyConfiguration propertyConfig = ReadPropertyConfiguration(fillerParams.ModelName, fillerParams.PropertyName, fillerParams.ConfigKey); propertyBag.ShowDate = false; propertyBag.ShowTime = false; if (propertyConfig != null && propertyConfig.PropertyConfiguration != null) { if (propertyConfig.PropertyConfiguration.DateProperties != null) { ///******** Adding config properties to datePropertyBag **********/ propertyBag.DateProperties = propertyConfig.PropertyConfiguration.DateProperties; propertyBag.ShowDate = true; } if (propertyConfig.PropertyConfiguration.TimeProperties != null) { ///******** Adding config properties to datePropertyBag **********/ /// propertyBag.TimeProperties = propertyConfig.PropertyConfiguration.TimeProperties; propertyBag.ShowTime = true; } } } }
public override void Fill(NumericTextBoxPropertyBag propertyBag, FillerParams fillerParams) { if (fillerParams.SkipSecurityFill == false) { IModelPropertyConfiguration propertyConfig = ReadPropertyConfiguration(fillerParams.ModelName, fillerParams.PropertyName, fillerParams.ConfigKey); if (propertyConfig != null && propertyConfig.PropertyConfiguration != null) { IAccessPolicy accessSecurity = GetAccess(propertyConfig.PropertyConfiguration.Security); if (accessSecurity != null) { propertyBag.Enabled = accessSecurity.Enabled; propertyBag.ReadOnly = accessSecurity.ReadOnly; propertyBag.Masking = accessSecurity.Masking; propertyBag.Visibility = accessSecurity.Visibility; } } else { setDefalutSecurity(propertyBag); } } else { setDefalutSecurity(propertyBag); } }
private void fillValidators(ControlPropertyBag propertyBag, FillerParams fillerParams) { if (fillerParams.SkipValidationFill == false) { IModelPropertyConfiguration propertyConfig = ReadPropertyConfiguration(fillerParams.ModelName, fillerParams.PropertyName, fillerParams.ConfigKey); if (propertyConfig != null) { propertyBag.Mandatory = false; var isHavingConfigKey = false; if (propertyConfig.PropertyConfiguration != null && propertyConfig.PropertyConfiguration.Validators != null) { propertyBag.Validators = propertyConfig.PropertyConfiguration.Validators; if (propertyConfig.PropertyConfiguration.SiteConfig != null && propertyConfig.PropertyConfiguration.SiteConfig.Count > 0) { var siteConfig = propertyConfig.PropertyConfiguration.SiteConfig.Find(o => o.SiteConfigType == SiteConfigType.Mandatory); if (siteConfig != null) { ISiteConfigSetting siteConfigSetting = this.GetSiteConfigSetting(siteConfig.ConfigKey); if (siteConfigSetting != null) { if (siteConfigSetting.ConfigValue == true) { propertyBag.Mandatory = true; } isHavingConfigKey = true; } } } if (!isHavingConfigKey && propertyBag.Mandatory == false) { if (propertyBag.Validators != null && propertyBag.Validators.Count > 0) { var requiredValidation = propertyBag.Validators.Find(o => o.Type == ValidatorsType.Required); if (requiredValidation != null) { propertyBag.Mandatory = true; } } } } } } }
private void SetVisibility(ControlPropertyBag propertyBag, FillerParams fillerParams) { IModelPropertyConfiguration propertyConfig = ReadPropertyConfiguration(fillerParams.ModelName, fillerParams.PropertyName, fillerParams.ConfigKey); if (propertyConfig != null && propertyConfig.PropertyConfiguration != null && propertyConfig.PropertyConfiguration.SiteConfig != null && propertyConfig.PropertyConfiguration.SiteConfig.Count > 0) { var siteConfig = propertyConfig.PropertyConfiguration.SiteConfig.Find(o => o.SiteConfigType == SiteConfigType.Visible); if (siteConfig != null) { ISiteConfigSetting siteConfigSetting = this.GetSiteConfigSetting(siteConfig.ConfigKey); if (siteConfigSetting != null) { if (siteConfigSetting.ConfigValue == false) { propertyBag.Visibility = false; } } } } }
private void FillLiteral(ControlPropertyBag propertyBag, FillerParams fillerParams, bool skipWatermark = false) { string externalizationKey = string.Empty; if (fillerParams.IsBindingControl) { IModelPropertyConfiguration propertyConfig = ReadPropertyConfiguration(fillerParams.ModelName, fillerParams.PropertyName, fillerParams.ConfigKey); externalizationKey = propertyConfig != null ? propertyConfig.ExternalizationKey : string.Format(ControlLibConstants.EXTERNALIZATION_KEY_FORMAT, fillerParams.ModelName, fillerParams.PropertyName.Replace(".", "_")); } else { externalizationKey = fillerParams.ExternalizationKey; } propertyBag.Label = ControlLibraryConfig.ResourceService.GetLiteral(string.Format(ControlLibConstants.LABEL_FORMAT, externalizationKey)); propertyBag.ToolTip = ControlLibraryConfig.ResourceService.GetLiteral(string.Format(ControlLibConstants.TOOLTIP_FORMAT, externalizationKey)); if (!skipWatermark) { propertyBag.WaterMarkText = ControlLibraryConfig.ResourceService.GetLiteral(string.Format(ControlLibConstants.WATERMARK_FORMAT, externalizationKey)); } }
public override void Fill(LabelPropertyBag propertyBag, FillerParams fillerParams) { if (fillerParams.SkipBehaviourFill == false) { IModelPropertyConfiguration propertyConfig = ReadPropertyConfiguration(fillerParams.ModelName, fillerParams.PropertyName, fillerParams.ConfigKey); propertyBag.Masking = false; if (propertyConfig != null && propertyConfig.PropertyConfiguration != null) { if (propertyConfig.PropertyConfiguration.MaskingProperties != null) { propertyBag.MaskingProperties = new MaskingBehaviourPropertyBag(new Dictionary <string, string>() { { ControlLibConstants.MASKING_CHAR, !string.IsNullOrEmpty(propertyConfig.PropertyConfiguration.MaskingProperties.MaskingChar.ToString()) ? propertyConfig.PropertyConfiguration.MaskingProperties.MaskingChar.ToString() : propertyBag.MaskingProperties.MaskingChar.ToString() }, { ControlLibConstants.MASKING_TYPE, propertyConfig.PropertyConfiguration.MaskingProperties.MaskingType.ToString() }, { ControlLibConstants.MASKING_CHAR_LENGTH, propertyConfig.PropertyConfiguration.MaskingProperties.MaskCharLength > 0 ? propertyConfig.PropertyConfiguration.MaskingProperties.MaskCharLength.ToString() : propertyBag.MaskingProperties.MaskCharLength.ToString() }, { ControlLibConstants.MASKING_POSITION, propertyConfig.PropertyConfiguration.MaskingProperties.MaskingPosition.ToString() } }); } } } }
public override void Fill(TextBoxPropertyBag propertyBag, FillerParams fillerParams) { if (fillerParams.SkipBehaviourFill == false) { IModelPropertyConfiguration propertyConfig = ReadPropertyConfiguration(fillerParams.ModelName, fillerParams.PropertyName, fillerParams.ConfigKey); //propertyBag.AutoComplete = false; propertyBag.Masking = false; if (propertyConfig != null && propertyConfig.PropertyConfiguration != null) { if (propertyConfig.PropertyConfiguration.AutoCompleteProperties != null && propertyBag.AutoComplete) { propertyBag.AutoCompleteProperties = new AutoCompleteBehaviourPropertyBag(new Dictionary <string, string>() { { ControlLibConstants.ACTION_URL, propertyConfig.PropertyConfiguration.AutoCompleteProperties.ActionURL }, { ControlLibConstants.ACTION_NAME, propertyConfig.PropertyConfiguration.AutoCompleteProperties.ActionName }, { ControlLibConstants.CONTROLLER_NAME, propertyConfig.PropertyConfiguration.AutoCompleteProperties.ControllerName }, { ControlLibConstants.MIN_CHAR_REQUIRED, propertyConfig.PropertyConfiguration.AutoCompleteProperties.MinCharRequired > 0 ? propertyConfig.PropertyConfiguration.AutoCompleteProperties.MinCharRequired.ToString() : propertyBag.AutoCompleteProperties.MinCharRequired.ToString() }, { ControlLibConstants.MAX_RESULT_COUNT, propertyConfig.PropertyConfiguration.AutoCompleteProperties.MaxResultCount > 0 ? propertyConfig.PropertyConfiguration.AutoCompleteProperties.MaxResultCount.ToString() : propertyBag.AutoCompleteProperties.MaxResultCount.ToString() }, { ControlLibConstants.ORDER_BY, propertyConfig.PropertyConfiguration.AutoCompleteProperties.OrderBy.ToString() }, { ControlLibConstants.SEARCH_TYPE, propertyConfig.PropertyConfiguration.AutoCompleteProperties.SearchType.ToString() } }); //propertyBag.AutoComplete = true; } if (propertyConfig.PropertyConfiguration.MaskingProperties != null) { propertyBag.MaskingProperties = new MaskingBehaviourPropertyBag(new Dictionary <string, string>() { { ControlLibConstants.MASKING_CHAR, !string.IsNullOrEmpty(propertyConfig.PropertyConfiguration.MaskingProperties.MaskingChar.ToString()) ? propertyConfig.PropertyConfiguration.MaskingProperties.MaskingChar.ToString() : propertyBag.MaskingProperties.MaskingChar.ToString() }, { ControlLibConstants.MASKING_TYPE, propertyConfig.PropertyConfiguration.MaskingProperties.MaskingType.ToString() }, { ControlLibConstants.MASKING_CHAR_LENGTH, propertyConfig.PropertyConfiguration.MaskingProperties.MaskCharLength > 0 ? propertyConfig.PropertyConfiguration.MaskingProperties.MaskCharLength.ToString() : propertyBag.MaskingProperties.MaskCharLength.ToString() }, { ControlLibConstants.MASKING_POSITION, propertyConfig.PropertyConfiguration.MaskingProperties.MaskingPosition.ToString() } }); } } } }
private bool MandatoryCheck() { bool mandatory = true; IModelPropertyConfiguration propertyConfig = ReadPropertyConfiguration(_propertyBag._fillerParams.ModelName, _propertyBag._fillerParams.PropertyName, _propertyBag._fillerParams.ConfigKey); if (propertyConfig != null && propertyConfig.PropertyConfiguration != null && propertyConfig.PropertyConfiguration.SiteConfig != null && propertyConfig.PropertyConfiguration.SiteConfig.Count > 0) { var siteConfig = propertyConfig.PropertyConfiguration.SiteConfig.Find(o => o.SiteConfigType == SiteConfigType.Mandatory); if (siteConfig != null) { ISiteConfigSetting siteConfigSetting = ControlLibraryConfig.SiteConfigProvider.Current.GetSiteConfig(siteConfig.ConfigKey); if (siteConfigSetting != null) { if (siteConfigSetting.ConfigValue == false) { mandatory = false; } } } } return(mandatory); }
protected IModelPropertyConfiguration ReadPropertyConfiguration(string modelName, string propertyName, string configKey) { IModelPropertyConfiguration propertyConfig = ControlLibraryConfig.ControlConfigReader.GetConfigurationSettings(modelName, propertyName, configKey); return(propertyConfig); }
public bool Validate() { IDictionary <string, ModelPropertyConfiguration> modelPropConfig = ControlLibraryConfig.ControlConfigReader.GetModelConfigurationSettings(TypeName, this.ConfigKey); if (modelPropConfig != null) { foreach (KeyValuePair <string, ModelPropertyConfiguration> keyValue in modelPropConfig) { this.PropertyName = keyValue.Key; if (keyValue.Value.IsComplexType) { if (keyValue.Value.IsEnumerable) { IEnumerable enumerable = GetNestedPropertyValue(this.data, keyValue.Key) as IEnumerable; if (enumerable != null) { IEnumerator enumerator = enumerable.GetEnumerator(); int currentIndex = 0; while (enumerator.MoveNext()) { if (enumerator.Current != null) { this.PropertyName = string.Format("{0}_{1}_", keyValue.Key, currentIndex); ObjectValidator validator = new ObjectValidator(enumerator.Current, this, ConfigKey); if (false == validator.Validate()) { this.ErrorList.AddRange(validator.ErrorList); } } currentIndex++; } } } else { object data = GetNestedPropertyValue(this.data, keyValue.Key); if (null != data) { ObjectValidator validator = new ObjectValidator(data, this, ConfigKey); if (false == validator.Validate()) { this.ErrorList.AddRange(validator.ErrorList); } } } } else { //PropertyInfo info = this.GetType().GetProperty(keyValue.Key); object value = GetNestedPropertyValue(this.data, keyValue.Key); IModelPropertyConfiguration imodel = modelPropConfig[keyValue.Key]; if (imodel != null && imodel.PropertyConfiguration != null && imodel.PropertyConfiguration.Validators != null && imodel.PropertyConfiguration.Validators.Count > 0) { foreach (IValidator item in imodel.PropertyConfiguration.Validators) { if (item.Type == ValidatorsType.Custom) { CustomValidator validation = item as CustomValidator; CustomValidationExpressionConfiguration expressionConfig = ControlLibraryConfig.ControlConfigReader.GetCustomValidationExpressionConfiguration(validation.ValidationType.ToString()); string _exression = string.Empty; if (expressionConfig != null) { _exression = expressionConfig.Expression; } if (item.Validate(value, _exression) == false) { if (ErrorList == null) { ErrorList = new List <KeyValuePair <string, string> >(); } ErrorList.Add(new KeyValuePair <string, string>(this.GetCurrentPropertyName(), item.Message)); } } else if (item.Type == ValidatorsType.RegExp) { RegExValidator validation = item as RegExValidator; string _exression = validation.RegExpression; if (item.Validate(value, _exression) == false) { if (ErrorList == null) { ErrorList = new List <KeyValuePair <string, string> >(); } ErrorList.Add(new KeyValuePair <string, string>(this.GetCurrentPropertyName(), item.Message)); } } else if (item.Type == ValidatorsType.Required) { bool mandatory = true; if (imodel.PropertyConfiguration.SiteConfig != null && imodel.PropertyConfiguration.SiteConfig.Count > 0) { bool?configVlaueVisible = this.GetSiteConfigValue(imodel.PropertyConfiguration.SiteConfig, SiteConfigType.Visible); if (configVlaueVisible.HasValue && configVlaueVisible == false) { mandatory = false; } if (mandatory) { bool?configVlaueMandatory = this.GetSiteConfigValue(imodel.PropertyConfiguration.SiteConfig, SiteConfigType.Mandatory); if (configVlaueMandatory.HasValue && configVlaueMandatory == false) { mandatory = false; } } } if (mandatory) { if (item.Validate(value, string.Empty) == false) { if (ErrorList == null) { ErrorList = new List <KeyValuePair <string, string> >(); } ErrorList.Add(new KeyValuePair <string, string>(this.GetCurrentPropertyName(), item.Message)); } } } else { if (item.Validate(value, string.Empty) == false) { if (ErrorList == null) { ErrorList = new List <KeyValuePair <string, string> >(); } ErrorList.Add(new KeyValuePair <string, string>(this.GetCurrentPropertyName(), item.Message)); } } } } } } } return(this.ErrorList == null ? true : this.ErrorList.Count == 0); }