private void SetInterpolatorSettings()
        {
            foreach (var interpolator in Driver.Interpolators)
            {
                interpolator.Dispose();
            }

            Driver.Interpolators.Clear();
            if (Settings.Interpolators != null)
            {
                foreach (var interpolatorName in Settings.Interpolators)
                {
                    var plugin = new PluginReference(interpolatorName);
                    var type   = plugin.GetTypeReference <Interpolator>();

                    var interpolator = plugin.Construct <Interpolator>(Platform.Timer);
                    foreach (var property in type.GetProperties())
                    {
                        if (property.GetCustomAttribute <PropertyAttribute>(false) != null &&
                            Settings.PluginSettings.TryGetValue(type.FullName + "." + property.Name, out var strValue))
                        {
                            var value = Convert.ChangeType(strValue, property.PropertyType);
                            property.SetValue(interpolator, value);
                        }
                    }

                    Driver.Interpolators.Add(interpolator);

                    Log.Write("Settings", $"Interpolator: {interpolator}");
                }
            }
        }
        private void SetToolSettings()
        {
            foreach (var runningTool in Tools)
            {
                runningTool.Dispose();
            }

            foreach (var toolName in Settings.Tools)
            {
                var plugin = new PluginReference(toolName);
                var type   = plugin.GetTypeReference <ITool>();

                var tool = plugin.Construct <ITool>();
                foreach (var property in type.GetProperties())
                {
                    if (property.GetCustomAttribute <PropertyAttribute>(false) != null &&
                        Settings.PluginSettings.TryGetValue(type.FullName + "." + property.Name, out var strValue))
                    {
                        var value = Convert.ChangeType(strValue, property.PropertyType);
                        property.SetValue(tool, value);
                    }
                }

                if (tool.Initialize())
                {
                    Tools.Add(tool);
                }
                else
                {
                    Log.Write("Tool", $"Failed to initialize {plugin.Name} tool.", LogLevel.Error);
                }
            }
        }
예제 #3
0
 public static IBinding GetBinding(string full)
 {
     if (!string.IsNullOrWhiteSpace(full))
     {
         var tokens    = full.Contains(", ") ? full.Split(", ", 2) : full.Split(": ", 2);
         var pluginRef = new PluginReference(tokens[0]);
         var binding   = pluginRef.Construct <IBinding>();
         if (binding != null)
         {
             binding.Property = tokens[1];
         }
         return(binding);
     }
     else
     {
         return(null);
     }
 }