Class PackageConfigurationHelper
- Namespace
- Datamine.MineTrustConnector.Core
- Assembly
- Datamine.MineTrustConnector.Core.dll
Utility class providing operations for management of PackageConfiguration instances on the local machine. Provides high-level operations for location, loading and saving of instances, as well as some common business layer meanings (i.e. server configurations, archived & deleted configurations etc.)
public static class PackageConfigurationHelper
- Inheritance
-
PackageConfigurationHelper
- Inherited Members
Methods
Find(Func<PackageConfiguration, bool>, MTConnectorProfile?, bool)
Finds all available instances of
PackageConfiguration for which the specified
predicate evaluates to
true.
public static IEnumerable<PackageConfiguration> Find(Func<PackageConfiguration, bool> predicate, MTConnectorProfile? profile = null, bool suppressErrors = false)
Parameters
predicateFunc<PackageConfiguration, bool>-
The predicate.
profileMTConnectorProfile-
The user profile used to resolve the MineTrust endpoint. Defaults to current user
suppressErrorsbool-
if set to
trueskips any package configurations which resulted in a load error.
Returns
- IEnumerable<PackageConfiguration>
-
All matching PackageConfiguration instances
Find(string, string, bool, MTConnectorProfile?, bool)
Finds all available instances of
PackageConfiguration for whom the specified
jsonPath evaluates to the
testValue provided
(compared as strings, case-insensitively). Optionally
invert the truth result for each instance by specifying
the negate switch.
public static IEnumerable<PackageConfiguration> Find(string jsonPath, string testValue, bool negate = false, MTConnectorProfile? profile = null, bool suppressErrors = false)
Parameters
jsonPathstring-
The json path.
testValuestring-
The test value.
negatebool-
if set to
true[negate]. profileMTConnectorProfile-
The user profile used to resolve the MineTrust endpoint. Defaults to current user
suppressErrorsbool-
if set to
trueskips any package configurations which resulted in a load error.
Returns
- IEnumerable<PackageConfiguration>
-
All matching PackageConfiguration instances
FindItems(IDictionary<string, string>)
Finds all available instances of
IncludeConfiguration for which the specified
tagCriteria are met. An
instance of
IncludeConfiguration fails to meet the tag criteria,
either if it does not have any tags present, or if any of
the tag names specified don't match the corresponding
value, or are missing.
[Obsolete("Use TagsHelper instead")]
public static IEnumerable<IncludeConfiguration> FindItems(IDictionary<string, string> tagCriteria)
Parameters
tagCriteriaIDictionary<string, string>-
The tag criteria.
Returns
- IEnumerable<IncludeConfiguration>
-
All matching IncludeConfiguration instances
FindItems(Func<IncludeConfiguration, bool>)
Finds all available instances of
IncludeConfiguration for which the specified
predicate evaluates to
true.
[Obsolete("Use TagsHelper instead")]
public static IEnumerable<IncludeConfiguration> FindItems(Func<IncludeConfiguration, bool> predicate)
Parameters
predicateFunc<IncludeConfiguration, bool>-
The predicate.
Returns
- IEnumerable<IncludeConfiguration>
-
All matching IncludeConfiguration instances
FindItems(string, string)
Finds all available instances of
IncludeConfiguration for which the tag with name
tagName matches the
specified value tagValue.
[Obsolete("Use TagsHelper instead")]
public static IEnumerable<IncludeConfiguration> FindItems(string tagName, string tagValue)
Parameters
Returns
- IEnumerable<IncludeConfiguration>
-
All matching IncludeConfiguration instances
GetArchivedPackages(string?, MTConnectorProfile?)
Returns an enumeration of all the package UIDs which have previously been marked as archived within MineTrust. Caller can optionally specify the destination MineTrust endpoint.
public static IEnumerable<string> GetArchivedPackages(string? serviceUID = null, MTConnectorProfile? profile = null)
Parameters
serviceUIDstring-
The service UID of the MineTrust endpoint.
profileMTConnectorProfile-
The user profile used to resolve the MineTrust endpoint. Defaults to current user
Returns
- IEnumerable<string>
-
The archived package UIDs
GetDeletedPackages(string?, MTConnectorProfile?)
Returns an enumeration of all the package UIDs which have previously been marked as deleted within MineTrust. Caller can optionally specify the destination MineTrust endpoint.
public static IEnumerable<string> GetDeletedPackages(string? serviceUID = null, MTConnectorProfile? profile = null)
Parameters
serviceUIDstring-
The service UID of the MineTrust endpoint.
profileMTConnectorProfile-
The user profile used to resolve the MineTrust endpoint. Defaults to current user
Returns
- IEnumerable<string>
-
The deleted package UIDs
GetPackageMetrics(string?)
Gets the metrics for the specified package. Package metrics are defined whenever a package's contents are deterministic (i.e. non-empty Include list and no wildcards). For packages in which metrics are not defined, the default metrics instance is entirely populated by -1.
public static PackageMetrics GetPackageMetrics(string? jsonFileOrPackageUID)
Parameters
jsonFileOrPackageUIDstring-
The json file or package uid.
Returns
- PackageMetrics
-
The package metrics
GetServerConfigurationFor(string?, MTConnectorProfile?, bool)
Gets the server configuration for the specified endpoint.
public static PackageConfiguration? GetServerConfigurationFor(string? serverUrl, MTConnectorProfile? profile = null, bool suppressErrors = false)
Parameters
serverUrlstring-
The server URL.
profileMTConnectorProfile-
The user profile used to resolve the MineTrust endpoint. Defaults to current user
suppressErrorsbool-
if set to
trueskips any package configurations which resulted in a load error.
Returns
- PackageConfiguration
-
The server configuration, if it exists.
GetServerConfigurations(MTConnectorProfile?, bool)
Gets the package configurations on disk which correspond to server configurations. These are precisely those whose package UID matches the subfolder name.
public static IEnumerable<PackageConfiguration> GetServerConfigurations(MTConnectorProfile? profile = null, bool suppressErrors = false)
Parameters
profileMTConnectorProfile-
The user profile used to resolve the MineTrust endpoint. Defaults to current user
suppressErrorsbool-
if set to
trueskips any package configurations which resulted in a load error.
Returns
- IEnumerable<PackageConfiguration>
-
The server configurations
GetShellExtensionName()
Gets the name of the MineTrust Connector Shell extension, as it appears installed on the local machine. If the current environment is non-Windows then null is returned.
public static string? GetShellExtensionName()
Returns
- string
-
The name of the installed shell extension
IsServerConfiguration(PackageConfiguration)
Determines whether or not thte specified PackageConfiguration is actually a server configuration.
public static bool IsServerConfiguration(PackageConfiguration packageConfiguration)
Parameters
packageConfigurationPackageConfiguration-
The package configuration.
Returns
- bool
-
trueif [is server configuration] [the specified package configuration]; otherwise,false.
Load(string?, bool)
Loads the specified package as a PackageConfiguration
public static PackageConfiguration? Load(string? jsonFileOrPackageUID, bool suppressErrors = false)
Parameters
jsonFileOrPackageUIDstring-
The path to the JSON file, or the package UID.
suppressErrorsbool-
if set to
true[suppress errors].
Returns
- PackageConfiguration
-
The package configuration
Exceptions
- FileNotFoundException
-
Package configuration file '{jsonFileOrPackageUID}' was not found
- Exception
-
Failed to read package configuration from '{jsonFileOrPackageUID}'
Refresh(PackageConfiguration, bool)
Refreshes the specified configuration from its
location on disk. Optionally suppresses errors and
returns a 'false' return value if the refresh operation
failed (for example if the file is no longer on disk, or
if the read operation encountered an error). Note that
errors suppressed do not include passing
null in the first argument - which would
always indicate incorrect usage.
public static bool Refresh(PackageConfiguration configuration, bool suppressErrors = false)
Parameters
configurationPackageConfiguration-
The configuration.
suppressErrorsbool-
if set to
true[suppress errors].
Returns
- bool
-
Whether or not the operation was successful
Exceptions
- Exception
-
$"Package configuration path is null
- FileNotFoundException
-
$"Package configuration file '{configuration.FilePath}' was not found, configuration.FilePath
- ArgumentNullException
- Exception
-
Package configuration path is null
- FileNotFoundException
-
Package configuration file '{configuration.FilePath}' was not found
Save(PackageConfiguration)
Saves the specified package configuration to disk
public static void Save(PackageConfiguration packageConfiguration)
Parameters
packageConfigurationPackageConfiguration-
The package configuration.
Exceptions
- ArgumentNullException
- Exception
-
Package configuration path is null
