Esempio n. 1
0
        static SequenceFlow CreateSequenceFlow(XElement sequenceFlowXElement)
        {
            var sequenceFlow = new SequenceFlow();

            var idAttr       = sequenceFlowXElement.Descendants("Id").FirstOrDefault();
            var nameAtrr     = sequenceFlowXElement.Descendants("Name").FirstOrDefault();
            var sourceIdAttr = sequenceFlowXElement.Descendants("SourceId").FirstOrDefault();
            var targetIdAttr = sequenceFlowXElement.Descendants("TargetId").FirstOrDefault();

            if (idAttr != null)
            {
                sequenceFlow.Id = idAttr.Value;
            }
            else
            {
                throw new InvalidElementException("ID must be set on every element");
            }

            if (sourceIdAttr != null)
            {
                sequenceFlow.SourceId = sourceIdAttr.Value;
            }
            else
            {
                throw new InvalidElementException("Sequence " + idAttr + " does not have a source");
            }

            if (targetIdAttr != null)
            {
                sequenceFlow.TargetId = targetIdAttr.Value;
            }

            else
            {
                throw new InvalidElementException("Sequence " + idAttr + " does not have a target");
            }

            if (nameAtrr != null)
            {
                sequenceFlow.Name      = nameAtrr.Value;
                sequenceFlow.Condition = nameAtrr.Value;
            }

            return(sequenceFlow);
        }
Esempio n. 2
0
        static SequenceFlow CreateSequenceFlow(XElement xSequenceFlow)
        {
            var sequenceFlow = new SequenceFlow();

            var xIdElement     = xSequenceFlow.Element("Id");
            var xNameElement   = xSequenceFlow.Element("Name");
            var xSourceElement = xSequenceFlow.Element("SourceId");
            var xTargetElement = xSequenceFlow.Element("TargetId");

            if (xIdElement != null)
            {
                sequenceFlow.Id = xIdElement.Value;
            }
            else
            {
                throw new InvalidElementException($"Sequence flow at line {ContractParser.GetLineNumber(xSequenceFlow)} is missing an ID");
            }

            if (xSourceElement != null)
            {
                sequenceFlow.SourceId = xSourceElement.Value;
            }
            else
            {
                throw new InvalidElementException($"Sequence flow at line {ContractParser.GetLineNumber(xSequenceFlow)} is missing a source");
            }

            if (xTargetElement != null)
            {
                sequenceFlow.TargetId = xTargetElement.Value;
            }
            else
            {
                throw new InvalidElementException($"Sequence flow at line {ContractParser.GetLineNumber(xSequenceFlow)} is missing a target");
            }

            if (xNameElement != null)
            {
                sequenceFlow.Name      = xNameElement.Value;
                sequenceFlow.Condition = xNameElement.Value;
            }
            return(sequenceFlow);
        }