Esempio n. 1
0
        /*
         *      public string Description {
         *              get {
         *                      return _parent.GetHost().PreferenceSupplier.GetDescription(this);
         *              }
         *      }
         */

        protected PreferenceValidationResult GetSharedValidationResult()
        {
            PreferenceValidationResult r = _parent.GetHost().SharedValidationResult;

            r.Reset();
            return(r);
        }
Esempio n. 2
0
        public void Import(IPreferenceFolder newvalues)
        {
            if (this.FullQualifiedId != newvalues.FullQualifiedId)
            {
                throw new InvalidOperationException("ID mismatch");
            }

            PreferenceValidationResult r = GetHost().SharedValidationResult;

            r.Reset();

            GetSupplier().ValidateFolder(newvalues, r);
            if (!r.Validated)
            {
                GetHost().ValidationError(this, r);
            }
            else
            {
                //fire listener
                //このあたりの仕様いまいちだな。Folderの階層とイベントの関係を明らかにしておきたい
                if (_listenerList != null)
                {
                    foreach (IPreferenceChangeListener l in _listenerList)
                    {
                        l.OnPreferenceImport(this, newvalues);
                    }
                }

                ImportSnapshot(newvalues as PreferenceFolder);
            }
        }
Esempio n. 3
0
        internal PreferenceValidationResult Clone()
        {
            PreferenceValidationResult r = new PreferenceValidationResult();

            r._message = _message;
            return(r);
        }
Esempio n. 4
0
 //ValidationErrorの通知
 internal void ValidationError(IPreferenceItemBase item, PreferenceValidationResult result)
 {
     if (_loading)            //ロード中のエラーは初期値に戻すだけ。どこかにWarningは出してもいいかもな
     {
         item.ResetValue();
     }
     else
     {
         throw new ValidationException(item, result.Clone());
     }
 }
Esempio n. 5
0
 public PlugInHost(PreferencePlugin parent, IPreferenceSupplier supplier, StructuredText root, int index)
 {
     _parent      = parent;
     _supplier    = supplier;
     _storageNode = root.FindChild(supplier.PreferenceID);
     if (_storageNode == null)
     {
         _storageNode = root.AddChild(supplier.PreferenceID);                    //空で作成しておく
     }
     _supplierID   = supplier.PreferenceID;
     _index        = index;
     _sharedResult = new PreferenceValidationResult();
 }
Esempio n. 6
0
        }                                                 //デフォルト値と違うかどうか

        protected bool Validate <T>(T value, PreferenceItemValidator <T> validator, ErrorMode errormode)
        {
            if (validator != null)
            {
                PreferenceValidationResult r = GetSharedValidationResult();
                validator(value, r);
                if (!r.Validated)
                {
                    if (errormode == ErrorMode.Reset)
                    {
                        ResetValue();
                    }
                    else
                    {
                        ValidationError(r);
                    }
                    return(false);
                }
            }

            return(true);
        }
Esempio n. 7
0
        private bool Validate(T value, ErrorMode errormode)
        {
            if (_validator != null)
            {
                PreferenceValidationResult r = GetSharedValidationResult();
                _validator(value, r);
                if (!r.Validated)
                {
                    if (errormode == ErrorMode.Reset)
                    {
                        ResetValue();
                    }
                    else
                    {
                        ValidationError(r);
                    }
                    return(false);
                }
            }

            return(true);
        }
Esempio n. 8
0
 protected void ValidationError(PreferenceValidationResult result)
 {
     _parent.GetHost().ValidationError(this, result);
 }