コード例 #1
0
        /// <summary>
        /// Pass in a property by LINQ expression so that it can be defined by modifying the resulting AnalyticalChild
        /// The AnalyticalChild constructor will try to guess the type.
        /// </summary>
        /// <typeparam name="TProperty">Type of property to be defined</typeparam>
        /// <param name="propertyExpression"></param>
        /// <param name="directParent">Direct parent, this should not be set by the user</param>
        /// <returns></returns>
        public AnalyticalChild <T, TProperty> Property <TProperty>(Expression <Func <T, TProperty> > propertyExpression,
                                                                   AnalyticalObject <T> directParent = null)
        {
            var    expression = (MemberExpression)propertyExpression.Body;
            string name       = expression.Member.Name;
            Type   childType  = propertyExpression.ReturnType;
            var    child      = new AnalyticalChild <T, TProperty>(directParent ?? this, name, childType, this.TypeMap);

            return(child);
        }
コード例 #2
0
        /// <summary>
        /// Override default behavior to modify parent passing
        /// </summary>
        /// <typeparam name="TProperty"></typeparam>
        /// <param name="propertyExpression"></param>
        /// <param name="directParent"></param>
        /// <returns></returns>
        public new AnalyticalChild <T, TProperty> Property <TProperty>(Expression <Func <T, TProperty> > propertyExpression, AnalyticalObject <T> directParent = null)
        {
            var    expression = (MemberExpression)propertyExpression.Body;
            string name       = expression.Member.Name;
            Type   childType  = propertyExpression.ReturnType;
            AnalyticalChild <T, TProperty> child;

            // Passing the type maps down to the child, so that all children/grandchildren share the same type dictionary
            child = new AnalyticalChild <T, TProperty>(this, name, childType, this.TypeMap, this.parentName);
            return(child);
        }
コード例 #3
0
        public AnalyticalChild <T, TProperty> Property <TProperty>(string propertyName, AnalyticalObject <TProperty> type)
        {
            var child = new AnalyticalChild <T, TProperty>(this, propertyName, type.AnalyzedType, this.TypeMap);

            PopulateTypeMaps(new NodeProperties()
            {
                InternalType = InternalType.NEVER
            }, Name, propertyName);

            foreach (var kv in type.TypeMap)
            {
                PopulateTypeMaps(kv.Value, $"{propertyName}_{kv.Key}", true);
            }

            return(child);
        }