Example #1
0
        public static string RoutingTypeToString(RoutingItemType routingType)
        {
            string result;

            if (!RoutingEntryHeaderSerializer.TryGetDefinedRoutingTypeToString(routingType, out result))
            {
                result = routingType.ToString();
            }
            return(result);
        }
Example #2
0
        internal static string SerializableRoutingTypeToString(RoutingItemType routingType)
        {
            if (routingType == RoutingItemType.Unknown)
            {
                throw new NotSupportedException("Cannot serialize routing entries of type Unknown");
            }
            string result;

            if (!RoutingEntryHeaderSerializer.TryGetDefinedRoutingTypeToString(routingType, out result))
            {
                throw new ArgumentException(string.Format("Unrecognized routing type: {0}", routingType));
            }
            return(result);
        }
Example #3
0
        public static IRoutingEntry Deserialize(string headerValue)
        {
            if (headerValue == null)
            {
                throw new ArgumentNullException("headerValue");
            }
            RoutingEntryHeaderSerializer.RoutingEntryParts routingEntryParts;
            if (!RoutingEntryHeaderSerializer.TrySplitEntry(headerValue, out routingEntryParts))
            {
                throw new ArgumentException("Value is incorrectly formatted", "headerValue");
            }
            IRoutingKey         key         = RoutingEntryHeaderSerializer.DeserializeRoutingKey(routingEntryParts.KeyType, routingEntryParts.KeyValue);
            IRoutingDestination destination = RoutingEntryHeaderSerializer.DeserializeRoutingDestination(routingEntryParts.DestinationType, routingEntryParts.DestinationValue);

            return(RoutingEntryHeaderSerializer.AssembleRoutingEntry(key, destination, routingEntryParts.Timestamp));
        }
Example #4
0
        public static string Serialize(IRoutingEntry routingEntry)
        {
            if (routingEntry == null)
            {
                throw new ArgumentNullException("routingEntry");
            }
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.Append(RoutingEntryHeaderSerializer.SerializableRoutingTypeToString(routingEntry.Key.RoutingItemType));
            stringBuilder.Append(':');
            stringBuilder.Append(Uri.EscapeDataString(routingEntry.Key.Value));
            stringBuilder.Append('=');
            stringBuilder.Append(RoutingEntryHeaderSerializer.SerializableRoutingTypeToString(routingEntry.Destination.RoutingItemType));
            stringBuilder.Append(':');
            stringBuilder.Append(Uri.EscapeDataString(routingEntry.Destination.Value));
            foreach (string value in routingEntry.Destination.Properties)
            {
                stringBuilder.Append('+');
                stringBuilder.Append(value);
            }
            stringBuilder.Append('@');
            stringBuilder.Append(routingEntry.Timestamp);
            return(stringBuilder.ToString());
        }
Example #5
0
 public static bool IsValidHeaderString(string headerValue)
 {
     RoutingEntryHeaderSerializer.RoutingEntryParts routingEntryParts;
     return(headerValue != null && RoutingEntryHeaderSerializer.TrySplitEntry(headerValue, out routingEntryParts));
 }