public static bool TryParse(string id, out T result) { try { var instance = (T)Activator.CreateInstance(typeof(T), true); var stringTenantUrn = AggregateRootId.Parse(id, urnFormatProvider); var newId = instance.Construct(stringTenantUrn.Id, stringTenantUrn.Tenant); if (stringTenantUrn.AggregateRootName == newId.AggregateRootName) { result = newId; } else { throw new Exception("bum"); } //todo check if ar name mateches.. return(true); } catch (Exception ex) { result = null; return(false); } }
public static T Parse(string id) { var instance = (T)Activator.CreateInstance(typeof(T), true); var stringTenantUrn = AggregateRootId.Parse(id, urnFormatProvider); var newId = instance.Construct(stringTenantUrn.Id, stringTenantUrn.Tenant); if (stringTenantUrn.AggregateRootName == newId.AggregateRootName) { return(newId); } else { throw new Exception("bum"); } //todo check if ar name mateches.. }