This project has moved. For the latest updates, please go here.

Any way to get Parts in particular type?

Dec 9, 2009 at 2:05 PM

For instance, I have a class, with some methods. Class and methods are decorated with custom metadata/export attributes.


[ControlClass(ReferenceName = "Reference")]
    public class ReferenceControl : ControlBase
        /// <summary>
        /// Test control method
        /// </summary>
        /// <param name="inserted">что вставляли</param>
        /// <param name="deleted">что получилось </param>
        /// <exception cref="ReferenceException"><c>ReferenceException</c>.</exception>
        [Control(BeforeInsert = true, BeforeUpdate = true)]
        public void Sample(object inserted, object deleted)
            throw new ReferenceException("LALALALAAL!LLA!");

So, i want to get class by metadata(ReferenceName), then all methods from that class and execute them. How could I do that?

PS I could decorate every method with an attribute pointing to ReferenceName, but this is really not so good.


var q1 = ReflectionHelper.Mef.GetExports<Action<object, object>, IControlAttribute>("EntityControl");
                    var q = q1.Where(c => c.Metadata.ReferenceName == referenceName);




Dec 10, 2009 at 6:26 PM

Maybe I don't understand... Once you've got the part, why don't normal reflection techniques work?

Dec 10, 2009 at 7:26 PM

yes, I've decided to do so