/// <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(); }
private Dictionary<string, ChangeList> DeserializeChangeMap(MgBinaryDeserializer d) { Dictionary<string, ChangeList> changes = new Dictionary<string, ChangeList>(); int changeListCount = d.ReadInt32(); while (changeListCount-- > 0) { bool isLayer = d.ReadByte() > 0; string objid = d.ReadString(); ChangeList c = null; if (!changes.ContainsKey(objid)) { c = new ChangeList(objid, isLayer); changes.Add(c.ObjectId, c); } else { c = changes[objid]; } int changeCount = d.ReadInt32(); while (changeCount-- > 0) { //Split up to avoid dependency on argument evaluation order int ctype = d.ReadInt32(); c.Changes.Add(new Change((Change.ChangeType)ctype, d.ReadString())); } } return changes; }