Exemple #1
0
        public static EmailSender CreateInstance(string name, string configXml)
        {
            EmailSender result;

            if (string.IsNullOrEmpty(name))
            {
                result = null;
            }
            else
            {
                Type plugin = EmailPlugins.Instance().GetPlugin("EmailSender", name);
                if (plugin == null)
                {
                    result = null;
                }
                else
                {
                    EmailSender emailSender = Activator.CreateInstance(plugin) as EmailSender;
                    if (emailSender != null && !string.IsNullOrEmpty(configXml))
                    {
                        XmlDocument xmlDocument = new XmlDocument();
                        xmlDocument.LoadXml(configXml);
                        emailSender.InitConfig(xmlDocument.FirstChild);
                    }
                    result = emailSender;
                }
            }
            return(result);
        }
Exemple #2
0
 public static EmailPlugins Instance()
 {
     if (instance == null)
     {
         lock (LockHelper)
         {
             if (instance == null)
             {
                 instance = new EmailPlugins();
             }
         }
     }
     instance.VerifyIndex();
     return(instance);
 }
Exemple #3
0
 public static EmailPlugins Instance()
 {
     if (instance == null)
     {
         lock (LockHelper)
         {
             if (instance == null)
             {
                 instance = new EmailPlugins();
             }
         }
     }
     instance.VerifyIndex();
     return instance;
 }
Exemple #4
0
 private static void ProcessEmailSender(HttpContext context)
 {
     if (context.Request["action"] == "getlist")
     {
         EmailPlugins emailPlugins = EmailPlugins.Instance();
         context.Response.ContentType = "application/json";
         context.Response.Write(emailPlugins.GetPlugins().ToJsonString());
         return;
     }
     if (context.Request["action"] == "getmetadata")
     {
         context.Response.ContentType = "text/xml";
         EmailSender emailSender = EmailSender.CreateInstance(context.Request["name"]);
         if (emailSender == null)
         {
             context.Response.Write("<xml></xml>");
             return;
         }
         context.Response.Write(emailSender.GetMetaData().OuterXml);
     }
 }
Exemple #5
0
 public static EmailPlugins Instance()
 {
     if (EmailPlugins.instance == null)
     {
         object lockHelper;
         Monitor.Enter(lockHelper = EmailPlugins.LockHelper);
         try
         {
             if (EmailPlugins.instance == null)
             {
                 EmailPlugins.instance = new EmailPlugins();
             }
         }
         finally
         {
             Monitor.Exit(lockHelper);
         }
     }
     EmailPlugins.instance.VerifyIndex();
     return(EmailPlugins.instance);
 }
Exemple #6
0
        public static EmailSender CreateInstance(string name, string configXml)
        {
            if (string.IsNullOrEmpty(name))
            {
                return(null);
            }
            Type plugin = EmailPlugins.Instance().GetPlugin("EmailSender", name);

            if (plugin == null)
            {
                return(null);
            }
            EmailSender sender = Activator.CreateInstance(plugin) as EmailSender;

            if ((sender != null) && !string.IsNullOrEmpty(configXml))
            {
                XmlDocument document = new XmlDocument();
                document.LoadXml(configXml);
                sender.InitConfig(document.FirstChild);
            }
            return(sender);
        }