Esempio n. 1
0
 void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
 {
     writer.WriteStartObject();
     writer.WritePropertyName("urls");
     writer.WriteStartArray();
     foreach (var item in Urls)
     {
         writer.WriteStringValue(item);
     }
     writer.WriteEndArray();
     writer.WritePropertyName("username");
     writer.WriteStringValue(Username);
     writer.WritePropertyName("credential");
     writer.WriteStringValue(Credential);
     writer.WritePropertyName("routeType");
     writer.WriteStringValue(RouteType.ToString());
     writer.WriteEndObject();
 }
        public CommunicationIceServer(IEnumerable <string> urls, string username, string credential, RouteType routeType)
        {
            if (urls == null)
            {
                throw new ArgumentNullException(nameof(urls));
            }
            if (username == null)
            {
                throw new ArgumentNullException(nameof(username));
            }
            if (credential == null)
            {
                throw new ArgumentNullException(nameof(credential));
            }

            Urls       = urls.ToList();
            Username   = username;
            Credential = credential;
            RouteType  = routeType;
        }
Esempio n. 3
0
        internal static CommunicationIceServer DeserializeCommunicationIceServer(JsonElement element)
        {
            IList <string> urls       = default;
            string         username   = default;
            string         credential = default;
            RouteType      routeType  = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("urls"))
                {
                    List <string> array = new List <string>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(item.GetString());
                    }
                    urls = array;
                    continue;
                }
                if (property.NameEquals("username"))
                {
                    username = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("credential"))
                {
                    credential = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("routeType"))
                {
                    routeType = new RouteType(property.Value.GetString());
                    continue;
                }
            }
            return(new CommunicationIceServer(urls, username, credential, routeType));
        }
 internal CommunicationIceServer(IList <string> urls, string username, string credential, RouteType routeType)
 {
     Urls       = urls;
     Username   = username;
     Credential = credential;
     RouteType  = routeType;
 }
Esempio n. 5
0
        public static CommunicationIceServer CommunicationIceServer(IEnumerable <string> urls = null, string username = null, string credential = null, RouteType routeType = default)
        {
            urls ??= new List <string>();

            return(new CommunicationIceServer(urls?.ToList(), username, credential, routeType));
        }