c52d8d0171
I was wrong. AVEVA Tech Note 537 ("Creating an Application Object Script
Using GRAccess", April 2008) documents the supported pattern:
ConfigurableAttributes[<script>.<field>].SetValue(MxValue) inside a
CheckOut/Save/CheckIn cycle. graccesscli's existing
FindAttributeForMutation already follows this — writes to MxCategoryPackageOnly_Lockable
script-text fields persist correctly.
The earlier "writeback gap" diagnosis was a phantom caused by a reader-side
issue. `object attribute value get` against a script body returns
"Supported: False / Attribute value is not exposed" because
MxValueDetails uses a case-sensitive `ReadProperty(attr, "Value")` lookup
plus an accessor probe (GetBoolean -> GetInteger -> GetFloat -> GetDouble
-> GetString) that can fall through silently for some MxValue shapes. The
COM-side property is exposed as `value` (lowercase), readable as
`attr.value.GetString()` -- which the live probe at
`analysis/ide-edit-investigation/probe_setvalue/` does and confirms the
post-write content matches the marker exactly.
Live verification on $TestMachine.UpdateTestChangingInt.DeclarationsText
and $DelmiaReceiver.ProcessRecipe.{ExecuteText,DeclarationsText}:
=== verdict ===
marker landed on same-proxy ConfigurableAttributes: True
marker landed on same-proxy Attributes : True
marker landed on fresh-proxy ConfigurableAttributes: True
marker landed on fresh-proxy Attributes : True
The probe also confirmed that two earlier graccesscli `object scripts set`
invocations (which I had wrongly believed failed) had persisted -- the
marker text I wrote previously was still on disk in
ProcessRecipe.{ExecuteText,DeclarationsText} when read directly via
attr.value.GetString(). The probe restored both fields to their original
values.
This commit:
- Updates the misleading [Command(...)] / [CommandOption(...)]
descriptions in GRAccessSurfaceCommands.cs back to honest versions
citing TN-537.
- Restores the --file-using examples for `object scripts set` and
`object scripts create` across script-editing.md, llm-integration.md,
usage.md, and zb-testmachine.md.
- Removes the test that asserted the (wrong) EnsureMutableViaSetValue
guard. Re-aims ScriptCommandDescriptions_… at the corrected wording.
- Removes two leftover EnsureMutableViaSetValue calls in the trigger-period
/ trigger-type write paths (both targeted MxCategoryWriteable_C_Lockable
attributes; would never have fired even if the helper still existed).
- Adds analysis/ide-edit-investigation/REPORT.md (replacing the earlier
wrong report) plus the probe sources under probe_setvalue/.
The MxValueDetails reader gap (case-sensitive ReadProperty + accessor
probe) is a real follow-up: `object attribute value get` should
case-insensitively read `value` and try GetString first when the
underlying MxValue.DataType is MxString. Out of scope here -- that's a
separate, smaller fix.
Test count delta: 67 -> 66 (-2 wrong tests, +1 corrected description test).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1115 lines
42 KiB
C#
1115 lines
42 KiB
C#
using System;
|
|
using System.CodeDom.Compiler;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.ComponentModel.Composition;
|
|
using System.Diagnostics;
|
|
using System.Diagnostics.CodeAnalysis;
|
|
using System.Globalization;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Reflection;
|
|
using System.Resources;
|
|
using System.Runtime.CompilerServices;
|
|
using System.Runtime.InteropServices;
|
|
using System.Runtime.Versioning;
|
|
using System.Threading;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Input;
|
|
using System.Windows.Media;
|
|
using ArchestrA.Client.AppConfig;
|
|
using ArchestrA.Client.AppConfigInt.Resources;
|
|
using ArchestrA.Client.CommonCore;
|
|
using ArchestrA.Client.CommonTypes;
|
|
using ArchestrA.Client.HostContracts;
|
|
using ArchestrA.Configuration;
|
|
using ArchestrA.Configuration.GalaxyGraphics;
|
|
using ArchestrA.Core;
|
|
using ArchestrA.Diagnostics;
|
|
using ArchestrA.Visualization.Client.Common;
|
|
using ArchestrA.Visualization.CommandSupport;
|
|
using ArchestrA.Visualization.CommonUI.Dialogs;
|
|
using ArchestrA.Visualization.Display.Logic;
|
|
using ArchestrA.Visualization.Display.Logic.Common;
|
|
using ArchestrA.Visualization.DisplayModuleSupport;
|
|
using ArchestrA.Visualization.EntitySupport;
|
|
using ArchestrA.Visualization.ModernEditors;
|
|
using Prism.Mvvm;
|
|
|
|
[assembly: CompilationRelaxations(8)]
|
|
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
|
|
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
|
|
[assembly: AssemblyCompany("AVEVA Software, PLC.")]
|
|
[assembly: AssemblyCopyright("Copyright 2020 AVEVA Group plc and its subsidiaries. All rights reserved.")]
|
|
[assembly: AssemblyTrademark("Refer to: https://sw.aveva.com/legal/trademarks")]
|
|
[assembly: AssemblyProduct("AVEVA Application Server")]
|
|
[assembly: AssemblyInformationalVersion("20.0.000")]
|
|
[assembly: AssemblyFileVersion("2917.0626.2833.2")]
|
|
[assembly: SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", Scope = "namespace", Target = "ArchestrA.Client.AppConfigInt")]
|
|
[assembly: AssemblyTitle("ArchestrA.Client.AppConfigInt")]
|
|
[assembly: AssemblyDescription("")]
|
|
[assembly: AssemblyConfiguration("")]
|
|
[assembly: CLSCompliant(false)]
|
|
[assembly: NeutralResourcesLanguage("en")]
|
|
[assembly: ComVisible(false)]
|
|
[assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)]
|
|
[assembly: InternalsVisibleTo("ArchestrA.Client.AppConfigInt.Fakes,PublicKey=0024000004800000940000000602000000240000525341310004000001000100e92decb949446f688ab9f6973436c535bf50acd1fd580495aae3f875aa4e4f663ca77908c63b7f0996977cb98fcfdb35e05aa2c842002703cad835473caac5ef14107e3a7fae01120a96558785f48319f66daabc862872b2c53f5ac11fa335c0165e202b4c011334c7bc8f4c4e570cf255190f4e3e2cbc9137ca57cb687947bc")]
|
|
[assembly: InternalsVisibleTo("ArchestrA.Client.AppConfigInt.Test,PublicKey=0024000004800000940000000602000000240000525341310004000001000100a79fb5ce9af5b80294b8b7ae7b476bcbf30b0713351655b2170195cd14acd8ed1462df1ab3a167d5463bd76a6151dd1766b94c350994d233a7024266591ee249882a4ee9c9e4de90dcd4c3762f274652cabac4a99704a9073872505b090f638e1a0827aeac9ff572d93d1a7800669dc0ce920817bd5aa5d70bacb7df88b4fdb3")]
|
|
[assembly: TargetFramework(".NETFramework,Version=v4.7.1", FrameworkDisplayName = ".NET Framework 4.7.1")]
|
|
[assembly: AssemblyVersion("1.0.0.0")]
|
|
namespace ArchestrA.Client.AppConfigInt
|
|
{
|
|
internal class AppCommandManager : IAppCommandManagerBase
|
|
{
|
|
private readonly ICommandManager commandManager;
|
|
|
|
public AppCommandManager(ICommandManager commandManager)
|
|
{
|
|
this.commandManager = commandManager;
|
|
}
|
|
|
|
public IAppCommandManagerBase AddPopupCommand(IAppCommandUI appCommandUI, object content)
|
|
{
|
|
ICommandUI commandUI = AppCommandUIProvider.GetCommandUI(appCommandUI);
|
|
commandManager.AddPopupCommand(commandUI, content);
|
|
return (IAppCommandManagerBase)(object)this;
|
|
}
|
|
|
|
public IAppCommandManagerBase AddSimpleCommand(ICommand command, IAppCommandUI appCommandUI)
|
|
{
|
|
ICommandUI commandUI = AppCommandUIProvider.GetCommandUI(appCommandUI);
|
|
commandManager.AddSimpleCommand(command, commandUI);
|
|
return (IAppCommandManagerBase)(object)this;
|
|
}
|
|
|
|
public IAppCommandManagerBase AddSplitCommand(ICommand command, IAppCommandUI appCommandUI, object content)
|
|
{
|
|
ICommandUI commandUI = AppCommandUIProvider.GetCommandUI(appCommandUI);
|
|
commandManager.AddSplitCommand(command, commandUI, content);
|
|
return (IAppCommandManagerBase)(object)this;
|
|
}
|
|
|
|
public IAppCommandManagerBase BeginCommandGroup(IAppCommandUI appCommandUI)
|
|
{
|
|
ICommandUI commandUI = AppCommandUIProvider.GetCommandUI(appCommandUI);
|
|
commandManager.BeginCommandGroup(commandUI);
|
|
return (IAppCommandManagerBase)(object)this;
|
|
}
|
|
|
|
public IAppCommandManagerBase BeginCommandGroup()
|
|
{
|
|
commandManager.BeginCommandGroup();
|
|
return (IAppCommandManagerBase)(object)this;
|
|
}
|
|
|
|
public IAppCommandManagerBase ClearCommands()
|
|
{
|
|
commandManager.ClearCommands();
|
|
return (IAppCommandManagerBase)(object)this;
|
|
}
|
|
|
|
public IAppCommandManagerBase WithoutLabel()
|
|
{
|
|
commandManager.WithoutLabel();
|
|
return (IAppCommandManagerBase)(object)this;
|
|
}
|
|
|
|
public IAppCommandUI CreateAppCommandUI(string label, string toolTip, DrawingBrush icon)
|
|
{
|
|
return AppCommandUIProvider.CreateAppCommandUI(label, toolTip, icon);
|
|
}
|
|
}
|
|
[SuppressMessage("Microsoft.Design", "CA1053:StaticHolderTypesShouldNotHaveConstructors")]
|
|
public sealed class AppCommandUIProvider
|
|
{
|
|
private sealed class AutoCommandUI : BindableBase, IAppCommandUI
|
|
{
|
|
private readonly string label;
|
|
|
|
private readonly string accessKey;
|
|
|
|
private readonly string toolTip;
|
|
|
|
private readonly DrawingBrush icon;
|
|
|
|
public string Label => label;
|
|
|
|
public string AccessKey => accessKey;
|
|
|
|
public string ToolTip => toolTip;
|
|
|
|
public DrawingBrush Icon => icon;
|
|
|
|
public AutoCommandUI(string label, string accessKey, string toolTip, DrawingBrush icon)
|
|
{
|
|
this.label = label;
|
|
this.accessKey = accessKey;
|
|
this.toolTip = toolTip;
|
|
this.icon = icon;
|
|
}
|
|
}
|
|
|
|
private sealed class OriginalCommandUI : BindableBase, ICommandUI
|
|
{
|
|
private readonly string getLabel;
|
|
|
|
private readonly string getAccessKey;
|
|
|
|
private readonly string getToolTip;
|
|
|
|
private readonly DrawingBrush icon;
|
|
|
|
public string Label => getLabel;
|
|
|
|
public string AccessKey => getAccessKey;
|
|
|
|
public string ToolTip => getToolTip;
|
|
|
|
public DrawingBrush Icon => icon;
|
|
|
|
public OriginalCommandUI(string getLabel, string getAccessKey, string getToolTip, DrawingBrush icon)
|
|
{
|
|
this.getLabel = getLabel;
|
|
this.getAccessKey = getAccessKey;
|
|
this.getToolTip = getToolTip;
|
|
this.icon = icon;
|
|
}
|
|
}
|
|
|
|
internal static ICommandUI GetCommandUI(IAppCommandUI commandUI)
|
|
{
|
|
return (ICommandUI)(object)new OriginalCommandUI(commandUI.Label, commandUI.AccessKey, commandUI.ToolTip, commandUI.Icon);
|
|
}
|
|
|
|
internal static IAppCommandUI CreateAppCommandUI(string label, string toolTip, DrawingBrush icon)
|
|
{
|
|
return (IAppCommandUI)(object)new AutoCommandUI(label, null, toolTip, icon);
|
|
}
|
|
}
|
|
public class AppPublisher
|
|
{
|
|
private static readonly object SingletonAccessLock = new object();
|
|
|
|
private static volatile AppPublisher appPublisher;
|
|
|
|
private IGalaxyConfiguration galaxyConfiguration;
|
|
|
|
private IGalaxyGraphics galaxyGraphics;
|
|
|
|
public static AppPublisher Instance
|
|
{
|
|
get
|
|
{
|
|
if (appPublisher == null)
|
|
{
|
|
lock (SingletonAccessLock)
|
|
{
|
|
if (appPublisher == null)
|
|
{
|
|
appPublisher = new AppPublisher();
|
|
}
|
|
}
|
|
}
|
|
return appPublisher;
|
|
}
|
|
}
|
|
|
|
public void Init(IGalaxyConfiguration galaxyConfiguration)
|
|
{
|
|
this.galaxyConfiguration = galaxyConfiguration;
|
|
galaxyGraphics = galaxyConfiguration.GetGalaxyGraphics() as IGalaxyGraphics;
|
|
}
|
|
|
|
public void Init(IGalaxyGraphics galaxyGraphics)
|
|
{
|
|
this.galaxyGraphics = galaxyGraphics;
|
|
}
|
|
|
|
public void PublishIfNeeded(string objectName, string destPath)
|
|
{
|
|
int iDFromObjectName = galaxyConfiguration.GetIDFromObjectName(Namespace.VisualElement, objectName);
|
|
PublishIfNeeded(objectName, iDFromObjectName, destPath);
|
|
}
|
|
|
|
public void PublishIfNeeded(string objectName, int objectID, string destPath)
|
|
{
|
|
PublishAndGetEditorMetadata(objectName, objectID, destPath, loadEditorMetadata: false);
|
|
}
|
|
|
|
public Tuple<string, EditorMetadata> PublishAndGetEditorMetadata(string objectName, int objectID, string destPath, bool loadEditorMetadata)
|
|
{
|
|
return PublishAndGetEditorMetadata(galaxyGraphics, objectName, objectID, destPath, loadEditorMetadata);
|
|
}
|
|
|
|
public static void PublishIfNeededOnServer(IGalaxyGraphics galaxyGraphics, string objectName, int objectID, string destPath)
|
|
{
|
|
PublishAndGetEditorMetadata(galaxyGraphics, objectName, objectID, destPath, loadEditorMetadata: false);
|
|
}
|
|
|
|
[SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "objectID")]
|
|
private static Tuple<string, EditorMetadata> PublishAndGetEditorMetadata(IGalaxyGraphics galaxyGraphics, string objectName, int objectID, string destPath, bool loadEditorMetadata)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(destPath))
|
|
{
|
|
ArchestrA.Diagnostics.Logger.LogWarning(() => "Invalid Destination Path: Value cannot be null, empty or whitespace");
|
|
return null;
|
|
}
|
|
string sourceDir = null;
|
|
bool flag = false;
|
|
int i;
|
|
for (i = 0; i < 100; i++)
|
|
{
|
|
if (string.IsNullOrEmpty(sourceDir))
|
|
{
|
|
sourceDir = GetLibraryPath(galaxyGraphics, objectName);
|
|
ArchestrA.Diagnostics.Logger.LogCustom(CustomFlags.AppEditor, () => string.Format(CultureInfo.InvariantCulture, Strings.AppPublisher_AppSourcePath, objectName, sourceDir));
|
|
}
|
|
if (!string.IsNullOrEmpty(sourceDir) && Directory.Exists(sourceDir))
|
|
{
|
|
flag = true;
|
|
ArchestrA.Diagnostics.Logger.LogTrace(() => $"App path {sourceDir} found {i * 200} ms after change notification.");
|
|
break;
|
|
}
|
|
Thread.Sleep(200);
|
|
if (string.IsNullOrEmpty(sourceDir))
|
|
{
|
|
ArchestrA.Diagnostics.Logger.LogInfo(() => $"Checked in path for {objectName} is empty. Will retry ...");
|
|
}
|
|
else
|
|
{
|
|
ArchestrA.Diagnostics.Logger.LogInfo(() => $"{sourceDir} in the shared folder is not available yet. Waiting ...");
|
|
}
|
|
}
|
|
if (string.IsNullOrEmpty(sourceDir))
|
|
{
|
|
ArchestrA.Diagnostics.Logger.LogWarning(() => $"Cannot find file storage path for visual element {objectName}.");
|
|
return null;
|
|
}
|
|
if (!flag)
|
|
{
|
|
ArchestrA.Diagnostics.Logger.LogWarning(() => $"File storage path for visual element {objectName} does not exist: {sourceDir}");
|
|
return null;
|
|
}
|
|
Tuple<bool, EditorMetadata> tuple = IsCopyRequired(sourceDir, destPath, loadEditorMetadata);
|
|
if (tuple.Item1)
|
|
{
|
|
destPath = CopyAppAssemblies(objectName, sourceDir, destPath);
|
|
}
|
|
return new Tuple<string, EditorMetadata>(destPath, tuple.Item2);
|
|
}
|
|
|
|
public string[] GetGalaxyCredentialNameList()
|
|
{
|
|
try
|
|
{
|
|
Stopwatch stopWatch = new Stopwatch();
|
|
stopWatch.Start();
|
|
string[] credentials = (galaxyConfiguration as IGalaxyConfigurationV31).GetGalaxyCredentialNameList();
|
|
stopWatch.Stop();
|
|
ArchestrA.Diagnostics.Logger.LogCustom(CustomFlags.CredentialEditor, () => string.Format(CultureInfo.InvariantCulture, Strings.GetCredentials_Label, stopWatch.ElapsedMilliseconds, (credentials != null) ? credentials.Length : 0));
|
|
return credentials;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Exception ex2 = ex;
|
|
Exception ex3 = ex2;
|
|
ArchestrA.Diagnostics.Logger.LogWarning(() => string.Format(CultureInfo.InvariantCulture, "Error occured while retrieving the credentials from galaxy configuration. {0}", ex3.ToString()));
|
|
return null;
|
|
}
|
|
}
|
|
|
|
private static Tuple<bool, EditorMetadata> IsCopyRequired(string sourcePath, string destPath, bool loadEditorMetadata)
|
|
{
|
|
string text = null;
|
|
string text2 = null;
|
|
AppManifestSchemaElement val = ValidateAndLoadAppManifest(sourcePath);
|
|
if (val == null)
|
|
{
|
|
if (loadEditorMetadata)
|
|
{
|
|
ArchestrA.Diagnostics.Logger.LogCustom(CustomFlags.AppEditor, () => string.Format(CultureInfo.InvariantCulture, Strings.AppPublisher_CopyAppAssembliesInformation, sourcePath, "Don't"));
|
|
return new Tuple<bool, EditorMetadata>(item1: false, null);
|
|
}
|
|
return new Tuple<bool, EditorMetadata>(item1: true, null);
|
|
}
|
|
if (loadEditorMetadata && (string.IsNullOrEmpty(val.Editor.AssemblyName) || string.IsNullOrEmpty(val.Editor.FullName)))
|
|
{
|
|
ArchestrA.Diagnostics.Logger.LogCustom(CustomFlags.AppEditor, () => string.Format(CultureInfo.InvariantCulture, Strings.AppPublisher_EditorAssemblyFileNotfound, sourcePath));
|
|
return new Tuple<bool, EditorMetadata>(item1: false, null);
|
|
}
|
|
text = val.AppVersion;
|
|
AppManifestSchemaElement val2 = ValidateAndLoadAppManifest(destPath);
|
|
if (val2 == null)
|
|
{
|
|
ArchestrA.Diagnostics.Logger.LogCustom(CustomFlags.AppEditor, () => string.Format(CultureInfo.InvariantCulture, Strings.AppPublisher_CopyAppAssembliesInformation, destPath, string.Empty));
|
|
return new Tuple<bool, EditorMetadata>(item1: true, val.Editor);
|
|
}
|
|
text2 = val2.AppVersion;
|
|
if (string.IsNullOrEmpty(text))
|
|
{
|
|
return new Tuple<bool, EditorMetadata>(item1: false, val.Editor);
|
|
}
|
|
if (string.Equals(text, text2, StringComparison.Ordinal))
|
|
{
|
|
return new Tuple<bool, EditorMetadata>(item1: false, val2.Editor);
|
|
}
|
|
return new Tuple<bool, EditorMetadata>(item1: true, val.Editor);
|
|
}
|
|
|
|
internal static AppManifestSchemaElement ValidateAndLoadAppManifest(string directoryPath)
|
|
{
|
|
//IL_0027: Expected O, but got Unknown
|
|
try
|
|
{
|
|
string text = Path.Combine(directoryPath, "AppManifest.xml");
|
|
return File.Exists(text) ? DisplayLibraryManager.ValidateAndLoadXml(text) : null;
|
|
}
|
|
catch (DisplayOperationException ex)
|
|
{
|
|
DisplayOperationException ex2 = ex;
|
|
DisplayOperationException ex3 = ex2;
|
|
ArchestrA.Diagnostics.Logger.LogWarning(() => ((Exception)(object)ex3).Message);
|
|
}
|
|
catch (Exception ex4)
|
|
{
|
|
Exception ex5 = ex4;
|
|
Exception ex6 = ex5;
|
|
ArchestrA.Diagnostics.Logger.LogWarning(() => ex6.Message);
|
|
}
|
|
return null;
|
|
}
|
|
|
|
private static string CopyAppAssemblies(string objectName, string sourceDir, string destPath)
|
|
{
|
|
ArchestrA.Diagnostics.Logger.LogCustom(CustomFlags.AppEditor, () => string.Format(CultureInfo.InvariantCulture, Strings.AppPublisher_CopyAppLibrary, objectName, sourceDir, destPath));
|
|
Stopwatch stopWatch = new Stopwatch();
|
|
stopWatch.Start();
|
|
DeleteAndCopyFiles(objectName, sourceDir, ref destPath);
|
|
stopWatch.Stop();
|
|
ArchestrA.Diagnostics.Logger.LogCustom(CustomFlags.AppEditorPerformance, () => string.Format(CultureInfo.InvariantCulture, Strings.AppPublisher_CopyAppPerformance, objectName, sourceDir, destPath, stopWatch.ElapsedMilliseconds));
|
|
return destPath;
|
|
}
|
|
|
|
private static void DeleteAndCopyFiles(string objectName, string sourceDir, ref string destPath)
|
|
{
|
|
//IL_00af: Expected O, but got Unknown
|
|
try
|
|
{
|
|
Utils.MaximumDirNameLengthCheck(sourceDir);
|
|
if (Directory.Exists(destPath))
|
|
{
|
|
string formattedString = string.Format(CultureInfo.InvariantCulture, Strings.Directory_DeletionInformation, objectName, destPath);
|
|
ArchestrA.Diagnostics.Logger.LogCustom(CustomFlags.AppEditor, () => formattedString);
|
|
Directory.Delete(destPath, recursive: true);
|
|
}
|
|
Utils.DirectoryCopy(sourceDir, destPath, true, new string[1] { "AppManifest.xml" });
|
|
string text = Path.Combine(sourceDir, "AppManifest.xml");
|
|
if (File.Exists(text))
|
|
{
|
|
File.Copy(text, Path.Combine(destPath, "AppManifest.xml"), overwrite: true);
|
|
}
|
|
}
|
|
catch (DisplayOperationException ex)
|
|
{
|
|
DisplayOperationException ex2 = ex;
|
|
DisplayOperationException doe = ex2;
|
|
ArchestrA.Diagnostics.Logger.LogWarning(() => string.Format(CultureInfo.InvariantCulture, Strings.AppPublisher_ErrorMessage, objectName, doe));
|
|
destPath = null;
|
|
}
|
|
catch (DirectoryNotFoundException ex3)
|
|
{
|
|
DirectoryNotFoundException ex4 = ex3;
|
|
DirectoryNotFoundException dnf = ex4;
|
|
ArchestrA.Diagnostics.Logger.LogWarning(() => string.Format(CultureInfo.InvariantCulture, Strings.AppPublisher_ErrorMessage, objectName, dnf));
|
|
destPath = null;
|
|
}
|
|
catch (UnauthorizedAccessException)
|
|
{
|
|
destPath = null;
|
|
throw;
|
|
}
|
|
catch (Exception ex6)
|
|
{
|
|
Exception ex7 = ex6;
|
|
Exception ex8 = ex7;
|
|
ArchestrA.Diagnostics.Logger.LogWarning(() => string.Format(CultureInfo.InvariantCulture, Strings.CopyError, ex8.Message));
|
|
}
|
|
}
|
|
|
|
private static string GetLibraryPath(IGalaxyGraphics galaxyGraphics, string objectName)
|
|
{
|
|
IVisualElementReference visualElementReference = galaxyGraphics.CreateVisualElementReference();
|
|
visualElementReference.Name = objectName;
|
|
visualElementReference.Type = "DisplayModule";
|
|
ERRORCODE status;
|
|
string statusMessage;
|
|
return galaxyGraphics.GetVisualElementDescription(visualElementReference, preferCheckedOutVersion: true, out status, out statusMessage)?.GetAssociatedFilePath(AssociatedFilePathType.CheckedInPath);
|
|
}
|
|
}
|
|
internal class ControlLoader : Disposable
|
|
{
|
|
private readonly string libraryBasePath;
|
|
|
|
private readonly EditorMetadata editorMetadata;
|
|
|
|
private AppDomain appDomain;
|
|
|
|
public ControlLoader(string path)
|
|
{
|
|
libraryBasePath = path;
|
|
appDomain = AppDomain.CurrentDomain;
|
|
}
|
|
|
|
public ControlLoader(Tuple<string, EditorMetadata> appPathEditorTuple)
|
|
{
|
|
libraryBasePath = appPathEditorTuple.Item1;
|
|
editorMetadata = appPathEditorTuple.Item2;
|
|
appDomain = AppDomain.CurrentDomain;
|
|
}
|
|
|
|
internal IEditorConfig LoadEditorConfig(out bool previousVersionBinaryFound)
|
|
{
|
|
previousVersionBinaryFound = false;
|
|
try
|
|
{
|
|
appDomain.AssemblyResolve += AppDomain_AssemblyResolve;
|
|
if (!string.IsNullOrWhiteSpace(editorMetadata.AssemblyName) && !string.IsNullOrWhiteSpace(editorMetadata.FullName))
|
|
{
|
|
Assembly assembly = Assembly.Load(editorMetadata.AssemblyName);
|
|
DateTime assemblyCreationDateTime = GetAssemblyCreationDateTime(string.Join("\\", libraryBasePath, editorMetadata.AssemblyName + ".dll"));
|
|
DateTime assemblyCreationDateTime2 = GetAssemblyCreationDateTime(assembly.Location);
|
|
if (!DateTime.Equals(assemblyCreationDateTime, assemblyCreationDateTime2))
|
|
{
|
|
previousVersionBinaryFound = true;
|
|
return null;
|
|
}
|
|
object obj = Activator.CreateInstance(assembly.GetType(editorMetadata.FullName));
|
|
return (IEditorConfig)((obj is IEditorConfig) ? obj : null);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Exception ex2 = ex;
|
|
Exception ex3 = ex2;
|
|
ArchestrA.Diagnostics.Logger.LogWarning(() => string.Format(CultureInfo.InvariantCulture, Strings.ControlLoader_EditorLoadFailure, libraryBasePath, ex3));
|
|
}
|
|
return null;
|
|
}
|
|
|
|
private static DateTime GetAssemblyCreationDateTime(string path)
|
|
{
|
|
return new FileInfo(path).LastWriteTime;
|
|
}
|
|
|
|
[SuppressMessage("Microsoft.Reliability", "CA2001:AvoidCallingProblematicMethods", MessageId = "System.Reflection.Assembly.LoadFrom", Justification = "Needed to load the dependent assmblies of app Editor")]
|
|
private Assembly AppDomain_AssemblyResolve(object sender, ResolveEventArgs args)
|
|
{
|
|
try
|
|
{
|
|
string text = Directory.GetFiles(libraryBasePath, args.Name + ".dll", SearchOption.AllDirectories).FirstOrDefault();
|
|
if (!string.IsNullOrEmpty(text))
|
|
{
|
|
return Assembly.LoadFrom(text);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Exception ex2 = ex;
|
|
Exception ex3 = ex2;
|
|
ArchestrA.Diagnostics.Logger.LogWarning(() => string.Format(CultureInfo.InvariantCulture, Strings.ControlLoader_EditorLoadFailure, libraryBasePath, ex3));
|
|
}
|
|
return null;
|
|
}
|
|
|
|
protected override void Dispose(bool disposing)
|
|
{
|
|
if (disposing && appDomain != null)
|
|
{
|
|
appDomain.AssemblyResolve -= AppDomain_AssemblyResolve;
|
|
appDomain = null;
|
|
}
|
|
base.Dispose(disposing);
|
|
}
|
|
}
|
|
public sealed class AppEditorSupportEntity : DisplayModuleEntity
|
|
{
|
|
public IVisualElementReferenceList References { get; set; }
|
|
|
|
public bool LoadAppData(Stream stream, out Dictionary<string, byte[]> appData)
|
|
{
|
|
appData = null;
|
|
if (!((DisplayModuleEntity)this).LoadAppData(stream))
|
|
{
|
|
return false;
|
|
}
|
|
appData = ((DisplayModuleEntity)this).AppData;
|
|
return true;
|
|
}
|
|
|
|
public bool SaveData(Stream stream, Dictionary<string, byte[]> appData)
|
|
{
|
|
((DisplayModuleEntity)this).AppData.Clear();
|
|
foreach (KeyValuePair<string, byte[]> appDatum in appData)
|
|
{
|
|
((DisplayModuleEntity)this).AppData.Add(appDatum.Key, appDatum.Value);
|
|
}
|
|
return ((DisplayModuleEntity)this).SaveAppData(stream);
|
|
}
|
|
|
|
public override bool SaveAppData(Stream stream)
|
|
{
|
|
if (!((DisplayModuleEntity)this).SaveAppData(stream))
|
|
{
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
}
|
|
public class CredentialEditorControlInternal : Control
|
|
{
|
|
public static readonly DependencyProperty ItemsSourceProperty;
|
|
|
|
public static readonly DependencyProperty TextProperty;
|
|
|
|
internal Dictionary<string, string> ItemsSource
|
|
{
|
|
get
|
|
{
|
|
return (Dictionary<string, string>)GetValue(ItemsSourceProperty);
|
|
}
|
|
set
|
|
{
|
|
SetValue(ItemsSourceProperty, value);
|
|
}
|
|
}
|
|
|
|
public string Text
|
|
{
|
|
get
|
|
{
|
|
return (string)GetValue(TextProperty);
|
|
}
|
|
set
|
|
{
|
|
SetValue(TextProperty, value);
|
|
}
|
|
}
|
|
|
|
public event EventHandler TextChanged;
|
|
|
|
private static void OnTextPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
|
{
|
|
(d as CredentialEditorControlInternal).TextChanged?.Invoke(null, null);
|
|
}
|
|
|
|
public void UpdateTextProperty(string text)
|
|
{
|
|
if (Text != text)
|
|
{
|
|
Text = text;
|
|
}
|
|
}
|
|
|
|
[SuppressMessage("Microsoft.Performance", "CA1810:InitializeReferenceTypeStaticFieldsInline")]
|
|
static CredentialEditorControlInternal()
|
|
{
|
|
ItemsSourceProperty = DependencyProperty.Register("ItemsSource", typeof(Dictionary<string, string>), typeof(CredentialEditorControlInternal), new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault));
|
|
TextProperty = DependencyProperty.Register("Text", typeof(string), typeof(CredentialEditorControlInternal), new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnTextPropertyChanged));
|
|
FrameworkElement.DefaultStyleKeyProperty.OverrideMetadata(typeof(CredentialEditorControlInternal), new FrameworkPropertyMetadata(typeof(CredentialEditorControlInternal)));
|
|
}
|
|
|
|
public override void OnApplyTemplate()
|
|
{
|
|
PoupulateComboBox();
|
|
}
|
|
|
|
private void PoupulateComboBox()
|
|
{
|
|
try
|
|
{
|
|
string[] galaxyCredentialNameList = AppPublisher.Instance.GetGalaxyCredentialNameList();
|
|
if (galaxyCredentialNameList == null || galaxyCredentialNameList.Length == 0)
|
|
{
|
|
ArchestrA.Diagnostics.Logger.LogWarning(() => "Querying GalaxyConfiguration for configured credentials returns zero results. Please ensure credentials are configuired in galaxy security configuration.");
|
|
return;
|
|
}
|
|
Dictionary<string, string> dictionary = new Dictionary<string, string> {
|
|
{
|
|
Strings.None_Label,
|
|
null
|
|
} };
|
|
string[] array = galaxyCredentialNameList;
|
|
foreach (string text in array)
|
|
{
|
|
dictionary.Add(text, text);
|
|
}
|
|
ItemsSource = dictionary;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Exception ex2 = ex;
|
|
Exception ex3 = ex2;
|
|
ArchestrA.Diagnostics.Logger.LogWarning(() => ex3.ToString());
|
|
}
|
|
}
|
|
}
|
|
public class EditorControlFactoryInternal : EditorControlFactory, IExtension
|
|
{
|
|
private const string ControlFactory = "ArchestrA.Client.AppConfig.CredentialEditorControl";
|
|
|
|
public string ExtensionTypeName => typeof(EditorControlFactoryInternal).FullName;
|
|
|
|
public override FrameworkElement GetControl(string type)
|
|
{
|
|
if (type == "ArchestrA.Client.AppConfig.CredentialEditorControl")
|
|
{
|
|
return new CredentialEditorControlInternal();
|
|
}
|
|
return null;
|
|
}
|
|
}
|
|
internal static class CustomFlags
|
|
{
|
|
internal static readonly string AppEditor = "AppEditor";
|
|
|
|
internal static readonly string AppEditorPerformance = "AppEditorPerformance";
|
|
|
|
internal static readonly string CredentialEditor = "CredentialEditor";
|
|
}
|
|
[Export(typeof(IEditorFactory))]
|
|
internal sealed class EditorFactory : IEditorFactory
|
|
{
|
|
private const string BaseAppsDir = "ArchestrA\\Apps";
|
|
|
|
public string Codebase => "DemoTestApp.Editor";
|
|
|
|
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Justification = "MEF")]
|
|
[Import]
|
|
internal IDialogService DialogService { get; private set; }
|
|
|
|
public EditorViewModelBase Create(IVisualElementConfiguration configuration, bool isReadOnly)
|
|
{
|
|
//IL_021e: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0223: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_023d: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0262: Expected O, but got Unknown
|
|
//IL_01db: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0205: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0215: Expected O, but got Unknown
|
|
//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0100: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_011a: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_012a: Expected O, but got Unknown
|
|
IEditorConfig control = null;
|
|
AppEditorSupportViewModel appEditorSupportViewModel = null;
|
|
bool previousVersionBinaryFound = false;
|
|
try
|
|
{
|
|
string destinationPath = GetDestinationPath(configuration);
|
|
Tuple<string, EditorMetadata> appPathEditorTuple = AppPublisher.Instance.PublishAndGetEditorMetadata(configuration.ElementName, configuration.ObjectID, destinationPath, loadEditorMetadata: true);
|
|
Stopwatch stopWatch = new Stopwatch();
|
|
stopWatch.Start();
|
|
if (Directory.Exists(appPathEditorTuple.Item1))
|
|
{
|
|
ArchestrA.Diagnostics.Logger.LogCustom(CustomFlags.AppEditor, () => string.Format(CultureInfo.InvariantCulture, Strings.EditorFactory_AppPublishedPath, configuration.ElementName, appPathEditorTuple.Item1));
|
|
using (ControlLoader controlLoader = new ControlLoader(appPathEditorTuple))
|
|
{
|
|
control = controlLoader.LoadEditorConfig(out previousVersionBinaryFound);
|
|
}
|
|
if (control == null)
|
|
{
|
|
stopWatch.Stop();
|
|
if (previousVersionBinaryFound)
|
|
{
|
|
DialogService.DisplayNotification(new NotificationDialogParameters
|
|
{
|
|
Details = string.Format(CultureInfo.CurrentCulture, Strings.AppEditor_LatestAppVersionFound),
|
|
Title = Strings.AppEditor_Title
|
|
});
|
|
return null;
|
|
}
|
|
ArchestrA.Diagnostics.Logger.LogCustom(CustomFlags.AppEditorPerformance, () => string.Format(CultureInfo.InvariantCulture, Strings.EditorFactory_AppEditorPerformance, configuration.ElementName, stopWatch.ElapsedMilliseconds));
|
|
}
|
|
else
|
|
{
|
|
ArchestrA.Diagnostics.Logger.LogCustom(CustomFlags.AppEditor, () => string.Format(CultureInfo.InvariantCulture, Strings.EditorFactory_EditorConfig, ((object)control).GetType()));
|
|
appEditorSupportViewModel = new AppEditorSupportViewModel(configuration, isReadOnly, control);
|
|
ArchestrA.Diagnostics.Logger.LogCustom(CustomFlags.AppEditor, () => string.Format(CultureInfo.InvariantCulture, Strings.EditorFactory_InitializeAppEditor, configuration.ElementName));
|
|
control.InitializeEditor((IEditorBase)(object)appEditorSupportViewModel);
|
|
stopWatch.Stop();
|
|
ArchestrA.Diagnostics.Logger.LogCustom(CustomFlags.AppEditorPerformance, () => string.Format(CultureInfo.InvariantCulture, Strings.EditorFactory_AppEditorPerformance, configuration.ElementName, stopWatch.ElapsedMilliseconds));
|
|
}
|
|
}
|
|
if (appEditorSupportViewModel == null)
|
|
{
|
|
DialogService.DisplayNotification(new NotificationDialogParameters
|
|
{
|
|
Details = string.Format(CultureInfo.CurrentCulture, Strings.AppEditorNotfoundNotificationDetail, configuration.ElementName),
|
|
Title = Strings.AppEditor_Title
|
|
});
|
|
}
|
|
}
|
|
catch (UnauthorizedAccessException)
|
|
{
|
|
DialogService.DisplayNotification(new NotificationDialogParameters
|
|
{
|
|
Details = string.Format(CultureInfo.CurrentCulture, Strings.AppEditor_LatestAppVersionFound),
|
|
Title = string.Format(CultureInfo.CurrentCulture, Strings.AppEditor_LatestAppVersionFound_Title, configuration.ElementName)
|
|
});
|
|
}
|
|
return (EditorViewModelBase)(object)appEditorSupportViewModel;
|
|
}
|
|
|
|
private static string GetDestinationPath(IVisualElementConfiguration configuration)
|
|
{
|
|
string path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "ArchestrA\\Apps");
|
|
return Path.Combine(path2: configuration.ObjectID.ToString(CultureInfo.InvariantCulture), path1: Path.Combine(path, EditorLauncher.GalaxyName));
|
|
}
|
|
}
|
|
internal sealed class AppEditorSupportPreferences : EditorPreferencesBase
|
|
{
|
|
[SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
|
|
private readonly IEditorConfig control;
|
|
|
|
public AppEditorSupportPreferences(IEditorConfig control)
|
|
{
|
|
this.control = control;
|
|
}
|
|
}
|
|
public sealed class AppEditorSupportViewModel : EditorViewModelBase
|
|
{
|
|
private const string VisualElementDefinitionGrmAttribute = "_VisualElementDefinitionGRM";
|
|
|
|
private readonly IEditorConfig control;
|
|
|
|
public override object SelectedItem { get; set; }
|
|
|
|
public override string EditorName => ((EditorViewModelBase)this).Entity.Name + " Editor";
|
|
|
|
public AppEditorSupportViewModel(IVisualElementConfiguration configuration, bool isReadOnly, IEditorConfig control)
|
|
: base(configuration, isReadOnly, (IEntity)(object)new AppEditorSupportEntity(), (EditorPreferencesBase)(object)new AppEditorSupportPreferences(control))
|
|
{
|
|
this.control = control;
|
|
}
|
|
|
|
protected override IEnumerable<IEditorActivity> CreateActivities()
|
|
{
|
|
Load();
|
|
return control.GetActivities();
|
|
}
|
|
|
|
protected override void OnInitialized()
|
|
{
|
|
((EditorViewModelBase)this).OnInitialized();
|
|
((EditorViewModelBase)this).AppCommandManager = (IAppCommandManagerBase)(object)new AppCommandManager(((EditorViewModelBase)this).CommandManager);
|
|
}
|
|
|
|
[SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", MessageId = "VisualElementDefinitionGrmAttribute")]
|
|
private void Load()
|
|
{
|
|
try
|
|
{
|
|
byte[] array = (byte[])((EditorViewModelBase)this).Configuration.GetAttribute("_VisualElementDefinitionGRM");
|
|
if (array == null || (array.Length == 1 && array[0] == 0))
|
|
{
|
|
return;
|
|
}
|
|
ArchestrA.Diagnostics.Logger.LogTrace(() => "Loading existing data.");
|
|
using MemoryStream stream = new MemoryStream(array);
|
|
object[] array2 = (object[])((EditorViewModelBase)this).Configuration.GetAttribute("_VisualElementReferenceList");
|
|
object[] array3 = (object[])((EditorViewModelBase)this).Configuration.GetAttribute("_VisualElementReferenceStatusList");
|
|
VisualElementReferenceList references = ((array2 != null && array3 != null) ? new VisualElementReferenceList(array2.Cast<string>().ToArray(), array3.Select((object s) => string.Equals((string)s, "1", StringComparison.Ordinal)).ToArray()) : new VisualElementReferenceList());
|
|
AppEditorSupportEntity obj = ((EditorViewModelBase)this).Entity as AppEditorSupportEntity;
|
|
obj.References = references;
|
|
obj.LoadAppData(stream, out var appData);
|
|
control.Load(appData);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Exception ex2 = ex;
|
|
Exception ex3 = ex2;
|
|
ArchestrA.Diagnostics.Logger.LogError(() => $"Failed to load VisualElementDefinitionGrmAttribute value. Error details = {ex3.ToString()}");
|
|
}
|
|
}
|
|
|
|
public override bool Save(bool isClosing)
|
|
{
|
|
bool result = true;
|
|
try
|
|
{
|
|
((EditorViewModelBase)this).Configuration.SetAttribute("_ConfigErrors", (object)((IEnumerable<object>)((EditorViewModelBase)this).Errors.ToArray()).ToArray());
|
|
((EditorViewModelBase)this).Configuration.SetAttribute("_ConfigWarnings", (object)((IEnumerable<object>)((EditorViewModelBase)this).InternalWarnings.ToArray()).ToArray());
|
|
using (MemoryStream memoryStream = new MemoryStream())
|
|
{
|
|
try
|
|
{
|
|
AppEditorSupportEntity obj = ((EditorViewModelBase)this).Entity as AppEditorSupportEntity;
|
|
Dictionary<string, byte[]> appData = control.Save();
|
|
if (!obj.SaveData(memoryStream, appData))
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Exception ex2 = ex;
|
|
Exception saveException = ex2;
|
|
ArchestrA.Diagnostics.Logger.LogWarning(() => $"Failed to save configuration for the Entity '{((EditorViewModelBase)this).Entity.Name}'. Error = {saveException}");
|
|
return false;
|
|
}
|
|
((EditorViewModelBase)this).Configuration.SetAttribute("_VisualElementDefinitionGRM", (object)memoryStream.GetBuffer());
|
|
string a = ((EditorViewModelBase)this).Validate(isClosing);
|
|
if (string.Equals(a, ConfirmationDialogCommand.Cancel.Id, StringComparison.Ordinal))
|
|
{
|
|
return false;
|
|
}
|
|
if (string.Equals(a, ConfirmationDialogCommand.No.Id, StringComparison.Ordinal))
|
|
{
|
|
return true;
|
|
}
|
|
if (!((EditorViewModelBase)this).Configuration.Commit())
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
((EditorViewModelBase)this).IsDirty = false;
|
|
}
|
|
catch (Exception ex3)
|
|
{
|
|
Exception ex2 = ex3;
|
|
Exception ex4 = ex2;
|
|
ArchestrA.Diagnostics.Logger.LogWarning(() => $"Error while saving the configuration for the entity '{((EditorViewModelBase)this).Entity.Name}'. Error = {ex4.ToString()}");
|
|
result = false;
|
|
}
|
|
return result;
|
|
}
|
|
}
|
|
}
|
|
namespace ArchestrA.Client.AppConfigInt.Resources
|
|
{
|
|
[GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")]
|
|
[DebuggerNonUserCode]
|
|
[CompilerGenerated]
|
|
internal class Strings
|
|
{
|
|
private static ResourceManager resourceMan;
|
|
|
|
private static CultureInfo resourceCulture;
|
|
|
|
[EditorBrowsable(EditorBrowsableState.Advanced)]
|
|
internal static ResourceManager ResourceManager
|
|
{
|
|
get
|
|
{
|
|
if (resourceMan == null)
|
|
{
|
|
resourceMan = new ResourceManager("ArchestrA.Client.AppConfigInt.Resources.Strings", typeof(Strings).Assembly);
|
|
}
|
|
return resourceMan;
|
|
}
|
|
}
|
|
|
|
[EditorBrowsable(EditorBrowsableState.Advanced)]
|
|
internal static CultureInfo Culture
|
|
{
|
|
get
|
|
{
|
|
return resourceCulture;
|
|
}
|
|
set
|
|
{
|
|
resourceCulture = value;
|
|
}
|
|
}
|
|
|
|
internal static string AddItem_Label => ResourceManager.GetString("AddItem_Label", resourceCulture);
|
|
|
|
internal static string AppEditor_LatestAppVersionFound => ResourceManager.GetString("AppEditor_LatestAppVersionFound", resourceCulture);
|
|
|
|
internal static string AppEditor_LatestAppVersionFound_Title => ResourceManager.GetString("AppEditor_LatestAppVersionFound_Title", resourceCulture);
|
|
|
|
internal static string AppEditor_Title => ResourceManager.GetString("AppEditor_Title", resourceCulture);
|
|
|
|
internal static string AppEditorNotfoundNotificationDetail => ResourceManager.GetString("AppEditorNotfoundNotificationDetail", resourceCulture);
|
|
|
|
internal static string AppPublisher_AppSourcePath => ResourceManager.GetString("AppPublisher_AppSourcePath", resourceCulture);
|
|
|
|
internal static string AppPublisher_CopyAppAssembliesInformation => ResourceManager.GetString("AppPublisher_CopyAppAssembliesInformation", resourceCulture);
|
|
|
|
internal static string AppPublisher_CopyAppLibrary => ResourceManager.GetString("AppPublisher_CopyAppLibrary", resourceCulture);
|
|
|
|
internal static string AppPublisher_CopyAppPerformance => ResourceManager.GetString("AppPublisher_CopyAppPerformance", resourceCulture);
|
|
|
|
internal static string AppPublisher_EditorAssemblyFileNotfound => ResourceManager.GetString("AppPublisher_EditorAssemblyFileNotfound", resourceCulture);
|
|
|
|
internal static string AppPublisher_ErrorMessage => ResourceManager.GetString("AppPublisher_ErrorMessage", resourceCulture);
|
|
|
|
internal static string Compound1_Label => ResourceManager.GetString("Compound1_Label", resourceCulture);
|
|
|
|
internal static string Compound2_Label => ResourceManager.GetString("Compound2_Label", resourceCulture);
|
|
|
|
internal static string ControlLoader_EditorLoadFailure => ResourceManager.GetString("ControlLoader_EditorLoadFailure", resourceCulture);
|
|
|
|
internal static string CopyError => ResourceManager.GetString("CopyError", resourceCulture);
|
|
|
|
internal static string Directory_DeletionInformation => ResourceManager.GetString("Directory_DeletionInformation", resourceCulture);
|
|
|
|
internal static string EditorFactory_AppEditorPerformance => ResourceManager.GetString("EditorFactory_AppEditorPerformance", resourceCulture);
|
|
|
|
internal static string EditorFactory_AppPublishedPath => ResourceManager.GetString("EditorFactory_AppPublishedPath", resourceCulture);
|
|
|
|
internal static string EditorFactory_EditorConfig => ResourceManager.GetString("EditorFactory_EditorConfig", resourceCulture);
|
|
|
|
internal static string EditorFactory_InitializeAppEditor => ResourceManager.GetString("EditorFactory_InitializeAppEditor", resourceCulture);
|
|
|
|
internal static string GetCredentials_Label => ResourceManager.GetString("GetCredentials_Label", resourceCulture);
|
|
|
|
internal static string ItemCommands_Label => ResourceManager.GetString("ItemCommands_Label", resourceCulture);
|
|
|
|
internal static string MoveItemDown_Label => ResourceManager.GetString("MoveItemDown_Label", resourceCulture);
|
|
|
|
internal static string MoveItemUp_Label => ResourceManager.GetString("MoveItemUp_Label", resourceCulture);
|
|
|
|
internal static string None_Label => ResourceManager.GetString("None_Label", resourceCulture);
|
|
|
|
internal static string RedoStack_Label => ResourceManager.GetString("RedoStack_Label", resourceCulture);
|
|
|
|
internal static string RemoveItem_Label => ResourceManager.GetString("RemoveItem_Label", resourceCulture);
|
|
|
|
internal static string SetProperty_Label => ResourceManager.GetString("SetProperty_Label", resourceCulture);
|
|
|
|
internal static string TestMainActivityViewModel_Label => ResourceManager.GetString("TestMainActivityViewModel_Label", resourceCulture);
|
|
|
|
internal static string TestScriptActivityViewModel_Label => ResourceManager.GetString("TestScriptActivityViewModel_Label", resourceCulture);
|
|
|
|
internal static string Toggle_Label => ResourceManager.GetString("Toggle_Label", resourceCulture);
|
|
|
|
internal static string UndoStack_Label => ResourceManager.GetString("UndoStack_Label", resourceCulture);
|
|
|
|
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
|
internal Strings()
|
|
{
|
|
}
|
|
}
|
|
}
|
|
namespace ArchestrA.Diagnostics
|
|
{
|
|
[ExcludeFromCodeCoverage]
|
|
internal static class Logger
|
|
{
|
|
private static ILoggerClient loggerClient = LoggerClient.CreateNew(Assembly.GetExecutingAssembly().GetName().Name);
|
|
|
|
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
|
public static bool IsErrorEnabled
|
|
{
|
|
get
|
|
{
|
|
if (loggerClient == null)
|
|
{
|
|
return false;
|
|
}
|
|
return loggerClient.IsErrorEnabled;
|
|
}
|
|
}
|
|
|
|
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
|
public static bool IsWarningEnabled
|
|
{
|
|
get
|
|
{
|
|
if (loggerClient == null)
|
|
{
|
|
return false;
|
|
}
|
|
return loggerClient.IsWarningEnabled;
|
|
}
|
|
}
|
|
|
|
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
|
public static bool IsInfoEnabled
|
|
{
|
|
get
|
|
{
|
|
if (loggerClient == null)
|
|
{
|
|
return false;
|
|
}
|
|
return loggerClient.IsInfoEnabled;
|
|
}
|
|
}
|
|
|
|
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
|
public static bool IsTraceEnabled
|
|
{
|
|
get
|
|
{
|
|
if (loggerClient == null)
|
|
{
|
|
return false;
|
|
}
|
|
return loggerClient.IsTraceEnabled;
|
|
}
|
|
}
|
|
|
|
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
|
public static bool IsCustomLogEnabled(string customLogName)
|
|
{
|
|
if (loggerClient == null)
|
|
{
|
|
return false;
|
|
}
|
|
return loggerClient.IsCustomLogEnabled(customLogName);
|
|
}
|
|
|
|
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Justification = "Method does not have to be used by all clients of the Logger.")]
|
|
public static void LogError(Func<string> getMessage, Exception exception = null)
|
|
{
|
|
loggerClient?.LogError(getMessage, exception);
|
|
}
|
|
|
|
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Justification = "Method does not have to be used by all clients of the Logger.")]
|
|
public static void LogWarning(Func<string> getMessage, Exception exception = null)
|
|
{
|
|
loggerClient?.LogWarning(getMessage, exception);
|
|
}
|
|
|
|
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Justification = "Method does not have to be used by all clients of the Logger.")]
|
|
public static void LogInfo(Func<string> getMessage)
|
|
{
|
|
loggerClient?.LogInfo(getMessage);
|
|
}
|
|
|
|
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Justification = "Method does not have to be used by all clients of the Logger.")]
|
|
public static void LogTrace(Func<string> getMessage, Exception exception = null)
|
|
{
|
|
loggerClient?.LogTrace(getMessage, exception);
|
|
}
|
|
|
|
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Justification = "Method does not have to be used by all clients of the Logger.")]
|
|
public static void LogCustom(string customLogName, Func<string> getMessage)
|
|
{
|
|
loggerClient?.LogCustom(customLogName, getMessage);
|
|
}
|
|
|
|
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Justification = "Method does not have to be used by all clients of the Logger.")]
|
|
public static void LogEntry(Func<string> getMessage, [CallerMemberName] string callerName = "")
|
|
{
|
|
loggerClient?.LogEntryExit(getMessage, "Entered", callerName);
|
|
}
|
|
|
|
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Justification = "Method does not have to be used by all clients of the Logger.")]
|
|
public static void LogExit(Func<string> getMessage, [CallerMemberName] string callerName = "")
|
|
{
|
|
loggerClient?.LogEntryExit(getMessage, "Exiting", callerName);
|
|
}
|
|
|
|
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Justification = "Method does not have to be used by all clients of the Logger.")]
|
|
public static void LogDispose(string className)
|
|
{
|
|
loggerClient?.LogWarning(() => $"Failed to call Dispose() for class {className}. Clean up of unmanaged resource was deferred to garbage collector.");
|
|
}
|
|
}
|
|
}
|