Black.Beard.ComponentModel
1.0.4
See the version list below for details.
dotnet add package Black.Beard.ComponentModel --version 1.0.4
NuGet\Install-Package Black.Beard.ComponentModel -Version 1.0.4
<PackageReference Include="Black.Beard.ComponentModel" Version="1.0.4" />
paket add Black.Beard.ComponentModel --version 1.0.4
#r "nuget: Black.Beard.ComponentModel, 1.0.4"
// Install Black.Beard.ComponentModel as a Cake Addin
#addin nuget:?package=Black.Beard.ComponentModel&version=1.0.4
// Install Black.Beard.ComponentModel as a Cake Tool
#tool nuget:?package=Black.Beard.ComponentModel&version=1.0.4
Black.Beard.ComponentModel
Method helper for resolve types and methods.
How to use
You can use in non-intrusive mode. use the type descriptor.
Register the new TypeDescriptorProvider
GenericTypeDescriptionProvider.Register<ExampleType>();
Create a new instance for the specified type
var instance = (ExampleType)TypeDescriptor.CreateInstance(null, typeof(ExampleType), null, null);
var p = TypeDescriptor.GetProperties(i);
var property = p[nameof(ExampleType.Message)];
property.GetValue(i).Should().Be("3");
Add a virtual property
The part based on PropertyTypeDescriptor is insparated from MatthewKing / DynamicDescriptors
var instanceToBind = new ExampleClass();
var descriptor = DynamicDescriptor.CreateFromInstance(instanceToBind);
descriptor.GetDynamicProperty("PropertyOne") // Get the property using its name.
.SetDisplayName("Property #1")
.SetDescription("The first property")
.SetCategory("Example category");
descriptor.GetDynamicProperty((ExampleClass x) => x.Property2) // Get the property using an expression.
.SetDisplayName("Property #2")
.SetDescription("The second property")
.SetCategory("Example category");
propertyGrid.SelectedObject = descriptor;
Binding to an object instance
We can create a DynamicDescriptor for an object instance:
var instance = new ExampleClass();
var descriptor = DynamicDescriptor.CreateFromInstance(instance);
Binding to a dictionary
We can create a DynamicDescriptor backed by a dictionary. This will act as if the dictionary key/value pairs are properties of a bound object:
var data = new Dictionary<string, object>();
data["Property1"] = "hello";
data["Property2"] = "world";
var descriptor = DynamicDescriptor.CreateFromDictionary(data);
We can also supply type information:
var data = new Dictionary<string, object>();
data["Property1"] = "value";
data["Property2"] = 1;
var types = new Dictionary<string, Type>();
types["Property1"] = typeof(string);
types["Property2"] = typeof(int);
var descriptor = DynamicDescriptor.CreateFromDictionary(data, types);
What can be customized?
DisplayName:
descriptor.GetDynamicProperty("PropertyName").SetDisplayName("Property display name");
This modifies the value returned by the DisplayName property.
Description:
descriptor.GetDynamicProperty("PropertyName").SetDescription("A description of the property");
This modifies the value returned by the Description property.
Category:
descriptor.GetDynamicProperty("PropertyName").SetCategory("Category name");
This modifies the value returned by the Category property.
Converter:
TypeConverter converter = /* your custom type converter */;
descriptor.GetDynamicProperty("PropertyName").SetConverter(converter);
This modifies the value returned by the Converter property.
IsReadOnly:
descriptor.GetDynamicProperty("PropertyName").SetReadOnly(true);
This modifies the value returned by the IsReadOnly property.
Property order:
descriptor.GetDynamicProperty("PropertyOne").SetPropertyOrder(1);
descriptor.GetDynamicProperty("PropertyTwo").SetPropertyOrder(2);
descriptor.GetDynamicProperty("PropertyThree").SetPropertyOrder(3);
This modifies the order in which properties are returned by the GetProperties method.
Installation
Just grab it from NuGet
PM> Install-Package DynamicDescriptors
License and copyright
Copyright Matthew King 2012-2020. Distributed under the MIT License. Refer to license.txt for more information.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net6.0
- Black.Beard.ComponentModel.Attributes (>= 1.0.4)
- System.ComponentModel.Annotations (>= 4.6.0)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on Black.Beard.ComponentModel:
Package | Downloads |
---|---|
Black.Beard.Jslt
Implementation of jslt language in DOTNET. Use a template for transform Json document to another json document. |
|
Black.Beard.Roslyn
Helper for compile Csharp at runtime |
|
Black.Beard.Web.Server
Provide a service base for just concentrate your services |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.95 | 92 | 5/5/2024 |
1.0.94 | 97 | 5/4/2024 |
1.0.93 | 46 | 5/3/2024 |
1.0.92 | 54 | 5/3/2024 |
1.0.91 | 154 | 5/2/2024 |
1.0.90 | 62 | 5/1/2024 |
1.0.89 | 88 | 4/24/2024 |
1.0.88 | 96 | 4/24/2024 |
1.0.87 | 85 | 4/24/2024 |
1.0.86 | 109 | 4/22/2024 |
1.0.85 | 86 | 4/22/2024 |
1.0.84 | 75 | 4/21/2024 |
1.0.83 | 77 | 4/21/2024 |
1.0.82 | 82 | 4/21/2024 |
1.0.81 | 78 | 4/21/2024 |
1.0.80 | 75 | 4/21/2024 |
1.0.79 | 74 | 4/18/2024 |
1.0.78 | 79 | 4/18/2024 |
1.0.77 | 83 | 4/18/2024 |
1.0.76 | 76 | 4/18/2024 |
1.0.75 | 86 | 4/15/2024 |
1.0.74 | 102 | 4/14/2024 |
1.0.73 | 89 | 4/14/2024 |
1.0.72 | 84 | 4/14/2024 |
1.0.71 | 89 | 4/14/2024 |
1.0.70 | 96 | 4/13/2024 |
1.0.69 | 91 | 4/13/2024 |
1.0.68 | 89 | 4/13/2024 |
1.0.67 | 85 | 4/13/2024 |
1.0.66 | 83 | 4/13/2024 |
1.0.65 | 84 | 4/13/2024 |
1.0.64 | 84 | 4/12/2024 |
1.0.63 | 78 | 4/12/2024 |
1.0.62 | 86 | 4/11/2024 |
1.0.61 | 80 | 4/10/2024 |
1.0.60 | 100 | 4/8/2024 |
1.0.58 | 164 | 4/6/2024 |
1.0.57 | 950 | 3/9/2024 |
1.0.56 | 92 | 3/5/2024 |
1.0.55 | 111 | 3/5/2024 |
1.0.54 | 92 | 3/4/2024 |
1.0.53 | 143 | 3/4/2024 |
1.0.52 | 267 | 3/3/2024 |
1.0.51 | 90 | 3/3/2024 |
1.0.50 | 78 | 3/3/2024 |
1.0.49 | 95 | 3/2/2024 |
1.0.48 | 638 | 2/4/2024 |
1.0.47 | 90 | 1/27/2024 |
1.0.46 | 144 | 1/6/2024 |
1.0.45 | 102 | 1/6/2024 |
1.0.44 | 124 | 1/6/2024 |
1.0.41 | 1,372 | 6/17/2023 |
1.0.40 | 240 | 6/17/2023 |
1.0.37 | 6,114 | 3/19/2022 |
1.0.36 | 4,093 | 3/15/2022 |
1.0.35 | 431 | 3/6/2022 |
1.0.34 | 424 | 2/11/2022 |
1.0.33 | 410 | 2/11/2022 |
1.0.32 | 411 | 2/11/2022 |
1.0.30 | 412 | 2/11/2022 |
1.0.29 | 434 | 2/9/2022 |
1.0.28 | 394 | 2/8/2022 |
1.0.27 | 403 | 2/8/2022 |
1.0.26 | 415 | 2/8/2022 |
1.0.25 | 410 | 2/6/2022 |
1.0.24 | 464 | 2/4/2022 |
1.0.23 | 444 | 2/2/2022 |
1.0.22 | 419 | 2/1/2022 |
1.0.21 | 426 | 1/27/2022 |
1.0.20 | 426 | 1/27/2022 |
1.0.19 | 429 | 1/26/2022 |
1.0.18 | 436 | 1/26/2022 |
1.0.17 | 424 | 1/20/2022 |
1.0.16 | 425 | 1/15/2022 |
1.0.15 | 432 | 1/15/2022 |
1.0.14 | 440 | 1/12/2022 |
1.0.13 | 281 | 1/12/2022 |
1.0.12 | 448 | 1/12/2022 |
1.0.9 | 276 | 1/9/2022 |
1.0.8 | 279 | 1/9/2022 |
1.0.7 | 257 | 1/9/2022 |
1.0.6 | 274 | 1/8/2022 |
1.0.5 | 10,775 | 12/19/2021 |
1.0.4 | 289 | 12/19/2021 |
1.0.3 | 308 | 12/19/2021 |