示例#1
0
        /// <summary>
        /// Get unflat targets for given flatPropertyName, objects will be created if null encountered in the path towards the target, you can set the value from flatProperty into the target(s)
        /// </summary>
        /// <param name="flatPropertyName">flat property name</param>
        /// <param name="lookupObject">object to look for targets into</param>
        /// <param name="match">match func used for checking the last property in the trail</param>
        /// <param name="comparison"></param>
        /// <param name="activator">creator func, used to create objects along the way if null is encountered, by default Activator.CreateIntance is used</param>
        /// <returns>all matching unflat targets info</returns>
        public static IEnumerable <PropertyWithComponent> Unflat(string flatPropertyName, object lookupObject, Func <string, PropertyInfo, bool> match, StringComparison comparison, Func <PropertyInfo, object, object> activator = null)
        {
            var trails = TrailFinder.GetTrails(flatPropertyName, lookupObject, match, comparison, false).Where(o => o != null);

            return(trails.Select(trail => Tunnelier.Digg(trail, lookupObject, activator)));
        }
示例#2
0
        /// <summary>
        /// Get unflat targets for given flatPropertyName, you can use the result to get value from and set it into the flat property
        /// </summary>
        /// <param name="flatPropertyName">flat property name</param>
        /// <param name="lookupObject">object to look for targets into</param>
        /// <param name="match">match func used for checking the last property in the trail</param>
        /// <param name="comparison">StringComparison type used for building the flat trail</param>
        /// <returns>all matching unflat targets info</returns>
        public static IEnumerable <PropertyWithComponent> Flat(string flatPropertyName, object lookupObject, Func <string, PropertyInfo, bool> match, StringComparison comparison)
        {
            var trails = TrailFinder.GetTrails(flatPropertyName, lookupObject, match, comparison).Where(o => o != null);

            return(trails.Select(trail => Tunnelier.Find(trail, lookupObject)));
        }
示例#3
0
        public static IEnumerable <PropertyWithComponent> Flat(string flatPropertyName, object source, Func <string, PropertyInfo, bool> match, StringComparison comparison)
        {
            var trails = TrailFinder.GetTrails(flatPropertyName, source.GetType().GetProps(), match, comparison).Where(o => o != null);

            return(trails.Select(trail => Tunnelier.GetValue(trail, source)));
        }