Volume Control
Application-specific hotkeys for Windows
VolumeControl.Core.Input.TemplateProviderManager Class Reference

Manages ITemplateProvider & ITemplateDictionaryProvider instances to provide action settings with a suitable value editor DataTemplate. More...

Collaboration diagram for VolumeControl.Core.Input.TemplateProviderManager:

Public Types

enum class  FallbackMode {
  Never = 0 , OnNullTemplate = 1 , OnMissingKey = 2 , OnFailedProvider = 4 ,
  Always = OnNullTemplate | OnMissingKey | OnFailedProvider
}
 Defines the cases when the FindDataTemplateFor(Type?, string?, Type, FallbackMode) method will fall back to fall back to providers that weren't explicitly specified. More...
 

Public Member Functions

int IndexOfProviderType (Type providerType)
 Gets the index of the ITemplateProvider type specified by providerType in TemplateProviders. More...
 
int IndexOfDictionaryProviderType (Type dictionaryProviderType)
 Gets the index of the ITemplateDictionaryProvider type specified by dictionaryProviderType in DictionaryProviders. More...
 
bool TryGetProvider (Type providerType, out ITemplateProvider provider)
 Attempts to get the provider instance with the specified providerType . More...
 
bool TryGetDictionaryProvider (Type dictionaryProviderType, out ITemplateDictionaryProvider dictionaryProvider)
 Attempts to get the dictionaryProvider instance with the specified dictionaryProviderType . More...
 
DataTemplate? FindDataTemplate (string key)
 Finds the DataTemplate with the specified key in the TemplateDictionaryProviders list. More...
 
DataTemplate? FindDataTemplate (Type valueType)
 Finds the most recent DataTemplate instance that supports the specified valueType . More...
 
DataTemplate? FindDataTemplateFor (Type? providerType, string? templateKey, Type valueType, FallbackMode fallbackMode)
 Finds a suitable DataTemplate instance with the specified parameters. More...
 
DataTemplate? FindDataTemplateFor (Type? providerType, string? templateKey, Type valueType, bool allowFallbackOnMissingKey=false)
 Finds a suitable DataTemplate instance with the specified parameters. More...
 
ResourceDictionary[] GetProviderResourceDictionaries ()
 Gets all of the ResourceDictionary objects from the list of template dictionary providers. More...
 

Properties

IReadOnlyList< ITemplateProviderTemplateProviders [get]
 Gets the list of ITemplateProvider instances. More...
 
IReadOnlyList< ITemplateDictionaryProviderTemplateDictionaryProviders [get]
 Gets the list of ITemplateDictionaryProvider instances. More...
 
IReadOnlySet< Type > FailedTypes [get]
 Gets the list of types that failed to initialize for any reason.
If initialization of a provider type fails, it is added to this list and not attempted again. More...
 

Detailed Description

Manages ITemplateProvider & ITemplateDictionaryProvider instances to provide action settings with a suitable value editor DataTemplate.

Member Enumeration Documentation

◆ FallbackMode

Defines the cases when the FindDataTemplateFor(Type?, string?, Type, FallbackMode) method will fall back to fall back to providers that weren't explicitly specified.

Enumerator
Never 

Never fallback to templates that weren't specified.
Only searches all providers when no provider was specified.

It is recommended that OnNullTemplate is used instead of this, as some providers are designed to return null to fallback to other providers.

OnNullTemplate 

Fallback to other providers when the specified provider returned a null template.

OnMissingKey 

Fallback to other providers when the specified template key wasn't found.

OnFailedProvider 

Fallback to other providers when the specified provider failed to initialize.

Always 

Always fallback to other providers.

Member Function Documentation

◆ FindDataTemplate() [1/2]

DataTemplate? VolumeControl.Core.Input.TemplateProviderManager.FindDataTemplate ( string  key)

Finds the DataTemplate with the specified key in the TemplateDictionaryProviders list.

Parameters
keyThe key name of the target DataTemplate instance.
Returns
The ActionSettingDataTemplate instance with the specified key when found; otherwise null.

References VolumeControl.Log.FLog.FilterEventType(), VolumeControl.Core.Input.TemplateProviderManager.TemplateDictionaryProviders, and VolumeControl.Log.FLog.Trace().

Referenced by VolumeControl.Core.Input.TemplateProviderManager.FindDataTemplateFor().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FindDataTemplate() [2/2]

DataTemplate? VolumeControl.Core.Input.TemplateProviderManager.FindDataTemplate ( Type  valueType)

