/// <summary> /// Notifica que o estado foi alterado. /// </summary> protected void OnChanged(IStatebleItem obj, string stateName) { if (StateChanged != null) { StateChanged(this, new StateChangedEventArgs(obj.PropertyName, stateName)); } }
/// <summary> /// Insere as validações de entrada na propriedade. /// </summary> /// <param name="propertryState">Estado atual da propriedade</param> /// <param name="aggregateValidator">Agregador</param> /// <param name="inputValidateUid">Identificador da validação que será incluída.</param> private void InsertValidate(IStatebleItem propertryState, Validators.AggregateValidator aggregateValidator, Guid inputValidateUid) { var inputValidate = Settings.GetInputValidate(inputValidateUid); if (inputValidate != null) { CalculateInputValidateInfo(propertryState, inputValidate, aggregateValidator, new List <Guid>()); } }
/// <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> /// Copia as informações de outra instância. /// </summary> /// <param name="source"></param> /// <returns></returns> public IStatebleItem CopyFrom(IStatebleItem source) { if (source == null) { return(this); } Identifier = source.Identifier; IsConfigured = source.IsConfigured; ReloadSettings = source.ReloadSettings; CopyValue = source.CopyValue; Options = source.Options; if ((CheckDigits == null) || (source.CheckDigits == null) || (CheckDigits.Base != source.CheckDigits.Base) || (CheckDigits.Digits != source.CheckDigits.Digits) || (CheckDigits.Limit != source.CheckDigits.Limit) || (CheckDigits.Start != source.CheckDigits.Start)) { CheckDigits = source.CheckDigits; } if ((Customization == null) || (!Customization.Equals(source.Customization))) { Customization = source.Customization; } if ((DefaultValue == null) || (source.DefaultValue == null) || (!String.Equals(DefaultValue.DefaultValue, source.DefaultValue.DefaultValue))) { DefaultValue = source.DefaultValue; } if ((IndexedValues == null) || (source.IndexedValues == null) || (!Enumerable.SequenceEqual(IndexedValues.Select(d => d.IndexDescription + "!" + d.IndexValue), source.IndexedValues.Select(d => d.IndexDescription + "!" + d.IndexValue)))) { IndexedValues = source.IndexedValues; } if ((Label == null) || (source.Label == null) || (!String.Equals(Label.Title, source.Label.Title)) || (!String.Equals(Label.Description, source.Label.Description))) { Label = source.Label; } if ((Length == null) || (source.Length == null) || (Math.Abs(Length.MaxValue - source.Length.MaxValue) > 1E-3) || (Math.Abs(Length.MinValue - source.Length.MinValue) > 1E-3)) { Length = source.Length; } if ((Mask == null) || (source.Mask == null) || (!String.Equals(Mask.Mask, source.Mask.Mask))) { Mask = source.Mask; } if (!Object.Equals(Parser, source.Parser)) { Parser = source.Parser; } if ((Range == null) || (source.Range == null) || (!String.Equals(Range.FromValue, source.Range.FromValue)) || (!String.Equals(Range.ToValue, source.Range.ToValue))) { Range = source.Range; } var asEquatable = Validation as IEquatable <IValidator>; if ((Validation == null) || (source.Validation == null) || (!String.Equals(Validation.DefaultMessageTemplate, source.Validation.DefaultMessageTemplate)) || (!String.Equals(Validation.FullName, source.Validation.FullName)) || (Validation.IsExclusiveInList != source.Validation.IsExclusiveInList) || (!String.Equals(Validation.ReturnedParameters, source.Validation.ReturnedParameters)) || (asEquatable == null) || (!asEquatable.Equals(source.Validation))) { Validation = source.Validation; } if ((ValidChars == null) || (source.ValidChars == null) || (!String.Equals(ValidChars.ValidChars, source.ValidChars.ValidChars))) { ValidChars = source.ValidChars; } if ((Values == null) || (source.Values == null) || (!Enumerable.SequenceEqual(Values.Select(v => v.Value), source.Values.Select(v => v.Value)))) { Values = source.Values; } return(this); }
/// <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); } } } }