Beispiel #1
0
        /// <summary>
        /// Serializes this instance to a binary stream
        /// </summary>
        /// <param name="s"></param>
        public virtual void Serialize(MgBinarySerializer s)
        {
            s.Write(this.Group);

            if (s.SiteVersion <= SiteVersions.GetVersion(KnownSiteVersions.MapGuideEP1_1))
                s.WriteClassId(19003);
            else
                s.WriteClassId(30501);

            s.WriteResourceIdentifier(this.LayerDefinitionID);

            if (s.SiteVersion < SiteVersions.GetVersion(KnownSiteVersions.MapGuideOS1_2))
            {
                s.Write(this.Name);
                s.Write(this.ObjectId);

                s.Write(this.Type);

                s.Write((byte)(this.Visible ? 1 : 0));
                s.Write((byte)(this.Selectable ? 1 : 0));
                s.Write((byte)(this.ShowInLegend ? 1 : 0));
                s.Write((byte)(this.ExpandInLegend ? 1 : 0));

                s.Write(this.LegendLabel);
                s.Write((byte)(this.NeedsRefresh ? 1 : 0));
                s.Write(this.DisplayOrder);

                s.Write(_scaleRanges.Length);
                foreach (double d in _scaleRanges)
                    s.Write(d);

                s.Write(this.FeatureSourceID);
                s.Write(this.QualifiedClassName);
                s.Write(this.GeometryPropertyName);

                s.Write(this.IdentityProperties.Length);
                foreach (var x in this.IdentityProperties)
                {
                    s.Write((short)ConvertNetTypeToMgType(x.Type));
                    s.Write(x.Name);
                }
            }
            else
            {
                s.WriteStringInternal(this.Name);
                s.WriteStringInternal(this.ObjectId);
                s.WriteRaw(BitConverter.GetBytes(this.Type));
                int flags = 0;
                flags |= this.Visible ? 1 : 0;
                flags |= this.Selectable ? 2 : 0;
                flags |= this.ShowInLegend ? 4 : 0;
                flags |= this.ExpandInLegend ? 8 : 0;
                flags |= this.NeedsRefresh ? 16 : 0;
                flags |= this.HasTooltips ? 32 : 0;
                s.WriteRaw(new byte[] { (byte)flags });

                s.WriteStringInternal(this.LegendLabel);
                s.WriteRaw(BitConverter.GetBytes(this.DisplayOrder));

                s.WriteRaw(BitConverter.GetBytes(_scaleRanges.Length));
                foreach (double d in _scaleRanges)
                    s.WriteRaw(BitConverter.GetBytes(d));

                s.WriteStringInternal(this.FeatureSourceID);
                s.WriteStringInternal(this.QualifiedClassName);
                if (s.SiteVersion > SiteVersions.GetVersion(KnownSiteVersions.MapGuideOS2_1))
                    s.WriteStringInternal(this.Filter);
                s.WriteStringInternal(this.SchemaName);
                s.WriteStringInternal(this.GeometryPropertyName);

                s.WriteRaw(BitConverter.GetBytes(this.IdentityProperties.Length));
                foreach (var x in this.IdentityProperties)
                {
                    s.WriteRaw(BitConverter.GetBytes((short)ConvertNetTypeToMgType(x.Type)));
                    s.WriteStringInternal(x.Name);
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Serializes this instance to the specified binary stream
        /// </summary>
        /// <param name="s"></param>
        public virtual void Serialize(MgBinarySerializer s)
        {
            if (s.SiteVersion >= SiteVersions.GetVersion(KnownSiteVersions.MapGuideOS1_2))
            {
                s.Write(MgBinaryVersion);
                s.WriteResourceIdentifier(this.ResourceID);
            }

            s.Write(this.Name);
            s.Write(this.ObjectId);
            s.WriteResourceIdentifier(this.MapDefinition);
            s.Write(this.CoordinateSystem);
            //base.m_extents.Serialize(s);
            SerializeExtent(this.MapExtent, s);
            s.WriteCoordinates(new double[] { this.ViewCenter.X, this.ViewCenter.Y }, 0);
            s.Write(this.ViewScale);
            SerializeExtent(this.DataExtent, s);
            s.Write(this.DisplayDpi);
            s.Write(this.DisplayWidth);
            s.Write(this.DisplayHeight);
            s.Write(Utility.SerializeHTMLColor(this.BackgroundColor, true));
            s.Write(this.MetersPerUnit);

            if (s.SiteVersion >= SiteVersions.GetVersion(KnownSiteVersions.MapGuideOS1_2))
                s.Write(this.LayerRefreshMode);

            s.Write(_finiteDisplayScales.Length);
            foreach (double d in _finiteDisplayScales)
                s.Write(d);

            if (s.SiteVersion >= SiteVersions.GetVersion(KnownSiteVersions.MapGuideOS1_2))
            {
                SerializeChangeMap(s);
                if (s.SiteVersion >= new Version(2, 3)) //SiteVersions.GetVersion(KnownSiteVersions.MapGuideEP2012))
                {
                    s.Write(this.WatermarkUsage);
                }
                s.Write((int)0);
            }
            else
            {
                SerializeLayerData(s);
                SerializeChangeMap(s);
            }
        }