/// <summary> /// Create a JSON representation of the given internationalized string. /// </summary> /// <param name="JPropertyKey">The name of the JSON property key.</param> /// <param name="I18N">An internationalized string.</param> public static JProperty ToJSON(String JPropertyKey, I18NString I18N) { if (I18N.Any()) return new JProperty(JPropertyKey, JSONHelper.ToJSON(I18N)); else return null; }
/// <summary> /// Create a new geographical coordinate or position on a map. /// </summary> /// <param name="Latitude">The Latitude (south to nord).</param> /// <param name="Longitude">The Longitude (parallel to equator).</param> /// <param name="Altitude">The (optional) Altitude.</param> /// <param name="Name">An optional name for this geo location.</param> public AdditionalGeoLocation(Latitude Latitude, Longitude Longitude, Altitude? Altitude = null, I18NString Name = null) { this.Name = Name != null ? Name : new I18NString(); }
/// <summary> /// Create new business details for an Charging Station Operator. /// </summary> /// <param name="Name">Name of the operator.</param> /// <param name="Website">Link to the operator's website.</param> /// <param name="Logo">Image link to the operator's logo.</param> public BusinessDetails(I18NString Name, Uri Website, Image Logo) { #region Initial checks if (Name == null) throw new ArgumentNullException("Name", "The given parameter must not be null!"); #endregion this._Name = Name; this._Website = Website; this._Logo = Logo; }
/// <summary> /// Create a JSON representation of the given internationalized string. /// </summary> /// <param name="I18N">An internationalized string.</param> public static JArray ToJSON(I18NString I18N) { return new JArray(I18N.SafeSelect(i18n => new JObject(new JProperty("language", i18n.Language.ToString()), new JProperty("text", i18n.Text)))); }
public static Boolean TryParseI18NString(HTTPRequest HTTPRequest, JObject DescriptionJSON, out I18NString I18N, out HTTPResponse Response) { if (DescriptionJSON == null) { I18N = null; Response = new HTTPResponseBuilder(HTTPRequest) { HTTPStatusCode = HTTPStatusCode.BadRequest, ContentType = HTTPContentType.JSON_UTF8, Content = new JObject(new JProperty("description", "Invalid roaming network description!")).ToUTF8Bytes() }.AsImmutable(); return false; } Languages Language; JValue Text; I18N = I18NString.Empty; foreach (var Description in DescriptionJSON) { if (!Enum.TryParse(Description.Key, out Language)) { I18N = null; Response = new HTTPResponseBuilder(HTTPRequest) { HTTPStatusCode = HTTPStatusCode.BadRequest, ContentType = HTTPContentType.JSON_UTF8, Content = new JObject(new JProperty("description", "Unknown or invalid language definition '" + Description.Key + "'!")).ToUTF8Bytes() }.AsImmutable(); return false; } Text = Description.Value as JValue; if (Text == null) { I18N = null; Response = new HTTPResponseBuilder(HTTPRequest) { HTTPStatusCode = HTTPStatusCode.BadRequest, ContentType = HTTPContentType.JSON_UTF8, Content = new JObject(new JProperty("description", "Invalid description text!")).ToUTF8Bytes() }.AsImmutable(); return false; } I18N.Add(Language, Text.Value<String>()); } Response = null; return true; }