예제 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PersistencePluginProxy"/> class.
        /// </summary>
        /// <param name="config">The configuration used to configure the proxy.</param>
        /// <exception cref="ArgumentException">
        /// This exception is thrown when configuration is undefined for the plugin
        /// or an unknown plugin type is defined.
        /// </exception>
        public PersistencePluginProxy(Config config)
        {
            _config = config;
            var pluginId = Self.Path.Name;

            if (pluginId.Equals("akka.persistence.journal.proxy"))
            {
                _pluginType = new Journal();
            }
            else if (pluginId.Equals("akka.persistence.snapshot-store.proxy"))
            {
                _pluginType = new SnapshotStore();
            }
            else
            {
                throw new ArgumentException($"Unknown plugin type: {pluginId}.");
            }
            _initTimeout = config.GetTimeSpan("init-timeout", null);
            var key = "target-" + _pluginType.Qualifier + "-plugin";

            _targetPluginId = config.GetString(key, null);
            if (string.IsNullOrEmpty(_targetPluginId))
            {
                throw new ArgumentException($"{pluginId}.{key} must be defined.");
            }
            _startTarget = config.GetBoolean("start-target-" + _pluginType.Qualifier, false);

            _selfAddress = ((ExtendedActorSystem)Context.System).Provider.DefaultAddress;
        }
예제 #2
0
        public void Should_return_plugin_instances_that_apply_to_context()
        {
            var plugin1a = new Plugin1a();
            var plugin1b = new Plugin1b();
            var plugin2  = new Plugin2();
            var plugin3  = new Plugin3();
            var plugin4  = new Plugin4();

            var instances = new IPluginType[] { plugin1a, plugin1b, plugin2, plugin3, plugin4 };

            var plugins = new ConditionalPlugins <IPluginType, Context>(false)
                          .Configure(x => x
                                     .Append <Plugin1a>(c => c.Value == 1)
                                     .Append <Plugin1b>(c => c.Value == 1)
                                     .Append <Plugin2>(c => c.Value == 2)
                                     .Append <Plugin3>());

            var apply = plugins.ThatApplyTo(instances, new Context {
                Value = 1
            }).ToList();

            apply.Count.ShouldEqual(3);
            apply[0].Instance.ShouldEqual(plugin1a);
            apply[1].Instance.ShouldEqual(plugin1b);
            apply[2].Instance.ShouldEqual(plugin3);

            apply = plugins.ThatApplyTo(instances, new Context {
                Value = 2
            }).ToList();

            apply.Count.ShouldEqual(2);
            apply[0].Instance.ShouldEqual(plugin2);
            apply[1].Instance.ShouldEqual(plugin3);
        }
예제 #3
0
 /// <summary>
 ///   A simple constructor that initializes the values of the object.
 /// </summary>
 /// <param name="p_strName">The name of the plugin.</param>
 /// <param name="p_strDesc">The description of the plugin.</param>
 /// <param name="p_imgImage">The plugin image.</param>
 /// <param name="p_ptpType">The <see cref="PluginType" /> of the plugin.</param>
 public PluginInfo(string p_strName, string p_strDesc, Image p_imgImage, IPluginType p_ptpType)
 {
   Name = p_strName;
   Files = new List<PluginFile>();
   Flags = new List<ConditionalFlag>();
   m_ptpType = p_ptpType;
   Description = p_strDesc;
   Image = p_imgImage;
 }
예제 #4
0
파일: PluginInfo.cs 프로젝트: vjmira/fomm
 /// <summary>
 ///   A simple constructor that initializes the values of the object.
 /// </summary>
 /// <param name="p_strName">The name of the plugin.</param>
 /// <param name="p_strDesc">The description of the plugin.</param>
 /// <param name="p_imgImage">The plugin image.</param>
 /// <param name="p_ptpType">The <see cref="PluginType" /> of the plugin.</param>
 public PluginInfo(string p_strName, string p_strDesc, Image p_imgImage, IPluginType p_ptpType)
 {
     Name        = p_strName;
     Files       = new List <PluginFile>();
     Flags       = new List <ConditionalFlag>();
     m_ptpType   = p_ptpType;
     Description = p_strDesc;
     Image       = p_imgImage;
 }
