/// <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 MethodExportBuilder WithMethod <T>(this ITypedExportBuilder <T> tc,
                                                         Expression <Action <T> > method)
        {
            var prop = LambdaHelpers.ParseMethodLambda(method);
            ClassOrInterfaceExportBuilder tcb = tc as ClassOrInterfaceExportBuilder;
            var methodConf = new MethodExportBuilder(tcb.Blueprint, prop);

            tcb.ExtractParameters(method);
            return(methodConf);
        }
Exemplo n.º 2
0
        protected internal void ApplyMethodsConfiguration(IEnumerable <MethodInfo> methds,

                                                          Action <MethodExportBuilder> configuration = null)
        {
            Blueprint.NotifyFlattenTouched();
            foreach (var methodInfo in methds)
            {
                var conf = new MethodExportBuilder(Blueprint, methodInfo);
                if (configuration == null)
                {
                    continue;
                }
                try
                {
                    configuration(conf);
                }
                catch (Exception ex)
                {
                    ErrorMessages.RTE0006_FluentSingleError.Throw(ex.Message, "method",
                                                                  string.Format("{0}.{1}(...)", methodInfo.DeclaringType.FullName, methodInfo.Name));
                }
            }
        }
 /// <summary>
 ///     Specifies whether exported method must be considered async.
 ///     If this value is specified explicitly then exported method will be considered async based on
 ///     this value. If the value is null then RT will automatically decide whether method must be async
 ///     based on its return type (Task`N).
 /// </summary>
 /// <param name="conf">Configurator</param>
 /// <param name="isAsync">True to make method async, false otherwise</param>
 /// <returns></returns>
 public static MethodExportBuilder ForceAsync(this MethodExportBuilder conf, bool?isAsync)
 {
     conf.Attr.ForceAsync = isAsync;
     return(conf);
 }
 /// <summary>
 ///     Overrides member type on export with strong type.
 ///     Feel free to use delegates here. It is very comfortable instead of regular TS functions syntax.
 ///     Actually this method does the same as .Type call. Just for your convinence
 /// </summary>
 /// <param name="conf">Configurator</param>
 public static MethodExportBuilder Returns <T>(this MethodExportBuilder conf)
 {
     conf.Attr.StrongType = typeof(T);
     return(conf);
 }
 /// <summary>
 ///     Overrides member type on export with strong type.
 ///     Feel free to use delegates here. It is very comfortable instead of regular TS functions syntax.
 ///     Actually this method does the same as .Type call. Just for your convinence
 /// </summary>
 /// <param name="conf">Configurator</param>
 /// <param name="type">Type to override with</param>
 /// <returns></returns>
 public static MethodExportBuilder Returns(this MethodExportBuilder conf, Type type)
 {
     conf.Attr.StrongType = type;
     return(conf);
 }
 /// <summary>
 ///     Overrides member type name on export with textual string.
 ///     Beware of using this setting because specified type may not present in your TypeScript code and
 ///     this will lead to TypeScript compilation errors.
 ///     Actually this method does the same as .Type call. Just for your convinence
 /// </summary>
 /// <param name="conf">Configurator</param>
 /// <param name="typeName">TS-friendly type name</param>
 /// <returns></returns>
 public static MethodExportBuilder Returns(this MethodExportBuilder conf, string typeName)
 {
     conf.Attr.Type = typeName;
     return(conf);
 }
 /// <summary>
 /// Sets function body (works in case of class export) that will be converted to RtRaw and inserted as code block
 /// </summary>
 /// <param name="builder"></param>
 /// <param name="functionCode">Function code</param>
 /// <returns></returns>
 public static MethodExportBuilder Implement(this MethodExportBuilder builder, string functionCode)
 {
     builder.Attr.Implementation = functionCode;
     return(builder);
 }
 /// <summary>
 /// Sets order this membter will be written to output file in
 /// </summary>
 /// <param name="conf">Configurator</param>
 /// <param name="order">Order of member</param>
 /// <returns>Fluent</returns>
 public static MethodExportBuilder Order(this MethodExportBuilder conf, double order)
 {
     conf.Attr.Order = order;
     return(conf);
 }
 /// <summary>
 ///     Specifies code generator for member
 /// </summary>
 public static MethodExportBuilder WithCodeGenerator <T>(this MethodExportBuilder conf)
     where T : ITsCodeGenerator <MethodInfo>
 {
     conf.Attr.CodeGeneratorType = typeof(T);
     return(conf);
 }
Exemplo n.º 10
0
 /// <summary>
 ///     Specifies code generator for member
 /// </summary>
 public static MethodExportBuilder WithCodeGenerator <T>(this MethodExportBuilder conf, T codeGeneratorInstance)
     where T : ITsCodeGenerator <MethodInfo>
 {
     conf.Attr.CodeGeneratorInstance = codeGeneratorInstance;
     return(conf);
 }