net90_PropertyGridHelpers.ServiceProvidersNamespace - dparvin/PropertyGridHelpers GitHub Wiki
A lightweight implementation of that allows manual registration and retrieval of service instances by type.
This is particularly useful for testing scenarios involving components that depend on service injection, such as editors implementing or services using .
It can also be used at runtime to programmatically supply services that PropertyGridHelpers components rely on, especially when not using attributes for service resolution.
var serviceProvider = new CustomServiceProvider();
var instance = new TestClassWithAttribute();
var propDesc = TypeDescriptor.GetProperties(instance)["PropertyWithoutAttribute"];
var editor = new ResourcePathEditor();
var context = new CustomTypeDescriptorContext(propDesc, instance);
serviceProvider.AddService(typeof(IWindowsFormsEditorService), new FakeEditorService());
var result = editor.EditValue(context, serviceProvider, "(none)");
public type | description |
---|---|
class CustomServiceProvider | A lightweight implementation of IServiceProvider that allows manual registration and retrieval of service instances by type. |