Esempio n. 1
0
        public void FinalDicClear()
        {
            object otherKey = new object();

            _dic[this, SharedDicTestContext.Plugins[0], "key1"]     = "value1";
            _dic[this, SharedDicTestContext.Plugins[0], "key2"]     = "value2";
            _dic[this, SharedDicTestContext.Plugins[0], "key3"]     = "value3";
            _dic[otherKey, SharedDicTestContext.Plugins[0], "key1"] = "value1";
            _dic[otherKey, SharedDicTestContext.Plugins[0], "key2"] = "value2";
            _dic[otherKey, SharedDicTestContext.Plugins[0], "key3"] = "value3";
            _dic[this, SharedDicTestContext.Plugins[1], "key1"]     = "value1";
            _dic[this, SharedDicTestContext.Plugins[1], "key2"]     = "value2";
            _dic[this, SharedDicTestContext.Plugins[1], "key3"]     = "value3";
            _dic[otherKey, SharedDicTestContext.Plugins[1], "key1"] = "value1";
            _dic[otherKey, SharedDicTestContext.Plugins[1], "key2"] = "value2";
            _dic[otherKey, SharedDicTestContext.Plugins[1], "key3"] = "value3";

            IObjectPluginConfig finalDicThis1  = GetFinalDic(this, SharedDicTestContext.Plugins[0]);
            IObjectPluginConfig finalDicThis2  = GetFinalDic(this, SharedDicTestContext.Plugins[1]);
            IObjectPluginConfig finalDicOther1 = GetFinalDic(this, SharedDicTestContext.Plugins[0]);
            IObjectPluginConfig finalDicOther2 = GetFinalDic(this, SharedDicTestContext.Plugins[1]);

            finalDicThis1.Clear();
            Assert.That(!_lastConfigChangedEventArgs.IsAllConcerned);
            Assert.IsNull(_lastConfigChangedEventArgs.Key);
            Assert.That(_lastConfigChangedEventArgs.MultiObj.Count == 1);
            Assert.That(_lastConfigChangedEventArgs.MultiObj.Any((o) => { return(o == this); }));
            Assert.That(_lastConfigChangedEventArgs.MultiPluginId.Count == 1);
            Assert.That(_lastConfigChangedEventArgs.MultiPluginId.Any((p) => { return(p == SharedDicTestContext.Plugins[0]); }));
            Assert.That(_lastConfigChangedEventArgs.Obj == this);
            Assert.That(_lastConfigChangedEventArgs.Status == ChangeStatus.ContainerClear);
            Assert.IsNull(_lastConfigChangedEventArgs.Value);
        }
Esempio n. 2
0
        IObjectPluginConfig GetFinalDic(object key, IUniqueId id)
        {
            IObjectPluginConfig finalDic = _dic.GetObjectPluginConfig(this, SharedDicTestContext.Plugins[0]);

            Assert.IsNotNull(finalDic);
            return(finalDic);
        }
Esempio n. 3
0
        public void FinalDicUpdate()
        {
            IObjectPluginConfig finalDic = GetFinalDic(this, SharedDicTestContext.Plugins[0]);

            _dic.Add(this, SharedDicTestContext.Plugins[0], "key2", "value2");

            finalDic["key2"] = "NewValue2";
            Assert.That(!_lastConfigChangedEventArgs.IsAllConcerned);
            Assert.That(_lastConfigChangedEventArgs.Key == "key2");
            Assert.That(_lastConfigChangedEventArgs.MultiObj.Count == 1);
            Assert.That(_lastConfigChangedEventArgs.MultiObj.Contains(this));
            Assert.That(_lastConfigChangedEventArgs.MultiPluginId.Count == 1);
            Assert.That(_lastConfigChangedEventArgs.MultiPluginId.Any((p) => { return(p == SharedDicTestContext.Plugins[0]); }));
            Assert.That(_lastConfigChangedEventArgs.Obj == this);
            Assert.That(_lastConfigChangedEventArgs.Status == ChangeStatus.Update);
            Assert.That((string)_lastConfigChangedEventArgs.Value == "NewValue2");

            _lastConfigChangedEventArgs = null;

            finalDic.GetOrSet("key2", "NewNewValue2");
            Assert.IsNull(_lastConfigChangedEventArgs);

            Assert.Throws <ArgumentNullException>(() => finalDic.GetOrSet <bool>("key2", true, null));
            finalDic.GetOrSet <bool>("key2", true, (o) => { return(true); });
            Assert.IsNotNull(_lastConfigChangedEventArgs);
            Assert.That(!_lastConfigChangedEventArgs.IsAllConcerned);
            Assert.That(_lastConfigChangedEventArgs.Key == "key2");
            Assert.That(_lastConfigChangedEventArgs.MultiObj.Count == 1);
            Assert.That(_lastConfigChangedEventArgs.MultiObj.Contains(this));
            Assert.That(_lastConfigChangedEventArgs.MultiPluginId.Count == 1);
            Assert.That(_lastConfigChangedEventArgs.MultiPluginId.Any((p) => { return(p == SharedDicTestContext.Plugins[0]); }));
            Assert.That(_lastConfigChangedEventArgs.Obj == this);
            Assert.That(_lastConfigChangedEventArgs.Status == ChangeStatus.Update);
            Assert.That((bool)_lastConfigChangedEventArgs.Value == true);
        }
