Skip to content

Commit

Permalink
Create installation
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasArdal committed Nov 7, 2024
1 parent 96c90b9 commit d93cbae
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/Elmah.Io.Wpf/ElmahIoWpf.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ namespace Elmah.Io.Wpf
public static class ElmahIoWpf
{
private static readonly string _assemblyVersion = typeof(ElmahIoWpf).Assembly.GetName().Version.ToString();
private static readonly string _elmahIoClientAssemblyVersion = typeof(IElmahioAPI).Assembly.GetName().Version.ToString();
private static readonly string _presentationFrameworkAssemblyVersion = typeof(Application).Assembly.GetName().Version.ToString();

private static ElmahIoWpfOptions _options;
Expand Down Expand Up @@ -65,6 +66,8 @@ public static void Init(ElmahIoWpfOptions options)
if (!Debugger.IsAttached)
Log(args.Exception);
};

CreateInstallation();
}

/// <summary>
Expand Down Expand Up @@ -295,5 +298,37 @@ private static string UserAgent()
.Append(new ProductInfoHeaderValue(new ProductHeaderValue("PresentationFramework", _presentationFrameworkAssemblyVersion)).ToString())
.ToString();
}

private static void CreateInstallation()
{
try
{
var loggerInfo = new LoggerInfo
{
Type = "Elmah.Io.Wpf",
Properties = [],
ConfigFiles = [],
Assemblies =
[
new AssemblyInfo { Name = "Elmah.Io.Wpf", Version = _assemblyVersion },
new AssemblyInfo { Name = "Elmah.Io.Client", Version = _elmahIoClientAssemblyVersion },
new AssemblyInfo { Name = "PresentationFramework", Version = _presentationFrameworkAssemblyVersion }
],
};

var installation = new CreateInstallation
{
Type = "windowsapp",
Name = _options.Application,
Loggers = [loggerInfo]
};

_logger.Installations.Create(_options.LogId.ToString(), installation);
}
catch
{
// We don't want to crash the entire application if the installation fails. Carry on.
}
}
}
}

0 comments on commit d93cbae

Please sign in to comment.