private void AddOrReplaceDestinationRoutingItem(IUniversalRequestObject uro, IRoutingItem routingItem) { IRoutingItem destinationRoutingItem = FindDestinationRoutingItem(uro, routingItem); if (null == destinationRoutingItem) { uro.Destination.Items.Add(routingItem); } else { string readOnlyValue; if (destinationRoutingItem.Properties.TryGetValue(EmailProperties.ReadOnlyKey, out readOnlyValue)) { if (System.Convert.ToBoolean(readOnlyValue, System.Globalization.CultureInfo.InvariantCulture)) return; } if (!IsSmtpAddress(routingItem.Content)) return; if (destinationRoutingItem.Content != routingItem.Content) { destinationRoutingItem.Properties[EmailProperties.ModifiedKey] = bool.TrueString; foreach (KeyValuePair<string, string> propertyPair in destinationRoutingItem.Properties) { routingItem.Properties[propertyPair.Key] = propertyPair.Value; } uro.Destination.Items.Remove(destinationRoutingItem); uro.Destination.Items.Add(routingItem); } } }
/// <summary> /// Removes an RoutingItem from a policy set's master catalogue /// </summary> /// <param name="policySet">The policy set from whose catalogue we will remove the RoutingItem</param> /// <param name="location">The Channel to remove</param> private static void RemoveAddress(IPolicySet policySet, IRoutingItem address) { if (null == policySet || null == address) { return; } policySet.MasterCatalogue.Locations.Remove(address); }
private void AddReadOnlyAttribute(IRoutingItem routingItem) { if (null == routingItem) return; if (!IsSmtpAddress(routingItem.Content)) { routingItem.Properties.Add(EmailProperties.ReadOnlyKey, bool.TrueString); } }
private IRoutingItem FindDestinationRoutingItem(IUniversalRequestObject uro, IRoutingItem routingItem) { foreach (IRoutingItem destinationRoutingItem in uro.Destination.Items) { if ((destinationRoutingItem.Properties[SMTPItemPropertyKeys.DisplayName] == routingItem.Properties[SMTPItemPropertyKeys.DisplayName]) && (destinationRoutingItem.Properties[SMTPItemPropertyKeys.AddressType] == routingItem.Properties[SMTPItemPropertyKeys.AddressType])) { return destinationRoutingItem; } } return null; }
/// <summary> /// Reads the ContentType custom attribute from an IRoutingItem object /// </summary> /// <param name="policyObject"></param> /// <returns></returns> public static string GetContentType(IRoutingItem routingItem) { return routingItem[ContentTypeAttribute].Value; }
/// <summary> /// Sets the ContentType custom attribute on an IRoutingItem object /// </summary> /// <param name="routingItem"></param> /// <param name="routingItemType"></param> public static void SetContentType(IRoutingItem routingItem, string routingItemType) { routingItem[ContentTypeAttribute].Value = routingItemType; }
private static string FormatRoutingItem(IRoutingItem item) { string address = item.Content; string displayName ; if (!item.Properties.TryGetValue("DisplayName", out displayName)) { displayName = address; } else if (string.IsNullOrEmpty(displayName)) { displayName = address; } return String.Format(CultureInfo.InvariantCulture, "{0}<{1}>", displayName, address); }
internal static ContactEntity ExtractContact(IRoutingItem item) { ContactEntity contact = new ContactEntity(); contact.EmailAddress = item.Content; if (item.Properties.ContainsKey(SMTPItemPropertyKeys.DisplayName)) { contact.Alias = item.Properties[SMTPItemPropertyKeys.DisplayName]; } contact.InternalContact = false; string emailAddress = contact.EmailAddress; if (emailAddress.Contains("@")) { contact.Alias = emailAddress.Substring(0, emailAddress.IndexOf("@")); contact.EmailDomain = emailAddress.Substring(emailAddress.IndexOf("@") + 1); } return contact; }
public void WriteLocation(IRoutingItem location) { if (null == location) return; CollectionInserter<IRoutingItem>.Insert(m_locations, location); }