public IOptionLoader GetLoader(IOptionProvider provider) { if (provider == null) { return(null); } IOptionLoader loader; var providerType = provider.GetType(); if (_loaders.TryGetValue(providerType, out loader) && loader != null) { return(loader); } var attribute = (OptionLoaderAttribute)Attribute.GetCustomAttribute(providerType, typeof(OptionLoaderAttribute), true); if (attribute != null && attribute.LoaderType != null) { loader = this.CreateLoader(attribute.LoaderType); if (loader != null) { if (_loaders.TryAdd(providerType, loader)) { return(loader); } return(_loaders[providerType]); } } return(null); }
public SlackRequestHandler( IEventHandler eventHandler, IAsyncBlockActionHandler blockActionHandler, IBlockOptionProvider blockOptionProvider, IInteractiveMessageHandler interactiveMessageHandler, IAsyncMessageShortcutHandler messageShortcutHandler, IAsyncGlobalShortcutHandler globalShortcutHandler, IOptionProvider optionProvider, IDialogSubmissionHandler dialogSubmissionHandler, IAsyncViewSubmissionHandler viewSubmissionHandler, IAsyncSlashCommandHandler slashCommandHandler, SlackJsonSettings jsonSettings) { _eventHandler = eventHandler; _blockActionHandler = blockActionHandler; _blockOptionProvider = blockOptionProvider; _interactiveMessageHandler = interactiveMessageHandler; _messageShortcutHandler = messageShortcutHandler; _globalShortcutHandler = globalShortcutHandler; _optionProvider = optionProvider; _dialogSubmissionHandler = dialogSubmissionHandler; _viewSubmissionHandler = viewSubmissionHandler; _slashCommandHandler = slashCommandHandler; _jsonSettings = jsonSettings; }
public CommandProvider(IOptionProvider optionProvider, AbstractSwitch projectSwitch, AbstractSwitch packageSwitch, AbstractSwitch librarySwitch) { _optionProvider = optionProvider; _projectSwitch = projectSwitch; _packageSwitch = packageSwitch; _librarySwitch = librarySwitch; }
protected AbstractSwitch(ReferenceType type, IOptionProvider optionProvider, IProjectProvider projectProvider, IMessageProvider messageProvider) { Type = type; OptionProvider = optionProvider; ProjectProvider = projectProvider; MessageProvider = messageProvider; }
public Option(OptionNode node, IOptionProvider provider, IOptionViewBuilder viewBuilder) { _node = node ?? throw new ArgumentNullException(nameof(node)); _providers = new List <IOptionProvider>() { provider }; _viewBuilder = viewBuilder; _isDirty = false; }
private void Initialize(OptionNode node, IOptionProvider provider, IOptionView view, IOptionViewBuilder viewBuilder) { if(node == null) throw new ArgumentNullException("node"); _node = node; _provider = provider; _view = view; _viewBuilder = viewBuilder; _isDirty = false; }
private void Initialize(OptionNode node, IOptionProvider provider, IOptionView view, IOptionViewBuilder viewBuilder) { if (node == null) { throw new ArgumentNullException("node"); } _node = node; _provider = provider; _view = view; _viewBuilder = viewBuilder; _isDirty = false; }
public override void Load(IOptionProvider provider) { var proxy = provider as ConfigurationProxy; if (proxy != null) { base.LoadConfiguration(proxy.Value); } else { base.Load(provider); } }
public static void SetOptionObject <T>(this IOptionProvider optionProvider, object optionObject) where T : class { if (optionProvider == null) { throw new ArgumentNullException("optionProvider"); } string path = GetOptionPath(typeof(T)); if (string.IsNullOrWhiteSpace(path)) { throw new InvalidOperationException(string.Format("Invalid generic type '{0}'.", typeof(T).AssemblyQualifiedName)); } optionProvider.SetOptionObject(path, optionObject); }
public OptionNode Add(string name, IOptionProvider provider, string title = null, string description = null) { if (string.IsNullOrWhiteSpace(name)) { throw new ArgumentNullException("name"); } OptionNode node = new OptionNode(name, title, description); if (provider != null) { node.Option = new Option(node, provider); } this.Add(node); return(node); }
public override object Build(BuilderContext context) { Builtin builtin = context.Builtin; IOptionProvider provider = null; string providerValue = builtin.Properties.GetRawValue("provider"); var node = new OptionNode(builtin.Name, builtin.Properties.GetValue <string>("title"), builtin.Properties.GetValue <string>("description")); if (string.IsNullOrWhiteSpace(providerValue)) { return(node); } switch (providerValue.Trim().ToLower()) { case ".": case "plugin": provider = OptionUtility.GetConfiguration(builtin.Plugin); break; case "/": case "application": provider = context.PluginContext.ApplicationContext.Configuration; break; default: provider = builtin.Properties.GetValue <IOptionProvider>("provider"); break; } if (provider == null) { throw new PluginException(string.Format("Cann't obtain OptionProvider with '{0}'.", providerValue)); } node.Option = new Option(node, provider) { View = context.Builtin.Properties.GetValue <IOptionView>("view"), ViewBuilder = context.Builtin.Properties.GetValue <IOptionViewBuilder>("viewBuilder"), }; return(node); }
public static T GetOptionObject <T>(this IOptionProvider optionProvider) where T : class { if (optionProvider == null) { throw new ArgumentNullException("optionProvider"); } string path = GetOptionPath(typeof(T)); if (string.IsNullOrWhiteSpace(path)) { return(default(T)); } else { return(optionProvider.GetOptionObject(path) as T); } }
private void FillView3DOptions(IEnumerable <string> optionNames, ICollection <IOptionProvider> options) { foreach (PropertyDescriptor item in System.ComponentModel.TypeDescriptor.GetProperties(view3DX, new Attribute[] { new PropertyFilterAttribute(PropertyFilterOptions.All) })) { var dpp = DependencyPropertyDescriptor.FromProperty(item); //if ((dpp != null) && dpp.PropertyType.IsEnum && !dpp.IsReadOnly) if ((dpp != null) && optionNames.Any(s => string.Compare(s, dpp.Name) == 0)) { var tOption = typeof(EnumOptionProvider <>); Type[] tArgs = { dpp.PropertyType }; var tCostructed = tOption.MakeGenericType(tArgs); IOptionProvider instance = Activator.CreateInstance(tCostructed) as IOptionProvider; var binding = new Binding("Value"); instance.Name = dpp.Name; binding.Source = instance; view3DX.SetBinding(dpp.DependencyProperty, binding); options.Add(instance); } } }
private bool EnsureLoadProviders() { if (_unloadedProviders == null || _unloadedProviders.Count < 1) { return(false); } var loaderSelector = this.LoaderSelector; if (loaderSelector == null) { return(false); } var providers = new IOptionProvider[_unloadedProviders.Count]; _unloadedProviders.CopyTo(providers); _unloadedProviders.Clear(); foreach (var provider in providers) { if (provider == null) { continue; } var loader = loaderSelector.GetLoader(provider); if (loader != null) { loader.Load(provider); } } return(true); }
public LibrarySwitch(ReferenceType type, IOptionProvider optionProvider, IProjectProvider projectHelper, IMessageProvider messageHelper) : base(type, optionProvider, projectHelper, messageHelper) { }
public OptionsCommand(string name) : base(name) { _options = Zongsoft.Services.ApplicationContext.Current.Options; }
public Option(OptionNode node, IOptionProvider provider, IOptionViewBuilder viewBuilder) { this.Initialize(node, provider, null, viewBuilder); }
public Option(OptionNode node, IOptionProvider provider, IOptionView view) { this.Initialize(node, provider, view, null); }
public Option(OptionNode node, IOptionProvider provider) { this.Initialize(node, provider, null, null); }
public TConfig RegisterOptionProvider(string actionName, IOptionProvider provider) => Chain(() => AddLegacyOptionProvider(actionName, provider));
public VsixPackageOption() { OptionProvider = (IOptionProvider)Package.GetGlobalService(typeof(IOptionProvider)); }
public void SetProvider(string actionName, IOptionProvider provider) => _providers[actionName] = provider;
public InvitationController(IOptionProvider optionProvider, IEmailProvider emailProvider) { _optionProvider = optionProvider; _emailProvier = emailProvider; }
public void SetProvider(string actionName, IOptionProvider handler) => _options.SetProvider(actionName, handler);
public OptionsCommand() : base("Options") { _options = Zongsoft.Services.ApplicationContext.Current.Options; }
protected override void AddLegacyOptionProvider(string actionName, IOptionProvider provider) => AddKeyedHandler(actionName, provider);
public ApprovementController(IOptionProvider optionProvider, IEmailProvider emailProvider) { _optionProvider = optionProvider; _emailProvier = emailProvider; }
protected abstract void AddLegacyOptionProvider(string actionName, IOptionProvider provider);
public IOptionLoader GetLoader(IOptionProvider provider) { if(provider == null) return null; IOptionLoader loader; var providerType = provider.GetType(); if(_loaders.TryGetValue(providerType, out loader) && loader != null) return loader; var attribute = (OptionLoaderAttribute)Attribute.GetCustomAttribute(providerType, typeof(OptionLoaderAttribute), true); if(attribute != null && attribute.LoaderType != null) { loader = this.CreateLoader(attribute.LoaderType); if(loader != null) { if(_loaders.TryAdd(providerType, loader)) return loader; return _loaders[providerType]; } } return null; }
public Option(OptionNode node, IOptionProvider provider) : this(node, provider, (IOptionView)null) { }
public virtual void Unload(IOptionProvider provider) { this.UnloadConfiguration(provider as OptionConfiguration); }
private bool EnsureLoadProviders() { if(_unloadedProviders == null || _unloadedProviders.Count < 1) return false; var loaderSelector = this.LoaderSelector; if(loaderSelector == null) return false; var providers = new IOptionProvider[_unloadedProviders.Count]; _unloadedProviders.CopyTo(providers); _unloadedProviders.Clear(); foreach(var provider in providers) { if(provider == null) continue; var loader = loaderSelector.GetLoader(provider); if(loader != null) loader.Load(provider); } return true; }