Ejemplo n.º 1
0
        protected override void OnWindowLoaded(object sender, RoutedEventArgs e)
        {
            base.OnWindowLoaded(sender, e);

            if (!(sender is Window window))
            {
                return;
            }

            if (!_windowAddons.TryGetValue(window.GetType(), out var windowAddon))
            {
                return;
            }

            foreach (var obj in windowAddon)
            {
                if (!(obj is DictionaryEntry entry))
                {
                    continue;
                }

                if (!(entry.Value is WindowAddonItem windowAddonItem))
                {
                    continue;
                }

                var target = window.FindChild <ItemsControl>(windowAddonItem.Target);
                if (target == null)
                {
                    continue;
                }

                foreach (var element in windowAddonItem)
                {
                    // Create copy, otherwise we get a NotSupportedException
                    // because the MenuItem already has a parent set.
                    // I don't like this solution, but it makes it work
                    // Looking for better solution because of this
                    var copy = DeepCopy.Create(element, window.DataContext);
                    target.Items.Add(copy);
                }
            }
        }
 protected EqualityComparerBenchmarkBase()
 {
     _x = CreateRandom();
     _y = DeepCopy.Create(_x);
 }