Esempio n. 4
0
        internal PluginConfigAccessor(INamedVersionedUniqueId idEdited, IConfigManagerExtended cfg, object contextObject)
        {
            Debug.Assert(cfg != null);

            _idEdited        = idEdited;
            _configContainer = cfg.Container;

            _system  = _configContainer.GetObjectPluginConfig(cfg.ConfigManager.SystemConfiguration, _idEdited);
            _user    = _configContainer.GetObjectPluginConfig(cfg.ConfigManager.UserConfiguration, _idEdited);
            _context = _configContainer.GetObjectPluginConfig(contextObject, _idEdited);
        }
Esempio n. 5
0
        public bool Setup( IPluginSetupInfo info )
        {
            _obj = new object();

            Assert.That( Configuration != null );
            Assert.That( EditedConfiguration != null );

            _config = EditedConfiguration[this.SomeObject];
            UpdateEditedConfig( "testKey", "testValue" );

            return true;
        }
Esempio n. 6
0
        public bool Setup(IPluginSetupInfo info)
        {
            _obj = new object();

            Assert.That(Configuration != null);
            Assert.That(EditedConfiguration != null);

            _config = EditedConfiguration[this.SomeObject];
            UpdateEditedConfig("testKey", "testValue");

            return(true);
        }
Esempio n. 7
0
        public void FinalDicRemove()
        {
            IObjectPluginConfig finalDic = GetFinalDic(this, SharedDicTestContext.Plugins[0]);

            _dic.Add(this, SharedDicTestContext.Plugins[0], "key1", "value1");

            finalDic.Remove("key1");
            Assert.That(!_lastConfigChangedEventArgs.IsAllConcerned);
            Assert.That(_lastConfigChangedEventArgs.Key == "key1");
            Assert.That(_lastConfigChangedEventArgs.MultiObj.Count == 1);
            Assert.That(_lastConfigChangedEventArgs.MultiPluginId.Count == 1);
            Assert.That(_lastConfigChangedEventArgs.MultiPluginId.Any((p) => { return(p == SharedDicTestContext.Plugins[0]); }));
            Assert.That(_lastConfigChangedEventArgs.Obj == this);
            Assert.That(_lastConfigChangedEventArgs.Status == ChangeStatus.Delete);
            Assert.IsNull(_lastConfigChangedEventArgs.Value);
        }
        public SkinBasicConfigViewModel( AppViewModel app )
            : base(app.ConfigManager)
        {
            DisplayName = R.SkinBasicConfig;
            _app = app;
            _app.PluginRunner.PluginHost.StatusChanged += ( o, e ) =>
            {
                if( e.PluginProxy.PluginKey.PluginId == _skinId && _skinPlugin == null )
                {
                    _skinPlugin = _app.PluginRunner.PluginHost.FindLoadedPlugin( _skinId, true );
                    _config = _app.ConfigContainer.GetObjectPluginConfig( _app.CivikeyHost.Context.ConfigManager.UserConfiguration, _skinPlugin );
                }

                NotifyOfPropertyChange( () => ActivateSkin );
                NotifyOfPropertyChange( () => EnableAutoHide );
                NotifyOfPropertyChange( () => AutoHideTimeOut );
            };
        }
