Esempio n. 1
0
        public static IReadOnlyCollection <ChainNode> ListLeafPaths <T>(this Include <T> include, Type type)
        {
            var rootNode = include.CreateChainNode();
            var @paths   = ChainNodeTree.ListLeafPaths(rootNode);

            return(@paths);
        }
Esempio n. 2
0
 public static Func <ChainNode, IEnumerable <MemberInfo> > ComposeLeafRule(ChainNode root)
 {
     return((node) =>
     {
         var filteredProperties = new List <MemberInfo>();
         var path = ChainNodeTree.FindLinkedRootKeyPath(node);
         var n = default(ChainNode);
         if (path.Length == 0)
         {
             n = root;
         }
         else
         {
             if (ChainNodeTree.FindNode(root, path, out ChainMemberNode c))
             {
                 n = c;
             }
         }
         if (n != default(ChainNode))
         {
             var type = n.Type;
             foreach (var child in n.Children)
             {
                 var propertyName = child.Key;
                 var propertyInfo = type.GetProperty(propertyName);
                 filteredProperties.Add(propertyInfo);
             }
         }
         return filteredProperties;
     });
 }
Esempio n. 3
0
        /// <summary>
        /// Set to null all properties except included
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="entity"></param>
        /// <param name="include"></param>
        public static void Detach <T>(T entity, Include <T> include) where T : class
        {
            var chainNode = include.CreateChainNode();
            var paths     = ChainNodeTree.ListLeafKeyPaths(chainNode);

            DetachRecursive(entity, paths);
        }
Esempio n. 4
0
        public static bool IsSubsetOf <T>(this Include <T> include1, Include <T> include2)
        {
            var rootNode1 = include1.CreateChainNode();
            var rootNode2 = include2.CreateChainNode();

            bool @value = ChainNodeTree.IsSubTreeOf(rootNode1, rootNode2);

            return(@value);
        }
Esempio n. 5
0
        public static Include <T> Merge <T>(this Include <T> include1, Include <T> include2)
        {
            var rootNode1 = include1.CreateChainNode();
            var rootNode2 = include2.CreateChainNode();

            var union  = ChainNodeTree.Merge(rootNode1, rootNode2);
            var @value = union.ComposeInclude <T>();

            return(@value);
        }
Esempio n. 6
0
        public static void DetachAll <TCol, T>(IEnumerable <T> entities, Include <T> include) where TCol : IEnumerable <T>
        {
            var chainNode = include.CreateChainNode();
            var paths     = ChainNodeTree.ListLeafKeyPaths(chainNode);

            foreach (var entity in entities)
            {
                if (entity != null)
                {
                    DetachRecursive(entity, paths);
                }
            }
        }
Esempio n. 7
0
        public static IReadOnlyCollection <string> ListXPaths <T>(this Include <T> include)
        {
            if (include == null)
            {
                return new List <string> {
                           "/"
                }
            }
            ;
            var rootNode = include.CreateChainNode();
            var @paths   = ChainNodeTree.ListXPaths(rootNode);

            return(@paths);
        }
Esempio n. 8
0
 public static IReadOnlyCollection <string> ListXPaths(this ChainNode node)
 {
     return(ChainNodeTree.ListXPaths(node));
 }