/// <summary> /// Path. /// </summary> internal static Object ToPath(NpgsqlBackendTypeInfo TypeInfo, byte[] bBackendData, Int16 TypeSize, Int32 TypeModifier) { string BackendData = BackendEncoding.UTF8Encoding.GetString(bBackendData); Match m = pathpolygonRegex.Match(BackendData); Boolean open = (BackendData[0] == '['); List <NpgsqlPoint> points = new List <NpgsqlPoint>(); while (m.Success) { if (open) { points.Add( new NpgsqlPoint( Single.Parse(m.Groups[1].ToString(), NumberStyles.Any, CultureInfo.InvariantCulture.NumberFormat), Single.Parse(m.Groups[2].ToString(), NumberStyles.Any, CultureInfo.InvariantCulture.NumberFormat))); } else { // Here we have to do a little hack, because as of 2004-08-11 mono cvs version, the last group is returned with // a trailling ')' only when the last character of the string is a ')' which is the case for closed paths // returned by backend. This gives parsing exception when converting to single. // I still don't know if this is a bug in mono or in my regular expression. // Check if there is this character and remove it. String group2 = m.Groups[2].ToString(); if (group2.EndsWith(")")) { group2 = group2.Remove(group2.Length - 1, 1); } points.Add( new NpgsqlPoint( Single.Parse(m.Groups[1].ToString(), NumberStyles.Any, CultureInfo.InvariantCulture.NumberFormat), Single.Parse(group2, NumberStyles.Any, CultureInfo.InvariantCulture.NumberFormat))); } m = m.NextMatch(); } NpgsqlPath result = new NpgsqlPath(points.ToArray()); result.Open = open; return(result); }
public bool Equals(NpgsqlPath other) { if (Open != other.Open || Count != other.Count) { return(false); } else if (ReferenceEquals(_points, other._points))//Short cut for shallow copies. { return(true); } for (int i = 0; i != Count; ++i) { if (this[i] != other[i]) { return(false); } } return(true); }