예제 #1
0
        public static void Clear(object source, string sourceProp, object target, string targetProp)
        {
            string            sourceEvent = sourceProp + "Changed";
            string            targetEvent = targetProp + "Changed";
            Type              sourceType  = source.GetType();
            Type              targetType  = target.GetType();
            EventInfo         ei1         = sourceType.GetEvent(sourceEvent);
            EventInfo         ei2         = targetType.GetEvent(targetEvent);
            BindingController bh          = Find(source, sourceProp, target, targetProp);

            _instances.Remove(bh);
            ei1.RemoveEventHandler(source, new EventHandler(bh.SourceChanged));
            ei2.RemoveEventHandler(target, new EventHandler(bh.TargetChanged));
        }
예제 #2
0
        public static void Bind(object source, string sourceProp, object target, string targetProp)
        {
            string            sourceEvent = sourceProp + "Changed";
            string            targetEvent = targetProp + "Changed";
            Type              sourceType  = source.GetType();
            Type              targetType  = target.GetType();
            EventInfo         ei1         = sourceType.GetEvent(sourceEvent);
            EventInfo         ei2         = targetType.GetEvent(targetEvent);
            BindingController bh          = new BindingController(source, sourceProp, target, targetProp);

            _instances.Add(bh);
            ei1.AddEventHandler(source, new EventHandler(bh.SourceChanged));
            ei2.AddEventHandler(target, new EventHandler(bh.TargetChanged));
            bh.TargetChanged(bh, EventArgs.Empty);
        }