This directory contains example projects demonstrating various uses of the Replane .NET SDK.
| Example | Description |
|---|---|
| BasicUsage | Simple console app with basic config reading |
| ConsoleWithOverrides | Context-based overrides and user segmentation |
| BackgroundWorker | Long-running service with real-time config updates |
| WebApiIntegration | ASP.NET Core Web API with middleware and DI |
| UnitTesting | Unit testing with the in-memory test client |
Each example is a self-contained project. To run any example:
-
Copy the example directory to your local machine:
cp -r <example-name> ~/my-example cd ~/my-example
-
Set environment variables (or edit the code):
export REPLANE_BASE_URL="https://your-replane-server.com" export REPLANE_SDK_KEY="your-sdk-key"
-
Restore and run:
dotnet restore dotnet run
The simplest possible example - connect and read configs:
var client = new ReplaneClient(options);
await client.ConnectAsync();
var value = client.Get<bool>("feature-enabled");Shows how to use context for user-specific configuration:
var context = new ReplaneContext
{
["user_id"] = "user-123",
["plan"] = "premium"
};
var feature = client.Get<bool>("premium-feature", context);Demonstrates subscriptions for real-time updates:
client.Subscribe((name, config) =>
{
Console.WriteLine($"Config {name} changed!");
});Full ASP.NET Core integration with middleware:
// Maintenance mode middleware
app.Use(async (context, next) =>
{
if (client.Get<bool>("maintenance-mode"))
{
context.Response.StatusCode = 503;
return;
}
await next();
});Test your code without a server:
using var config = TestClient.Create(new Dictionary<string, object?>
{
["feature-enabled"] = true
});
var service = new MyService(config);
// Test with mocked configs- .NET 8.0 SDK or later
- A Replane server (except for UnitTesting example)
- All examples use default values, so they'll work even without a server
- Each example has its own README with detailed instructions
- Examples reference the
ReplaneNuGet package (version 0.1.0)