Example #1
0
        private void btnUpgrade_Click(object sender, EventArgs e)
        {
            var res  = _svc.GetEditedResource();
            var conn = _svc.CurrentConnection;
            var ver  = conn.Capabilities.GetMaxSupportedResourceVersion(res.ResourceType);

            using (new WaitCursor(this))
            {
                var conv = new ResourceObjectConverter();
                var res2 = conv.Convert(res, ver);

                using (var stream = ObjectFactory.Serialize(res2))
                {
                    using (var sr = new StreamReader(stream))
                    {
                        _svc.UpdateResourceContent(sr.ReadToEnd());
                        ((ResourceEditorService)_svc).ReReadSessionResource();
                    }
                }

                //This will re-init everything
                this.EditorService = this.EditorService;
                MessageBox.Show(string.Format(Strings.ResourceUpgraded, ver.Major, ver.Minor, ver.Build));
                this.EditorService.MarkDirty(); //It gets re-init with a clean slate, but an in-place upgrade is a dirty operation
            }
        }
Example #2
0
        public void TestWebLayoutConversions()
        {
            var conn = new Mock <IServerConnection>();
            var conv = new ResourceObjectConverter();

            var wl = ObjectFactory.CreateWebLayout(new Version(1, 0, 0), "Library://Test.MapDefinition");

            wl.ResourceID = "Library://Test.WebLayout";

            Assert.Equal("1.0.0", wl.GetResourceTypeDescriptor().Version);
            Assert.Equal("WebLayout-1.0.0.xsd", wl.GetResourceTypeDescriptor().XsdName);
            Assert.Equal("WebLayout-1.0.0.xsd", wl.ValidatingSchema);
            Assert.Equal(new Version(1, 0, 0), wl.ResourceVersion);

            using (var fs = Utils.OpenTempWrite("WebLayout_100.xml"))
            {
                using (var src = ObjectFactory.Serialize(wl))
                {
                    Utility.CopyStream(src, fs);
                }
            }

            var wl2 = (IWebLayout)conv.Convert(wl, new Version(1, 1, 0));

            Assert.Equal("1.1.0", wl2.GetResourceTypeDescriptor().Version);
            Assert.Equal("WebLayout-1.1.0.xsd", wl2.GetResourceTypeDescriptor().XsdName);
            Assert.Equal("WebLayout-1.1.0.xsd", wl2.ValidatingSchema);
            Assert.Equal(new Version(1, 1, 0), wl2.ResourceVersion);
            Assert.True(wl2 is IWebLayout2);

            using (var fs = Utils.OpenTempWrite("WebLayout_110.xml"))
            {
                using (var src = ObjectFactory.Serialize(wl2))
                {
                    Utility.CopyStream(src, fs);
                }
            }

            var maptip = wl.CommandSet.Commands.OfType <IBasicCommand>().Where(cmd => cmd.Action == BasicCommandActionType.MapTip);

            Assert.False(maptip.Any());

            var wl3 = (IWebLayout)conv.Convert(wl, new Version(2, 4, 0));

            Assert.Equal("2.4.0", wl3.GetResourceTypeDescriptor().Version);
            Assert.Equal("WebLayout-2.4.0.xsd", wl3.GetResourceTypeDescriptor().XsdName);
            Assert.Equal("WebLayout-2.4.0.xsd", wl3.ValidatingSchema);
            Assert.Equal(new Version(2, 4, 0), wl3.ResourceVersion);

            maptip = wl3.CommandSet.Commands.OfType <IBasicCommand>().Where(cmd => cmd.Action == BasicCommandActionType.MapTip);
            Assert.True(maptip.Any());
        }
