public static void SaveEnvironment(SreEnvironments envs)
        {
            IdpeKey key = new IdpeKey();

            key.Name        = IdpeKeyTypes.Environments.ToString();
            key.Type        = (int)IdpeKeyTypes.Environments;
            key.ValueBinary = new Binary(GZipArchive.Compress(envs.Serialize().GetByteArray()));
            new Manager().Save(key);
        }
        public static SreEnvironments GetEnvironments()
        {
            SreEnvironments envs = new SreEnvironments();
            IdpeKey         key  = new Manager().GetKey(IdpeKeyTypes.Environments);

            if (key != null)
            {
                try
                {
                    //envs = key.Value.Deserialize<SreEnvironments>();
                    envs = GZipArchive.Decompress(key.ValueBinary.ToArray()).GetString().Deserialize <SreEnvironments>();
                    if (envs.Count == 0)
                    {
                        envs = new SreEnvironments(true);
                    }
                    foreach (SreEnvironment env in envs)
                    {
                        foreach (SreEnvironmentConfig config in env.EnvironmentConfigs)
                        {
                            config.Environment = env;
                        }
                    }
                }
                catch
                {
                    envs = new SreEnvironments(true);
                    SaveEnvironment(envs);
                    return(envs);
                }
            }
            else
            {
                envs = new SreEnvironments(true);
            }

            return(envs);
        }