コード例 #1
0
 private static int GetFieldCount(ConditionBase condition)
 {
     return(condition
            .OfType <FieldCondition>()
            .SelectMany(c => c.Fields)
            .Distinct()
            .Count());
 }
コード例 #2
0
 private static int GetFieldCount(ConditionBase condition)
 {
     return(condition
            .OfType <FieldCondition>()
            .SelectMany(c => c.Fields)
            .GroupBy(f => new { f.ContentId, f.Name })
            .Count());
 }
コード例 #3
0
        private static FieldInfo[] GetFieldInfo(ConditionBase condition)
        {
            var result = new Dictionary <string, FieldInfo>();
            var id     = 0;

            foreach (var fieldCondition in condition.OfType <FieldCondition>())
            {
                var key      = "";
                var n        = 1;
                int?parentId = null;

                foreach (var field in fieldCondition.Fields)
                {
                    var isLast = fieldCondition.Fields.Length == n;
                    key += "_" + field.Name + (isLast ? "_" + fieldCondition.Type : null);

                    if (result.TryGetValue(key, out var info))
                    {
                        parentId = info.Id;
                    }
                    else
                    {
                        result[key] = new FieldInfo
                        {
                            Id        = id,
                            ParentId  = parentId,
                            Name      = field.Name,
                            Type      = isLast ? fieldCondition.Type : null,
                            ContentId = field.ContentId
                        };

                        parentId = id;

                        id++;
                    }
                    n++;
                }
            }

            return(result.Values.ToArray());
        }