private void OnRibbonPostBack(RibbonMethodPostBackEventArgs eventArgs)
        {
            if (eventArgs == null)
            {
                return;
            }

            if (string.IsNullOrEmpty(eventArgs.MethodName))
            {
                return;
            }

            try
            {
                var method = GetType().GetMethod(eventArgs.MethodName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
                method.Invoke(this, new object[] { eventArgs.Arguments });
            }
            catch (Exception ex)
            {
                if (ex.InnerException != null)
                {
                    throw ex.InnerException;
                }
                throw;
            }
        }
        private static string SerializePostBackEvent(RibbonMethodPostBackEventArgs arguments)
        {
            if (arguments == null)
            {
                throw new ArgumentNullException("arguments");
            }

            var serializer = new DataContractJsonSerializer(typeof(RibbonMethodPostBackEventArgs));

            using (var stream = new MemoryStream())
            {
                serializer.WriteObject(stream, arguments);
                return(Encoding.UTF8.GetString(stream.GetBuffer(), 0, (int)stream.Length));
            }
        }
 public void RaisePostBackEvent(string eventArgument)
 {
     OnRibbonPostBack(RibbonMethodPostBackEventArgs.Deserialize(eventArgument));
 }
        private static string SerializePostBackEvent(RibbonMethodPostBackEventArgs arguments)
        {
            if (arguments == null)
            {
                throw new ArgumentNullException("arguments");
            }

            var serializer = new DataContractJsonSerializer(typeof (RibbonMethodPostBackEventArgs));
            using (var stream = new MemoryStream())
            {
                serializer.WriteObject(stream, arguments);
                return Encoding.UTF8.GetString(stream.GetBuffer(), 0, (int) stream.Length);
            }
        }
Example #5
0
 /// <summary>
 ///   Deserialize the JSON event argument and raise post back event for the custom ribbon commands
 /// </summary>
 /// <param name = "eventArgument">JSON event arguments</param>
 public void RaisePostBackEvent(string eventArgument)
 {
     OnRibbonPostBack(RibbonMethodPostBackEventArgs.Deserialize(eventArgument));
     OnRibbonPostBack(new JavaScriptSerializer().Deserialize <RibbonPostBackEventArgs>(eventArgument));
 }
Example #6
0
        private void OnRibbonPostBack(RibbonMethodPostBackEventArgs eventArgs)
        {
            if (eventArgs == null)
            {
                return;
            }

            if (string.IsNullOrEmpty(eventArgs.MethodName))
            {
                return;
            }

            try
            {
                var method = GetType().BaseType.GetMethod(eventArgs.MethodName,
                                                          BindingFlags.Instance | BindingFlags.Public |
                                                          BindingFlags.NonPublic);
                method.Invoke(this, new object[] {eventArgs.Arguments});
            }
            catch (Exception ex)
            {
                if (ex.InnerException != null)
                {
                    throw ex.InnerException;
                }
                throw;
            }
        }