Firing generic events with EventAggregator

Topics: Prism v1
Sep 15, 2009 at 3:55 AM

Hi; I'm trying to use generic events with event aggregator with CAG 1.0. Control is not coming to the event subscription handler where as it work perfectly allright with simple types. I don't see runtime errors either. pl let me know if I’m doing something wrong. Code snippet is given below. Thanks in advance.

Event:
public class AddSDCCriteriaItem<T> : CompositeWpfEvent<SDCSessionCriteriaItem<T>> where T:DatabaseItem { }

Publisher:
SessionEventAggregator.GetEvent<AddSDCCriteriaItem>().Publish(SDCCriteriaItem);

Subscriber:
SessionEventAggregator.GetEvent<AddSDCCriteriaItem<DatabaseItem>>().Subscribe(AddCriteriaHandler<DatabaseItem>,

                                                                              Microsoft.Practices.Composite.Wpf.Events.ThreadOption.UIThread, true);

Handler:
public void AddCriteriaHandler<T>(SDCSessionCriteriaItem<T> SelecedCriteriaItem) where T : DatabaseItem

{
 //do something...  
}

 
And the payload is,

public class SDCSessionCriteriaItem <T> where T: DatabaseItem

    {

        public MetaData.DataItem SDCDataItem;
        private List<T> _selectedValues;
        public List<T> SelectedValues
        {
            get
            {
                if (_selectedValues == null)
                    _selectedValues = new List<T>();
                return _selectedValues;
            }
            set
            {
                _selectedValues = value;
            }
        }
        public SDCSessionCriteriaItem() { }
    }

Sep 15, 2009 at 10:51 PM

Hi

I have tried to reproduce your error using the Prism Event Aggregator quickstart with no success as the event did get to the handler. I have uploaded the outcome solution here so you can check the differences to find the issue.

Please let me know if this helps.

Damian Schenkelman
http://blogs.southworks.net/dschenkelman

Sep 23, 2009 at 12:40 PM

Hi Damian; Thanks for your reply and accept my apologies for late response on this. I'm still having same issue at my end, not sure where is the issue L. Appreciate if you can further put any thought were i can I need to have a look, any specific area you can suggest for debugging.

Regards,

Ram