Suggestions

Mar 21, 2011 at 6:34 PM

Took me a while to really understand how it worked but i've finally figured it out. I was expecting the magic to operate by itself so i didnt read requirements carefully.

I think that what confused me is that you mention simple class definition without having them subclass a Property Notifier class. Please include that in your explaination

Also, would it be possible to have MagicAttribute(params string[] extranotifications) as in :

[Magic]
public class MagicUser : PropertyNotifier
{
     [Magic("FullName")]
     public string LastName { get; set; }
     [Magic("FullName")]
     public string FirstName { get; set; }

     // Only getter, no magic will be applied
     // But changing FirstName or LastName will
     //     trigger FullName property changed event
     public string FullName { get; }
}
Regards
a Magic Fan
Mar 21, 2011 at 10:57 PM

After that post, i continued trying to figure out an issue i had with Kind Of Magic. I knew i understood requirement, yet i still had an issue in my big project which i finally figured out.

To make use of Magic in an existing project, i changed which namespace my PropertyNotifier class was defined into. Well, guess using System as the namespace to avoid having to add a using to my files was a wrong idea.

I tracked my issue to System.PropertyNotifier not being listed on my full class hierarchy because it is considered a "core" type, which then prevented my superclasses to be properly Magicified. Anyway, just thought i'd let you know and maybe a note regarding this issue could be added to your information document.

Coordinator
Mar 26, 2011 at 1:43 PM

Done!

Thank you for the feedback

May 14, 2011 at 4:06 PM

Hi,
Thank you Lex for this great product.
I think extra notification is very usefull and looks like easy to implement.

In the project:

class MagicAttribute : Attribute
{
   public MagicAttribute() { }
   public MagicAttribute(string ExtraPropertyName) { }
}

 

In KindOfMagic project, in Processor.cs, in ProcessProperty(), after #region this.RaisePropertyChanged(p.Name), place this lines:

#region this.RaisePropertyChanged(extra);

var attr = p.CustomAttributes.FirstOrDefault(a => _magic.Contains(a.AttributeType.FullName));
if (attr != null && attr.ConstructorArguments.Count > 0)
{
    string extra = attr.ConstructorArguments[0].Value as string;
    ops.Ldarg_0();
    ops.Ldstr(extra);
    if (isVirtual)
        ops.Callvirt(raise);
    else
        ops.Call(raise);
}

#endregion

Thanks,
Cristian

Coordinator
Nov 7, 2012 at 6:20 PM

Very nice idea! Mind if I put it in main branch?