Ejemplo n.º 1
0
        private static Dictionary<TableAndGroup, CacheItem> EnsureItems(string schema)
        {
            Dictionary<TableAndGroup, CacheItem> byTableAndGroup;
            if (bySchemaTableAndGroup.TryGetValue(schema, out byTableAndGroup))
                return byTableAndGroup;

            var temp = new Dictionary<TableAndGroup, CacheItem>();

#if COREFX
            var rows = Dependency.Resolve<ICustomFieldListService>().List(schema).ToList();
#else
            var rows = Dependency.Resolve<ICustomFieldListService>(schema).List(schema).ToList();
#endif
            rows.Sort((x, y) =>
            {
                var c = x.Table.CompareTo(y.Table);
                if (c == 0)
                    c = x.FieldGroup.CompareTo(y.FieldGroup);
                if (c == 0)
                    c = x.DisplayOrder.CompareTo(y.DisplayOrder);
                if (c == 0)
                    c = x.Id.CompareTo(y.Id);

                return c;
            });

            string priorTable = null;
            int priorGroup = Int32.MinValue;

            CacheItem item = null;

            foreach (var row in rows)
            {
                if (priorTable == null ||
                    priorTable != row.Table ||
                    priorGroup != row.FieldGroup)
                {
                    var key = new TableAndGroup(row.Table, row.FieldGroup);

                    if (!temp.TryGetValue(key, out item))
                    {
                        item = new CacheItem();
                        temp[key] = item;
                    }
                }

                item.inDisplayOrder.Add(row);
            }

            var newBySchemaTableAndGroup = new Dictionary<string, Dictionary<TableAndGroup, CacheItem>>(bySchemaTableAndGroup, StringComparer.OrdinalIgnoreCase);
            newBySchemaTableAndGroup[schema] = temp;

            bySchemaTableAndGroup = newBySchemaTableAndGroup;
            return temp;
        }
Ejemplo n.º 2
0
        private static Dictionary <TableAndGroup, CacheItem> EnsureItems(string schema)
        {
            Dictionary <TableAndGroup, CacheItem> byTableAndGroup;

            if (bySchemaTableAndGroup.TryGetValue(schema, out byTableAndGroup))
            {
                return(byTableAndGroup);
            }

            var temp = new Dictionary <TableAndGroup, CacheItem>();

#if COREFX
            var rows = Dependency.Resolve <ICustomFieldListService>().List(schema).ToList();
#else
            var rows = Dependency.Resolve <ICustomFieldListService>(schema).List(schema).ToList();
#endif
            rows.Sort((x, y) =>
            {
                var c = x.Table.CompareTo(y.Table);
                if (c == 0)
                {
                    c = x.FieldGroup.CompareTo(y.FieldGroup);
                }
                if (c == 0)
                {
                    c = x.DisplayOrder.CompareTo(y.DisplayOrder);
                }
                if (c == 0)
                {
                    c = x.Id.CompareTo(y.Id);
                }

                return(c);
            });

            string priorTable = null;
            int    priorGroup = Int32.MinValue;

            CacheItem item = null;

            foreach (var row in rows)
            {
                if (priorTable == null ||
                    priorTable != row.Table ||
                    priorGroup != row.FieldGroup)
                {
                    var key = new TableAndGroup(row.Table, row.FieldGroup);

                    if (!temp.TryGetValue(key, out item))
                    {
                        item      = new CacheItem();
                        temp[key] = item;
                    }
                }

                item.inDisplayOrder.Add(row);
            }

            var newBySchemaTableAndGroup = new Dictionary <string, Dictionary <TableAndGroup, CacheItem> >(bySchemaTableAndGroup, StringComparer.OrdinalIgnoreCase);
            newBySchemaTableAndGroup[schema] = temp;

            bySchemaTableAndGroup = newBySchemaTableAndGroup;
            return(temp);
        }