Пример #1
0
        /// <summary>
        /// Create the template output
        /// </summary>
        public virtual string TransformText()
        {
            this.Write(@"
using System.Collections.Generic;
using Newtonsoft.Json;
using SweepableEstimator = Microsoft.ML.AutoML.SweepableEstimator;
using Microsoft.ML.AutoML.CodeGen;
using ColorsOrder = Microsoft.ML.Transforms.Image.ImagePixelExtractingEstimator.ColorsOrder;
using ColorBits = Microsoft.ML.Transforms.Image.ImagePixelExtractingEstimator.ColorBits;
using ResizingKind = Microsoft.ML.Transforms.Image.ImageResizingEstimator.ResizingKind;
using Anchor = Microsoft.ML.Transforms.Image.ImageResizingEstimator.Anchor;
using Microsoft.ML.SearchSpace;

namespace ");
            this.Write(this.ToStringHelper.ToStringWithCulture(NameSpace));
            this.Write("\r\n{\r\n    internal partial class ");
            this.Write(this.ToStringHelper.ToStringWithCulture(ClassName));
            this.Write(" : SweepableEstimator<");
            this.Write(this.ToStringHelper.ToStringWithCulture(TOption));
            this.Write(">\r\n    {\r\n        public ");
            this.Write(this.ToStringHelper.ToStringWithCulture(ClassName));
            this.Write("(");
            this.Write(this.ToStringHelper.ToStringWithCulture(TOption));
            this.Write(" defaultOption, SearchSpace<");
            this.Write(this.ToStringHelper.ToStringWithCulture(TOption));
            this.Write("> searchSpace = null)\r\n        {\r\n            this.TParameter = defaultOption;\r\n " +
                       "           this.SearchSpace = searchSpace;\r\n            this.EstimatorType = Est" +
                       "imatorType.");
            this.Write(this.ToStringHelper.ToStringWithCulture(ClassName));
            this.Write(";\r\n        }\r\n\r\n        internal ");
            this.Write(this.ToStringHelper.ToStringWithCulture(ClassName));
            this.Write("()\r\n        {\r\n            this.EstimatorType = EstimatorType.");
            this.Write(this.ToStringHelper.ToStringWithCulture(ClassName));
            this.Write(";\r\n            this.TParameter = new ");
            this.Write(this.ToStringHelper.ToStringWithCulture(TOption));
            this.Write("();\r\n        }\r\n    \r\n        internal override IEnumerable<string> CSharpUsingSt" +
                       "atements \r\n        {\r\n            get => new string[] {");
            this.Write(this.ToStringHelper.ToStringWithCulture(Utils.PrettyPrintListOfString(UsingStatements.Select(x => $"using {x};"))));
            this.Write("};\r\n        }\r\n\r\n        internal override IEnumerable<string> NugetDependencies\r" +
                       "\n        {\r\n            get => new string[] {");
            this.Write(this.ToStringHelper.ToStringWithCulture(Utils.PrettyPrintListOfString(NugetDependencies)));
            this.Write("};\r\n        }\r\n\r\n        internal override string FunctionName \r\n        {\r\n     " +
                       "       get => \"");
            this.Write(this.ToStringHelper.ToStringWithCulture(Utils.GetPrefix(Type)));
            this.Write(".");
            this.Write(this.ToStringHelper.ToStringWithCulture(FunctionName));
            this.Write("\";\r\n        }\r\n    }\r\n}\r\n\r\n");
            return(this.GenerationEnvironment.ToString());
        }
Пример #2
0
        /// <summary>
        /// Create the template output
        /// </summary>
        public virtual string TransformText()
        {
            this.Write(@"
using System.Collections.Generic;
using Newtonsoft.Json;
using SweepableEstimator = Microsoft.ML.AutoML.SweepableEstimator;
using Microsoft.ML.AutoML.CodeGen;
using ColorsOrder = Microsoft.ML.Transforms.Image.ImagePixelExtractingEstimator.ColorsOrder;
using ColorBits = Microsoft.ML.Transforms.Image.ImagePixelExtractingEstimator.ColorBits;
using ResizingKind = Microsoft.ML.Transforms.Image.ImageResizingEstimator.ResizingKind;
using Anchor = Microsoft.ML.Transforms.Image.ImageResizingEstimator.Anchor;

namespace ");
            this.Write(this.ToStringHelper.ToStringWithCulture(NameSpace));
            this.Write("\r\n{\r\n    internal partial class ");
            this.Write(this.ToStringHelper.ToStringWithCulture(ClassName));
            this.Write(" : SweepableEstimator\r\n    {\r\n        public ");
            this.Write(this.ToStringHelper.ToStringWithCulture(ClassName));
            this.Write("()\r\n        {\r\n            this.EstimatorType = EstimatorType.");
            this.Write(this.ToStringHelper.ToStringWithCulture(ClassName));
            this.Write(";\r\n        }\r\n    \r\n");
            foreach (var arg in ArgumentsList)
            {
                var typeAttributeName = Utils.CapitalFirstLetter(arg.ArgumentType);
                var propertyName      = Utils.CapitalFirstLetter(arg.ArgumentName);
                this.Write("        [");
                this.Write(this.ToStringHelper.ToStringWithCulture(typeAttributeName));
                this.Write("]\r\n        [JsonProperty(NullValueHandling=NullValueHandling.Ignore)]\r\n        pu" +
                           "blic string ");
                this.Write(this.ToStringHelper.ToStringWithCulture(propertyName));
                this.Write(" { get; set; }\r\n\r\n");
            }
            this.Write("        internal override IEnumerable<string> CSharpUsingStatements \r\n        {\r\n" +
                       "            get => new string[] {");
            this.Write(this.ToStringHelper.ToStringWithCulture(Utils.PrettyPrintListOfString(UsingStatements.Select(x => $"using {x};"))));
            this.Write("};\r\n        }\r\n\r\n        internal override IEnumerable<string> NugetDependencies\r" +
                       "\n        {\r\n            get => new string[] {");
            this.Write(this.ToStringHelper.ToStringWithCulture(Utils.PrettyPrintListOfString(NugetDependencies)));
            this.Write("};\r\n        }\r\n\r\n        internal override string FunctionName \r\n        {\r\n     " +
                       "       get => \"");
            this.Write(this.ToStringHelper.ToStringWithCulture(Utils.GetPrefix(Type)));
            this.Write(".");
            this.Write(this.ToStringHelper.ToStringWithCulture(FunctionName));
            this.Write("\";\r\n        }\r\n    }\r\n}\r\n\r\n");
            return(this.GenerationEnvironment.ToString());
        }