Advertisement
Guest User

Bind refactoring2

a guest
Jun 11th, 2022
19
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.13 KB | None | 0 0
  1.         private void Bind()
  2.     {
  3.         if (Related == null)
  4.             return;
  5.        
  6.         // Для каждого визуального контрола поищем метод, с которым его надо связать
  7.         for (int i = 0; i < BindingBehavior.Count; i++)
  8.         {
  9.             BindingEvent eventContainer = null;
  10.             var behaviorName = BindingBehavior[i].Name;
  11.            
  12.             if (!IsDoneBinding(behaviorName))
  13.             {
  14.                 eventContainer = Related.GetBindingEvent(behaviorName);
  15.                 AddDoneBinding(behaviorName);
  16.             }
  17.            
  18.             if (eventContainer != null)
  19.             {
  20.                 BindEvent(BindingBehavior[i], eventContainer);
  21.             }
  22.         }
  23.        
  24.         // Для каждого метода, поищем визуальный контрол, который не знает как себя вести
  25.         for (int i = 0; i < BindingEvent.Count; i++)
  26.         {
  27.             var eventName = BindingEvent[i].Name;
  28.             if (IsDoneBinding(eventName))
  29.                 continue;
  30.            
  31.             BindingBehavior behaviorContainer;
  32.             behaviorContainer = Related.GetBindingBehavior(eventName);
  33.            
  34.             if (behaviorContainer != null)
  35.             {
  36.                 BindEvent(behaviorContainer, BindingEvent[i]);
  37.                 AddDoneBinding(eventName);
  38.             }
  39.         }
  40.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement