Пример #1
0
        public object GetCurrentPattern(AutomationPattern pattern)
        {
            if (pattern == null)
            {
                throw new ArgumentNullException("pattern");
            }
            string patternPath = null;

            try {
                patternPath = dbusElement.GetCurrentPatternPath(pattern.Id);
            } catch (Exception ex) {
                throw DbusExceptionTranslator.Translate(ex);
            }
            if (string.IsNullOrEmpty(patternPath))
            {
                throw new InvalidOperationException();
            }
            object ret = null;

            if (pattern.Id == DockPatternIdentifiers.Pattern.Id)
            {
                DCI.IDockPattern dockPattern = Bus.Session.GetObject <DCI.IDockPattern>
                                                   (busName, new ObjectPath(dbusPath + "/" + DC.Constants.DockPatternSubPath));
                ret = new UiaDbusDockPattern(dockPattern);
            }
            else if (pattern.Id == ExpandCollapsePatternIdentifiers.Pattern.Id)
            {
                DCI.IExpandCollapsePattern expandCollapsePattern = Bus.Session.GetObject <DCI.IExpandCollapsePattern>
                                                                       (busName, new ObjectPath(dbusPath + "/" + DC.Constants.ExpandCollapsePatternSubPath));
                ret = new UiaDbusExpandCollapsePattern(expandCollapsePattern);
            }
            else if (pattern.Id == GridPatternIdentifiers.Pattern.Id)
            {
                DCI.IGridPattern gridPattern = Bus.Session.GetObject <DCI.IGridPattern>
                                                   (busName, new ObjectPath(dbusPath + "/" + DC.Constants.GridPatternSubPath));
                ret = new UiaDbusGridPattern(gridPattern, busName, source);
            }
            else if (pattern.Id == GridItemPatternIdentifiers.Pattern.Id)
            {
                DCI.IGridItemPattern gridItemPattern = Bus.Session.GetObject <DCI.IGridItemPattern>
                                                           (busName, new ObjectPath(dbusPath + "/" + DC.Constants.GridItemPatternSubPath));
                ret = new UiaDbusGridItemPattern(gridItemPattern, busName, source);
            }
            else if (pattern.Id == InvokePatternIdentifiers.Pattern.Id)
            {
                DCI.IInvokePattern invokePattern = Bus.Session.GetObject <DCI.IInvokePattern>
                                                       (busName, new ObjectPath(dbusPath + "/" + DC.Constants.InvokePatternSubPath));
                ret = new UiaDbusInvokePattern(invokePattern);
            }
            else if (pattern.Id == MultipleViewPatternIdentifiers.Pattern.Id)
            {
                DCI.IMultipleViewPattern multipleViewPattern = Bus.Session.GetObject <DCI.IMultipleViewPattern>
                                                                   (busName, new ObjectPath(dbusPath + "/" + DC.Constants.MultipleViewPatternSubPath));
                ret = new UiaDbusMultipleViewPattern(multipleViewPattern);
            }
            else if (pattern.Id == RangeValuePatternIdentifiers.Pattern.Id)
            {
                DCI.IRangeValuePattern rangeValuePattern = Bus.Session.GetObject <DCI.IRangeValuePattern>
                                                               (busName, new ObjectPath(dbusPath + "/" + DC.Constants.RangeValuePatternSubPath));
                ret = new UiaDbusRangeValuePattern(rangeValuePattern);
            }
            else if (pattern.Id == ScrollItemPatternIdentifiers.Pattern.Id)
            {
                DCI.IScrollItemPattern scrollItemPattern = Bus.Session.GetObject <DCI.IScrollItemPattern>
                                                               (busName, new ObjectPath(dbusPath + "/" + DC.Constants.ScrollItemPatternSubPath));
                ret = new UiaDbusScrollItemPattern(scrollItemPattern);
            }
            else if (pattern.Id == ScrollPatternIdentifiers.Pattern.Id)
            {
                DCI.IScrollPattern scrollPattern = Bus.Session.GetObject <DCI.IScrollPattern>
                                                       (busName, new ObjectPath(dbusPath + "/" + DC.Constants.ScrollPatternSubPath));
                ret = new UiaDbusScrollPattern(scrollPattern);
            }
            else if (pattern.Id == SelectionPatternIdentifiers.Pattern.Id)
            {
                DCI.ISelectionPattern selectionPattern = Bus.Session.GetObject <DCI.ISelectionPattern>
                                                             (busName, new ObjectPath(dbusPath + "/" + DC.Constants.SelectionPatternSubPath));
                ret = new UiaDbusSelectionPattern(selectionPattern, busName, source);
            }
            else if (pattern.Id == SelectionItemPatternIdentifiers.Pattern.Id)
            {
                DCI.ISelectionItemPattern selectionItemPattern = Bus.Session.GetObject <DCI.ISelectionItemPattern>
                                                                     (busName, new ObjectPath(dbusPath + "/" + DC.Constants.SelectionItemPatternSubPath));
                ret = new UiaDbusSelectionItemPattern(selectionItemPattern, busName, source);
            }
            else if (pattern.Id == TablePatternIdentifiers.Pattern.Id)
            {
                DCI.ITablePattern tablePattern = Bus.Session.GetObject <DCI.ITablePattern>
                                                     (busName, new ObjectPath(dbusPath + "/" + DC.Constants.TablePatternSubPath));
                ret = new UiaDbusTablePattern(tablePattern, busName, source);
            }
            else if (pattern.Id == TableItemPatternIdentifiers.Pattern.Id)
            {
                DCI.ITableItemPattern tableItemPattern = Bus.Session.GetObject <DCI.ITableItemPattern>
                                                             (busName, new ObjectPath(dbusPath + "/" + DC.Constants.TableItemPatternSubPath));
                ret = new UiaDbusTableItemPattern(tableItemPattern, busName, source);
            }
            else if (pattern.Id == TextPatternIdentifiers.Pattern.Id)
            {
                DCI.ITextPattern textPattern = Bus.Session.GetObject <DCI.ITextPattern>
                                                   (busName, new ObjectPath(dbusPath + "/" + DC.Constants.TextPatternSubPath));
                ret = new UiaDbusTextPattern(textPattern, busName, source);
            }
            else if (pattern.Id == TogglePatternIdentifiers.Pattern.Id)
            {
                DCI.ITogglePattern togglePattern = Bus.Session.GetObject <DCI.ITogglePattern>
                                                       (busName, new ObjectPath(dbusPath + "/" + DC.Constants.TogglePatternSubPath));
                ret = new UiaDbusTogglePattern(togglePattern);
            }
            else if (pattern.Id == ValuePatternIdentifiers.Pattern.Id)
            {
                DCI.IValuePattern valuePattern = Bus.Session.GetObject <DCI.IValuePattern>
                                                     (busName, new ObjectPath(dbusPath + "/" + DC.Constants.ValuePatternSubPath));
                ret = new UiaDbusValuePattern(valuePattern);
            }
            else if (pattern.Id == TransformPatternIdentifiers.Pattern.Id)
            {
                DCI.ITransformPattern transformPattern = Bus.Session.GetObject <DCI.ITransformPattern>
                                                             (busName, new ObjectPath(dbusPath + "/" + DC.Constants.TransformPatternSubPath));
                ret = new UiaDbusTransformPattern(transformPattern);
            }
            else if (pattern.Id == WindowPatternIdentifiers.Pattern.Id)
            {
                DCI.IWindowPattern windowPattern = Bus.Session.GetObject <DCI.IWindowPattern>
                                                       (busName, new ObjectPath(dbusPath + "/" + DC.Constants.WindowPatternSubPath));
                ret = new UiaDbusWindowPattern(windowPattern);
            }
            else
            {
                throw new InvalidOperationException();
            }

            return(ret);
        }
