Пример #1
0
 public static WC.ElementContainer <WC.Element> AsElementContainer(this WC.Element element)
 {
     if (element == null)
     {
         throw new NullReferenceException();
     }
     if (!(element is WC.ElementContainer <WC.Element>))
     {
         throw new InvalidCastException(element.GetType().Name + " does not implement ElementContainer<Element>.");
     }
     return(element as WC.ElementContainer <WC.Element>);
 }
Пример #2
0
        internal sealed override void Initialize(Element untypedElement)
        {
            if (element != null)
            {
                throw new InvalidOperationException(Resources.Control_HasAlreadyBeenInitialized);
            }

            var typedElement = untypedElement as TElement;

            if (typedElement == null && untypedElement != null)
            {
                throw new WatiNException(String.Format(
                                             "The element was of type '{0}' but expected an element of type {1}.", untypedElement.GetType(), typeof(TElement)));
            }

            element = typedElement;
            InitializeContents();
        }