[mapguide-commits] r8763 - trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Mapping

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Wed Sep 23 05:29:07 PDT 2015


Author: jng
Date: 2015-09-23 05:29:06 -0700 (Wed, 23 Sep 2015)
New Revision: 8763

Modified:
   trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Mapping/RuntimeMap.cs
Log:
Avoid excessive version checking in RuntimeMap

Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Mapping/RuntimeMap.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Mapping/RuntimeMap.cs	2015-09-23 10:54:16 UTC (rev 8762)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Mapping/RuntimeMap.cs	2015-09-23 12:29:06 UTC (rev 8763)
@@ -706,7 +706,11 @@
         /// <param name="s"></param>
         public virtual void Serialize(MgBinarySerializer s)
         {
-            if (s.SiteVersion >= SiteVersions.GetVersion(KnownSiteVersions.MapGuideOS1_2))
+            bool bNewerThanMGOS12 = s.SiteVersion >= SiteVersions.GetVersion(KnownSiteVersions.MapGuideOS1_2);
+            bool bNewerThanMGOS23 = s.SiteVersion >= new Version(2, 3);
+            bool bNewerThanMGOS30 = s.SiteVersion >= new Version(3, 0);
+
+            if (bNewerThanMGOS12)
             {
                 s.Write(MgBinaryVersion);
                 s.WriteResourceIdentifier(this.ResourceID);
@@ -727,21 +731,21 @@
             s.Write(Utility.SerializeHTMLColor(this.BackgroundColor, true));
             s.Write(this.MetersPerUnit);
 
-            if (s.SiteVersion >= SiteVersions.GetVersion(KnownSiteVersions.MapGuideOS1_2))
+            if (bNewerThanMGOS12)
                 s.Write(this.LayerRefreshMode);
 
             s.Write(_finiteDisplayScales.Length);
             foreach (double d in _finiteDisplayScales)
                 s.Write(d);
 
-            if (s.SiteVersion >= SiteVersions.GetVersion(KnownSiteVersions.MapGuideOS1_2))
+            if (bNewerThanMGOS12)
             {
                 SerializeChangeMap(s);
-                if (s.SiteVersion >= new Version(2, 3)) //SiteVersions.GetVersion(KnownSiteVersions.MapGuideEP2012))
+                if (bNewerThanMGOS23)
                 {
                     s.Write(this.WatermarkUsage);
                 }
-                if (s.SiteVersion >= new Version(3, 0))
+                if (bNewerThanMGOS30)
                 {
                     s.WriteResourceIdentifier(this.TileSetDefinition);
                 }
@@ -909,7 +913,11 @@
         {
             _disableChangeTracking = true;
 
-            if (d.SiteVersion >= SiteVersions.GetVersion(KnownSiteVersions.MapGuideOS1_2))
+            bool bNewerThanMGOS12 = d.SiteVersion >= SiteVersions.GetVersion(KnownSiteVersions.MapGuideOS1_2);
+            bool bNewerThanMGOS23 = d.SiteVersion >= new Version(2, 3);
+            bool bNewerThanMGOS30 = d.SiteVersion >= new Version(3, 0);
+
+            if (bNewerThanMGOS12)
             {
                 if (d.ReadInt32() != MgBinaryVersion)
                     throw new Exception(Strings.ErrorInvalidMapVersion);
@@ -942,7 +950,7 @@
             this.BackgroundColor = Utility.ParseHTMLColor(d.ReadString());
             this.MetersPerUnit = d.ReadDouble();
 
-            if (d.SiteVersion >= SiteVersions.GetVersion(KnownSiteVersions.MapGuideOS1_2))
+            if (bNewerThanMGOS12)
                 this.LayerRefreshMode = d.ReadInt32();
 
             var fds = new List<double>();
@@ -953,14 +961,14 @@
             _finiteDisplayScales = fds.ToArray();
 
             m_changeList = new Dictionary<string, ChangeList>();
-            if (d.SiteVersion >= SiteVersions.GetVersion(KnownSiteVersions.MapGuideOS1_2))
+            if (bNewerThanMGOS12)
             {
                 m_changeList = DeserializeChangeMap(d);
-                if (d.SiteVersion >= new Version(2, 3))
+                if (bNewerThanMGOS23)
                 {
                     this.WatermarkUsage = d.ReadInt32();
                 }
-                if (d.SiteVersion >= new Version(3, 0))
+                if (bNewerThanMGOS30)
                 {
                     this.TileSetDefinition = d.ReadResourceIdentifier();
                 }



More information about the mapguide-commits mailing list