/// <summary> /// Cria o estado da propriedade. /// </summary> /// <param name="propertyName"></param> /// <param name="propertyInfo"></param> /// <param name="identifier"></param> /// <param name="culture"></param> /// <returns></returns> private IStatebleItem CreatePropertyState(string propertyName, IPropertySettingsInfo propertyInfo, string identifier, System.Globalization.CultureInfo culture) { IStatebleItem propertyStateble = _validationManager.CreatePropertyState(this, propertyName, propertyInfo, _entity.UIContext, culture); if (propertyStateble != null) { propertyStateble.PropertyChanged += StateItemChanged; } return(propertyStateble); }
/// <summary> /// Cria o estado da propriedade pelo identificador. /// </summary> /// <param name="propertyName">Nome da propriedade.</param> /// <param name="identifier"></param> /// <param name="culture"></param> /// <returns></returns> private IStatebleItem CreatePropertyStateByIdentifier(string propertyName, string identifier, System.Globalization.CultureInfo culture) { if (_entitySettings == null) { return(null); } IPropertySettingsInfo propertyInfo = _entitySettings.Where(f => StringComparer.InvariantCultureIgnoreCase.Equals(f.Identifier, identifier)).FirstOrDefault(); if (propertyInfo != null) { var propertyState = _validationManager.CreatePropertyState(this, propertyName, propertyInfo, _entity.UIContext, culture); propertyState.PropertyChanged += StateItemChanged; return(propertyState); } else { return(null); } }
/// <summary> /// Carrega as configurações do tipo. /// </summary> /// <param name="culture"></param> private void LoadTypeSettings(System.Globalization.CultureInfo culture) { var entityTypeName = Colosoft.Reflection.TypeName.Get(_entity.GetType()); if (_entitySettings == null) { _entitySettings = _validationManager.LoadSettings(entityTypeName); } string startString = EntityTypeStartString; var allIdentifiers = GetIdentifierSpecialize(entityTypeName, startString, startString, String.Empty); foreach (string identifier in allIdentifiers.Keys) { IPropertySettingsInfo currentPropertSettings = _entitySettings.Where(f => f.Identifier == identifier).FirstOrDefault(); if (currentPropertSettings != null) { IStatebleItem stateble = CreatePropertyStateByIdentifier(allIdentifiers[identifier], identifier, culture); if (stateble != null) { stateble.IsConfigured = true; _propertyAttributes.Add(identifier, stateble); } } else { string[] propertyPath = allIdentifiers[identifier].Split('.'); var currentObjectTypeName = Colosoft.Reflection.TypeName.Get(this.GetType()); bool findPath = true; IEntityPropertyInfo info = null; for (int index = 0; index < propertyPath.Length - 1; index++) { string currentProperty = propertyPath[index]; info = _validationManager.LoadTypeProperty(currentObjectTypeName, currentProperty); if (info == null) { findPath = false; break; } else { currentObjectTypeName = info.PropertyType; } } if ((findPath) && (info != null) && (info.IsInstance)) { IPropertySettingsInfo propertyInfo = _validationManager.LoadSettings(currentObjectTypeName).Where(f => f.Identifier.EndsWith(propertyPath[propertyPath.Length - 1])).FirstOrDefault(); if (propertyInfo != null) { var propertyStateble = CreatePropertyState(allIdentifiers[identifier], propertyInfo, identifier, culture); propertyStateble.IsConfigured = true; _propertyAttributes.Add(identifier, propertyStateble); } else { var propertyState = CreatePropertyState(allIdentifiers[identifier], identifier, culture); _propertyAttributes.Add(identifier, propertyState); } } else { var propertyState = CreatePropertyState(allIdentifiers[identifier], identifier, culture); _propertyAttributes.Add(identifier, propertyState); } } } }
/// <summary> /// Carrega o estado da propriedade. /// </summary> /// <param name="owner">Proprietário do item.</param> /// <param name="propertyName">Nome da propriedade</param> /// <param name="information">Informações de estado da propriedade</param> /// <param name="uiContext">Identificador do contexto de usuário</param> /// <param name="culture">Cultura que será usada na criação.</param> /// <returns></returns> public IStatebleItem CreatePropertyState(IStateble owner, string propertyName, IPropertySettingsInfo information, string uiContext, System.Globalization.CultureInfo culture) { return(null); }
public override IStatebleItem CreatePropertyState(IStateble owner, string propertyName, IPropertySettingsInfo information, string uiContext, System.Globalization.CultureInfo culture) { var args = new StatebleItemCreatorEventArgs(); args.Identifier = information.Identifier; args.PropertyName = propertyName; args.CopyValue = information.CopyValue; args.ReloadSettings = information.ReloadSettings; var labelInfo = GetLabel(owner.Type, uiContext, propertyName); if (labelInfo != null) { args.Label = labelInfo.Label; } else { args.Label = new PropertyLabel(propertyName.GetFormatter(), null); } var result = new Lazy <IStatebleItem>(() => CreateStatebleItem(owner, args)); var aggregateValidator = new Validators.AggregateValidator(); if (information.InputRulesGroupId.HasValue) { var rules = Settings.GetRules(information.InputRulesGroupId.Value, uiContext); if (rules != null) { args.Options = rules.Options; if ((args.Options & InputRulesOptions.Necessary) == InputRulesOptions.Necessary) { aggregateValidator.Add(ValidationManager.NecessaryValidator); } if (!string.IsNullOrEmpty(rules.Label)) { args.Label = new PropertyLabel(rules.Label.GetFormatter(), rules.Label.GetFormatter()); } if (rules.ParseId.HasValue) { args.Parse = CreateParse(rules.ParseId.Value); } if (rules.InputValidateUid.HasValue) { InsertValidate(result.Value, aggregateValidator, rules.InputValidateUid.Value); } } } if ((information.ValidationId.HasValue) && (information.ValidationId > 0)) { var validator = GetValidator(information.ValidationId.Value, culture); if (validator != null) { aggregateValidator.Add(validator); } } if (aggregateValidator.Count > 0) { result.Value.Validation = aggregateValidator; } return(result.Value); }
/// <summary> /// Carrega o estado da propriedade. /// </summary> /// <param name="owner">Proprietário do item que será criado.</param> /// <param name="propertyName">Nome da propriedade</param> /// <param name="information">Informações de estado da propriedade</param> /// <param name="uiContext">Identificador do contexto de usuário</param> /// <param name="culture">Cultura que será usada na criação.</param> /// <returns></returns> public virtual IStatebleItem CreatePropertyState(IStateble owner, string propertyName, IPropertySettingsInfo information, string uiContext, System.Globalization.CultureInfo culture) { throw new NotImplementedException(); }