Exemplo n.º 1
0
        /// <summary>
        /// Create an object of the type identified by <see cref="Action"/>.
        /// </summary>
        /// <param name="finder">Responsible for instantiating an object of the required type</param>
        /// <param name="message">JSON</param>
        /// <param name="output">Result</param>
        /// <returns>True if converted; otherwise, false.</returns>
        public static bool TryParseFromAction(IXenMessageFinder finder, string message, out XenMessage output)
        {
            try
            {
                object temp;

                var converted = TryParse(typeof(UnknownXenMessage), message, out temp);

                if (!converted)
                {
                    output = null;
                    return(false);
                }

                var msgTemp    = temp as XenMessage;
                var actionName = string.Empty;

                if (msgTemp != null)
                {
                    actionName = msgTemp.Action;
                }

                if (string.IsNullOrWhiteSpace(actionName))
                {
                    output = null;
                    return(false);
                }

                var actionType = finder.Find(actionName);

                if (actionType == null)
                {
                    output = null;
                    return(false);
                }

                object tempActionObject;
                var    parsed = TryParse(actionType, message, out tempActionObject);

                var actionObject = tempActionObject as XenMessage;
                output = actionObject;

                return(parsed && actionObject != null);
            }
            catch (Exception)
            {
                output = null;
                return(false);
            }
        }
Exemplo n.º 2
0
 public DefaultToolboxWorkflow(IXenMessageFinder messageFinder, ToolboxLogging log)
     : base(messageFinder, log)
 {
     // ignored
 }
Exemplo n.º 3
0
 /// <summary>
 /// Instantiate a <see cref="DefaultDesignWorkflow"/>.
 /// </summary>
 /// <param name="messageFinder">Instantiates objects, using reflection.</param>
 /// <param name="server">When a message has been dispatched, the response is sent to the toolbox.</param>
 public DefaultDesignWorkflow(IXenMessageFinder messageFinder, DesignServer server) : base(server)
 {
     _messageFinder = messageFinder;
 }
Exemplo n.º 4
0
 protected ToolboxWorkflow(IXenMessageFinder messageFinder, ToolboxLogging log)
 {
     MessageFinder = messageFinder;
     Log           = log;
     Registrar     = new List <Registration>();
 }