Exemple #1
0
        private void ReportErrorToDOM(ApplicationUnhandledExceptionEventArgs e)
        {
            try
            {
                string errorMsg = e.ExceptionObject.Message + e.ExceptionObject.StackTrace;
                errorMsg = errorMsg.Replace('"', '\'').Replace("\r\n", @"\n");

                Moxie.log(errorMsg);
            }
            catch (Exception)
            {
            }
        }
Exemple #2
0
        public object create(Moxie mOxie, String uid, String compName)
        {
            object comp;

            String compFQName = "Moxiecode.Com." + compName;
            Type   compClass  = Type.GetType(compFQName);

            if (compClass != null)
            {
                comp = Activator.CreateInstance(compClass);

                FieldInfo fieldInfo  = compClass.GetField("dispatches", BindingFlags.Static | BindingFlags.Public);
                object[]  dispatches = (object[])fieldInfo.GetValue(comp);

                if (dispatches != null)
                {
                    foreach (string eventName in dispatches)
                    {
                        EventInfo    eventInfo     = compClass.GetEvent(eventName);
                        EventHandler handlerMethod = createEventHandler(mOxie, uid, eventName);
                        Delegate     handler       = Delegate.CreateDelegate(eventInfo.EventHandlerType, handlerMethod.Target, handlerMethod.Method);
                        eventInfo.AddEventHandler(comp, handler);
                    }
                }

                // if component is a control, display it
                if (comp is FrameworkElement)
                {
                    mOxie.Layout.Children.Add((FrameworkElement)comp);
                }

                if (_registry.ContainsKey(uid))
                {
                    throw new RuntimeError(RuntimeError.COMP_CONFLICT);
                }

                _registry.Add(uid, comp);
                return(comp);
            }
            else
            {
                // throw not supported exception
                return(null);
            }
        }
        public object create(Moxie mOxie, String uid, String compName)
        {
            object comp;

            String compFQName = "Moxiecode.Com." + compName;
            Type compClass = Type.GetType(compFQName);

            if (compClass != null) {
                comp = Activator.CreateInstance(compClass);

                FieldInfo fieldInfo = compClass.GetField("dispatches", BindingFlags.Static | BindingFlags.Public);
                object[] dispatches = (object[])fieldInfo.GetValue(comp);

                if (dispatches != null) {
                    foreach (string eventName in dispatches) {
                        EventInfo eventInfo = compClass.GetEvent(eventName);
                        EventHandler handlerMethod = createEventHandler(mOxie, uid, eventName);
                        Delegate handler = Delegate.CreateDelegate(eventInfo.EventHandlerType, handlerMethod.Target, handlerMethod.Method);
                        eventInfo.AddEventHandler(comp, handler);
                    }
                }

                // if component is a control, display it
                if (comp is FrameworkElement) {
                    mOxie.Layout.Children.Add((FrameworkElement)comp);
                }

                if (!_registry.ContainsKey(uid)) {
                    _registry.Add(uid, new Dictionary<string, object>());
                }

                _registry[uid].Add(compName, comp);
                return comp;
            } else {
                // throw not supported exception
                return null;
            }
        }
Exemple #4
0
 public EventHandler createEventHandler(Moxie mOxie, string uid, string eventName)
 {
     return(new EventHandler(delegate(object sender, EventArgs args) {
         mOxie.OnComponentEvent(uid, sender, args, eventName);
     }));
 }
 public EventHandler createEventHandler(Moxie mOxie, string uid, string eventName)
 {
     return new EventHandler(delegate(object sender, EventArgs args) {
         mOxie.OnComponentEvent(uid, sender, args, eventName);
     });
 }