예제 #1
0
        /// <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();
        }
예제 #2
0
파일: RuntimeMap.cs 프로젝트: kanbang/Colt
        /// <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;
        }