CodeSharp.EventSourcing.Address.Parse C# (CSharp) Method

Parse() public static method

Parses a string and returns an Address.
public static Parse ( string address ) : Address
address string
return Address
        public static Address Parse(string address)
        {
            if (string.IsNullOrEmpty(address))
            {
                throw new InvalidOperationException("Invalid endpoint address specified");
            }

            var items = address.Split('@');

            var queue = items[0];
            var machine = defaultMachine;

            if (items.Length == 2)
            {
                if (items[1] != "." && items[1].ToLower() != "localhost" && items[1] != IPAddress.Loopback.ToString())
                {
                    machine = items[1];
                }
            }
            return new Address(queue, machine);
        }

Usage Example

Example #1
0
 /// <summary>
 /// Gets the name of the return address from the provided value.
 /// If the target includes a machine name, uses the local machine name in the returned value
 /// otherwise uses the local IP address in the returned value.
 /// </summary>
 /// <param name="value"></param>
 /// <param name="target"></param>
 /// <returns></returns>
 public static string GetReturnAddress(string value, string target)
 {
     return(GetReturnAddress(Address.Parse(value), Address.Parse(target)));
 }
All Usage Examples Of CodeSharp.EventSourcing.Address::Parse