Example #1
0
 public bool Equals(DValue other)
 {
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     if (other == null)
     {
         return(false);
     }
     return(Equals(Value, other.Value));
 }
        public CardControlViewModel(IAttribute attribute, IType type, object initValue, bool isReadOnly,
                                    IPilotDialogService dialogService, IObjectsRepository repository, IObjectCardAutoComplete autoComplete,
                                    IAttributeFormatParser attributeFormatParser, bool editMode)
        {
            if (dialogService == null)
            {
                throw new ArgumentNullException(nameof(dialogService));
            }
            if (repository == null)
            {
                throw new ArgumentNullException(nameof(repository));
            }
            if (attributeFormatParser == null)
            {
                throw new ArgumentNullException(nameof(attributeFormatParser));
            }
            if (autoComplete == null)
            {
                throw new ArgumentNullException(nameof(autoComplete));
            }
            if (attribute == null)
            {
                throw new ArgumentNullException(nameof(attribute));
            }

            _type                  = type;
            _dialogService         = dialogService;
            _repository            = repository;
            _attributeFormatParser = attributeFormatParser;
            _autoComplete          = autoComplete;
            _editMode              = editMode;

            Attribute      = attribute;
            _originalValue = DValue.GetDValue(initValue);
            _value         = initValue;
            IsReadOnly     = isReadOnly;

            Format = _attributeFormatParser.GetAttributeFormat(Attribute.Configuration);
            if (_originalValue != null && (_originalValue.DateValue != null && Format == null))
            {
                Format = CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern;
            }

            Culture = _attributeFormatParser.GetAttributeFormatCulture(Attribute.Configuration);
        }