{"id":277989,"date":"2016-04-10T20:05:03","date_gmt":"2016-04-10T16:05:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=277989"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=277989","title":{"rendered":"\u0427\u0438\u0441\u0442\u044b\u0439 \u043a\u043e\u0434 \u043f\u043e\u0434 \u0444\u043b\u0430\u0433\u043e\u043c \u0410\u041e\u041f \u0438 \u043d\u0435\u043d\u0430\u0432\u0438\u0441\u0442\u043d\u044b\u0439 #\u041f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0430\u044e\u041d\u0435\u0434\u0432\u0438\u0436\u0438\u043c\u043e\u0441\u0442\u044c\u0418\u0437\u043c\u0435\u043d\u0438\u043b\u0441\u044f"},"content":{"rendered":"<p>       \u041f\u043e\u0434\u0434\u0430\u0432\u0448\u0438\u0441\u044c \u043e\u0431\u0449\u0435\u0439 \u0438\u0441\u0442\u0435\u0440\u0438\u0438 \u043d\u0430 \u0445\u0430\u0431\u0440\u0435,<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/cc4\/59b\/537\/cc459b5375664c8e932d06ec05373cb1.png\"\/><br \/>  (\u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u00ab\u041f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0430\u044e \u041d\u0435\u0434\u0432\u0438\u0436\u0438\u043c\u043e\u0441\u0442\u044c \u0418\u0437\u043c\u0435\u043d\u0438\u043b\u0441\u044f\u00bb \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0438\u0442 \u0413\u0443\u0433\u043b\u0435\u043a\u0441 \u0432\u0441\u0435\u043c\u0438 \u043b\u044e\u0431\u0438\u043c\u044b\u0439 \u00abI Notify Property Changed\u00bb) \u043f\u043e \u043f\u043e\u0432\u043e\u0434\u0443 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0439 \u043e\u0431 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438. \u042f \u0440\u0435\u0448\u0438\u043b \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0434\u0430\u043b\u0435\u043a\u043e \u043f\u0440\u043e\u0434\u0432\u0438\u043d\u0443\u043b\u043e\u0441\u044c \u0447\u0435\u043b\u043e\u0432\u0435\u0447\u0435\u0441\u0442\u0432\u043e \u0432 \u0438\u0437\u043e\u0431\u0440\u0435\u0442\u0435\u043d\u0438\u0438 \u0432\u0435\u043b\u043e\u0441\u0438\u043f\u0435\u0434\u043e\u0432.<br \/>  <a name=\"habracut\"><\/a><br \/>  <b>OnPropertyChanged(\u00abProperty\u00bb)<\/b><br \/>  <b>OnPropertyChanged(()=&gt;Property)<\/b><br \/>  <b>SetProperty(ref storage, value)<\/b><br \/>  <b>[CallerMemberName]<\/b><br \/>  <b>[Magic]<\/b><br \/>  <b>\u0410\u041e\u041f<\/b> \u0440\u0430\u0437\u043d\u044b\u0445 \u043c\u0430\u0441\u0442\u0435\u0439<br \/>  \u0434\u0430\u0436\u0435 \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e\u0442 <a href=\"https:\/\/roslyn.codeplex.com\/discussions\/550266\">roslyn.codeplex.com\/discussions\/550266<\/a> \u043f\u043e\u0447\u0435\u043c\u0443 \u0431\u044b \u043c \u043d\u0435\u0442.<br \/>  \u041a\u0440\u0443\u0447\u0435 \u0432\u0441\u0435\u0445 \u0432\u0441\u0435 \u0436\u0435 <b>nameof(Property)<\/b> \u2014 \u043e\u0441\u0442\u043e\u0440\u043e\u0436\u043d\u043e \u0441\u0438 \u0448\u0430\u0440\u043f 6.<br \/>  \u041f\u043e\u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u044f \u0438\u0441\u0442\u0435\u0440\u0438\u0438 \u0432\u044b\u0440\u0430\u0436\u0430\u044e\u0442\u0441\u044f \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0440\u0430\u0431\u043e\u0442\u0430\u0445<br \/>  <a href=\"https:\/\/habrahabr.ru\/post\/199378\/\">habrahabr.ru\/post\/199378<\/a><br \/>  <a href=\"https:\/\/habrahabr.ru\/post\/246469\/\">habrahabr.ru\/post\/246469<\/a><br \/>  <a href=\"https:\/\/habrahabr.ru\/post\/95211\/\">habrahabr.ru\/post\/95211<\/a><br \/>  \u041b\u0438\u0447\u043d\u043e \u043c\u0435\u043d\u044f \u0443\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u0442 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b <b>OnPropertyChanged(nameof(Property))<\/b> \u0438 <b>OnPropertyChanged(()=&gt;Property)<\/b>, \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0431\u044b\u0441\u0442\u0440\u0435\u0435.<br \/>  \u041d\u043e \u0447\u0430\u0449\u0435 \u0432\u0441\u0435\u0433\u043e \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e <b>SetProperty(ref storage, value)<\/b>, \u043a\u043e\u0440\u043e\u0431\u043e\u0447\u043d\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 <a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/dn736263(v=pandp.50).aspx\">BindableBase<\/a>.<br \/>  \u0425\u0430\u0431\u0440\u0430\u0436\u0438\u0442\u0435\u043b\u044c  <a href=\"https:\/\/habrahabr.ru\/users\/scrooge2\/\" class=\"user_link\">Scrooge2<\/a> \u0437\u0430\u043f\u043e\u0441\u0442\u0438\u043b <\/p>\n<blockquote><p>\u0425\u0432\u0430\u0442\u0438\u0442 \u0438\u0437\u043e\u0431\u0440\u0435\u0430\u0442\u044c \u0432\u0435\u043b\u043e\u0441\u0438\u043f\u0435\u0434\u044b.<br \/>  \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u044b\u0447\u043d\u044b\u0439 INotifyPropertyChanged \u0440\u0443\u043a\u0438 \u043d\u0435 \u043e\u0442\u043f\u0430\u0434\u0443\u0442, \u0431\u0435\u0437 \u0432\u0441\u044f\u043a\u0438\u0445 \u043d\u043e.<\/p><\/blockquote>\n<p>  \u041f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e, \u043d\u043e\u2026 \u041d\u0415\u0422.<br \/>  \u041d\u0443 \u0447\u0442\u043e \u0436\u0435, \u043d\u0430\u043f\u0438\u043b\u044c\u043d\u0438\u043a \u0438 \u043a\u0443\u0432\u0430\u043b\u0434\u0430.<br \/>  \u042f \u0437\u0430 \u0447\u0438\u0441\u0442\u044b\u0439 \u043a\u043e\u0434! \u041b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435, \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u044b \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439, \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043f\u0440\u0430\u0432 \u0434\u043e\u0441\u0442\u0443\u043f\u0430, \u0432\u0441\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0435 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f \u0438 \u0442.\u0434. \u2014 \u0437\u0430\u0434\u044b\u043c\u043b\u044f\u044e\u0442 \u043a\u043e\u0434.\u041e\u0447\u0438\u0441\u0442\u0438\u0442\u044c \u043a\u043e\u0434 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0442 \u0434\u0440\u0435\u0432\u043d\u0438\u0435 \u0437\u043d\u0430\u043d\u0438\u044f \u0448\u0430\u0431\u043b\u043e\u043d\u0430 Proxy, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 <a href=\"https:\/\/habrahabr.ru\/post\/88722\/\">habrahabr.ru\/post\/88722<\/a>.<br \/>  \u041e\u0441\u043b\u043e\u0436\u043d\u044e \u0441\u0435\u0431\u0435 \u0436\u0438\u0437\u043d\u044c \u0438 \u0431\u0443\u0434\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u043b\u0430\u0441\u0441\u044b \u0430 \u043d\u0435 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u044b.  <\/p>\n<pre><code class=\"cs\">public class Data     {         public virtual int Value { get; set; }          public virtual string Source { get; set; }     }  <\/code><\/pre>\n<p>  \u0423\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f, \u043d\u0438\u0447\u0435\u0433\u043e \u043b\u0438\u0447\u043d\u043e\u0433\u043e  <\/p>\n<pre><code class=\"cs\">class BindableObject : BindableBase     {         public new bool SetProperty&lt;T&gt;(ref T storage, T value, [CallerMemberName] string propertyName = null)         {             return base.SetProperty&lt;T&gt;(ref storage, value, propertyName);         }     } <\/code><\/pre>\n<p>  \u0418 \u0441\u0430\u043c \u0437\u0430\u043c\u0435\u0441\u0442\u0438\u0442\u0435\u043b\u044c, \u0432\u0437\u044f\u0432\u0448\u0438\u0439 \u043d\u0430 \u0441\u0435\u0431\u044f \u0432\u0441\u044e \u0433\u0440\u044f\u0437\u043d\u0443\u044e \u0440\u0430\u0431\u043e\u0442\u0443  <\/p>\n<pre><code class=\"cs\">public class ProxyData : Data, INotifyPropertyChanged     {         Data _target;         BindableObject _notifier;          public ProxyData(Data target)         {             _target = target;             _notifier = new BindableObject();         }          public override int Value         {              set             {                 int newValue = 0;                  if (_notifier.SetProperty(ref newValue, value))                     base.Value = newValue;             }         }          public override string Source         {              set             {                 string newSource = null;                  if (_notifier.SetProperty(ref newSource, value))                     base.Source = newSource;             }         }          public event PropertyChangedEventHandler PropertyChanged         {             add { _notifier.PropertyChanged += value; }             remove { _notifier.PropertyChanged -= value; }         }     } <\/code><\/pre>\n<p>  \u0421\u043e\u0437\u0434\u0430\u043c \u043a\u043e\u043d\u0441\u043e\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0433\u0434\u0435 \u043a\u0430\u043a \u043d\u0435 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u041f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0430\u044e\u041d\u0435\u0434\u0432\u0438\u0436\u0438\u043c\u043e\u0441\u0442\u044c\u0418\u0437\u043c\u0435\u043d\u0438\u043b\u0441\u044f  <\/p>\n<pre><code class=\"cs\">data = new ProxyData(new Data()); (data as INotifyPropertyChanged).PropertyChanged += (s, e) =&gt; { Console.WriteLine(string.Format(&quot;Property {0} changed!&quot;, e.PropertyName)); };                data.Value = 10; data.Source = &quot;List&quot;; <\/code><\/pre>\n<p>  <b>\u041f\u043b\u044e\u0441\u044b<\/b>: \u0447\u0438\u0441\u0442\u0435\u0439\u0448\u0438\u0439 \u043a\u043b\u0430\u0441\u0441 Data, \u0432\u0441\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0438 \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043a\u0443\u0447\u0443 \u0440\u0430\u0437\u043d\u044b\u0445 \u043f\u0440\u043e\u043a\u0441\u0438 logger, access \u0438 \u0442\u0434, \u0441\u043a\u043e\u043c\u0431\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e \u0443\u0434\u0430\u043b\u044f\u0442\u044c \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0440\u0430\u0437\u043d\u044b\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b \u043d\u0435 \u043e\u0442\u043d\u043e\u0441\u044f\u0449\u0438\u0439\u0441\u044f \u043a \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<br \/>  <b>\u041c\u0438\u043d\u0443\u0441\u044b<\/b>: \u0411\u0435\u0441\u043f\u043e\u043b\u0435\u0437\u043d\u043e, \u044d\u0442\u043e \u043f\u043e\u0434\u043c\u0435\u043d\u0430 \u043f\u043e\u043d\u044f\u0442\u0438\u0439 \u0432\u044c\u044e\u043c\u043e\u0434\u0435\u043b\u044c \u044f \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u043b \u0432 \u043c\u043e\u0434\u0435\u043b\u044c, \u043f\u043e\u043b\u0443\u0447\u0438\u0432 \u0435\u0449\u0435 1 \u0437\u0432\u0435\u043d\u043e \u0448\u0430\u0431\u043b\u043e\u043d\u0430 Model -&gt; ViewModel -&gt; Proxy -&gt; View, \u043e\u0434\u043d\u043e \u0438\u0437 \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 ViewModel \u2014 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0435, \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0432 vm \u043c\u043e\u0436\u043d\u043e \u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0443 \u0434\u0430\u043d\u043d\u044b\u0445\u2026 \u041f\u043b\u044e\u0441 \u043a\u043e \u0432\u0441\u0435\u043c\u0443 \u043a\u043e\u0434\u0430 \u0441\u0442\u0430\u043b\u043e \u0435\u0449\u0435 \u0431\u043e\u043b\u044c\u0448\u0435, \u0445\u043e\u0442\u044f \u0432\u0440\u043e\u0434\u0435 \u043a\u0430\u043a \u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0441\u0442\u044c vm \u0441\u043d\u0438\u0437\u0438\u043b\u0430\u0441\u044c, \u043e\u0445 solid SOLID.<br \/>  <b>\u0418\u0441\u0442\u0435\u0440\u0438\u044f!<\/b> \u041f\u0440\u0438\u0448\u043b\u043e \u0432\u0440\u0435\u043c\u044f \u0410\u041e\u041f, \u043f\u0440\u043e \u0430\u043e\u043f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043e \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043c\u043d\u043e\u0433\u043e \u0438 \u043d\u0430 \u0442\u0435\u043e\u0440\u0438\u0438 \u044f \u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0435 \u0431\u0443\u0434\u0443.<br \/>  \u044f \u0440\u0430\u0431\u043e\u0442\u0430\u044e \u0441 <b>IUnityContainer<\/b>, \u0442.\u043a. \u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u043a\u043e\u0440\u043e\u0431\u043e\u0447\u043d\u044b\u043c, \u0445\u043e\u0440\u043e\u0448\u043e \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0443\u0435\u0442 \u0441 <b>Prism<\/b>. <br \/>  \u0410 \u0432\u043e\u0442 \u0438 \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u043e\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u044f\u0442\u043e\u0440\u0430, \u0436\u0443\u0442\u044c  <\/p>\n<pre><code class=\"cs\">class NotifyPropertyChangedBehavior : IInterceptionBehavior, INotifyPropertyChanged     {         static readonly MethodBase _add;         static readonly MethodBase _remove;          static NotifyPropertyChangedBehavior()         {             var methods = typeof(INotifyPropertyChanged).GetMethods();             _add = methods[0];             _remove = methods[1];         }          public IEnumerable&lt;Type&gt; GetRequiredInterfaces()         {             return Type.EmptyTypes;         }          public IMethodReturn Invoke(IMethodInvocation input, GetNextInterceptionBehaviorDelegate getNext)         {             IMethodReturn result = null;             if (IsPropertyChanged(input))                 if (SubscribeUnsubscribe(input))                     result = input.CreateMethodReturn(null);                 else                 {                     PropertyInfo property;                      if (IsSetMethodCalled(out property, input))                         result = SetValue(property, input, getNext);                 }              return result ?? getNext()(input, getNext);         }          public bool WillExecute         {             get { return true; }         }          public event PropertyChangedEventHandler PropertyChanged;          \/\/\/ &lt;summary&gt;         \/\/\/ \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0432\u044b\u0437\u043e\u0432\u0430 \u043c\u0443\u0442\u0430\u0442\u043e\u0440\u0430         \/\/\/ &lt;\/summary&gt;         \/\/\/ &lt;returns&gt;&lt;\/returns&gt;         bool IsSetMethodCalled(out PropertyInfo property, IMethodInvocation input)         {             string propertyName = input.MethodBase.Name.TrimStart(&quot;set_&quot;.ToArray());             property = input.Target.GetType().GetProperty(propertyName);              return property != null;         }          \/\/\/ &lt;summary&gt;         \/\/\/ \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c          \/\/\/ &lt;\/summary&gt;         \/\/\/ &lt;returns&gt;&lt;\/returns&gt;         IMethodReturn SetValue(PropertyInfo property, IMethodInvocation input, GetNextInterceptionBehaviorDelegate getNext)         {             var oldValue = property.GetValue(input.Target, new object[0]);             var newValue = input.Arguments[0];             IMethodReturn result = null;             \/\/\u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0435\u0441\u043b\u0438 \u043f\u0440\u0438\u0448\u043b\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u043e\u0432\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435             if (!Equals(oldValue, newValue))             {                 result = getNext()(input, getNext);                 if (PropertyChanged != null)                     PropertyChanged(input.Target, new PropertyChangedEventArgs(property.Name));             }             else result = input.CreateMethodReturn(null);                          return result;         }          \/\/\/ &lt;summary&gt;         \/\/\/ \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0432\u044b\u0437\u043e\u0432\u0430 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 INotifyPropertyChanged         \/\/\/ &lt;\/summary&gt;         bool SubscribeUnsubscribe(IMethodInvocation input)         {             if (input.MethodBase == _add)             {                 PropertyChanged += (PropertyChangedEventHandler)input.Arguments[0];                 return true;             }             else if (input.MethodBase == _remove)             {                 PropertyChanged -= (PropertyChangedEventHandler)input.Arguments[0];                 return true;             }             return false;         }          \/\/\/ &lt;summary&gt;         \/\/\/ \u0412\u044b\u0437\u043e\u0432 \u043d\u0430 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0449\u0438\u043c INotifyPropertyChanged         \/\/\/ &lt;\/summary&gt;         bool IsPropertyChanged(IMethodInvocation input) { return input.Target is INotifyPropertyChanged; }     } <\/code><\/pre>\n<p>  \u043d\u0443 \u0438 \u043a\u0443\u0441\u043e\u043a \u043a\u043e\u0434\u0430, \u0433\u0434\u0435 \u0432\u0441\u0435 \u044d\u0442\u043e \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f  <\/p>\n<pre><code class=\"cs\">IUnityContainer container = new UnityContainer();  container.AddNewExtension&lt;Interception&gt;();  container.RegisterType&lt;Data&gt;(new Interceptor&lt;VirtualMethodInterceptor&gt;(),                 new InterceptionBehavior&lt;NotifyPropertyChangedBehavior&gt;()                 , new AdditionalInterface&lt;INotifyPropertyChanged&gt;()); var data = container.Resolve&lt;Data&gt;();  (data as INotifyPropertyChanged).PropertyChanged += (s, e) =&gt; { Console.WriteLine(string.Format(&quot;Property {0} changed!&quot;, e.PropertyName)); };                 data.Value = 10; data.Source = &quot;List&quot;; data.Value = 10;  Console.ReadKey(); <\/code><\/pre>\n<p>  Result &#8212;&#8212;&gt;<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/3c9\/841\/08e\/3c984108e6ff4fd0b10818af29397173.png\" alt=\"image\"\/><br \/>  \u043f\u043b\u044e\u0448\u043a\u0430 \u0434\u043b\u044f \u043e\u0441\u043e\u0431\u043e \u043b\u0435\u043d\u0438\u0432\u044b\u0445  <\/p>\n<pre><code class=\"cs\">public static class Extensions     {         public static IUnityContainer RegisterViewModel&lt;T&gt;(this IUnityContainer container) where T : class         {             container.AddNewExtension&lt;Interception&gt;();              return container.RegisterType&lt;T&gt;(new Interceptor&lt;VirtualMethodInterceptor&gt;(),                 new InterceptionBehavior&lt;NotifyPropertyChangedBehavior&gt;()                 , new AdditionalInterface&lt;INotifyPropertyChanged&gt;());         }     } <\/code><\/pre>\n<p>  \u043c\u0438\u043d\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438  <\/p>\n<pre><code class=\"cs\">container.RegisterViewModel&lt;Data&gt;(); <\/code><\/pre>\n<p>  \u041d\u0435\u043b\u044c\u0437\u044f \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0438\u043b\u043b\u044e\u0437\u0438\u0439, \u0432 \u043e\u0441\u043d\u043e\u0432\u0435 \u0432\u0441\u0435 \u0442\u043e\u0442 \u0436\u0435 \u0417\u0410\u041c\u0415\u0421\u0422\u0418\u0422\u0415\u041b\u042c, \u0442\u043e\u043b\u044c\u043a\u043e \u043c\u044b \u043e \u043d\u0435\u043c \u043d\u0435 \u0437\u043d\u0430\u0435\u043c \u0422\u0441\u0441\u0441\u0421\u0421\u0441\u0441\u0441\u0441\u0441\u0441.<br \/>  <b>\u041f\u043b\u044e\u0441\u044b<\/b>: \u0442\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c VM \u0438\u0437 \u0432\u0441\u0435\u0433\u043e \u0443 \u0447\u0435\u0433\u043e \u0435\u0441\u0442\u044c \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430, \u043f\u043e\u043b\u043d\u0430\u044f \u043c\u0438\u043d\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f \u043a\u043e\u0434\u0430, \u0447\u0438\u0441\u0442\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u0431\u0435\u0437 \u041f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0430\u044e\u041d\u0435\u0434\u0432\u0438\u0436\u0438\u043c\u043e\u0441\u0442\u044c\u0418\u0437\u043c\u0435\u043d\u0438\u043b\u0441\u044f, \u0432\u0441\u044f\u043a\u0438\u0445 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432 \u0438 \u0442\u043e\u043c\u0443 \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0445 \u0442\u0435\u0445\u043d\u043e\u043c\u0430\u0433\u0438\u0439.<br \/>  <b>\u041c\u0438\u043d\u0443\u0441\u044b<\/b>: \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e, \u043d\u0443\u0436\u043d\u043e \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0442\u044c\u0441\u044f \u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0435 \u0438 \u0435\u0433\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044f\u0445 \u0430\u043e\u043f, \u043d\u0435 \u044f\u0432\u043d\u043e\u0441\u0442\u044c \u0432 \u0447\u0438\u0441\u0442\u043e\u043c \u0432\u0438\u0434\u0435, \u0432\u043e\u0441\u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u043c\u0430\u044f \u043a\u0430\u043a \u043c\u0430\u0433\u0438\u044f, \u043a\u0443\u0447\u0430 \u0440\u0435\u0444\u043b\u0438\u043a\u0441\u0438\u0438 \u2014 \u044d\u0442\u043e \u043d\u0435 \u0434\u043b\u044f \u0441\u043b\u0430\u0431\u043e\u043d\u0435\u0440\u0432\u043d\u044b\u0445, \u043f\u0440\u043e\u0441\u0435\u0432 \u043f\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438.<br \/>  \u041f\u0440\u043e\u0432\u0435\u0434\u044f \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442 \u043d\u0430 \u0441\u043e\u0442\u0440\u0443\u0434\u043d\u0438\u043a\u0430\u0445, \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043f\u043b\u0430\u0447\u0435\u0432\u043d\u044b\u0439, \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u044b \u0438\u0441\u043f\u044b\u0442\u044b\u0432\u0430\u043b\u0438 \u0431\u043e\u043b\u044c \u043a\u043e\u0433\u0434\u0430 \u044f \u043f\u043e\u043f\u0440\u043e\u0441\u0438\u043b \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u043a\u0430\u043a \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442.<br \/>  \u041d\u043e \u043e\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442.<br \/>  \u0412 \u0446\u0435\u043b\u043e\u043c \u0432\u043d\u0435\u0434\u0440\u044f\u0442\u044c \u044d\u0442\u043e \u043d\u0435 \u0441\u0442\u0430\u043b\u0438 \u0438 \u0447\u0443\u0442\u044c \u043d\u0435 \u043f\u0440\u0438\u0434\u0430\u043b\u0438 \u043f\u0440\u0430\u0432\u0435\u0434\u043d\u043e\u043c\u0443 \u043e\u0433\u043d\u044e, \u0430\u043e\u043f \u044d\u0442\u043e \u043a\u0440\u0443\u0442\u043e, \u043d\u043e \u0432\u0441\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0443\u0440\u043e\u0432\u043d\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0438 \u0438\u0445 \u0441\u0442\u0440\u0435\u043c\u043b\u0435\u043d\u0438\u044e \u043a \u0437\u0430\u043c\u043e\u0440\u043e\u0447\u043a\u0430\u043c. <\/p>\n<p>  <b>P.S.<\/b> \u0412\u0441\u0435\u043c \u043a\u043e\u0433\u043e \u043f\u0443\u0433\u0430\u0435\u0442 \u044d\u0442\u0430 \u0436\u0435\u0441\u0442\u044c \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e <b>OnPropertyChanged(nameof(Property))<\/b> \u2014 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u043f\u043e \u0432\u0441\u0435\u043c \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044f\u043c, \u043a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e \u0447\u0442\u043e \u044d\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0420\u0423\u041a\u0410\u041c\u0418. \u0411\u0443!               <\/p>\n<div class=\"clear\"><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habrahabr.ru\/post\/281294\/\"> https:\/\/habrahabr.ru\/post\/281294\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>       \u041f\u043e\u0434\u0434\u0430\u0432\u0448\u0438\u0441\u044c \u043e\u0431\u0449\u0435\u0439 \u0438\u0441\u0442\u0435\u0440\u0438\u0438 \u043d\u0430 \u0445\u0430\u0431\u0440\u0435,<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/cc4\/59b\/537\/cc459b5375664c8e932d06ec05373cb1.png\"\/><br \/>  (\u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u00ab\u041f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0430\u044e \u041d\u0435\u0434\u0432\u0438\u0436\u0438\u043c\u043e\u0441\u0442\u044c \u0418\u0437\u043c\u0435\u043d\u0438\u043b\u0441\u044f\u00bb \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0438\u0442 \u0413\u0443\u0433\u043b\u0435\u043a\u0441 \u0432\u0441\u0435\u043c\u0438 \u043b\u044e\u0431\u0438\u043c\u044b\u0439 \u00abI Notify Property Changed\u00bb) \u043f\u043e \u043f\u043e\u0432\u043e\u0434\u0443 \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0439 \u043e\u0431 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438. \u042f \u0440\u0435\u0448\u0438\u043b \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0434\u0430\u043b\u0435\u043a\u043e \u043f\u0440\u043e\u0434\u0432\u0438\u043d\u0443\u043b\u043e\u0441\u044c \u0447\u0435\u043b\u043e\u0432\u0435\u0447\u0435\u0441\u0442\u0432\u043e \u0432 \u0438\u0437\u043e\u0431\u0440\u0435\u0442\u0435\u043d\u0438\u0438 \u0432\u0435\u043b\u043e\u0441\u0438\u043f\u0435\u0434\u043e\u0432.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-277989","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/277989","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=277989"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/277989\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=277989"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=277989"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=277989"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}