Exemple #1
0
        /// <summary>
        /// creates a class that is registered to notification of INotifyCollectionChanged
        /// </summary>
        /// <param name="strategy">The strategy to create an instance</param>
        /// <returns>Return a listener instance that is registered to notifications</returns>
        public static IValueConverter RegisterCollectionNotification(Type strategy)
        {
            if (strategy.GetInterface(typeof(ICollectionNotificationStrategy).FullName) == null)
            {
                throw new InvalidOperationException("The type of CollectionNotificationStrategy must implement the ICollectionNotificationStrategy");
            }

            ICollectionNotificationStrategy collNottificationStategy = null;

            try
            {
                collNottificationStategy = (ICollectionNotificationStrategy)Activator.CreateInstance(strategy);
            }
            catch (System.Exception e)
            {
                throw new ArgumentException("Cannot create instance of the CollectionNotificationStrategy passed. See inner exception for more detail",
                                            "strategy", e);
            }
            return(new CollectionNotifier(collNottificationStategy));
        }
Exemple #2
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="strategy">The strategy to use to convert data</param>
 public CollectionNotifier(ICollectionNotificationStrategy strategy)
 {
     this.strategy = strategy;
 }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="strategy">The strategy to use to convert data</param>
 public CollectionNotifier(ICollectionNotificationStrategy strategy)
 {
     this.strategy = strategy;
 }