ArxOne / MrAdvice

.NET aspect weaver (build task under NuGet package)
MIT License
311 stars 45 forks source link

INotifyPropertyChanged实现 #132

Closed hbbliyong closed 5 years ago

hbbliyong commented 6 years ago

您好,咱们这个有INotifyPropertyChanged接口的封装实现吗?

picrap commented 6 years ago

Sorry dude, I'm french, I only speak english 😉

picrap commented 6 years ago

OK, I brought your question to my friend Google Translate, and regarding INotifyPropertyChanged, there is no implementation in MrAdvice, which does not offer implementations. However, I have another project, named MrAdvice.MVVM, which uses MrAdvice and implements INotifyPropertyChanged, so you can probably see how its done and take the code you need.

hbbliyong commented 6 years ago

Thank you. I see. I'll try. where is the "INotifyPropertyChanged" code,how do i use it?

picrap commented 6 years ago

Lazy boy. The code is here and you only need to apply the NotifyPropertyChanged attribute to a given property to make it work. Also, your view-model needs to implement the INotifyPropertyChangedViewModel (which can be found here). The code probably won't build if you only use the two given classes, but you'll be closer to success.

hbbliyong commented 6 years ago

hi,my code

 public class CheckAndKeepGplotLaster : Attribute,IMethodAdvice
    {
        /// <summary>
        /// 是否检测墙数据是否是最新的,默认检测
        /// </summary>
        public bool IsCheckWalls { get; set; } = true;
        /// <summary>
        /// 是否检测Revit模型是否是最新的,默认检测
        /// </summary>
        public bool IsCheckRevitModel { get; set; } = true;
        private Gplot m_gplot;
        public void Advise(MethodAdviceContext context)
        {
            m_gplot = context.Target as Gplot;
}}

abstract class

public   abstract class Gplot {
public abstract void Show();
}

Subclass

   public abstract class SpaceRelated:Gplot
    {
        protected SpaceRelated()
        {
            IsSpace = true;
        }
    }
  public  class SpaceNeighborhood : SpaceRelated {
 [CheckAndKeepGplotLaster]
        public override void Show()
        {

        }
}

invoke

  var gplot=   GplotFactory.Create(GraphTypeEnum.SpaceNeighborhood);
            gplot.Show();

the mradvice is not work

picrap commented 6 years ago

Please help me to help you: can you provide a full sample? If this does not work, it's probably that the assembly is not weaved, but how can I guess that? If the bug is not related to your question, you can also open a new issue, this makes things more clear. So: do you have a simple project with a failure sample? Or can you provide a bit more information, such as the project target (.NET, .NET Core), etc.?