/// <inheritdoc /> public Task <IDictionary <string, string> > TranslateAsync(IEnumerable <string> conceptValues, string targetClientName) { var translations = new Dictionary <string, string>(); foreach (var path in conceptValues) { if (!ConceptValue.TryParse(path, out var conceptValue)) { translations[path] = path; continue; } var value = conceptValue.Value; if (conceptValue.Value.Contains("client-")) { value = value.Replace("client-", "server-"); } else if (conceptValue.Value.Contains("server-")) { value = value.Replace("server-", "client-"); } translations[path] = value; } return(Task.FromResult((IDictionary <string, string>)translations)); }
public void ParseContext() { var conceptValue = ConceptValue.Parse("(concept!context!value)"); Microsoft.VisualStudio.TestTools.UnitTesting.Assert.AreEqual("concept", conceptValue.ConceptName); Microsoft.VisualStudio.TestTools.UnitTesting.Assert.AreEqual("context", conceptValue.ContextName); Microsoft.VisualStudio.TestTools.UnitTesting.Assert.AreEqual("value", conceptValue.Value); Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsNull(conceptValue.ClientName); }
public void ClientToPath() { var conceptValue = new ConceptValue { ConceptName = "concept", ClientName = "client", Value = "value" }; var path = conceptValue.ToPath(); Microsoft.VisualStudio.TestTools.UnitTesting.Assert.AreEqual("(concept!~client!value)", path); }
public Task <Foo> UpdateAndReturnAsync([TranslationConcept(Foo.IdConceptName)] string id, Foo item, CancellationToken token = default) { InternalContract.RequireNotNullOrWhiteSpace(id, nameof(id)); InternalContract.RequireNotNull(item, nameof(item)); var success = ConceptValue.TryParse(item.Id, out var conceptValue); FulcrumAssert.IsTrue(success); FulcrumAssert.AreEqual(Foo.IdConceptName, conceptValue.ConceptName); FulcrumAssert.AreEqual(Foo.ConsumerName, conceptValue.ClientName); InternalContract.Require(id == item.Id, $"Expected {nameof(id)} to be identical to {nameof(item)}.{nameof(item.Id)}."); item.Id = Translator.Decorate(Foo.IdConceptName, Foo.ProducerName, Foo.ProducerId1); return(Task.FromResult(item)); }
private static IConceptValue ToConceptValue(string conceptValuePath) { return(ConceptValue.TryParse(conceptValuePath, out var conceptValue) ? conceptValue : null); }