Example #1
0
            public override JsonValue ToJson()
            {
                dynamic json = base.ToJson();

                if (Ensemble != null)
                {
                    json.ensemble = Ensemble;
                }
                if (LogisticRegression != null)
                {
                    json.logisticregression = LogisticRegression;
                }
                if (Model != null)
                {
                    json.model = Model;
                }

                if (InputData.Count > 0)
                {
                    var input_data = new JsonObject();
                    foreach (var kv in InputData)
                    {
                        JsonPrimitive value;
                        JsonPrimitive.TryCreate(kv.Value, out value);
                        input_data[kv.Key] = value;
                    }
                    json.input_data = input_data;
                }

                return(json);
            }
        private static JsonValue CreatePrimitive(object value)
        {
            JsonPrimitive jsonPrimitive;

            if (JsonPrimitive.TryCreate(value, out jsonPrimitive))
            {
                return(jsonPrimitive);
            }

            return(null);
        }
Example #3
0
        private void CheckValues(object[] values, JsonType expectedType)
        {
            JsonPrimitive target;
            bool          success;

            foreach (object value in values)
            {
                success = JsonPrimitive.TryCreate(value, out target);
                Assert.IsTrue(success);
                Assert.IsNotNull(target);
                Assert.AreEqual(expectedType, target.JsonType);
            }
        }
Example #4
0
        public void ValueTest()
        {
            object[] values =
            {
                AnyInstance.AnyInt, AnyInstance.AnyString, AnyInstance.AnyGuid, AnyInstance.AnyDecimal, AnyInstance.AnyBool, AnyInstance.AnyDateTime
            };

            foreach (object value in values)
            {
                JsonPrimitive jp;
                bool          success = JsonPrimitive.TryCreate(value, out jp);
                Assert.IsTrue(success);
                Assert.AreEqual(value, jp.Value);
            }
        }
Example #5
0
        public void TryCreateInvalidTest()
        {
            bool          success;
            JsonPrimitive target;

            object[] values =
            {
                AnyInstance.AnyJsonArray, AnyInstance.AnyJsonObject,    AnyInstance.AnyJsonPrimitive,
                null,                     AnyInstance.DefaultJsonValue, AnyInstance.AnyDynamic,      AnyInstance.AnyAddress,
                AnyInstance.AnyPerson
            };

            foreach (object value in values)
            {
                success = JsonPrimitive.TryCreate(value, out target);
                Assert.IsFalse(success);
                Assert.IsNull(target);
            }
        }
Example #6
0
            public override JsonValue ToJson()
            {
                dynamic json = base.ToJson();

                json.model = Model;
                if (InputData.Count > 0)
                {
                    var input_data = new JsonObject();
                    foreach (var kv in InputData)
                    {
                        JsonPrimitive value;
                        JsonPrimitive.TryCreate(kv.Value, out value);
                        input_data[kv.Key] = value;
                    }
                    json.input_data = input_data;
                }

                return(json);
            }
Example #7
0
            public override JsonValue ToJson()
            {
                dynamic json = base.ToJson();

                if (!string.IsNullOrWhiteSpace(Anomaly))
                {
                    json.anomaly = Anomaly;
                }
                if (InputData.Count > 0)
                {
                    var input_data = new JsonObject();
                    foreach (var kv in InputData)
                    {
                        JsonPrimitive value;
                        JsonPrimitive.TryCreate(kv.Value, out value);
                        input_data[kv.Key] = value;
                    }
                    json.input_data = input_data;
                }
                return(json);
            }