Esempio n. 1
0
        /// <summary>
        ///     Include specified field to resulting typing
        /// </summary>
        /// <param name="tc">Configuration builder</param>
        /// <param name="field">Field to include</param>
        /// <returns>Fluent</returns>
        public static PropertyExportConfigurationBuilder WithField <T, TData>(this TypeConfigurationBuilder <T> tc,
                                                                              Expression <Func <T, TData> > field)
        {
            var prop = LambdaHelpers.ParseFieldLambda(field);
            ITypeConfigurationBuilder tcb = tc;

            return(new PropertyExportConfigurationBuilder(prop, tc._blueprint));
        }
        /// <summary>
        ///     Include specified field to resulting typing
        /// </summary>
        /// <param name="tc">Configuration builder</param>
        /// <param name="field">Field to include</param>
        /// <returns>Fluent</returns>
        public static PropertyExportConfigurationBuilder WithField <T, TData>(this TypeConfigurationBuilder <T> tc,
                                                                              Expression <Func <T, TData> > field)
        {
            var prop = LambdaHelpers.ParseFieldLambda(field);
            ITypeConfigurationBuilder tcb = tc;

            return
                ((PropertyExportConfigurationBuilder)
                 tcb.MembersConfiguration.GetOrCreate(prop, () => new PropertyExportConfigurationBuilder(prop)));
        }
        /// <summary>
        ///     Include specified property to resulting typing
        /// </summary>
        /// <param name="tc">Configuration builder</param>
        /// <param name="property">Property to include</param>
        /// <returns>Fluent</returns>
        public static PropertyExportConfiguration WithProperty <T, TData>(this TypeConfigurationBuilder <T> tc,
                                                                          Expression <Func <T, TData> > property)
        {
            var prop = LambdaHelpers.ParsePropertyLambda(property);
            ITypeConfigurationBuilder tcb = tc;

            return
                ((PropertyExportConfiguration)
                 tcb.MembersConfiguration.GetOrCreate(prop, () => new PropertyExportConfiguration()));
        }
        /// <summary>
        ///     Include specified method to resulting typing.
        ///     User <see cref="Ts.Parameter{T}()" /> to mock up method parameters or specify configuration for perticular method
        ///     parameter
        /// </summary>
        /// <param name="tc">Configuration builder</param>
        /// <param name="method">Method to include</param>
        /// <returns>Fluent</returns>
        public static MethodConfigurationBuilder WithMethod <T>(this TypeConfigurationBuilder <T> tc,
                                                                Expression <Action <T> > method)
        {
            var prop = LambdaHelpers.ParseMethodLambda(method);
            ITypeConfigurationBuilder tcb = tc;
            var methodConf = new MethodConfigurationBuilder(prop, tc._blueprint);

            ExtractParameters(tcb, method);
            return(methodConf);
        }
        /// <summary>
        ///     Include specified method to resulting typing.
        ///     User <see cref="Ts.Parameter{T}()" /> to mock up method parameters or specify configuration for perticular method
        ///     parameter
        /// </summary>
        /// <param name="tc">Configuration builder</param>
        /// <param name="method">Method to include</param>
        /// <returns>Fluent</returns>
        public static MethodExportConfiguration WithMethod <T>(this TypeConfigurationBuilder <T> tc,
                                                               Expression <Action <T> > method)
        {
            var prop = LambdaHelpers.ParseMethodLambda(method);
            ITypeConfigurationBuilder tcb = tc;
            var methodConf =
                (MethodExportConfiguration)
                tcb.MembersConfiguration.GetOrCreate(prop, () => new MethodExportConfiguration());

            ExtractParameters(tcb, method);
            return(methodConf);
        }