Exemplo n.º 1
0
        private static object BuildStructuredLayoutRow(GlimpseStructuredLayoutSection section)
        {
            if (section == null)
            {
                return(null);
            }

            var result = new List <object>();

            foreach (var cell in section)
            {
                var item = new Dictionary <string, object>();
                if (!String.IsNullOrEmpty(cell.Align))
                {
                    item.Add("align", cell.Align);
                }
                if (!String.IsNullOrEmpty(cell.Width))
                {
                    item.Add("width", cell.Width);
                }
                if (cell.IsKey.GetValueOrDefault())
                {
                    item.Add("key", cell.IsKey);
                }
                if (!String.IsNullOrEmpty(cell.Prefix))
                {
                    item.Add("pre", cell.Prefix);
                }
                if (!String.IsNullOrEmpty(cell.Postfix))
                {
                    item.Add("post", cell.Postfix);
                }
                if (!String.IsNullOrEmpty(cell.ClassName))
                {
                    item.Add("className", cell.ClassName);
                }
                if (cell.IsCode.GetValueOrDefault())
                {
                    item.Add("isCode", cell.IsCode);
                }
                if (!String.IsNullOrEmpty(cell.CodeType))
                {
                    item.Add("codeType", cell.CodeType);
                }
                if (cell.Span.HasValue)
                {
                    item.Add("span", cell.Span.Value);
                }
                if (cell.SuppressAutoPreview.GetValueOrDefault())
                {
                    item.Add("forceFull", cell.SuppressAutoPreview);
                }
                if (cell.MinimalDisplay.GetValueOrDefault())
                {
                    item.Add("minDisplay", cell.MinimalDisplay);
                }
                if (cell.Limit.HasValue)
                {
                    item.Add("limit", cell.Limit.Value);
                }


                if (cell.Data != null)
                {
                    var typedData = cell.Data as GlimpseStructuredLayoutSection;
                    item.Add("data", typedData == null ? cell.Data : BuildStructuredLayoutRow(typedData));
                }
                if (cell.Structure != null)
                {
                    var structure = cell.Structure;

                    var collectionStructure = structure as GlimpseStructuredLayoutSubStructure;
                    if (collectionStructure != null)
                    {
                        var collection = new Dictionary <int, object>();
                        foreach (var sub in collectionStructure)
                        {
                            collection.Add(sub.Key, BuildStructuredLayout(sub.Value));
                        }
                        structure = collection;
                    }

                    var itemStructure = structure as GlimpseStructuredLayout;
                    if (itemStructure != null)
                    {
                        structure = BuildStructuredLayout(itemStructure);
                    }

                    item.Add("structure", structure);
                }
                result.Add(item);
            }
            return(result);
        }
Exemplo n.º 2
0
        private static object BuildStructuredLayoutRow(GlimpseStructuredLayoutSection section)
        {
            if (section == null)
                return null;

            var result = new List<object>();
            foreach (var cell in section)
            {
                var item = new Dictionary<string, object>();
                if (!String.IsNullOrEmpty(cell.Align))
                    item.Add("align", cell.Align);
                if (!String.IsNullOrEmpty(cell.Width))
                    item.Add("width", cell.Width);
                if (cell.IsKey.GetValueOrDefault())
                    item.Add("key", cell.IsKey);
                if (!String.IsNullOrEmpty(cell.Prefix))
                    item.Add("pre", cell.Prefix);
                if (!String.IsNullOrEmpty(cell.Postfix))
                    item.Add("post", cell.Postfix);
                if (!String.IsNullOrEmpty(cell.ClassName))
                    item.Add("className", cell.ClassName);
                if (cell.IsCode.GetValueOrDefault())
                    item.Add("isCode", cell.IsCode);
                if (!String.IsNullOrEmpty(cell.CodeType))
                    item.Add("codeType", cell.CodeType);
                if (cell.Span.HasValue)
                    item.Add("span", cell.Span.Value);
                if (cell.SuppressAutoPreview.GetValueOrDefault())
                    item.Add("forceFull", cell.SuppressAutoPreview);
                if (cell.MinimalDisplay.GetValueOrDefault())
                    item.Add("minDisplay", cell.MinimalDisplay);
                if (cell.Limit.HasValue)
                    item.Add("limit", cell.Limit.Value);

                if (cell.Data != null)
                {
                    var typedData = cell.Data as GlimpseStructuredLayoutSection;
                    item.Add("data", typedData == null ? cell.Data : BuildStructuredLayoutRow(typedData));
                }
                if (cell.Structure != null)
                {
                    var structure = cell.Structure;

                    var collectionStructure = structure as GlimpseStructuredLayoutSubStructure;
                    if (collectionStructure != null)
                    {
                        var collection = new Dictionary<int, object>();
                        foreach (var sub in collectionStructure)
                            collection.Add(sub.Key, BuildStructuredLayout(sub.Value));
                        structure = collection;

                    }

                    var itemStructure = structure as GlimpseStructuredLayout;
                    if (itemStructure != null)
                        structure = BuildStructuredLayout(itemStructure);

                    item.Add("structure", structure);
                }
                result.Add(item);
            }
            return result;
        }