Example #3
0
        public void TestLoadProcedureConversions()
        {
            var conn = new Mock <IServerConnection>();
            var conv = new ResourceObjectConverter();

            var lproc = ObjectFactory.CreateLoadProcedure(LoadType.Sdf);

            lproc.ResourceID = "Library://Samples/Sheboygan/Load/Load.LoadProcedure";

            Assert.Equal("1.0.0", lproc.GetResourceTypeDescriptor().Version);
            Assert.Equal("LoadProcedure-1.0.0.xsd", lproc.GetResourceTypeDescriptor().XsdName);
            Assert.Equal("LoadProcedure-1.0.0.xsd", lproc.ValidatingSchema);
            Assert.Equal(new Version(1, 0, 0), lproc.ResourceVersion);

            using (var fs = Utils.OpenTempWrite("LoadProc_100.xml"))
            {
                using (var src = ObjectFactory.Serialize(lproc))
                {
                    Utility.CopyStream(src, fs);
                }
            }

            var lproc2 = (ILoadProcedure)conv.Convert(lproc, new Version(1, 1, 0));

            Assert.Equal("1.1.0", lproc2.GetResourceTypeDescriptor().Version);
            Assert.Equal("LoadProcedure-1.1.0.xsd", lproc2.GetResourceTypeDescriptor().XsdName);
            Assert.Equal("LoadProcedure-1.1.0.xsd", lproc2.ValidatingSchema);
            Assert.Equal(new Version(1, 1, 0), lproc2.ResourceVersion);

            using (var fs = Utils.OpenTempWrite("LoadProc_110.xml"))
            {
                using (var src = ObjectFactory.Serialize(lproc2))
                {
                    Utility.CopyStream(src, fs);
                }
            }

            var lproc3 = (ILoadProcedure)conv.Convert(lproc2, new Version(2, 2, 0));

            Assert.Equal("2.2.0", lproc3.GetResourceTypeDescriptor().Version);
            Assert.Equal("LoadProcedure-2.2.0.xsd", lproc3.GetResourceTypeDescriptor().XsdName);
            Assert.Equal("LoadProcedure-2.2.0.xsd", lproc3.ValidatingSchema);
            Assert.Equal(new Version(2, 2, 0), lproc3.ResourceVersion);

            using (var fs = Utils.OpenTempWrite("LoadProc_220.xml"))
            {
                using (var src = ObjectFactory.Serialize(lproc3))
                {
                    Utility.CopyStream(src, fs);
                }
            }
        }
Example #4
0
        public void TestMapDefinitionConversions()
        {
            var conn = new Mock <IServerConnection>();
            var conv = new ResourceObjectConverter();

            var mdf = ObjectFactory.CreateMapDefinition(new Version(1, 0, 0), "Test Map");

            mdf.ResourceID = "Library://Samples/Sheboygan/Maps/Sheboygan.MapDefinition";

            Assert.Equal("1.0.0", mdf.GetResourceTypeDescriptor().Version);
            Assert.Equal("MapDefinition-1.0.0.xsd", mdf.GetResourceTypeDescriptor().XsdName);
            Assert.Equal("MapDefinition-1.0.0.xsd", mdf.ValidatingSchema);
            Assert.Equal(new Version(1, 0, 0), mdf.ResourceVersion);

            using (var fs = Utils.OpenTempWrite("MapDef_100.xml"))
            {
                using (var src = ObjectFactory.Serialize(mdf))
                {
                    Utility.CopyStream(src, fs);
                }
            }

            var mdf2 = (IMapDefinition)conv.Convert(mdf, new Version(2, 3, 0));

            Assert.Equal("2.3.0", mdf2.GetResourceTypeDescriptor().Version);
            Assert.Equal("MapDefinition-2.3.0.xsd", mdf2.GetResourceTypeDescriptor().XsdName);
            Assert.Equal("MapDefinition-2.3.0.xsd", mdf2.ValidatingSchema);
            Assert.Equal(new Version(2, 3, 0), mdf2.ResourceVersion);
            Assert.True(mdf2 is IMapDefinition2);

            using (var fs = Utils.OpenTempWrite("MapDef_230.xml"))
            {
                using (var src = ObjectFactory.Serialize(mdf2))
                {
                    Utility.CopyStream(src, fs);
                }
            }
        }
