https://github.com/roydukkey/Dado.ComponentModel.Mutations
Provides attributes that are used to help ensure data integrity for objects used as data sources.
https://github.com/roydukkey/Dado.ComponentModel.Mutations
c-sharp component-model data-annotations data-attributes
Last synced: 9 months ago
JSON representation
Provides attributes that are used to help ensure data integrity for objects used as data sources.
- Host: GitHub
- URL: https://github.com/roydukkey/Dado.ComponentModel.Mutations
- Owner: roydukkey
- License: apache-2.0
- Archived: true
- Created: 2016-04-11T19:30:03.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2018-11-01T01:45:26.000Z (over 7 years ago)
- Last Synced: 2025-04-30T06:43:53.188Z (10 months ago)
- Topics: c-sharp, component-model, data-annotations, data-attributes
- Language: C#
- Homepage: https://www.nuget.org/packages/Dado.ComponentModel.Mutations
- Size: 125 KB
- Stars: 8
- Watchers: 1
- Forks: 0
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# Dado.ComponentModel.Mutations
Provides attributes that are used to help ensure data integrity for objects used as data sources.
NuGet: https://www.nuget.org/packages/Dado.ComponentModel.Mutations
## Sample Usage
The following class shows that a property should be converted to lowercase and replaced of invalid characters.
```csharp
using System.Text.RegularExpressions;
public class User
{
private string _userName;
public string UserName {
get {
return _userName;
}
set {
value = value.ToLower();
_userName = Regex.Replace(value, @"[^a-z0-9._]", String.Empty);
}
}
}
```
Altering the example to use a mutation attributes will produce the following code.
```csharp
using Dado.ComponentModel.DataMutations;
public class User
{
[
ToLower,
RegexReplace(@"[^a-z0-9._]")
]
public string UserName { get; set; }
}
```
Now, when `Mutator.Mutate(context);` is executed the value of `User.UserName` will be lowercased and have all invalid characters replaced.
[API Documentation](Documentation/README.md#documentation-index)
## Further Development
~~This project is still initial development. APIs have been submitted to [dotnet/corefx#7660](https://www.github.com/dotnet/corefx/issues/7660) for review and are likely to change.~~
## License
Dado.ComponentModel.Mutations is licensed under the [Apache License, Version 2.0](LICENSE).