PropertyChanging
Injects INotifyPropertyChanging code into properties at compile time.
Install / Use
/learn @Fody/PropertyChangingREADME
<img src="/package_icon.png" height="30px"> PropertyChanging.Fody
Injects INotifyPropertyChanging code into properties at compile time.
See Milestones for release notes.
This is an add-in for Fody
It is expected that all developers using Fody become a Patron on OpenCollective. See Licensing/Patron FAQ for more information.
Usage
See also Fody usage.
NuGet installation
Install the PropertyChanging.Fody NuGet package and update the Fody NuGet package:
PM> Install-Package Fody
PM> Install-Package PropertyChanging.Fody
The Install-Package Fody is required since NuGet always defaults to the oldest, and most buggy, version of any dependency.
Your Code
[ImplementPropertyChanging]
public class Person
{
public string GivenNames { get; set; }
public string FamilyName { get; set; }
public string FullName
{
get
{
return string.Format("{0} {1}", GivenNames, FamilyName);
}
}
}
What gets compiled
public class Person : INotifyPropertyChanging
{
public event PropertyChangingEventHandler PropertyChanging;
string givenNames;
public string GivenNames
{
get { return givenNames; }
set
{
if (value != givenNames)
{
OnPropertyChanging("GivenNames");
OnPropertyChanging("FullName");
givenNames = value;
}
}
}
string familyName;
public string FamilyName
{
get { return familyName; }
set
{
if (value != familyName)
{
OnPropertyChanging("FamilyName");
OnPropertyChanging("FullName");
familyName = value;
}
}
}
public string FullName
{
get
{
return string.Format("{0} {1}", GivenNames, FamilyName);
}
}
public virtual void OnPropertyChanging(string propertyName)
{
var propertyChanging = PropertyChanging;
if (propertyChanging != null)
{
propertyChanging(this, new PropertyChangingEventArgs(propertyName));
}
}
}
More Info
- AccessBeforeValue
- Attributes
- EqualityChecking
- EventInvokerSelectionInjection
- ExampleUsage
- NotificationInterception
- On_PropertyName_Changing
- PropertyDependencies
- Options
- WeavingWithoutAddingAReference
Icon
Icon courtesy of The Noun Project
Related Skills
node-connect
347.2kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
108.0kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
347.2kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
347.2kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
