示例#1
0
 internal virtual void OnSourceChangedImpl(object oldSource, object newSource)
 {
     if (!string.IsNullOrEmpty(GetEventName()) && (string.Compare(GetEventName(), "Loaded", StringComparison.Ordinal) != 0))
     {
         if ((oldSource != null) && SourceTypeConstraint.IsAssignableFrom(oldSource.GetType()))
         {
             UnregisterEvent(oldSource, GetEventName());
         }
         if ((newSource != null) && SourceTypeConstraint.IsAssignableFrom(newSource.GetType()))
         {
             RegisterEvent(newSource, GetEventName());
         }
     }
 }
示例#2
0
        internal virtual void OnSourceChangedImpl(object oldSource, object newSource)
        {
            if (String.IsNullOrEmpty(GetEventName()) || String.Equals(GetEventName(), loadedEventName, StringComparison.Ordinal))
            {
                return;
            }

            if (null != oldSource && SourceTypeConstraint.GetTypeInfo().IsAssignableFrom(oldSource.GetType().GetTypeInfo()))
            {
                UnregisterEvent(oldSource, GetEventName());
            }

            if (null == newSource || !SourceTypeConstraint.GetTypeInfo().IsAssignableFrom(newSource.GetType().GetTypeInfo()))
            {
                return;
            }

            RegisterEvent(newSource, GetEventName());
        }