Skip to content

Commit

Permalink
LanguageWeaverProvider 2.0.4.0 - SDLCOM-6283: Resolved an issue with …
Browse files Browse the repository at this point in the history
…using both Edge and Cloud in the same session for project automation within a standalone application.
  • Loading branch information
aflorescu579774 committed Nov 6, 2024
1 parent 2c29054 commit e3da907
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 8 deletions.
2 changes: 2 additions & 0 deletions LanguageWeaverProvider/ApplicationInitializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ public class ApplicationInitializer : IApplicationInitializer

public static ITranslationProviderCredentialStore CredentialStore { get; set; }

public static PluginVersion PluginVersion { get; set; } = PluginVersion.None;

public static IDictionary<string, ITranslationOptions> TranslationOptions { get; set; } = new Dictionary<string, ITranslationOptions>();
public static bool IsStandalone { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ public static int GetLastTqeIndex(this ITranslationOrigin translationOrigin)
return lastIndex;
}

public static PluginVersion ToPluginVersion(this Uri translationProviderUri)
=> translationProviderUri.AbsoluteUri switch
{
Constants.CloudFullScheme => PluginVersion.LanguageWeaverCloud,
Constants.EdgeFullScheme => PluginVersion.LanguageWeaverEdge,
_ => PluginVersion.None,
};

public static void SetMetaData(this ITranslationOrigin translationOrigin, TranslationData translationData)
{
var evaluationTime = DateTime.Now.ToUniversalTime();
Expand Down
2 changes: 1 addition & 1 deletion LanguageWeaverProvider/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@
// [assembly: AssemblyVersion("1.0.*")]

[assembly: AssemblyVersion("2.0.0.0")]
[assembly: AssemblyFileVersion("2.0.3.1")]
[assembly: AssemblyFileVersion("2.0.4.0")]
7 changes: 1 addition & 6 deletions LanguageWeaverProvider/Services/CredentialManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,7 @@ public static bool CredentialsArePersisted(Uri translationProviderUri)
return false;
}

var pluginVersion = translationProviderUri.AbsoluteUri switch
{
Constants.CloudFullScheme => PluginVersion.LanguageWeaverCloud,
Constants.EdgeFullScheme => PluginVersion.LanguageWeaverEdge,
_ => PluginVersion.None
};
var pluginVersion = translationProviderUri.ToPluginVersion();

if (pluginVersion == PluginVersion.None)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ internal class TranslationProviderFactory : ITranslationProviderFactory
public ITranslationProvider CreateTranslationProvider(Uri translationProviderUri, string translationProviderState, ITranslationProviderCredentialStore credentialStore)
{
ApplicationInitializer.CredentialStore = credentialStore;
ApplicationInitializer.PluginVersion = translationProviderUri.ToPluginVersion();

if (translationProviderState is null) return new TranslationProvider(new TranslationOptions());

var serializedCredentials = credentialStore.GetCredential(translationProviderUri).Credential;
Expand Down Expand Up @@ -47,6 +49,13 @@ public TranslationProviderInfo GetTranslationProviderInfo(Uri translationProvide

public bool SupportsTranslationProviderUri(Uri translationProviderUri)
{
var providerVersion = translationProviderUri.ToPluginVersion();
if (providerVersion != PluginVersion.None &&
providerVersion != ApplicationInitializer.PluginVersion)
{
ApplicationInitializer.CredentialStore = null;
}

if (ApplicationInitializer.CredentialStore is not null && !CredentialManager.CredentialsArePersisted(translationProviderUri))
{
return false;
Expand Down
2 changes: 1 addition & 1 deletion LanguageWeaverProvider/pluginpackage.manifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<PlugInName>Language Weaver Provider</PlugInName>
<Description>Language Weaver Provider</Description>

<Version>2.0.3.1</Version>
<Version>2.0.4.0</Version>
<RequiredProduct name="TradosStudio" minversion="18.0" maxversion="18.9" />

<Include>
Expand Down

0 comments on commit e3da907

Please sign in to comment.