Finds the most recent DataTemplate instance that supports the specified valueType .

Parameters
valueTypeThe type of value displayed in the data template.
Returns
The most recently-added ActionSettingDataTemplate instance that supports valueType when found; otherwise null.

References VolumeControl.Log.FLog.FilterEventType(), VolumeControl.Core.Input.TemplateProviderManager.TemplateDictionaryProviders, VolumeControl.Core.Input.TemplateProviderManager.TemplateProviders, and VolumeControl.Log.FLog.Trace().

Here is the call graph for this function:

◆ FindDataTemplateFor() [1/2]

DataTemplate? VolumeControl.Core.Input.TemplateProviderManager.FindDataTemplateFor ( Type?  providerType,
string?  templateKey,
Type  valueType,
bool  allowFallbackOnMissingKey = false 
)

Finds a suitable DataTemplate instance with the specified parameters.

Parameters
providerTypeOptional type that implements
templateKeyOptional key for a specific ActionSettingDataTemplate instance in a ITemplateDictionaryProvider.
When providerType is null
valueTypeThe type of value that will be displayed in the DataTemplate.
allowFallbackOnMissingKeyWhen true & templateKey wasn't found and isn't null, fallback to searching all dictionaries for a DataTemplate that supports the specified valueType instead of returning null.
Returns
DataTemplate instance for the specified parameters when successful; otherwise null.
Exceptions
InvalidProviderTypeExceptionproviderType does not implement ITemplateProvider or ITemplateDictionaryProvider.
ArgumentNullExceptionvalueType was null and the providerType and templateKey didn't resolve to a valid template.

References VolumeControl.Log.FLog.Debug(), VolumeControl.Log.FLog.Error(), VolumeControl.Core.Input.TemplateProviderManager.FailedTypes, VolumeControl.Log.FLog.FilterEventType(), VolumeControl.Core.Input.TemplateProviderManager.FindDataTemplate(), VolumeControl.Log.FLog.Trace(), VolumeControl.Core.Input.TemplateProviderManager.TryGetDictionaryProvider(), VolumeControl.Core.Input.TemplateProviderManager.TryGetProvider(), and VolumeControl.Log.FLog.Warning().

Here is the call graph for this function:

◆ FindDataTemplateFor() [2/2]

DataTemplate? VolumeControl.Core.Input.TemplateProviderManager.FindDataTemplateFor ( Type?  providerType,
string?  templateKey,
Type  valueType,
FallbackMode  fallbackMode 
)

Finds a suitable DataTemplate instance with the specified parameters.

Parameters
providerTypeOptional type that implements
templateKeyOptional key for a specific ActionSettingDataTemplate instance in a ITemplateDictionaryProvider.
When providerType is null
valueTypeThe type of value that will be displayed in the DataTemplate.
fallbackModeThe FallbackMode to use when searching for a template.
Returns
DataTemplate instance for the specified parameters when successful; otherwise null.
Exceptions
InvalidProviderTypeExceptionproviderType does not implement ITemplateProvider or ITemplateDictionaryProvider.
ArgumentNullExceptionvalueType was null and the providerType and templateKey didn't resolve to a valid template.

References VolumeControl.Log.FLog.Debug(), VolumeControl.Log.FLog.Error(), VolumeControl.Core.Input.TemplateProviderManager.FailedTypes, VolumeControl.Log.FLog.FilterEventType(), VolumeControl.Core.Input.TemplateProviderManager.FindDataTemplate(), VolumeControl.Log.FLog.Trace(), VolumeControl.Core.Input.TemplateProviderManager.TryGetDictionaryProvider(), VolumeControl.Core.Input.TemplateProviderManager.TryGetProvider(), and VolumeControl.Log.FLog.Warning().

Referenced by VolumeControl.Core.Input.HotkeyActionAddonLoader.LoadActions().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetProviderResourceDictionaries()

ResourceDictionary [] VolumeControl.Core.Input.TemplateProviderManager.GetProviderResourceDictionaries ( )

Gets all of the ResourceDictionary objects from the list of template dictionary providers.

Not all ITemplateDictionaryProvider instances are derived from ResourceDictionary, so the number of returned objects may be different.

Returns
An array of all of the loaded ResourceDictionary objects.

References VolumeControl.Core.Input.TemplateProviderManager.TemplateDictionaryProviders.

◆ IndexOfDictionaryProviderType()

int VolumeControl.Core.Input.TemplateProviderManager.IndexOfDictionaryProviderType ( Type  dictionaryProviderType)

