CreateInstance() public static method

public static CreateInstance ( XmlElement element ) : object
element System.Xml.XmlElement
return object
Exemplo n.º 1
0
 public static void ExecuteMainWindowLoadedProcessors(Window mainWindow)
 {
     foreach (var plugin in PluginManager.GetEnabledPlugins())
     {
         try
         {
             var          xml   = plugin.PluginXmlDocument;
             const string xpath = "/plugin/mainWindow/loaded/processor";
             foreach (XmlElement processorNode in xml.SelectElements(xpath))
             {
                 var obj = (IMainWindowLoadedProcessor)Plugin.CreateInstance(processorNode);
                 ExecuteAsync(() => obj.Process(mainWindow));
             }
         }
         catch (Exception ex)
         {
             PluginManager.HandleError(plugin, ex);
         }
     }
 }
Exemplo n.º 2
0
        private static void ExecuteInitProcessor(XmlElement processorNode)
        {
            using (new ProfileSection("Execute <init> processor", typeof(PluginManager)))
            {
                ProfileSection.Argument("processorNode", processorNode);

                var isAsync = processorNode.GetAttribute("mode").EqualsIgnoreCase("async");
                var obj     = (IInitProcessor)Plugin.CreateInstance(processorNode);
                if (!isAsync)
                {
                    obj.Process();

                    ProfileSection.Result("Done");
                    return;
                }

                ExecuteAsync(obj.Process);

                ProfileSection.Result("Started async");
            }
        }