Example #1
0
        private Dictionary <StandardCodeSequence, AimTemplateTree> AimTemplateTreeFromXsdTemplate(TemplateContainer container)
        {
            var templates = new Dictionary <StandardCodeSequence, AimTemplateTree>();

            if (container.Template != null && container.Template.Any())
            {
                foreach (var template in container.Template)
                {
                    var aimTemplateTree = new AimTemplateTree();

                    if (template.creationDateSpecified)
                    {
                        aimTemplateTree.CreationDate = template.creationDate;
                    }

                    aimTemplateTree.TemplateName                 = template.name;
                    aimTemplateTree.TemplateDescription          = template.description;
                    aimTemplateTree.TemplateAuthors              = template.authors;
                    aimTemplateTree.SelectedTemplateUid          = template.uid;
                    aimTemplateTree.SelectedTemplateContainerUid = container.uid;

                    foreach (TemplateComponent templateComponent in template.Component)
                    {
                        var node = AimTemplateTreeNodeFromXsdComponent(templateComponent);
                        if (node != null)
                        {
                            aimTemplateTree.TemplateNodes.Add(node);
                        }
                    }

                    StandardCodeSequence codeSequence;

                    var sequenceNumber = String.Empty;
                    int sequence       = 0;

                    do
                    {
                        codeSequence = new StandardCodeSequence(
                            template.codeValue + sequenceNumber,
                            template.codeMeaning,
                            template.codingSchemeDesignator,
                            template.codingSchemeVersion);
                        sequenceNumber = sequence.ToString();
                        sequence++;
                    } while (templates.ContainsKey(codeSequence));

                    aimTemplateTree.StandardCodeSequence = codeSequence;
                    templates.Add(codeSequence, aimTemplateTree);
                }
            }
            else
            {
                throw new Exception("Template container invalid or contained no templates.");
            }

            return(templates);
        }
Example #2
0
        private MemoryStream SerializeAimTemplateTree(AimTemplateTree tree)
        {
            XmlObjectSerializer serializer = new DataContractSerializer(typeof(AimTemplateTree));

            MemoryStream ms = new MemoryStream();

            serializer.WriteObject(ms, tree);
            ms.Seek(0, SeekOrigin.Begin);
            return(ms);
        }
Example #3
0
        private AimTemplateTree DeserializeAimTemplateTree(MemoryStream ms)
        {
            AimTemplateTree tree = null;

            XmlDictionaryReader reader =
                XmlDictionaryReader.CreateTextReader(ms, new XmlDictionaryReaderQuotas());
            var ser = new DataContractSerializer(typeof(AimTemplateTree));

            tree = (AimTemplateTree)ser.ReadObject(reader, true);
            reader.Close();

            return(tree);
        }
        private MemoryStream SerializeAimTemplateTree(AimTemplateTree tree)
        {
            XmlObjectSerializer serializer = new DataContractSerializer(typeof(AimTemplateTree));

            MemoryStream ms = new MemoryStream();
            serializer.WriteObject(ms, tree);
            ms.Seek(0, SeekOrigin.Begin);
            return ms;
        }
        private Dictionary<StandardCodeSequence, AimTemplateTree> AimTemplateTreeFromXsdTemplate(TemplateContainer container)
        {
            var templates = new Dictionary<StandardCodeSequence, AimTemplateTree>();

            if (container.Template != null && container.Template.Any())
                foreach (var template in container.Template)
                {
                    var aimTemplateTree = new AimTemplateTree();

                    if (template.creationDateSpecified)
                        aimTemplateTree.CreationDate = template.creationDate;

                    aimTemplateTree.TemplateName = template.name;
                    aimTemplateTree.TemplateDescription = template.description;
                    aimTemplateTree.TemplateAuthors = template.authors;
                    aimTemplateTree.SelectedTemplateUid = template.uid;
                    aimTemplateTree.SelectedTemplateContainerUid = container.uid;

                    foreach (TemplateComponent templateComponent in template.Component)
                    {
                        var node = AimTemplateTreeNodeFromXsdComponent(templateComponent);
                        if (node != null)
                            aimTemplateTree.TemplateNodes.Add(node);
                    }

                    StandardCodeSequence codeSequence;

                    var sequenceNumber = String.Empty;
                    int sequence = 0;

                    do
                    {
                        codeSequence = new StandardCodeSequence(
                            template.codeValue + sequenceNumber,
                            template.codeMeaning,
                            template.codingSchemeDesignator,
                            template.codingSchemeVersion);
                        sequenceNumber = sequence.ToString();
                        sequence++;

                    } while (templates.ContainsKey(codeSequence));

                    aimTemplateTree.StandardCodeSequence = codeSequence;
                    templates.Add(codeSequence, aimTemplateTree);
                }
            else
            {
                throw new Exception("Template container invalid or contained no templates.");
            }

            return templates;
        }
        public AimTemplateTree AimAnnotationToTemplateTree(IAimAnnotationInstance aimAnnotation, AimTemplateTree startingTree)
        {
            if (aimAnnotation == null)
            {
                return(null);
            }

            switch (aimAnnotation.AimVersion)
            {
            case AimVersion.AimVersion3:
                return(Aim3.AimTemplateConverter.AimAnnotationToAimTemplateTree((Aim3.Aim3AnnotationInstance)aimAnnotation, startingTree));

            case AimVersion.AimVersion4:
                return(Aim4.AimTemplateConverter.AimAnnotationToAimTemplateTree((Aim4.Aim4AnnotationInstance)aimAnnotation, startingTree));

            default:
                Debug.Assert(false, "AimManager.AimAnnotationToTemplateTree: Unexpected AIM version");
                break;
            }

            return(null);
        }