Esempio n. 1
0
        internal static IPsecPolicy DeserializeIPsecPolicy(JsonElement element)
        {
            int             saLifeTimeSeconds   = default;
            int             saDataSizeKilobytes = default;
            IPsecEncryption ipsecEncryption     = default;
            IPsecIntegrity  ipsecIntegrity      = default;
            IkeEncryption   ikeEncryption       = default;
            IkeIntegrity    ikeIntegrity        = default;
            DhGroup         dhGroup             = default;
            PfsGroup        pfsGroup            = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("saLifeTimeSeconds"))
                {
                    saLifeTimeSeconds = property.Value.GetInt32();
                    continue;
                }
                if (property.NameEquals("saDataSizeKilobytes"))
                {
                    saDataSizeKilobytes = property.Value.GetInt32();
                    continue;
                }
                if (property.NameEquals("ipsecEncryption"))
                {
                    ipsecEncryption = new IPsecEncryption(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("ipsecIntegrity"))
                {
                    ipsecIntegrity = new IPsecIntegrity(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("ikeEncryption"))
                {
                    ikeEncryption = new IkeEncryption(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("ikeIntegrity"))
                {
                    ikeIntegrity = new IkeIntegrity(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("dhGroup"))
                {
                    dhGroup = new DhGroup(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("pfsGroup"))
                {
                    pfsGroup = new PfsGroup(property.Value.GetString());
                    continue;
                }
            }
            return(new IPsecPolicy(saLifeTimeSeconds, saDataSizeKilobytes, ipsecEncryption, ipsecIntegrity, ikeEncryption, ikeIntegrity, dhGroup, pfsGroup));
        }
Esempio n. 2
0
 void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
 {
     writer.WriteStartObject();
     writer.WritePropertyName("saLifeTimeSeconds");
     writer.WriteNumberValue(SaLifeTimeSeconds);
     writer.WritePropertyName("saDataSizeKilobytes");
     writer.WriteNumberValue(SaDataSizeKilobytes);
     writer.WritePropertyName("ipsecEncryption");
     writer.WriteStringValue(IPsecEncryption.ToString());
     writer.WritePropertyName("ipsecIntegrity");
     writer.WriteStringValue(IPsecIntegrity.ToString());
     writer.WritePropertyName("ikeEncryption");
     writer.WriteStringValue(IkeEncryption.ToString());
     writer.WritePropertyName("ikeIntegrity");
     writer.WriteStringValue(IkeIntegrity.ToString());
     writer.WritePropertyName("dhGroup");
     writer.WriteStringValue(DhGroup.ToString());
     writer.WritePropertyName("pfsGroup");
     writer.WriteStringValue(PfsGroup.ToString());
     writer.WriteEndObject();
 }