Demonstrates how to use context for override evaluation in Replane.
- .NET 8.0 SDK or later
- A running Replane server (optional - works with defaults)
- An SDK key from your Replane project
-
Copy this directory to your local machine:
cp -r ConsoleWithOverrides ~/my-replane-example cd ~/my-replane-example
-
Set your environment variables:
export REPLANE_BASE_URL="https://your-replane-server.com" export REPLANE_SDK_KEY="your-sdk-key"
-
Restore packages:
dotnet restore
dotnet runSet a default context that applies to all config reads:
var client = new ReplaneClient(new ReplaneClientOptions
{
// ...
Context = new ReplaneContext
{
["app_version"] = "2.0.0",
["platform"] = "console"
}
});Pass additional context when reading configs:
var userContext = new ReplaneContext
{
["user_id"] = "user-123",
["plan"] = "premium"
};
var feature = client.Get<bool>("premium-feature", userContext);When you provide context to Get(), it's merged with the default context:
- Per-request context takes precedence for duplicate keys
- Default context fills in any missing keys
Context is used to evaluate override conditions on the client side:
Server Configuration (example):
{
"name": "premium-feature",
"value": false,
"overrides": [
{
"name": "premium-users",
"conditions": [
{
"operator": "in",
"property": "plan",
"value": ["premium", "enterprise"]
}
],
"value": true
}
]
}Client Evaluation:
// Free user - gets base value (false)
client.Get<bool>("premium-feature", new ReplaneContext { ["plan"] = "free" });
// Premium user - matches override, gets true
client.Get<bool>("premium-feature", new ReplaneContext { ["plan"] = "premium" });- Context never leaves the client - All evaluation happens locally
- Overrides are evaluated in order - First match wins
- Missing context properties - Result in "unknown" evaluation, override is skipped
- Type coercion - The SDK handles type conversion between context and condition values
- Feature flags per user plan: Enable features for premium users
- Regional configuration: Different settings per region
- A/B testing: Gradual rollouts based on user ID segmentation
- Device-specific config: Different behavior for mobile vs desktop