Beispiel #1
0
        public static GroupExpansionRecipients Parse(string data)
        {
            if (string.IsNullOrEmpty(data))
            {
                throw new ArgumentNullException("data");
            }
            GroupExpansionRecipients groupExpansionRecipients = new GroupExpansionRecipients();

            string[] array = data.Split(new string[]
            {
                "|"
            }, StringSplitOptions.RemoveEmptyEntries);
            foreach (string data2 in array)
            {
                groupExpansionRecipients.Recipients.Add(RecipientToIndex.Parse(data2));
            }
            return(groupExpansionRecipients);
        }
Beispiel #2
0
 internal static GroupExpansionRecipients RetrieveFromStore(MessageItem messageItem, StorePropertyDefinition propertyDefinition)
 {
     if (messageItem == null)
     {
         return(null);
     }
     try
     {
         object propertyValue = messageItem.TryGetProperty(propertyDefinition);
         if (PropertyError.IsPropertyNotFound(propertyValue))
         {
             return(null);
         }
         if (PropertyError.IsPropertyValueTooBig(propertyValue))
         {
             using (Stream stream = messageItem.OpenPropertyStream(propertyDefinition, PropertyOpenMode.ReadOnly))
             {
                 Encoding encoding = new UnicodeEncoding(false, false);
                 using (StreamReader streamReader = new StreamReader(stream, encoding))
                 {
                     string data = streamReader.ReadToEnd();
                     return(GroupExpansionRecipients.Parse(data));
                 }
             }
         }
         if (PropertyError.IsPropertyError(propertyValue))
         {
             return(null);
         }
         string text = messageItem[propertyDefinition] as string;
         if (!string.IsNullOrEmpty(text))
         {
             return(GroupExpansionRecipients.Parse(text));
         }
     }
     catch (PropertyErrorException)
     {
         return(null);
     }
     return(null);
 }
Beispiel #3
0
        protected override object InternalTryGetValue(PropertyBag.BasicPropertyStore propertyBag)
        {
            MessageItem messageItem = propertyBag.Context.StoreObject as MessageItem;

            if (messageItem != null)
            {
                GroupExpansionRecipients groupExpansionRecipients = GroupExpansionRecipients.RetrieveFromStore(messageItem, InternalSchema.GroupExpansionRecipients);
                if (groupExpansionRecipients != null)
                {
                    if (this.recipientItemType != null && this.recipientItemType != null)
                    {
                        RecipientItemType recipientType = this.recipientItemType.Value;
                        return(new List <RecipientToIndex>(from r in groupExpansionRecipients.Recipients
                                                           where r.RecipientType == recipientType
                                                           select r));
                    }
                    return(groupExpansionRecipients.Recipients);
                }
            }
            return(new PropertyError(this, PropertyErrorCode.GetCalculatedPropertyError));
        }