Exemplo n.º 1
0
        private enDev2ColumnArgumentDirection AddScalarsShape(XmlNode c, ref XmlAttribute descAttribute, ref XmlAttribute columnIoDirection)
        {
            enDev2ColumnArgumentDirection columnDirection;

            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 scalar = new Scalar {
                Name = c.Name, Description = descriptionValue, IODirection = columnDirection, IsEditable = true
            };

            Scalars.Add(scalar);
            ShapeScalars.Add(scalar);
            return(columnDirection);
        }
Exemplo n.º 2
0
        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 jsonAttribute = false;
                            var xmlAttribute  = c.Attributes?["IsJson"];
                            if (xmlAttribute != null)
                            {
                                bool.TryParse(xmlAttribute.Value, out jsonAttribute);
                            }
                            if (jsonAttribute)
                            {
                                AddComplexObjectFromXmlNode(c);
                            }
                            else
                            {
                                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);
                        }
                    }
                }
            }
        }