コード例 #1
0
        protected static KeyStateMapping LoadWorkflowStateShortcut(XPathNavigator shortcutNav)
        {
            string         key           = null;
            string         workflowState = null;
            XPathNavigator attrNav       = shortcutNav.Clone();

            if (attrNav.MoveToFirstAttribute())
            {
                do
                {
                    switch (attrNav.Name)
                    {
                    case "Key":
                        key = attrNav.Value;
                        break;

                    case "WorkflowState":
                        workflowState = attrNav.Value;
                        break;

                    default:
                        throw new ArgumentException("'" + shortcutNav.Name + "' element doesn't support an attribute '" + attrNav.Name + "'");
                    }
                } while (attrNav.MoveToNextAttribute());
            }
            if (string.IsNullOrEmpty(key))
            {
                throw new ArgumentException(string.Format("{0}: 'Key' attribute is missing", shortcutNav.Name));
            }
            if (string.IsNullOrEmpty(workflowState))
            {
                throw new ArgumentException(string.Format("{0}: 'WorkflowState' attribute missing", shortcutNav.Name));
            }

            IWorkflowManager workflowManager = ServiceRegistration.Get <IWorkflowManager>();
            WorkflowState    state;

            // We can only create shortcuts for workflow states that have been defined before
            if (!workflowManager.States.TryGetValue(new Guid(workflowState), out state))
            {
                throw new ArgumentException(string.Format("{0} WorkflowState with ID {1} does not exists, skipping shortcut!", shortcutNav.Name, workflowState));
            }

            KeyStateMapping mapping = new KeyStateMapping();

            mapping.Keys.AddRange(ParseKeys(key));
            mapping.State = state;

            return(mapping);
        }
コード例 #2
0
    protected static KeyStateMapping LoadWorkflowStateShortcut(XPathNavigator shortcutNav)
    {
      string key = null;
      string workflowState = null;
      XPathNavigator attrNav = shortcutNav.Clone();
      if (attrNav.MoveToFirstAttribute())
        do
        {
          switch (attrNav.Name)
          {
            case "Key":
              key = attrNav.Value;
              break;
            case "WorkflowState":
              workflowState = attrNav.Value;
              break;
            default:
              throw new ArgumentException("'" + shortcutNav.Name + "' element doesn't support an attribute '" + attrNav.Name + "'");
          }
        } while (attrNav.MoveToNextAttribute());
      if (string.IsNullOrEmpty(key))
        throw new ArgumentException(string.Format("{0}: 'Key' attribute is missing", shortcutNav.Name));
      if (string.IsNullOrEmpty(workflowState))
        throw new ArgumentException(string.Format("{0}: 'WorkflowState' attribute missing", shortcutNav.Name));

      IWorkflowManager workflowManager = ServiceRegistration.Get<IWorkflowManager>();
      WorkflowState state;
      // We can only create shortcuts for workflow states that have been defined before
      if (!workflowManager.States.TryGetValue(new Guid(workflowState), out state))
        throw new ArgumentException(string.Format("{0} WorkflowState with ID {1} does not exists, skipping shortcut!", shortcutNav.Name, workflowState));

      KeyStateMapping mapping = new KeyStateMapping();
      mapping.Keys.AddRange(ParseKeys(key));
      mapping.State = state;
      
      return mapping;
    }