EdwardHsu.ModifyDetector
1.1.1
dotnet add package EdwardHsu.ModifyDetector --version 1.1.1
NuGet\Install-Package EdwardHsu.ModifyDetector -Version 1.1.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="EdwardHsu.ModifyDetector" Version="1.1.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add EdwardHsu.ModifyDetector --version 1.1.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: EdwardHsu.ModifyDetector, 1.1.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install EdwardHsu.ModifyDetector as a Cake Addin #addin nuget:?package=EdwardHsu.ModifyDetector&version=1.1.1 // Install EdwardHsu.ModifyDetector as a Cake Tool #tool nuget:?package=EdwardHsu.ModifyDetector&version=1.1.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
EdwardHsu.ModifyDetector
This library is a .NET library designed to facilitate property modification detection within your classes. It provides a simple and efficient way to implement property change detection within your own classes.
Features
- Property Modification Detection: Detect modifications to properties within your classes.
- Modified Property List Retrieval: Easily retrieve a list of properties that have been modified.
Getting Started
To get started with ModifyDetector, follow these simple steps:
- Install the ModifyDetector package: You can install the ModifyDetector library via NuGet Package Manager or NuGet CLI:
dotnet add package EdwardHsu.ModifyDetector
- Inherit from ModifyDetector class: In the class where you want to implement modification detection, inherit from the
ModifyDetector
class.
using EdwardHsu.ModifyDetector;
public class YourClass : ModifyDetector
{
// Your class implementation
}
- Add ModifyDetectTargetAttribute attribute: Mark the properties or fields you want to monitor for modifications with the
ModifyDetectTargetAttribute
attribute.
using EdwardHsu.ModifyDetector;
public class YourClass : ModifyDetector
{
[ModifyDetectTarget(Order = 0)]
public Guid Id { get; set; }
[ModifyDetectTarget(Order = 1)]
public string Name { get; set; }
}
- Initialize Modification Detection: After setting initial values in your class constructor, call the
UpdateDetectorState()
method to initialize modification detection.
public class YourClass : ModifyDetector
{
public YourClass()
{
Id = Guid.NewGuid();
Name = "Untitled";
UpdateDetectorState();
}
[ModifyDetectTarget(Order = 0)]
public Guid Id { get; set; }
[ModifyDetectTarget(Order = 1)]
public string Name { get; set; }
}
- Access modification information: You can access information about property modifications using the
HasModified(out IEnumerable<ModifiedMember> modifiedMembers)
method.
var instance = new YourClass();
// Modify properties...
var hasModified = instance.HasModified(out var modifiedProperties);
Example
using EdwardHsu.ModifyDetector;
public class YourClass : ModifyDetector
{
public YourClass()
{
Id = Guid.NewGuid();
Name = "Untitled";
UpdateDetectorState();
}
[ModifyDetectTarget(Order = 0)]
public Guid Id { get; set; }
[ModifyDetectTarget(Order = 1)]
public string Name { get; set; }
}
public class Program
{
static void Main(string[] args)
{
var instance = new YourClass();
instance.Name = "New Name";
var hasModified = instance.HasModified(out var modifiedProperties);
// ...Do something...
}
}
License
This library is licensed under the MIT License.
Contribution
Contributions are welcome! Feel free to submit issues, feature requests, or pull requests.
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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net6.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.