bool TryResolve(byte[] id, out string tenant) { tenant = string.Empty; var urn = System.Text.Encoding.UTF8.GetString(id); StringTenantUrn stringTenantUrn; if (StringTenantUrn.TryParse(urn, out stringTenantUrn)) { tenant = stringTenantUrn.Tenant; return(true); } return(false); }
IAggregateRootId GetAggregateRootId(string mess) { var parts = mess.Split(new[] { "||" }, StringSplitOptions.RemoveEmptyEntries); foreach (var part in parts) { StringTenantUrn urn; if (StringTenantUrn.TryParse(part, out urn)) { return(new StringTenantId(urn, urn.ArName)); } else { byte[] raw = Convert.FromBase64String(part); string urnString = Encoding.UTF8.GetString(raw); if (StringTenantUrn.TryParse(urnString, out urn)) { return(new StringTenantId(urn, urn.ArName)); } } } throw new ArgumentException($"Invalid aggregate root id: {mess}", nameof(mess)); }