Esempio n. 9
0
        public void Start()
        {
            Assert.That( ServiceWrapped != null );
            Assert.That( ServiceWrapped.Status == RunningStatus.Started );

            IObjectPluginConfig config = Configuration[ServiceWrapped.Service.SomeObject];
            Assert.That( (string)config["testKey"] == "testValue" );

            string key = "newKey";
            object value = "newValue";

            ServiceWrapped.Service.UpdateEditedConfig( key, value );

            Assert.That( config[key] == value );

            ServiceWrapped.ServiceStatusChanged += ( o, e ) =>
            {
                _serviceHasBeenStopped = true;
            };
        }
Esempio n. 10
0
        public void FinalDicAdd()
        {
            IObjectPluginConfig finalDic = GetFinalDic(this, SharedDicTestContext.Plugins[0]);

            finalDic.Add("key1", "value1");
            Assert.IsNotNull(_lastConfigChangedEventArgs);
            Assert.IsNotNull(_lastSender);
            Assert.That(!_lastConfigChangedEventArgs.IsAllConcerned);
            Assert.That(_lastConfigChangedEventArgs.Key == "key1");
            Assert.That(_lastConfigChangedEventArgs.MultiObj.Count == 1);
            Assert.That(_lastConfigChangedEventArgs.MultiObj.Contains(this));
            Assert.That(_lastConfigChangedEventArgs.MultiPluginId.Count == 1);
            Assert.That(_lastConfigChangedEventArgs.MultiPluginId.Any((p) => { return(p == SharedDicTestContext.Plugins[0]); }));
            Assert.That(_lastConfigChangedEventArgs.Obj == this);
            Assert.That(_lastConfigChangedEventArgs.Status == ChangeStatus.Add);
            Assert.That((string)_lastConfigChangedEventArgs.Value == "value1");

            finalDic["key2"] = "value2";
            Assert.That(!_lastConfigChangedEventArgs.IsAllConcerned);
            Assert.That(_lastConfigChangedEventArgs.Key == "key2");
            Assert.That(_lastConfigChangedEventArgs.MultiObj.Count == 1);
            Assert.That(_lastConfigChangedEventArgs.MultiObj.Contains(this));
            Assert.That(_lastConfigChangedEventArgs.MultiPluginId.Count == 1);
            Assert.That(_lastConfigChangedEventArgs.MultiPluginId.Any((p) => { return(p == SharedDicTestContext.Plugins[0]); }));
            Assert.That(_lastConfigChangedEventArgs.Obj == this);
            Assert.That(_lastConfigChangedEventArgs.Status == ChangeStatus.Add);
            Assert.That((string)_lastConfigChangedEventArgs.Value == "value2");

            finalDic.GetOrSet("key3", "value3");
            Assert.That(!_lastConfigChangedEventArgs.IsAllConcerned);
            Assert.That(_lastConfigChangedEventArgs.Key == "key3");
            Assert.That(_lastConfigChangedEventArgs.MultiObj.Count == 1);
            Assert.That(_lastConfigChangedEventArgs.MultiObj.Contains(this));
            Assert.That(_lastConfigChangedEventArgs.MultiPluginId.Count == 1);
            Assert.That(_lastConfigChangedEventArgs.MultiPluginId.Any((p) => { return(p == SharedDicTestContext.Plugins[0]); }));
            Assert.That(_lastConfigChangedEventArgs.Obj == this);
            Assert.That(_lastConfigChangedEventArgs.Status == ChangeStatus.Add);
            Assert.That((string)_lastConfigChangedEventArgs.Value == "value3");
        }
 void InitializePlugin()
 {
     _skinPlugin = _app.PluginRunner.PluginHost.FindLoadedPlugin( _skinId, true );
     if( _skinPlugin != null ) _config = _app.ConfigContainer.GetObjectPluginConfig( _app.CivikeyHost.Context.ConfigManager.UserConfiguration, _skinPlugin );
 }
Esempio n. 12
0
        void InitializePlugin()
        {
            bool info = _pluginInfo == null;
            bool plugin = _plugin == null;

            _pluginInfo = _pluginInfo ?? _app.PluginRunner.Discoverer.FindPlugin( _editedPluginId );
            _plugin = _plugin ?? _app.PluginRunner.PluginHost.FindLoadedPlugin( _editedPluginId, true );

            if( _plugin != null )
            {
                _config = _app.ConfigContainer.GetObjectPluginConfig( _app.CivikeyHost.Context.ConfigManager.UserConfiguration, _plugin );
                Debug.Assert( _config != null );
            }

            if( info && _pluginInfo != null ) OnPluginDiscovered();
            if( plugin && _plugin != null ) OnPluginLoaded();

            NotifyOfPropertiesChange();
        }