Beispiel #1
0
            /// <summary>
            /// Removes a configuration for plugin or a service.
            /// </summary>
            /// <param name="serviceOrPluginFullName">The identifier.</param>
            /// <returns>Detailed result of the operation.</returns>
            public IYodiiEngineResult Remove(string serviceOrPluginFullName)
            {
                if (String.IsNullOrEmpty(serviceOrPluginFullName))
                {
                    throw new ArgumentException("serviceOrPluginFullName is null or empty");
                }

                ConfigurationItem target = _items.GetByKey(serviceOrPluginFullName);

                if (target != null)
                {
                    if (_layer._owner == null)
                    {
                        target.OnRemoved();
                        _items.Remove(target);
                        return(SuccessYodiiEngineResult.NullEngineSuccessResult);
                    }

                    IYodiiEngineResult result = _layer._owner.OnConfigurationItemRemoving(target);
                    if (result.Success)
                    {
                        target.OnRemoved();
                        _items.Remove(target);
                        _layer._owner.OnConfigurationChanged();
                        return(result);
                    }
                    return(result);
                }
                return(new YodiiEngineResult(new ConfigurationFailureResult("Item not found"), _layer._owner != null ? _layer._owner.Engine : null));
            }
Beispiel #2
0
            public IYodiiEngineResult Add(string serviceOrPluginFullName, ConfigurationStatus status, string statusReason = "", StartDependencyImpact impact = StartDependencyImpact.Unknown)
            {
                if (String.IsNullOrEmpty(serviceOrPluginFullName))
                {
                    throw new ArgumentException("serviceOrPluginFullName is null or empty");
                }

                ConfigurationItem existing = _items.GetByKey(serviceOrPluginFullName);

                if (existing != null)
                {
                    IYodiiEngineResult res = existing.SetStatus(status);
                    if (res.Success)
                    {
                        return(existing.SetImpact(impact));
                    }
                    return(res);
                }

                ConfigurationItem newItem = new ConfigurationItem(_layer, serviceOrPluginFullName, status, impact, statusReason);

                if (_layer._owner == null)
                {
                    _items.Add(newItem);
                    return(SuccessYodiiEngineResult.NullEngineSuccessResult);
                }

                IYodiiEngineResult result = _layer._owner.OnConfigurationItemAdding(newItem);

                if (result.Success)
                {
                    _items.Add(newItem);
                    _layer._owner.OnConfigurationChanged();
                    return(result);
                }
                newItem.OnRemoved();
                return(result);
            }