Esempio n. 1
0
        private void AttachToElement(FrameworkElement element, IEnumerable <IUIServiceFactory> serviceList)
        {
            if (isFullyAttached)
            {
                return;
            }

            log.DebugFormat(FrameworkElementFormatter.GetInstance(), "Attaching service list for {0}", element);
            this.element = element;
            foreach (var serviceFactory in serviceList)
            {
                var service     = serviceFactory.CreateUIService();
                var serviceType = service.GetType();
                var customAttrs = serviceType.GetCustomAttributes(typeof(ImplementedServiceAttribute), true);
                if (customAttrs != null && customAttrs.Count() > 0)
                {
                    foreach (ImplementedServiceAttribute customAttr in customAttrs)
                    {
                        serviceType = customAttr.ImplementedServiceType;
                        AddServiceAs(serviceType, service);
                    }
                }
                else
                {
                    AddServiceAs(serviceType, service);
                }
            }
            LoadedEventManager.AddListener(element, this);
            UnloadedEventManager.AddListener(element, this);
            if (element.IsLoaded)
            {
                Element_Loaded(element, new RoutedEventArgs());
            }
        }
        public static void InitializeAssembly(TestContext testContext)
        {
            TestLogUtils.InitializeLog(testContext);
            // Force LoggingExtensions class initialization.
            using (LoggingExtensions.Indent()) { }

            FrameworkElementFormatter.GetInstance().SetTypeFormatter(typeof(DataGridRow), new DataGridRowFormatter());
        }
Esempio n. 3
0
 public void Dispose()
 {
     log.DebugFormat(FrameworkElementFormatter.GetInstance(), "Detaching service provider from {0}", element);
     if (owningWindow != null)
     {
         owningWindow.Closed -= OwningWindow_Closed;
     }
     LoadedEventManager.RemoveListener(element, this);
     UnloadedEventManager.RemoveListener(element, this);
     DetachFromElement(element, serviceImplementations.Values);
     foreach (var service in serviceImplementations.Values)
     {
         service.Dispose();
     }
 }
        private ICellEnumerationService GetRowEnumerationServiceForItem(object item)
        {
            log.DebugFormat(FrameworkElementFormatter.GetInstance(), "Trying to get row enumeration service for {0}", item);

            var currentRow = GetItemContainer(item) as DataGridRow;

            if (currentRow == null)
            {
                log.DebugFormat("-- Failed retrieving item container from '{0}'", item);
                return(null);
            }

            var service = UIServiceProvider.GetService <ICellEnumerationService>(currentRow);

            log.DebugFormat("-- Found service provider {0}", service);

            //((IUIService)service).AttachToElement(currentRow);

            return(service);
        }