private bool TryParseCoordinate(RavenJArray coordinates, StringBuilder result) { if (coordinates != null && coordinates.Length > 1 && coordinates.All(x => x is RavenJValue)) { var vals = coordinates.Cast <RavenJValue>().ToList(); if (vals.All(x => x.Type == JTokenType.Float || x.Type == JTokenType.Integer)) { result.AppendFormat( CultureInfo.InvariantCulture, "{0} {1}", Convert.ToDouble(vals[0].Value), Convert.ToDouble(vals[1].Value) ); return(true); } } return(false); }
private bool TryParseCoordinate(RavenJArray coordinates, out CoordinateInfo result) { if (coordinates != null && coordinates.Length > 1 && coordinates.All(x => x is RavenJValue)) { var vals = coordinates.Cast <RavenJValue>().ToList(); if (vals.All(x => x.Type == JTokenType.Float || x.Type == JTokenType.Integer)) { result = new CoordinateInfo { X = Convert.ToDouble(vals[0].Value), Y = Convert.ToDouble(vals[1].Value), Z = vals.Count > 2 ? Convert.ToDouble(vals[2].Value) : (double?)null, M = vals.Count > 3 ? Convert.ToDouble(vals[3].Value) : (double?)null }; return(true); } } result = null; return(false); }
private bool TryParseCoordinate(RavenJArray coordinates, StringBuilder result) { if (coordinates != null && coordinates.Length > 1 && coordinates.All(x => x is RavenJValue)) { var vals = coordinates.Cast<RavenJValue>().ToList(); if (vals.All(x => x.Type == JTokenType.Float || x.Type == JTokenType.Integer)) { result.AppendFormat( CultureInfo.InvariantCulture, "{0} {1}", Convert.ToDouble(vals[0].Value), Convert.ToDouble(vals[1].Value) ); return true; } } return false; }
private bool TryParseCoordinate(RavenJArray coordinates, out CoordinateInfo result) { if (coordinates != null && coordinates.Length > 1 && coordinates.All(x => x is RavenJValue)) { var vals = coordinates.Cast<RavenJValue>().ToList(); if (vals.All(x => x.Type == JTokenType.Float || x.Type == JTokenType.Integer)) { result = new CoordinateInfo { X = Convert.ToDouble(vals[0].Value), Y = Convert.ToDouble(vals[1].Value), Z = vals.Count > 2 ? Convert.ToDouble(vals[2].Value) : (double?) null, M = vals.Count > 3 ? Convert.ToDouble(vals[3].Value) : (double?) null }; return true; } } result = null; return false; }