private static IEnvelope DeserializeExtents(MgBinaryDeserializer d) { int classid = d.ReadClassId(); if (d.SiteVersion <= SiteVersions.GetVersion(KnownSiteVersions.MapGuideEP1_1) && classid != 18001) throw new Exception(Strings.ErrorInvalidClassIdentifierBox2d); if (d.SiteVersion > SiteVersions.GetVersion(KnownSiteVersions.MapGuideEP1_1) && classid != 20001) throw new Exception(Strings.ErrorInvalidClassIdentifierBox2d); int dimensions = d.ReadInt32(); if (dimensions != 2 && dimensions != 0) throw new Exception(string.Format(Strings.ErrorBoundingBoxDoesNotHave2Dimensions, dimensions)); double x1 = d.ReadDouble(); double y1 = d.ReadDouble(); double x2 = d.ReadDouble(); double y2 = d.ReadDouble(); double minx = Math.Min(x1, x2); double miny = Math.Min(y1, y2); double maxx = Math.Max(x1, x2); double maxy = Math.Max(y1, y2); return ObjectFactory.CreateEnvelope(minx, miny, maxx, maxy); }
/// <summary> /// Initializes this instance with the specified binary stream /// </summary> /// <param name="d"></param> public virtual void Deserialize(MgBinaryDeserializer d) { this.Group = d.ReadString(); int classid = d.ReadClassId(); if (d.SiteVersion <= SiteVersions.GetVersion(KnownSiteVersions.MapGuideEP1_1) && classid != 19003) throw new Exception(string.Format(Strings.ErrorResourceIdentifierClassIdNotFound, classid)); if (d.SiteVersion > SiteVersions.GetVersion(KnownSiteVersions.MapGuideEP1_1) && classid != 30501) throw new Exception(string.Format(Strings.ErrorResourceIdentifierClassIdNotFound, classid)); this.LayerDefinitionID = d.ReadResourceIdentifier(); if (d.SiteVersion < SiteVersions.GetVersion(KnownSiteVersions.MapGuideOS1_2)) { this.Name = d.ReadString(); _objectId = d.ReadString(); _type = d.ReadInt32(); _visible = d.ReadByte() > 0; _selectable = d.ReadByte() > 0; _showInLegend = d.ReadByte() > 0; _expandInLegend = d.ReadByte() > 0; _legendLabel = d.ReadString(); _needsRefresh = d.ReadByte() > 0; _displayOrder = d.ReadDouble(); var scaleRanges = new List<double>(); int scales = d.ReadInt32(); while (scales-- > 0) scaleRanges.Add(d.ReadDouble()); _scaleRanges = scaleRanges.ToArray(); _featureSourceId = d.ReadString(); _qualifiedClassName = d.ReadString(); _geometryPropertyName = d.ReadString(); var ids = new List<PropertyInfo>(); int idCount = d.ReadInt32(); while (idCount-- > 0) { short idType = d.ReadInt16(); string idName = d.ReadString(); ids.Add(new PropertyInfo(idName, ConvertMgTypeToNetType(idType))); } this.IdentityProperties = ids.ToArray(); } else { //AAARGH!!! Now they bypass their own header system .... this.Name = d.ReadInternalString(); _objectId = d.ReadInternalString(); _type = BitConverter.ToInt32(d.ReadStreamRepeat(4), 0); int flags = d.ReadStreamRepeat(1)[0]; _visible = (flags & 1) > 0; _selectable = (flags & 2) > 0; _showInLegend = (flags & 4) > 0; _expandInLegend = (flags & 8) > 0; _needsRefresh = (flags & 16) > 0; _hasTooltips = (flags & 32) > 0; _legendLabel = d.ReadInternalString(); _displayOrder = BitConverter.ToDouble(d.ReadStreamRepeat(8), 0); var scaleRanges = new List<double>(); int scales = BitConverter.ToInt32(d.ReadStreamRepeat(4), 0); while (scales-- > 0) scaleRanges.Add(BitConverter.ToDouble(d.ReadStreamRepeat(8), 0)); _scaleRanges = scaleRanges.ToArray(); _featureSourceId = d.ReadInternalString(); _qualifiedClassName = d.ReadInternalString(); if (d.SiteVersion > SiteVersions.GetVersion(KnownSiteVersions.MapGuideOS2_1)) _filter = d.ReadInternalString(); //this.SchemaName = d.ReadInternalString(); d.ReadInternalString(); _geometryPropertyName = d.ReadInternalString(); var ids = new List<PropertyInfo>(); int idCount = BitConverter.ToInt32(d.ReadStreamRepeat(4), 0); while (idCount-- > 0) { short idType = BitConverter.ToInt16(d.ReadStreamRepeat(2), 0); string idName = d.ReadInternalString(); ids.Add(new PropertyInfo(idName, ConvertMgTypeToNetType(idType))); } this.IdentityProperties = ids.ToArray(); } EnsureOrderedMinMaxScales(); }
/// <summary> /// Initialize this instance using the specified binary stream /// </summary> /// <param name="d"></param> public virtual void Deserialize(MgBinaryDeserializer d) { this.Group = d.ReadString(); int objid = d.ReadClassId(); if (d.SiteVersion >= SiteVersions.GetVersion(KnownSiteVersions.MapGuideOS1_2)) { if (objid != 12001) throw new Exception(string.Format(Strings.ErrorInvalidGroupObjectId, objid)); } else if (objid != 19001) throw new Exception(string.Format(Strings.ErrorInvalidGroupObjectId, objid)); this.Name = d.ReadString(); this.ObjectId = d.ReadString(); this.Type = d.ReadInt32(); this.Visible = d.ReadBool(); this.ShowInLegend = d.ReadBool(); this.ExpandInLegend = d.ReadBool(); this.LegendLabel = d.ReadString(); }