/// <summary> /// Set type and optionally types of a JDF node. /// </summary> /// <param name="jdfNode"></param> /// <param name="isGrayBox">If true, makes a gray box (Process group with types set)</param> /// <param name="types"></param> /// <returns></returns> public static XElement SetTypeAndTypes(this XElement jdfNode, bool isGrayBox, params string[] types) { ParameterCheck.ParameterRequired(jdfNode, "jdfNode"); ThrowExceptionIfNotJdfElement(jdfNode); if (types == null || types.Length == 0) { jdfNode.SetAttributeValue("Type", ProcessType.ProcessGroup); jdfNode.SetXsiType(ProcessType.XsiJdfElementType(ProcessType.ProcessGroup).ToString()); } if (types.Length > 0 && isGrayBox) { MakeGrayBox(jdfNode, types); } else { if (types.Length == 1) { MakeSimpleProcess(jdfNode, types); } else { MakeCombinedProcess(jdfNode, types); } } return(jdfNode); }
static void MakeGrayBox(XElement jdfNode, string[] types) { jdfNode.SetAttributeValue("Type", ProcessType.ProcessGroup); jdfNode.SetXsiType(ProcessType.XsiJdfElementType(ProcessType.ProcessGroup).ToString()); jdfNode.SetAttributeValue("Types", string.Join(" ", types)); }
static void MakeSimpleProcess(XElement jdfNode, string[] types) { jdfNode.SetAttributeValue("Type", types[0]); jdfNode.SetXsiType(ProcessType.XsiJdfElementType(types[0]).ToString()); }
static void MakeCombinedProcess(XElement jdfNode, string[] types) { jdfNode.SetAttributeValue("Type", ProcessType.Combined); jdfNode.SetXsiType(ProcessType.XsiJdfElementType(ProcessType.Combined)); jdfNode.SetAttributeValue("Types", string.Join(" ", types)); }