Example #1
0
        public void Save()
        {
            var writer = XmlWriter.Create(pathName,
                                          new XmlWriterSettings()
            {
                Indent = true, IndentChars = @"    "
            });

            writer.WriteStartElement(@"settings");

            writer.WriteElementString(@"publicIp", PublicIp.ToString());
            writer.WriteElementString(@"turnUdpPort", TurnUdpPort.ToString());
            writer.WriteElementString(@"turnTcpPort", TurnTcpPort.ToString());
            writer.WriteElementString(@"turnTlsPort", TurnTlsPort.ToString());
            writer.WriteElementString(@"minPort", MinPort.ToString());
            writer.WriteElementString(@"maxPort", MaxPort.ToString());
            writer.WriteElementString(@"realm", Realm);
            writer.WriteElementString(@"key1", Convert.ToBase64String(Key1));
            writer.WriteElementString(@"key2", Convert.ToBase64String(Key2));
            writer.WriteElementString(@"adminName", AdminName);
            writer.WriteElementString(@"adminPass", AdminPass);

            writer.WriteEndElement();

            writer.Flush();
            writer.Close();
        }
Example #2
0
 /// <summary>
 /// ToString
 /// </summary>
 /// <returns>String or null if invalid range</returns>
 public override string ToString()
 {
     if (MinPort > 65535 || MaxPort > 65535 || MinPort < 0 || MaxPort < 0 || MaxPort < MinPort)
     {
         return(null);
     }
     else if (MinPort == MaxPort)
     {
         return(MinPort.ToString(CultureInfo.InvariantCulture));
     }
     return(MinPort.ToString(CultureInfo.InvariantCulture) + "-" + MaxPort.ToString(CultureInfo.InvariantCulture));
 }