DynamoVisualProgramming.DynamoServices by Autodesk

<PackageReference Include="DynamoVisualProgramming.DynamoServices" Version="4.0.0-beta2972" />

 NoNetworkModeHandler

Custom HTTP message handler to simulate an "offline mode" (no-network mode) for network requests. It can be used to intercept all outgoing HTTP requests and returns a predefined response indicating that the application is offline.
using System.Net; using System.Net.Http; using System.Text; using System.Threading; using System.Threading.Tasks; namespace Dynamo.Session { public class NoNetworkModeHandler : DelegatingHandler { public NoNetworkModeHandler() : base(new HttpClientHandler()) { } protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) { string content = "{\"success\":false,\"message\":\"Application is in offline mode\",\"content\":null}"; HttpResponseMessage result = new HttpResponseMessage(HttpStatusCode.ServiceUnavailable) { Content = new StringContent(content, Encoding.UTF8, "application/json"), ReasonPhrase = "Offline Mode Enabled" }; return Task.FromResult(result); } } }