private XElement ConvertTransitionToPnmlElement(PetriNetElement transition) { var transitionElement = new XElement("transition"); transition.ID = transition.ID ?? transition.ID ?? Guid.NewGuid().ToString().Substring(0, 8); transitionElement.SetAttributeValue("id", transition.ID); if (transition is ILabeledElement) { var nameElement = new XElement("name"); var textElement = new XElement("text", ((ILabeledElement)transition).Label); nameElement.Add(textElement); transitionElement.Add(nameElement); } AppendMetadataToPnmlElement(transitionElement, transition.GraphicsMetadata); var toolSpecificElement = new XElement("toolspecific"); toolSpecificElement.SetAttributeValue("tool", "Petrifier"); toolSpecificElement.SetAttributeValue("version", "0.1"); toolSpecificElement.Add(new XElement("transitiontype", transition.GetType().Name)); if (transition is IMethodReference) { var methodReference = (IMethodReference)transition; var implementorElement = new XElement("methodReference"); if (!string.IsNullOrEmpty(methodReference.AssemblyFileName)) { implementorElement.Add(new XElement("assembly", methodReference.AssemblyFileName)); } implementorElement.Add(new XElement("type", methodReference.TypeName)); implementorElement.Add(new XElement("method", methodReference.MethodName)); toolSpecificElement.Add(implementorElement); } transitionElement.Add(toolSpecificElement); return transitionElement; }
private PetriNetElementWidget CreateWidgetForElement(PetriNetElement element) { Type elementType = element.GetType(); if (elementType == typeof(Place)) return new PlaceWidget(element); if (elementType == typeof(Transition)) return new TransitionWidget(element); if (elementType == typeof(AndSplit)) return new AndSplitWidget(element); if (elementType == typeof(AndJoin)) return new AndJoinWidget(element); if (elementType == typeof(OrSplit)) return new OrSplitWidget(element); if (elementType == typeof(OrJoin)) return new OrJoinWidget(element); if (elementType == typeof(Subprocess)) return new SubprocessWidget(element); if (elementType == typeof(Arc)) return new ArcWidget(element); return null; }