Exemplo n.º 1
0
        public void TryLoadAdditionalOptionsFromAssemblyDir <T>(
            string pluginName, Assembly assy = null,
            JsonSerializerSettings settings  = null,
            LogInstance log = null) where T : AasxPluginOptionsBase
        {
            // expand assy?
            if (assy == null)
            {
                assy = Assembly.GetExecutingAssembly();
            }
            if (pluginName == null || pluginName == "")
            {
                return;
            }

            // build dir name
            var baseDir = System.IO.Path.GetDirectoryName(assy.Location);

            // search
            var files = Directory.GetFiles(baseDir, "*.add-options.json");

            foreach (var fn in files)
            {
                try
                {
                    var optText = File.ReadAllText(fn);
                    var opts    = Newtonsoft.Json.JsonConvert.DeserializeObject <T>(optText, settings);
                    this.Merge(opts);
                }
                catch (Exception ex)
                {
                    log?.Error(ex, $"loading additional options (${fn})");
                }
            }
        }
Exemplo n.º 2
0
 public ApplicationMessageDlg(LogInstance logger)
 {
     this.logger = logger;
 }