Пример #2
0
		public object GetCurrentPattern (AutomationPattern pattern)
		{
			if (pattern == null)
				throw new ArgumentNullException ("pattern");
			string patternPath = null;
			try {
				patternPath = dbusElement.GetCurrentPatternPath (pattern.Id);
			} catch (Exception ex) {
				throw DbusExceptionTranslator.Translate (ex);
			}
			if (string.IsNullOrEmpty (patternPath))
				throw new InvalidOperationException ();
			object ret = null;

			if (pattern.Id == DockPatternIdentifiers.Pattern.Id) {
				DCI.IDockPattern dockPattern = Bus.Session.GetObject<DCI.IDockPattern>
					(busName, new ObjectPath (dbusPath + "/" + DC.Constants.DockPatternSubPath));
				ret = new UiaDbusDockPattern (dockPattern);
			} else if (pattern.Id == ExpandCollapsePatternIdentifiers.Pattern.Id) {
				DCI.IExpandCollapsePattern expandCollapsePattern = Bus.Session.GetObject<DCI.IExpandCollapsePattern>
					(busName, new ObjectPath (dbusPath + "/" + DC.Constants.ExpandCollapsePatternSubPath));
				ret = new UiaDbusExpandCollapsePattern (expandCollapsePattern);
			} else if (pattern.Id == GridPatternIdentifiers.Pattern.Id) {
				DCI.IGridPattern gridPattern = Bus.Session.GetObject<DCI.IGridPattern>
					(busName, new ObjectPath (dbusPath + "/" + DC.Constants.GridPatternSubPath));
				ret = new UiaDbusGridPattern (gridPattern, busName, source);
			} else if (pattern.Id == GridItemPatternIdentifiers.Pattern.Id) {
				DCI.IGridItemPattern gridItemPattern = Bus.Session.GetObject<DCI.IGridItemPattern>
					(busName, new ObjectPath (dbusPath + "/" + DC.Constants.GridItemPatternSubPath));
				ret = new UiaDbusGridItemPattern (gridItemPattern, busName, source);
			} else if (pattern.Id == InvokePatternIdentifiers.Pattern.Id) {
				DCI.IInvokePattern invokePattern = Bus.Session.GetObject<DCI.IInvokePattern>
					(busName, new ObjectPath (dbusPath + "/" + DC.Constants.InvokePatternSubPath));
				ret = new UiaDbusInvokePattern (invokePattern);
			} else if (pattern.Id == MultipleViewPatternIdentifiers.Pattern.Id) {
				DCI.IMultipleViewPattern multipleViewPattern = Bus.Session.GetObject<DCI.IMultipleViewPattern>
					(busName, new ObjectPath (dbusPath + "/" + DC.Constants.MultipleViewPatternSubPath));
				ret = new UiaDbusMultipleViewPattern (multipleViewPattern);
			} else if (pattern.Id == RangeValuePatternIdentifiers.Pattern.Id) {
				DCI.IRangeValuePattern rangeValuePattern = Bus.Session.GetObject<DCI.IRangeValuePattern>
					(busName, new ObjectPath (dbusPath + "/" + DC.Constants.RangeValuePatternSubPath));
				ret = new UiaDbusRangeValuePattern (rangeValuePattern);
			} else if (pattern.Id == ScrollItemPatternIdentifiers.Pattern.Id) {
				DCI.IScrollItemPattern scrollItemPattern = Bus.Session.GetObject<DCI.IScrollItemPattern>
					(busName, new ObjectPath (dbusPath + "/" + DC.Constants.ScrollItemPatternSubPath));
				ret = new UiaDbusScrollItemPattern (scrollItemPattern);
			} else if (pattern.Id == ScrollPatternIdentifiers.Pattern.Id) {
				DCI.IScrollPattern scrollPattern = Bus.Session.GetObject<DCI.IScrollPattern>
					(busName, new ObjectPath (dbusPath + "/" + DC.Constants.ScrollPatternSubPath));
				ret = new UiaDbusScrollPattern (scrollPattern);
			} else if (pattern.Id == SelectionPatternIdentifiers.Pattern.Id) {
				DCI.ISelectionPattern selectionPattern = Bus.Session.GetObject<DCI.ISelectionPattern>
					(busName, new ObjectPath (dbusPath + "/" + DC.Constants.SelectionPatternSubPath));
				ret = new UiaDbusSelectionPattern (selectionPattern, busName, source);
			} else if (pattern.Id == SelectionItemPatternIdentifiers.Pattern.Id) {
				DCI.ISelectionItemPattern selectionItemPattern = Bus.Session.GetObject<DCI.ISelectionItemPattern>
					(busName, new ObjectPath (dbusPath + "/" + DC.Constants.SelectionItemPatternSubPath));
				ret = new UiaDbusSelectionItemPattern (selectionItemPattern, busName, source);
			} else if (pattern.Id == TablePatternIdentifiers.Pattern.Id) {
				DCI.ITablePattern tablePattern = Bus.Session.GetObject<DCI.ITablePattern>
					(busName, new ObjectPath (dbusPath + "/" + DC.Constants.TablePatternSubPath));
				ret = new UiaDbusTablePattern (tablePattern, busName, source);
			} else if (pattern.Id == TableItemPatternIdentifiers.Pattern.Id) {
				DCI.ITableItemPattern tableItemPattern = Bus.Session.GetObject<DCI.ITableItemPattern>
					(busName, new ObjectPath (dbusPath + "/" + DC.Constants.TableItemPatternSubPath));
				ret = new UiaDbusTableItemPattern (tableItemPattern, busName, source);
			} else if (pattern.Id == TextPatternIdentifiers.Pattern.Id) {
				DCI.ITextPattern textPattern = Bus.Session.GetObject<DCI.ITextPattern>
					(busName, new ObjectPath (dbusPath + "/" + DC.Constants.TextPatternSubPath));
				ret = new UiaDbusTextPattern (textPattern, busName, source);
			} else if (pattern.Id == TogglePatternIdentifiers.Pattern.Id) {
				DCI.ITogglePattern togglePattern = Bus.Session.GetObject<DCI.ITogglePattern>
					(busName, new ObjectPath (dbusPath + "/" + DC.Constants.TogglePatternSubPath));
				ret = new UiaDbusTogglePattern (togglePattern);
			} else if (pattern.Id == ValuePatternIdentifiers.Pattern.Id) {
				DCI.IValuePattern valuePattern = Bus.Session.GetObject<DCI.IValuePattern>
					(busName, new ObjectPath (dbusPath + "/" + DC.Constants.ValuePatternSubPath));
				ret = new UiaDbusValuePattern (valuePattern);
			} else if (pattern.Id == TransformPatternIdentifiers.Pattern.Id) {
				DCI.ITransformPattern transformPattern = Bus.Session.GetObject<DCI.ITransformPattern>
					(busName, new ObjectPath (dbusPath + "/" + DC.Constants.TransformPatternSubPath));
				ret = new UiaDbusTransformPattern (transformPattern);
			} else if (pattern.Id == WindowPatternIdentifiers.Pattern.Id) {
				DCI.IWindowPattern windowPattern = Bus.Session.GetObject<DCI.IWindowPattern>
					(busName, new ObjectPath (dbusPath + "/" + DC.Constants.WindowPatternSubPath));
				ret = new UiaDbusWindowPattern (windowPattern);
			} else
				throw new InvalidOperationException ();

			return ret;
		}