Beispiel #1
0
        private static IList <object> ExtractValuesForEnumerableNode <T>(T nodes, IStructureProperty property) where T : IEnumerable
        {
            var values = new List <object>();

            foreach (var node in nodes)
            {
                if (node == null)
                {
                    values.Add(null);
                    continue;
                }

                var nodeValue = property.GetValue(node);
                if (nodeValue == null)
                {
                    values.Add(null);
                    continue;
                }

                if (ValueIsEnumerable(nodeValue))
                {
                    values.AddRange(CollectionOfValuesToList((IEnumerable)nodeValue));
                }
                else
                {
                    values.Add(nodeValue);
                }
            }

            return(values);
        }
Beispiel #2
0
        private static IList <object> ExtractValuesForSimpleNode(object node, IStructureProperty property)
        {
            var currentValue = property.GetValue(node);

            if (currentValue == null)
            {
                return(null);
            }

            if (!property.IsEnumerable)
            {
                return new[] { currentValue }
            }
            ;

            return(CollectionOfValuesToList((IEnumerable)currentValue));
        }
Beispiel #3
0
        private static IList <IStructureIndexValue> ExtractValuesForSimpleNode(object node, IStructureProperty property, string startPath)
        {
            var currentValue = property.GetValue(node);

            if (currentValue == null)
            {
                return(null);
            }

            if (!property.IsEnumerable)
            {
                return new List <IStructureIndexValue> {
                           new StructureIndexValue($"{startPath}.{property.Name}", currentValue)
                }
            }
            ;

            return(CollectionOfValuesToList((IEnumerable)currentValue, property, startPath));
        }
Beispiel #4
0
        private static IList <IStructureIndexValue> ExtractValuesForEnumerableNode <T>(T nodes, IStructureProperty property, string startPath) where T : IEnumerable
        {
            var collection = nodes as ICollection;
            var values     = collection != null
                ? new List <IStructureIndexValue>(collection.Count)
                : new List <IStructureIndexValue>();

            var i = -1;

            foreach (var node in nodes)
            {
                i += 1;
                var path = $"{startPath}[{i}]";

                if (node == null)
                {
                    continue;
                }

                var nodeValue = property.GetValue(node);
                if (nodeValue == null)
                {
                    continue;
                }

                var enumerableNode = nodeValue as IEnumerable;

                if (enumerableNode != null && !(nodeValue is string))
                {
                    values.AddRange(CollectionOfValuesToList(enumerableNode, property, path));
                }
                else
                {
                    values.Add(new StructureIndexValue($"{path}.{property.Name}", nodeValue));
                }
            }

            return(values);
        }
Beispiel #5
0
 public IStructureId GetIdValue <T>(T item, IStructureProperty property) where T : class
 {
     return(StructureId.Create((long?)property.GetValue(item)));
 }