コード例 #1
0
        public void SetEventToMarkupExtensionWhichReturnsAMatchingDelegate_TreeValidator(object o)
        {
            EventElement eventElement = ((EventElement)o);
            int          fireCount    = eventElement.TapEventCount;

            eventElement.RaiseTapEvent();
            if (eventElement.TapEventCount != fireCount + 1)
            {
                throw new Exception("Tap event did not fire");
            }
        }
コード例 #2
0
        public void WriteValueOfEventAsDelegate()
        {
            XamlSchemaContext xsc = new XamlSchemaContext();
            XamlObjectWriter  ow  = new XamlObjectWriter(xsc);

            XamlType eventElementXT = xsc.GetXamlType(typeof(EventElement));

            ow.WriteStartObject(eventElementXT);
            ow.WriteStartMember(eventElementXT.GetMember("Tap"));
            EventElement.TapDelegate tapDelegate = new EventElement.TapDelegate(methodToCall);
            ow.WriteValue(tapDelegate);
            ow.WriteEndMember();
            ow.WriteEndObject();

            EventElement eventElement = ((EventElement)ow.Result);

            tapEventFired = false;
            eventElement.RaiseTapEvent();
            if (!tapEventFired)
            {
                throw new Exception("Tap event did not fire");
            }
        }
コード例 #3
0
        public void WriteEventWithAMarkupExtensionReturingADelegate()
        {
            XamlSchemaContext xsc = new XamlSchemaContext();
            XamlObjectWriter  ow  = new XamlObjectWriter(xsc);

            XamlType eventElementXT       = xsc.GetXamlType(typeof(EventElement));
            XamlType delegateCreatingMeXT = xsc.GetXamlType(typeof(DelegateCreatingME));

            ow.WriteStartObject(eventElementXT);
            ow.WriteStartMember(eventElementXT.GetMember("Tap"));
            ow.WriteStartObject(delegateCreatingMeXT);
            ow.WriteEndObject();
            ow.WriteEndMember();
            ow.WriteEndObject();

            EventElement eventElement = ((EventElement)ow.Result);
            int          fireCount    = eventElement.TapEventCount;

            eventElement.RaiseTapEvent();
            if (eventElement.TapEventCount != fireCount + 1)
            {
                throw new Exception("Tap event did not fire");
            }
        }