Example #5
0
        public void TestSymbolDefinitionConversions()
        {
            var conn = new Mock <IServerConnection>();
            var conv = new ResourceObjectConverter();

            var ssym = ObjectFactory.CreateSimpleSymbol(new Version(1, 0, 0), "SimpleSymbolTest", "Test simple symbol");

            ssym.ResourceID = "Library://Samples/Sheboygan/Symbols/Test.SymbolDefinition";

            Assert.Equal("1.0.0", ssym.GetResourceTypeDescriptor().Version);
            Assert.Equal("SymbolDefinition-1.0.0.xsd", ssym.GetResourceTypeDescriptor().XsdName);
            Assert.Equal("SymbolDefinition-1.0.0.xsd", ssym.ValidatingSchema);
            Assert.Equal(new Version(1, 0, 0), ssym.ResourceVersion);

            using (var fs = Utils.OpenTempWrite("SimpleSymDef_100.xml"))
            {
                using (var src = ObjectFactory.Serialize(ssym))
                {
                    Utility.CopyStream(src, fs);
                }
            }

            var ssym2 = (ISimpleSymbolDefinition)conv.Convert(ssym, new Version(1, 1, 0));

            Assert.Equal("1.1.0", ssym2.GetResourceTypeDescriptor().Version);
            Assert.Equal("SymbolDefinition-1.1.0.xsd", ssym2.GetResourceTypeDescriptor().XsdName);
            Assert.Equal("SymbolDefinition-1.1.0.xsd", ssym2.ValidatingSchema);
            Assert.Equal(new Version(1, 1, 0), ssym2.ResourceVersion);

            using (var fs = Utils.OpenTempWrite("SimpleSymDef_110.xml"))
            {
                using (var src = ObjectFactory.Serialize(ssym2))
                {
                    Utility.CopyStream(src, fs);
                }
            }

            var csym = ObjectFactory.CreateCompoundSymbol(new Version(1, 0, 0), "CompoundSymbolTest", "Test compound symbol");

            csym.ResourceID = "Library://Samples/Sheboygan/Symbols/Compound.SymbolDefinition";

            Assert.Equal("1.0.0", csym.GetResourceTypeDescriptor().Version);
            Assert.Equal("SymbolDefinition-1.0.0.xsd", csym.GetResourceTypeDescriptor().XsdName);
            Assert.Equal("SymbolDefinition-1.0.0.xsd", csym.ValidatingSchema);
            Assert.Equal(new Version(1, 0, 0), csym.ResourceVersion);

            using (var fs = Utils.OpenTempWrite("CompoundSymDef_100.xml"))
            {
                using (var src = ObjectFactory.Serialize(csym))
                {
                    Utility.CopyStream(src, fs);
                }
            }

            var csym2 = (ICompoundSymbolDefinition)conv.Convert(csym, new Version(1, 1, 0));

            Assert.Equal("1.1.0", csym2.GetResourceTypeDescriptor().Version);
            Assert.Equal("SymbolDefinition-1.1.0.xsd", csym2.GetResourceTypeDescriptor().XsdName);
            Assert.Equal("SymbolDefinition-1.1.0.xsd", csym2.ValidatingSchema);
            Assert.Equal(new Version(1, 1, 0), csym2.ResourceVersion);

            using (var fs = Utils.OpenTempWrite("CompoundSymDef_110.xml"))
            {
                using (var src = ObjectFactory.Serialize(csym2))
                {
                    Utility.CopyStream(src, fs);
                }
            }
        }
