Beispiel #1
0
 public static string GetProperty(this Node n, EnmUmbracoPropertyAlias alias, bool searchParent = true)
 {
     // Node bestaat?
     if (n != null)
     {
         // Haal de property op
         var p = n.GetProperty(alias.ToString());
         // Als er wat in zit retourneren we hem
         if (p != null && !String.IsNullOrEmpty(p.Value))
         {
             return(p.Value);
         }
         // Bestaat de parent?
         if (searchParent && n.Parent != null)
         {
             // Haal de property op van de parent
             p = n.Parent.GetProperty(alias.ToString());
             // Bestaat de property en zit er wat in?
             if (p != null && !String.IsNullOrEmpty(p.Value))
             {
                 // Retourneren
                 return(p.Value);
             }
         }
     }
     // Default: Retourneer een lege string
     return(string.Empty);
 }
 IEnumerable<MailAddress> GetEmailAdressesFromUmbracoProperty(INode node, EnmUmbracoPropertyAlias alias, bool recursive = true)
 {
     bool atleastOneResult = false;
     var p = node.GetProperty(alias.ToString());
     if (p != null && !String.IsNullOrEmpty(p.Value))
     {
         var data = Helper.FromJSON<List<PerplexEmailadres>>(p.Value);
         if (data != null)
             foreach (var email in data)
             {
                 MailAddress m = null;
                 try
                 {
                     if (!String.IsNullOrEmpty(email.Address))
                     {
                         var emailaddress = ReplaceTags(email.Address);
                         if (!String.IsNullOrEmpty(emailaddress) && System.Text.RegularExpressions.Regex.IsMatch(emailaddress, Constants.REGEX_EMAIL))
                             m = new MailAddress(emailaddress, ReplaceTags(email.DisplayName));
                     }
                 }
                 catch { } // "Jammer joh" exception
                 if (m != null)
                 {
                     atleastOneResult = true;
                     yield return m;
                 }
             }
     }
     if (!atleastOneResult && recursive)
         foreach (var email in GetEmailAdressesFromUmbracoProperty(node.Parent, alias, false))
             yield return email;
 }