public void Test() { var e = new Example() { Property = 3, Field = "3" }; var c = new Example(); MemberwiseCopier.Invoke(e, c, copier => copier.WithFields()); c.Property.Should().Be(e.Property); c.Field.Should().Be(e.Field); }
public void Test() { var e = new Example() { Property = 3, Field = "3" }; var c = new Example(); MemberwiseCopier.CopyMembers(e, c, o => o.AddFields()); c.Property.Should().Be(e.Property); c.Field.Should().Be(e.Field); }
internal FusionWebSocketServerBuilder(FusionBuilder fusion) { Fusion = fusion; if (Services.Contains(AddedTagDescriptor)) { return; } // We want above Contains call to run in O(1), so... Services.Insert(0, AddedTagDescriptor); Fusion.AddPublisher(); Services.TryAddSingleton <WebSocketServer.Options>(); Services.TryAddSingleton <WebSocketServer>(); Services.AddMvcCore() .AddNewtonsoftJson( options => MemberwiseCopier.CopyMembers( JsonNetSerializer.DefaultSettings, options.SerializerSettings)); }
public void ConfigureServices(IServiceCollection services) { // DbContext & related services var appTempDir = PathEx.GetApplicationTempDirectory("", true); var dbPath = appTempDir & "Chat.db"; services .AddDbContextPool <ChatDbContext>(builder => { builder.UseSqlite($"Data Source={dbPath}", sqlite => { }); }); // Fusion services services.AddSingleton(new Publisher.Options() { Id = Settings.PublisherId }); services.AddFusionWebSocketServer(); // Helpers used by ChatService services.AddTransient(c => new HttpClient()); services.AddRestEaseCore(); // This method registers services marked with any of ServiceAttributeBase descendants, including: // [Service], [ComputeService], [RestEaseReplicaService], [LiveStateUpdater] services.AddServices(Assembly.GetExecutingAssembly()); // Registering shared services from the client Client.Program.ConfigureSharedServices(services); // Web services.AddRouting(); services.AddMvc() .AddNewtonsoftJson(options => MemberwiseCopier .New(JsonNetSerializer.DefaultSettings) .Apply(options.SerializerSettings)) .AddApplicationPart(Assembly.GetExecutingAssembly()); services.AddServerSideBlazor(); // Swagger & debug tools services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new OpenApiInfo { Title = "Stl.Sample.Blazor.Server API", Version = "v1" }); }); }