Exemple #1
0
 static bool IsDirectWithMulticast(MSMQ.MessageQueue queue, FormatName fn)
 {
     try
     {
         return(fn.Scheme.Equals("OS", OrdinalIgnoreCase) && !string.IsNullOrEmpty(queue.MulticastAddress));
     }
     catch (MSMQ.MessageQueueException ex) when(ex.MessageQueueErrorCode == MSMQ.MessageQueueErrorCode.UnsupportedFormatNameOperation)
     {
         return(false);
     }
 }
Exemple #2
0
        internal static Uri QueueNameToUri(MSMQ.MessageQueue queue)
        {
            var fn = FormatName.Parse(queue.FormatName);

            if (fn == null)
            {
                return(null);
            }
            var sb = new StringBuilder(30);

            if (fn.Scheme.Equals("multicast", OrdinalIgnoreCase))
            {
                sb.Append("msmq+pgm://").Append(fn.Host).Append('/');
            }
            else if (IsDirectWithMulticast(queue, fn))
            {
                sb.Append("msmq+pgm://").Append(queue.MulticastAddress).Append(fn.Path.Replace('\\', '/'));
            }
            else
            {
                // not multicast
                if (string.Equals(fn.Scheme, "OS", OrdinalIgnoreCase))
                {
                    sb.Append("msmq+os");
                }
                else if (string.Equals(fn.Scheme, "TCP", OrdinalIgnoreCase))
                {
                    sb.Append("msmq+tcp");
                }
                else if (string.Equals(fn.Scheme, "HTTP", OrdinalIgnoreCase))
                {
                    sb.Append("msmq+http");
                }
                else if (string.Equals(fn.Scheme, "HTTPS", OrdinalIgnoreCase))
                {
                    sb.Append("msmq+https");
                }
                else
                {
                    return(null);
                }
                sb.Append("://").Append(fn.Host).Append(fn.Path.Replace('\\', '/'));
            }
            return(new Uri(sb.ToString()));
        }