Gets the index of the ITemplateDictionaryProvider type specified by dictionaryProviderType in DictionaryProviders.

Parameters
dictionaryProviderTypeA type that implements ITemplateDictionaryProvider.
Returns
The index of the dictionary provider with the specified dictionaryProviderType if found; otherwise -1.
Exceptions
InvalidProviderTypeExceptiondictionaryProviderType does not implement ITemplateDictionaryProvider.

References VolumeControl.Core.Input.TemplateProviderManager.TemplateDictionaryProviders.

Referenced by VolumeControl.Core.Input.TemplateProviderManager.TryGetDictionaryProvider().

Here is the caller graph for this function:

◆ IndexOfProviderType()

int VolumeControl.Core.Input.TemplateProviderManager.IndexOfProviderType ( Type  providerType)

Gets the index of the ITemplateProvider type specified by providerType in TemplateProviders.

Parameters
providerTypeA type that implements ITemplateProvider.
Returns
The index of the provider with the specified providerType if found; otherwise -1.
Exceptions
InvalidProviderTypeExceptionproviderType does not implement ITemplateProvider.

References VolumeControl.Core.Input.TemplateProviderManager.TemplateProviders.

Referenced by VolumeControl.Core.Input.TemplateProviderManager.TryGetProvider().

Here is the caller graph for this function:

◆ TryGetDictionaryProvider()

bool VolumeControl.Core.Input.TemplateProviderManager.TryGetDictionaryProvider ( Type  dictionaryProviderType,
out ITemplateDictionaryProvider  dictionaryProvider 
)

Attempts to get the dictionaryProvider instance with the specified dictionaryProviderType .

If no provider was found, a new instance is created. This method can fail if the provider initializer fails.

Parameters
dictionaryProviderTypeA type that implements ITemplateDictionaryProvider.
dictionaryProviderThe requested ITemplateDictionaryProvider instance when successful; otherwise null.
Returns
true when successful and dictionaryProvider is not null; false when the provider failed.
Exceptions
InvalidProviderTypeExceptiondictionaryProviderType does not implement ITemplateDictionaryProvider.

References VolumeControl.Log.LogMessage.Add(), VolumeControl.Log.FLog.Debug(), VolumeControl.Core.Input.TemplateProviderManager.FailedTypes, VolumeControl.Log.FLog.FilterEventType(), VolumeControl.Core.Input.TemplateProviderManager.IndexOfDictionaryProviderType(), VolumeControl.Log.LogMessage.Lines, VolumeControl.Log.FLog.LogMessage(), VolumeControl.Core.Input.TemplateProviderManager.TemplateDictionaryProviders, and VolumeControl.Log.FLog.Warning().

Referenced by VolumeControl.Core.Input.TemplateProviderManager.FindDataTemplateFor().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TryGetProvider()

bool VolumeControl.Core.Input.TemplateProviderManager.TryGetProvider ( Type  providerType,
out ITemplateProvider  provider 
)

Attempts to get the provider instance with the specified providerType .

If no provider was found, a new instance is created. This method can fail if the provider initializer fails.

Parameters
providerTypeA type that implements ITemplateProvider.
providerThe requested ITemplateProvider instance when successful; otherwise null.
Returns
true when successful and provider is not null; false when the provider failed.
Exceptions
InvalidProviderTypeExceptionproviderType does not implement ITemplateProvider.

References VolumeControl.Core.Input.TemplateProviderManager.FailedTypes, VolumeControl.Core.Input.TemplateProviderManager.IndexOfProviderType(), and VolumeControl.Core.Input.TemplateProviderManager.TemplateProviders.

Referenced by VolumeControl.Core.Input.TemplateProviderManager.FindDataTemplateFor().

Here is the call graph for this function:
Here is the caller graph for this function:

Property Documentation

◆ FailedTypes

IReadOnlySet<Type> VolumeControl.Core.Input.TemplateProviderManager.FailedTypes
get

Gets the list of types that failed to initialize for any reason.
If initialization of a provider type fails, it is added to this list and not attempted again.

Referenced by VolumeControl.Core.Input.TemplateProviderManager.FindDataTemplateFor(), VolumeControl.Core.Input.TemplateProviderManager.TryGetDictionaryProvider(), and VolumeControl.Core.Input.TemplateProviderManager.TryGetProvider().

◆ TemplateDictionaryProviders

◆ TemplateProviders


The documentation for this class was generated from the following file: