891a18819b
* react to renamespacing * merge dev * fmt * initialize things with typeloader * autocad initialization * add arcgis * add more projects to local * instrument rhino more * update nugets * fmt
45 lines
1.8 KiB
C#
45 lines
1.8 KiB
C#
using Speckle.Autofac.DependencyInjection;
|
|
using Speckle.Connectors.DUI.Bridge;
|
|
using Speckle.Connectors.DUI.Models.Card.SendFilter;
|
|
using Speckle.Connectors.DUI.Utils;
|
|
using Speckle.Connectors.Utils.Operations;
|
|
using Speckle.Newtonsoft.Json;
|
|
using Speckle.Newtonsoft.Json.Serialization;
|
|
using Speckle.Sdk.Transports;
|
|
|
|
namespace Speckle.Connectors.DUI;
|
|
|
|
public static class ContainerRegistration
|
|
{
|
|
public static void AddDUI(this SpeckleContainerBuilder speckleContainerBuilder)
|
|
{
|
|
// send operation and dependencies
|
|
speckleContainerBuilder.AddSingletonInstance<ISyncToThread, SyncToUIThread>();
|
|
speckleContainerBuilder.AddSingleton<IRootObjectSender, RootObjectSender>();
|
|
speckleContainerBuilder.AddTransient<IBridge, BrowserBridge>(); // POC: Each binding should have it's own bridge instance
|
|
speckleContainerBuilder.AddSingleton(GetJsonSerializerSettings());
|
|
speckleContainerBuilder.ScanAssemblyOfType<IdleCallManager>();
|
|
speckleContainerBuilder.ScanAssemblyOfType<IServerTransportFactory>();
|
|
}
|
|
|
|
private static JsonSerializerSettings GetJsonSerializerSettings()
|
|
{
|
|
// Register WebView2 panel stuff
|
|
JsonSerializerSettings settings =
|
|
new()
|
|
{
|
|
Error = (_, args) =>
|
|
{
|
|
// POC: we should probably do a bit more than just swallowing this!
|
|
Console.WriteLine("*** JSON ERROR: " + args.ErrorContext);
|
|
},
|
|
ContractResolver = new CamelCasePropertyNamesContractResolver(),
|
|
NullValueHandling = NullValueHandling.Ignore,
|
|
ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
|
|
DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate,
|
|
Converters = { new DiscriminatedObjectConverter(), new AbstractConverter<DiscriminatedObject, ISendFilter>() }
|
|
};
|
|
return settings;
|
|
}
|
|
}
|