using System; namespace SpectacleTransformer { public abstract class TranslationRequest { public readonly Uri InstanceUri; public readonly Language Source; public readonly Language Target; public readonly string Text; /// /// Create a new translation request. /// /// URI pointing to the server instance to use. /// The source language. /// The target language. /// The text to translate. public TranslationRequest(Uri InstanceUri, Language Source, Language Target, string Text) { if (Source.Equals(Target)) throw new ArgumentException("The source and target languages cannot be the same."); this.InstanceUri = InstanceUri; this.Source = Source; this.Target = Target; this.Text = Text; } /// /// Determines if this TranslationRequest can be instanciated with an instance URI. /// /// The instance URI to check. /// Whether this translation request can be performed on this instance URI. public static bool MatchesInstance(Uri InstanceUri) { return true; } /// /// Perform a translation request. /// /// The translated text, or null if the translation failed. public abstract string Run(); /// /// Called in the main thread with UI controls to allow further post-processing that could require them. /// /// The response returned by Run(). /// A processed response. public virtual string PostProcess(string response) { return response; } } }