예제 #1
0
    /// <summary>
    /// Searches for the application configuration corresponding to the current
    /// executing application
    /// </summary>
    private IApplicationConfig FindThisApplication()
    {
        var configurations = ApplicationConfig.GetAllApplications(LoaderConfig.GetApplicationConfigDirectory());
        var fullPath       = NormalizePath(Environment.CurrentProcessLocation.Value);

        Logger.LogWriteLineAsync($"Current Process Location: {fullPath}");

        foreach (var configuration in configurations)
        {
            var application = configuration.Config;
            var appLocation = ApplicationConfig.GetAbsoluteAppLocation(configuration);

            if (string.IsNullOrEmpty(appLocation))
            {
                continue;
            }

            var fullAppLocation = NormalizePath(appLocation);
            if (fullAppLocation.Equals(fullPath, StringComparison.OrdinalIgnoreCase))
            {
                return(application);
            }
        }

        return(null);
    }
 /// <summary>
 /// Creates the service instance given an instance of the configuration.
 /// </summary>
 /// <param name="config">Mod loader config.</param>
 /// <param name="context">Context to which background events should be synchronized.</param>
 public ApplicationConfigService(LoaderConfig config, SynchronizationContext context = null)
 {
     Initialize(config.GetApplicationConfigDirectory(), ApplicationConfig.ConfigFileName, GetAllConfigs, context);
 }
    /* Make LoaderConfig for Testing */
    public static LoaderConfig MakeTestConfig()
    {
        var config = new LoaderConfig();

        config.ApplicationConfigDirectory = IfNotExistsMakeDefaultDirectoryAndReturnFullPath(config.GetApplicationConfigDirectory(), "Apps");
        config.ModConfigDirectory         = IfNotExistsMakeDefaultDirectoryAndReturnFullPath(config.GetModConfigDirectory(), "Mods");
        config.PluginConfigDirectory      = IfNotExistsMakeDefaultDirectoryAndReturnFullPath(config.GetPluginConfigDirectory(), "Plugins");
        config.ModUserConfigDirectory     = IfNotExistsMakeDefaultDirectoryAndReturnFullPath(config.GetModUserConfigDirectory(), "UserConfigs");
        config.EnabledPlugins             = EmptyArray <string> .Instance;
        return(config);
    }