Esempio n. 1
0
        public IEnumerable RaiseSelectEventOnHost()
        {
            var eventType      = ParentHost.GetType().GetEvent(SelectEvent).EventHandlerType;
            var eventArgsTypes = eventType.GetGenericArguments();
            var eventArgsType  = eventArgsTypes.Length == 0 ? null : eventArgsTypes[0];

            var paramValues     = selectEventParameters.GetValues(Context, this);
            var eventArgsParams = paramValues.Values.Cast <object>().ToArray();

            var parameterTypes = selectEventParameters.OfType <Parameter>()
                                 .Select(p => ConvertToType(p.Type)).ToArray();
            var eventArgsCtor = eventArgsType.GetConstructor(parameterTypes);
            var eventArgs     = eventArgsCtor.Invoke(eventArgsParams) as EventArgs;

            RaiseEventOnHost(SelectEvent, eventArgs);

            var model = ParentHost.GetType()
                        .GetProperty("Model")
                        .GetValue(ParentHost, null);

            var result = model.GetType()
                         .GetProperty(SelectResult)
                         .GetValue(model, null)
                         as IEnumerable;

            return(result);
        }
 /// <summary>
 /// This method returns the Message
 /// </summary>
 public void SendMessage(string text)
 {
     // if the ParentHost exists
     if (HasParentHost)
     {
         // Add to the text of the query string
         ParentHost.AppendQueryText(text);
     }
 }
Esempio n. 3
0
        private void RaiseEventOnHost(string eventName, EventArgs e)
        {
            var eventDelegate = ParentHost.GetType().BaseType
                                .GetField(eventName, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public)
                                .GetValue(ParentHost) as MulticastDelegate;

            if (eventDelegate != null)
            {
                foreach (var handler in eventDelegate.GetInvocationList())
                {
                    handler.Method.Invoke(handler.Target, new[] { ParentHost, e });
                }
            }
        }