/// <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 bool ReloadSelection() { var resId = this.ResourceID.Replace(".Map", ".Selection"); //NOXLATE var bLoadedSelection = false; if (this.ResourceService.ResourceExists(resId)) { var dataItems = this.ResourceService.EnumerateResourceData(resId); foreach (var item in dataItems.ResourceData) { if (item.Name == "RuntimeData") //NOXLATE { var ser = new MgBinaryDeserializer(this.ResourceService.GetResourceData(resId, "RuntimeData"), this.CurrentConnection.SiteVersion); //NOXLATE _selection.Deserialize(ser); bLoadedSelection = true; break; } } } return bLoadedSelection; }
/// <summary> /// Initializes this instance from the specified binary stream /// </summary> /// <param name="d"></param> public virtual void Deserialize(MgBinaryDeserializer d) { _disableChangeTracking = true; if (d.SiteVersion >= SiteVersions.GetVersion(KnownSiteVersions.MapGuideOS1_2)) { if (d.ReadInt32() != MgBinaryVersion) throw new Exception(Strings.ErrorInvalidMapVersion); this.ResourceID = d.ReadResourceIdentifier(); } this.Name = d.ReadString(); this.ObjectId = d.ReadString(); this.MapDefinition = d.ReadResourceIdentifier(); this.CoordinateSystem = d.ReadString(); this.MapExtent = DeserializeExtents(d); var cc = d.ReadCoordinates(); if (this.ViewCenter != null) { this.ViewCenter.X = cc[0]; this.ViewCenter.Y = cc[1]; } else { this.SetViewCenter(cc[0], cc[1]); } this.ViewScale = d.ReadDouble(); this.DataExtent = DeserializeExtents(d); this.DisplayDpi = d.ReadInt32(); this.DisplayWidth = d.ReadInt32(); this.DisplayHeight = d.ReadInt32(); this.BackgroundColor = Utility.ParseHTMLColor(d.ReadString()); this.MetersPerUnit = d.ReadDouble(); if (d.SiteVersion >= SiteVersions.GetVersion(KnownSiteVersions.MapGuideOS1_2)) this.LayerRefreshMode = d.ReadInt32(); var fds = new List<double>(); int finiteScaleCount = d.ReadInt32(); while (finiteScaleCount-- > 0) fds.Add(d.ReadDouble()); _finiteDisplayScales = fds.ToArray(); m_changeList = new Dictionary<string, ChangeList>(); if (d.SiteVersion >= SiteVersions.GetVersion(KnownSiteVersions.MapGuideOS1_2)) { m_changeList = DeserializeChangeMap(d); if (d.SiteVersion >= new Version(2, 3)) { this.WatermarkUsage = d.ReadInt32(); } int mapLayerCount = d.ReadInt32(); if (mapLayerCount != 0) throw new Exception(Strings.ErrorShouldHaveNoLayerDataInMap); } else { //ri.LayerGroupBlob = d.ReadStreamRepeat(d.ReadInt32()); DeserializeLayerData(d); m_changeList = DeserializeChangeMap(d); } _disableChangeTracking = false; this.IsDirty = false; }
private RuntimeMapLayer DeserializeLayer(MgBinaryDeserializer d) { //TODO: Review when we split to specific implementations RuntimeMapLayer t = new RuntimeMapLayer(this); t.Deserialize(d); return t; }
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; }
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); }
internal void DeserializeLayerData(MgBinaryDeserializer d) { int groupCount = d.ReadInt32(); this.Groups.Clear(); for (int i = 0; i < groupCount; i++) { //TODO: Review when we split to specific implementations RuntimeMapGroup g = new RuntimeMapGroup(); g.Deserialize(d); this.Groups.Add(g); } int mapLayerCount = d.ReadInt32(); this.Layers.Clear(); while (mapLayerCount-- > 0) { RuntimeMapLayer t = DeserializeLayer(d); this.Layers.Add(t); } }
/// <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(); }