Esempio n. 1
0
        private TelemetryFunction NewFx()
        {
            var fx = new TelemetryFunction()
            {
                Name = "New Function"
            };

            fx.State = fx.Serialize();
            return(fx);
        }
Esempio n. 2
0
        private void SaveCustomFunctionFile(TelemetryFunction fx)
        {
            JsonSerializerSettings settings = new JsonSerializerSettings {
                TypeNameHandling = TypeNameHandling.Auto
            };
            var json          = JsonConvert.SerializeObject(fx, settings);
            var fieldListFile = Path.Combine(Constants.AppFolder, fx.FileName);

            if (File.Exists(fieldListFile))
            {
                File.Delete(fieldListFile);
            }
            File.WriteAllText(fieldListFile, json);
            fx.State = fx.Serialize();
        }
Esempio n. 3
0
        private TelemetryFunction LoadCustomFunctionFile(string fileName)
        {
            TelemetryFunction fx = null;

            if (File.Exists(fileName))
            {
                var json = File.ReadAllText(fileName);
                JsonSerializerSettings settings = new JsonSerializerSettings {
                    TypeNameHandling = TypeNameHandling.Auto
                };
                fx       = JsonConvert.DeserializeObject <TelemetryFunction>(json, settings);
                fx.State = fx.Serialize();
            }

            return(fx);
        }