예제 #1
0
        public void BuildRelationships(Dictionary <string, INode> nodeList)
        {
            if (nodeList.ContainsKey(_from) && nodeList.ContainsKey(_to))
            {
                INode fromNode = nodeList[_from];

                IDescriptor fromDescriptor = new CompendiumRelationshipDescriptor(fromNode, this, IoCContainer.GetInjectionInstance().GetInstance <CompendiumFromDescriptor>());

                _descriptors.Add(fromDescriptor);
                fromNode.AddDescriptor(fromDescriptor);

                INode toNode = nodeList[_to];

                IDescriptor toDescriptor = new CompendiumRelationshipDescriptor(toNode, this, IoCContainer.GetInjectionInstance().GetInstance <CompendiumToDescriptor>());

                _descriptors.Add(toDescriptor);
                toNode.AddDescriptor(toDescriptor);
            }
        }
        public void ConsumeLinkXml(Dictionary<string, INode> nodeList, XmlReader xml)
        {
            if (xml != null && xml.NodeType == XmlNodeType.Element && xml.Name == "link")
            {
                #region Attribute Values
                #region Id
                if (xml.MoveToAttribute("id"))
                {
                    Id = xml.Value;
                }
                #endregion

                #region NodeType - Not Currently Used
                /*
                if (xml.MoveToAttribute("type"))
                {
                    switch (xml.Value)
                    {
                        case ConNodeTypeId:
                            _nodeType = IoCContainer.GetInjectionInstance().GetInstance<ConNode>();
                            break;

                        case DecisionNodeTypeId:
                            _nodeType = IoCContainer.GetInjectionInstance().GetInstance<DecisionNode>();
                            break;

                        case IdeaNodeTypeId:
                            _nodeType = IoCContainer.GetInjectionInstance().GetInstance<IdeaNode>();
                            break;

                        case MapNodeTypeId:
                            _nodeType = IoCContainer.GetInjectionInstance().GetInstance<MapNode>();
                            break;

                        case ProNodeTypeId:
                            _nodeType = IoCContainer.GetInjectionInstance().GetInstance<ProNode>();
                            break;

                        case QuestionNodeTypeId:
                            _nodeType = IoCContainer.GetInjectionInstance().GetInstance<QuestionNode>();
                            break;

                        default:
                            break;
                    }
                }
                */
                #endregion

                #region CreatedBy
                if (xml.MoveToAttribute("author"))
                {
                    CreatedBy = xml.Value;
                }
                #endregion

                #region Created
                if (xml.MoveToAttribute("created"))
                {
                    string createdMillisecondsXmlValue = xml.Value;
                    long createdMilliseconds;

                    if (long.TryParse(createdMillisecondsXmlValue, out createdMilliseconds))
                    {
                        Created = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
                        Created = Created.AddMilliseconds(createdMilliseconds);
                    }
                }
                #endregion

                #region LastModified
                if (xml.MoveToAttribute("lastModified"))
                {
                    string lastModifiedMillisecondsXmlValue = xml.Value;
                    long lastModifiedMilliseconds;

                    if (long.TryParse(lastModifiedMillisecondsXmlValue, out lastModifiedMilliseconds))
                    {
                        LastModified = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
                        LastModified = LastModified.AddMilliseconds(lastModifiedMilliseconds);
                    }
                }
                #endregion

                #region Name
                if (xml.MoveToAttribute("label"))
                {
                    Name = xml.Value;
                }
                #endregion

                #region LastModifiedBy - Not Currently Used
                /*
                if (xml.MoveToAttribute("lastModificationAuthor"))
                {
                    LastModifiedBy = xml.Value;
                }
                */
                #endregion
                #endregion

                if (xml.MoveToAttribute("from"))
                {
                    string from = xml.Value;

                    INode fromNode = nodeList[from];

                    IDescriptor fromDescriptor = new CompendiumRelationshipDescriptor(fromNode, this, IoCContainer.GetInjectionInstance().GetInstance<CompendiumFromDescriptor>());

                    _descriptors.Add(fromDescriptor);
                    fromNode.AddDescriptor(fromDescriptor);
                }

                if (xml.MoveToAttribute("to"))
                {
                    string to = xml.Value;

                    INode toNode = nodeList[to];

                    IDescriptor toDescriptor = new CompendiumRelationshipDescriptor(toNode, this, IoCContainer.GetInjectionInstance().GetInstance<CompendiumFromDescriptor>());

                    _descriptors.Add(toDescriptor);
                    toNode.AddDescriptor(toDescriptor);
                }

                while (xml.Read())
                {
                    if (xml.NodeType == XmlNodeType.Element)
                    {
                    }
                    else if (xml.NodeType == XmlNodeType.EndElement && xml.Name == "link")
                    {
                        break;
                    }
                }
            }
        }
        public void ConsumeLinkXml(Dictionary <string, INode> nodeList, XmlReader xml)
        {
            if (xml != null && xml.NodeType == XmlNodeType.Element && xml.Name == "link")
            {
                #region Attribute Values
                #region Id
                if (xml.MoveToAttribute("id"))
                {
                    Id = xml.Value;
                }
                #endregion

                #region NodeType - Not Currently Used

                /*
                 * if (xml.MoveToAttribute("type"))
                 * {
                 *  switch (xml.Value)
                 *  {
                 *      case ConNodeTypeId:
                 *          _nodeType = IoCContainer.GetInjectionInstance().GetInstance<ConNode>();
                 *          break;
                 *
                 *      case DecisionNodeTypeId:
                 *          _nodeType = IoCContainer.GetInjectionInstance().GetInstance<DecisionNode>();
                 *          break;
                 *
                 *      case IdeaNodeTypeId:
                 *          _nodeType = IoCContainer.GetInjectionInstance().GetInstance<IdeaNode>();
                 *          break;
                 *
                 *      case MapNodeTypeId:
                 *          _nodeType = IoCContainer.GetInjectionInstance().GetInstance<MapNode>();
                 *          break;
                 *
                 *      case ProNodeTypeId:
                 *          _nodeType = IoCContainer.GetInjectionInstance().GetInstance<ProNode>();
                 *          break;
                 *
                 *      case QuestionNodeTypeId:
                 *          _nodeType = IoCContainer.GetInjectionInstance().GetInstance<QuestionNode>();
                 *          break;
                 *
                 *      default:
                 *          break;
                 *  }
                 * }
                 */
                #endregion

                #region CreatedBy
                if (xml.MoveToAttribute("author"))
                {
                    CreatedBy = xml.Value;
                }
                #endregion

                #region Created
                if (xml.MoveToAttribute("created"))
                {
                    string createdMillisecondsXmlValue = xml.Value;
                    long   createdMilliseconds;

                    if (long.TryParse(createdMillisecondsXmlValue, out createdMilliseconds))
                    {
                        Created = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
                        Created = Created.AddMilliseconds(createdMilliseconds);
                    }
                }
                #endregion

                #region LastModified
                if (xml.MoveToAttribute("lastModified"))
                {
                    string lastModifiedMillisecondsXmlValue = xml.Value;
                    long   lastModifiedMilliseconds;

                    if (long.TryParse(lastModifiedMillisecondsXmlValue, out lastModifiedMilliseconds))
                    {
                        LastModified = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
                        LastModified = LastModified.AddMilliseconds(lastModifiedMilliseconds);
                    }
                }
                #endregion

                #region Name
                if (xml.MoveToAttribute("label"))
                {
                    Name = xml.Value;
                }
                #endregion

                #region LastModifiedBy - Not Currently Used

                /*
                 * if (xml.MoveToAttribute("lastModificationAuthor"))
                 * {
                 *  LastModifiedBy = xml.Value;
                 * }
                 */
                #endregion
                #endregion

                if (xml.MoveToAttribute("from"))
                {
                    string from = xml.Value;

                    INode fromNode = nodeList[from];

                    IDescriptor fromDescriptor = new CompendiumRelationshipDescriptor(fromNode, this, IoCContainer.GetInjectionInstance().GetInstance <CompendiumFromDescriptor>());

                    _descriptors.Add(fromDescriptor);
                    fromNode.AddDescriptor(fromDescriptor);
                }

                if (xml.MoveToAttribute("to"))
                {
                    string to = xml.Value;

                    INode toNode = nodeList[to];

                    IDescriptor toDescriptor = new CompendiumRelationshipDescriptor(toNode, this, IoCContainer.GetInjectionInstance().GetInstance <CompendiumFromDescriptor>());

                    _descriptors.Add(toDescriptor);
                    toNode.AddDescriptor(toDescriptor);
                }

                while (xml.Read())
                {
                    if (xml.NodeType == XmlNodeType.Element)
                    {
                    }
                    else if (xml.NodeType == XmlNodeType.EndElement && xml.Name == "link")
                    {
                        break;
                    }
                }
            }
        }