예제 #5
0
 /// <summary>
 /// A simple constructor that initializes the values of the object.
 /// </summary>
 /// <param name="p_strName">The name of the plugin.</param>
 /// <param name="p_strDesc">The description of the plugin.</param>
 /// <param name="p_imgImage">The plugin image.</param>
 /// <param name="p_ptpType">The <see cref="PluginType"/> of the plugin.</param>
 public PluginInfo(string p_strName, string p_strDesc, Image p_imgImage, IPluginType p_ptpType)
 {
     m_strName = p_strName;
     m_lstFiles = new List<PluginFile>();
     m_lstFlags = new List<ConditionalFlag>();
     m_ptpType = p_ptpType;
     m_strDesc = p_strDesc;
     m_imgImage = p_imgImage;
 }
예제 #6
0
파일: Parser10.cs 프로젝트: vjmira/fomm
        /// <summary>
        ///   Reads a plugin's information from the configuration file.
        /// </summary>
        /// <param name="p_xndPlugin">The configuration file node corresponding to the plugin to read.</param>
        /// <returns>The plugin information.</returns>
        protected virtual PluginInfo parsePlugin(XmlNode p_xndPlugin)
        {
            var         strName           = p_xndPlugin.Attributes["name"].InnerText;
            var         strDesc           = p_xndPlugin.SelectSingleNode("description").InnerText.Trim();
            IPluginType iptType           = null;
            var         xndTypeDescriptor = p_xndPlugin.SelectSingleNode("typeDescriptor").FirstChild;

            switch (xndTypeDescriptor.Name)
            {
            case "type":
                iptType =
                    new StaticPluginType(
                        (PluginType)Enum.Parse(typeof(PluginType), xndTypeDescriptor.Attributes["name"].InnerText));
                break;

            case "dependancyType":
                var ptpDefaultType =
                    (PluginType)
                    Enum.Parse(typeof(PluginType),
                               xndTypeDescriptor.SelectSingleNode("defaultType").Attributes["name"].InnerText);
                iptType = new DependencyPluginType(ptpDefaultType);
                var dptDependentType = (DependencyPluginType)iptType;

                var xnlPatterns = xndTypeDescriptor.SelectNodes("patterns/*");
                foreach (XmlNode xndPattern in xnlPatterns)
                {
                    var ptpType =
                        (PluginType)
                        Enum.Parse(typeof(PluginType), xndPattern.SelectSingleNode("type").Attributes["name"].InnerText);
                    var cdpDependency = loadDependency(xndPattern.SelectSingleNode("dependancies"));
                    dptDependentType.AddPattern(ptpType, cdpDependency);
                }
                break;
            }
            var   xndImage = p_xndPlugin.SelectSingleNode("image");
            Image imgImage = null;

            if (xndImage != null)
            {
                var strImageFilePath = xndImage.Attributes["path"].InnerText;
                imgImage = Fomod.GetImage(strImageFilePath);
            }
            var pifPlugin = new PluginInfo(strName, strDesc, imgImage, iptType);

            var xnlPluginFiles = p_xndPlugin.SelectNodes("files/*");

            pifPlugin.Files.AddRange(readFileInfo(xnlPluginFiles));
            return(pifPlugin);
        }
예제 #7
0
        public void Should_get_the_default_instance()
        {
            var plugin1 = new Plugin1();
            var plugin2 = new Plugin2();
            var plugin3 = new Plugin3();
            var plugin4 = new Plugin4();

            var instances = new IPluginType[] { plugin1, plugin2, plugin3, plugin4 };

            var plugins = new ConditionalPlugins <IPluginType, Context>(false)
                          .Configure(x => x
                                     .Append <Plugin1>()
                                     .Append <Plugin2>(@default: true)
                                     .Append <Plugin3>(@default: true)
                                     .Append <Plugin4>());

            plugins.GetDefaultInstance(instances).ShouldEqual(plugin3);
        }
