Esempio n. 1
0
        public static object?TryFindViewService(this IViewServiceHost thisControl, Type viewServiceType)
        {
            // Search within ViewServices collection
            var    actParent = thisControl;
            object?result    = null;

            while ((actParent != null) &&
                   (result == null))
            {
                foreach (var actViewService in actParent.ViewServices)
                {
                    if (actViewService == null)
                    {
                        continue;
                    }

                    // ReSharper disable once UseMethodIsInstanceOfType
                    if (!viewServiceType.IsAssignableFrom(actViewService.GetType()))
                    {
                        continue;
                    }

                    result = actViewService;
                }

                actParent = actParent.ParentViewServiceHost;
            }
            if (result != null)
            {
                return(result);
            }

            // Search for default view services
            actParent = thisControl;
            while ((actParent != null) &&
                   (result == null))
            {
                result    = actParent.TryGetDefaultViewService(viewServiceType);
                actParent = actParent.ParentViewServiceHost;
            }

            return(result);
        }
Esempio n. 2
0
 public static T FindViewService <T>(this IViewServiceHost thisControl)
     where T : class
 {
     return((T)TryFindViewService(thisControl, typeof(T)) !);
 }
 public ViewServiceContainer(IViewServiceHost owner)
 {
     this.Owner = owner;
     this.ViewServices.CollectionChanged += this.OnViewServices_CollectionChanged;
 }