private void ReplacePlaceholders(ContactStringReplacer replacer, string signatureName)
        {
            if (string.IsNullOrEmpty(signatureName))
            {
                return;
            }

            using (ISignatures signatures = ThisAddIn.Instance.GetSignatures())
            {
                using (ISignature signature = signatures.Get(signatureName))
                {
                    if (signature == null)
                    {
                        return;
                    }

                    foreach (ISignatureFormat format in Enum.GetValues(typeof(ISignatureFormat)))
                    {
                        string template = signature.GetContentTemplate(format);
                        if (template != null)
                        {
                            string replaced = replacer.Replace(template);
                            signature.SetContent(replaced, format);
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
 internal string DefaultNameForFolder(AvailableFolder folder)
 {
     // Default include the store name in root folders
     if (folder.ParentId.IsNone)
     {
         if (folder.DefaultName == null)
         {
             using (ContactStringReplacer replacer = ContactStringReplacer.FromGAB(_gab, _user))
             {
                 if (replacer == null)
                 {
                     // No gab available, default to old
                     folder.DefaultName = folder.Name + " - " + folder.Store.UserName;
                 }
                 else
                 {
                     replacer.TokenOpen       = "%";
                     replacer.TokenClose      = "%";
                     replacer.UnknownReplacer = (token) =>
                     {
                         if (token == "foldername")
                         {
                             return(folder.Name);
                         }
                         return("");
                     };
                     folder.DefaultName = replacer.Replace(_feature.DefaultFolderNameFormat);
                 }
             }
         }
         return(folder.DefaultName);
     }
     else
     {
         return(folder.Name);
     }
 }