Example #6
0
        public void TestLayerDefinitionConversions()
        {
            var conn = new Mock <IServerConnection>();
            var conv = new ResourceObjectConverter();
            var ldf  = ObjectFactory.CreateDefaultLayer(LayerType.Vector, new Version(1, 0, 0));

            ldf.ResourceID          = "Library://Samples/Sheboygan/Layers/Parcels.LayerDefinition";
            ldf.SubLayer.ResourceId = "Library://Samples/Sheboygan/Data/Parcels.FeatureSource";
            ((IVectorLayerDefinition)ldf.SubLayer).FeatureName = "SHP_Schema:Parcels";
            ((IVectorLayerDefinition)ldf.SubLayer).Geometry    = "Geometry";

            Assert.Equal("1.0.0", ldf.GetResourceTypeDescriptor().Version);
            Assert.Equal("LayerDefinition-1.0.0.xsd", ldf.GetResourceTypeDescriptor().XsdName);
            Assert.Equal("LayerDefinition-1.0.0.xsd", ldf.ValidatingSchema);
            Assert.Equal(new Version(1, 0, 0), ldf.ResourceVersion);

            using (var fs = Utils.OpenTempWrite("LayerDef_100.xml"))
            {
                using (var src = ObjectFactory.Serialize(ldf))
                {
                    Utility.CopyStream(src, fs);
                }
            }

            var ldf1 = (ILayerDefinition)conv.Convert(ldf, new Version(1, 1, 0));

            Assert.Equal("1.1.0", ldf1.GetResourceTypeDescriptor().Version);
            Assert.Equal("LayerDefinition-1.1.0.xsd", ldf1.GetResourceTypeDescriptor().XsdName);
            Assert.Equal("LayerDefinition-1.1.0.xsd", ldf1.ValidatingSchema);
            Assert.Equal(new Version(1, 1, 0), ldf1.ResourceVersion);

            using (var fs = Utils.OpenTempWrite("LayerDef_110.xml"))
            {
                using (var src = ObjectFactory.Serialize(ldf1))
                {
                    Utility.CopyStream(src, fs);
                }
            }

            var ldf2 = (ILayerDefinition)conv.Convert(ldf1, new Version(1, 2, 0));

            Assert.Equal("1.2.0", ldf2.GetResourceTypeDescriptor().Version);
            Assert.Equal("LayerDefinition-1.2.0.xsd", ldf2.GetResourceTypeDescriptor().XsdName);
            Assert.Equal("LayerDefinition-1.2.0.xsd", ldf2.ValidatingSchema);
            Assert.Equal(new Version(1, 2, 0), ldf2.ResourceVersion);

            using (var fs = Utils.OpenTempWrite("LayerDef_120.xml"))
            {
                using (var src = ObjectFactory.Serialize(ldf2))
                {
                    Utility.CopyStream(src, fs);
                }
            }

            var ldf3 = (ILayerDefinition)conv.Convert(ldf2, new Version(1, 3, 0));

            Assert.Equal("1.3.0", ldf3.GetResourceTypeDescriptor().Version);
            Assert.Equal("LayerDefinition-1.3.0.xsd", ldf3.GetResourceTypeDescriptor().XsdName);
            Assert.Equal("LayerDefinition-1.3.0.xsd", ldf3.ValidatingSchema);
            Assert.Equal(new Version(1, 3, 0), ldf3.ResourceVersion);

            using (var fs = Utils.OpenTempWrite("LayerDef_130.xml"))
            {
                using (var src = ObjectFactory.Serialize(ldf3))
                {
                    Utility.CopyStream(src, fs);
                }
            }

            var ldf4 = (ILayerDefinition)conv.Convert(ldf2, new Version(2, 3, 0));

            Assert.Equal("2.3.0", ldf4.GetResourceTypeDescriptor().Version);
            Assert.Equal("LayerDefinition-2.3.0.xsd", ldf4.GetResourceTypeDescriptor().XsdName);
            Assert.Equal("LayerDefinition-2.3.0.xsd", ldf4.ValidatingSchema);
            Assert.Equal(new Version(2, 3, 0), ldf4.ResourceVersion);
            Assert.True(ldf4.SubLayer is ISubLayerDefinition2);

            using (var fs = Utils.OpenTempWrite("LayerDef_230.xml"))
            {
                using (var src = ObjectFactory.Serialize(ldf4))
                {
                    Utility.CopyStream(src, fs);
                }
            }

            var vl4 = ldf4.SubLayer as IVectorLayerDefinition;

            vl4.Url = "http://www.google.com";

            var ldf5 = (ILayerDefinition)conv.Convert(ldf4, new Version(2, 4, 0));

            Assert.Equal("2.4.0", ldf5.GetResourceTypeDescriptor().Version);
            Assert.Equal("LayerDefinition-2.4.0.xsd", ldf5.GetResourceTypeDescriptor().XsdName);
            Assert.Equal("LayerDefinition-2.4.0.xsd", ldf5.ValidatingSchema);
            Assert.Equal(new Version(2, 4, 0), ldf5.ResourceVersion);
            Assert.True(ldf5.SubLayer is ISubLayerDefinition2);

            var vl5 = ldf5.SubLayer as IVectorLayerDefinition;

            Assert.Equal("http://www.google.com", vl5.Url);

            using (var fs = Utils.OpenTempWrite("LayerDef_240.xml"))
            {
                using (var src = ObjectFactory.Serialize(ldf5))
                {
                    Utility.CopyStream(src, fs);
                }
            }
        }