Ejemplo n.º 1
0
        public ConfigToFieldsTranslator()
        {
            this.AddCase(Type.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 FieldAttributes(name, Type.Double, param);
            });

            this.AddCase(Type.Integer, 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 FieldAttributes(name, Type.Integer, param);
            });

            this.AddCase(Type.String, jObject => {

                string name = (string)jObject["name"];
                int? maxlen = (int)jObject["distribution_params"]["max_len"];
                FieldParam param = new FieldParam
                {
                    max_len = maxlen
                };
                return new FieldAttributes(name, Type.String, param);
            });
        }
        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));
            });
        }
 public FieldAttributes(string name, string typeID, FieldParam param)
 {
     this.name   = name;
     this.typeID = typeID;
     this.param  = param;
 }