Exemplo n.º 1
0
        public ConfigToFieldsTranslator()
        {
            this.AddCase("double", jObject => {
                string name      = (string)jObject["name"];
                double mean      = (double)jObject["distribution_params"]["mean"];
                double std       = (double)jObject["distribution_params"]["std"];
                FieldParam param = new FieldParam
                {
                    mean = mean,
                    standard_deviation = std
                };
                return(new Field(name, "double", param));
            });

            this.AddCase("int", jObject => {
                string name      = (string)jObject["name"];
                double mean      = (double)jObject["distribution_params"]["mean"];
                double std       = (double)jObject["distribution_params"]["std"];
                FieldParam param = new FieldParam
                {
                    mean = mean,
                    standard_deviation = std
                };
                return(new Field(name, "int", param));
            });

            this.AddCase("string", jObject => {
                string name      = (string)jObject["name"];
                int maxlen       = (int)jObject["distribution_params"]["max_len"];
                FieldParam param = new FieldParam
                {
                    max_len = maxlen
                };
                return(new Field(name, "string", param));
            });
        }
Exemplo n.º 2
0
 public Field(string name, string typeID, FieldParam param)
 {
     this.name   = name;
     this.typeID = typeID;
     this.param  = param;
 }
 public IJSONDataGenerator Make(FieldParam param)
 {
     return(new StringDataGenerator(param.max_len));
 }
 public IJSONDataGenerator Make(FieldParam param)
 {
     return(new IntegerDataGenerator(param.mean, param.standard_deviation));
 }