예제 #8
0
 public object Build(IPluginType pluginType, IPipelineContext context)
 {
     var arguments = new Arguments(_graph, context);
     return _builder.Value.BuildInstance(arguments);
 }
예제 #9
0
        // TODO -- unit tests here.  Get the thrown errors too.
        public object Build(IPipelineContext context, IPluginType pluginType)
        {
            // Move interception within context here
            return context.WithinFrame(pluginType, () =>
            {
                var value = 400.IsThrownBy(() => _builder.Build(pluginType, context));

                270.IsThrownBy(() => { value = Interceptor.Process(value, context); }, Name, pluginType);

                return value;
            });

            throw new NotImplementedException();
        }
        public void GatherPluginInfo(Dictionary <string, string> replacementsDictionary, object[] customParams)
        {
            var destination = replacementsDictionary["$destinationdirectory$"];

            _pluginInfo.Name        = replacementsDictionary["$specifiedsolutionname$"];
            _pluginInfo.Description = "This is my awesome plugin";
            _pluginInfo.Icon        = "ToyBrickPlus";

            var pluginInfoDialog          = new PluginInfoDialog(_pluginInfo);
            var pluginInfoDialogCompleted = pluginInfoDialog.ShowModal();

            if (pluginInfoDialogCompleted == false)
            {
                throw new WizardCancelledException();
            }

            // Paths
            replacementsDictionary["$ArtemisDirectory$"]        = GetRelativePath(_pluginInfo.ArtemisDirectory, destination);
            replacementsDictionary["$ArtemisDirectoryEscaped$"] = GetRelativePath(_pluginInfo.ArtemisDirectory, destination).Replace("\\", "\\\\");

            // Nuget package versions
            replacementsDictionary["$MaterialDesignThemesVersion$"]     = GetNugetFileVersion("MaterialDesignThemes.Wpf.dll");
            replacementsDictionary["$MaterialDesignExtensionsVersion$"] = GetNugetFileVersion("MaterialDesignExtensions.dll");
            replacementsDictionary["$FluentValidationVersion$"]         = GetNugetFileVersion("FluentValidation.dll");
            replacementsDictionary["$SkiaSharpVersion$"] = GetNugetFileVersion("SkiaSharp.dll");
            replacementsDictionary["$StyletVersion$"]    = GetNugetFileVersion("Stylet.dll");

            // Plugin info
            replacementsDictionary["$PluginGuid$"]        = _pluginInfo.Guid.ToString();
            replacementsDictionary["$PluginName$"]        = _pluginInfo.Name;
            replacementsDictionary["$PluginDescription$"] = _pluginInfo.Description;
            replacementsDictionary["$PluginAuthor$"]      = _pluginInfo.Author;
            replacementsDictionary["$PluginWebsite$"]     = _pluginInfo.Website != null ? $"\"{_pluginInfo.Website}\"" : "null";
            replacementsDictionary["$PluginRepository$"]  = _pluginInfo.Repository != null ? $"\"{_pluginInfo.Repository}\"" : "null";
            if (_pluginInfo.Icon != null)
            {
                replacementsDictionary["$PluginIcon$"] = _pluginInfo.Icon;
            }

            // customParams contains the path to the template
            if (customParams.Any(p => p.ToString().Contains("Module")))
            {
                _pluginType = new ModulePluginType(this, replacementsDictionary, customParams, _pluginInfo);
            }
            else if (customParams.Any(p => p.ToString().Contains("Layer Brush")))
            {
                _pluginType = new LayerBrushType(this, replacementsDictionary, customParams, _pluginInfo);
            }
            else if (customParams.Any(p => p.ToString().Contains("Layer Effect")))
            {
                _pluginType = new LayerEffectType(this, replacementsDictionary, customParams, _pluginInfo);
            }
            else if (customParams.Any(p => p.ToString().Contains("Device")))
            {
                _pluginType = new DeviceType(replacementsDictionary);
            }
            else
            {
                throw new Exception("Couldn't detect a plugin type based on the template that was selected.");
            }

            _pluginType.GatherInfo();
        }