Dev2.Data.DataListModel.CreateShape C# (CSharp) Method

CreateShape() public method

public CreateShape ( string shape ) : void
shape string
return void
        public void CreateShape(string shape)
        {
            XmlDocument xDoc = new XmlDocument();
            xDoc.LoadXml(shape);
            if(xDoc.DocumentElement != null)
            {
                XmlNodeList children = xDoc.DocumentElement.ChildNodes;

                var columnDirection = enDev2ColumnArgumentDirection.None;
                foreach(XmlNode c in children)
                {
                    XmlAttribute descAttribute = null;
                    XmlAttribute columnIoDirection = null;
                    if(!DataListUtil.IsSystemTag(c.Name))
                    {
                        if(c.HasChildNodes)
                        {
                            var cols = new List<IScalar>();
                            foreach(XmlNode subc in c.ChildNodes)
                            {
                                // It is possible for the .Attributes property to be null, a check should be added
                                if(subc.Attributes != null)
                                {
                                    descAttribute = subc.Attributes["Description"];
                                    columnIoDirection = subc.Attributes["ColumnIODirection"];
                                    if(columnIoDirection != null)
                                    {
                                        Enum.TryParse(columnIoDirection.Value, true, out columnDirection);
                                    }
                                }
                                var scalar = new Scalar { Name = subc.Name, IsEditable = true, IODirection = columnDirection };
                                if(descAttribute != null)
                                {
                                    scalar.Description = descAttribute.Value;
                                }
                                cols.Add(scalar);
                            }
                            if(c.Attributes != null)
                            {
                                descAttribute = c.Attributes["Description"];
                                columnIoDirection = c.Attributes["ColumnIODirection"];
                            }

                            var descriptionValue = "";
                            columnDirection = enDev2ColumnArgumentDirection.None;
                            if(descAttribute != null)
                            {
                                descriptionValue = descAttribute.Value;
                            }
                            if(columnIoDirection != null)
                            {
                                Enum.TryParse(columnIoDirection.Value, true, out columnDirection);
                            }
                            var recSet = new RecordSet { Columns = new Dictionary<int, List<IScalar>> { { 1, cols } }, Description = descriptionValue, IODirection = columnDirection, IsEditable = false, Name = c.Name };
                            RecordSets.Add(recSet);
                            var shapeRecSet = new RecordSet { Columns = new Dictionary<int, List<IScalar>> { { 1, cols } }, Description = descriptionValue, IODirection = columnDirection, IsEditable = false, Name = c.Name };
                            ShapeRecordSets.Add(shapeRecSet);
                        }
                        else
                        {
                            if(c.Attributes != null)
                            {
                                descAttribute = c.Attributes["Description"];
                                columnIoDirection = c.Attributes["ColumnIODirection"];
                            }
                            string descriptionValue = "";
                            columnDirection = enDev2ColumnArgumentDirection.None;
                            if(descAttribute != null)
                            {
                                descriptionValue = descAttribute.Value;
                            }
                            if(columnIoDirection != null)
                            {
                                Enum.TryParse(columnIoDirection.Value, true, out columnDirection);
                            }
                            var scalar = new Scalar { Name = c.Name, Description = descriptionValue, IODirection = columnDirection, IsEditable = true };
                            Scalars.Add(scalar);
                            ShapeScalars.Add(scalar);
                        }
                    }
                }
            }
        }
    }