Exemple #1
0
        private void btnUpgrade_Click(object sender, EventArgs e)
        {
            var res = _svc.GetEditedResource();
            var conn = res.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 = ResourceTypeRegistry.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
            }
        }
Exemple #2
0
        public void TestSymbolDefinitionConversions()
        {
            var conn = _mocks.NewMock<IServerConnection>();
            var conv = new ResourceObjectConverter();

            var ssym = ObjectFactory.CreateSimpleSymbol(conn, new Version(1, 0, 0), "SimpleSymbolTest", "Test simple symbol");
            ssym.ResourceID = "Library://Samples/Sheboygan/Symbols/Test.SymbolDefinition";

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

            using (var fs = File.OpenWrite("SimpleSymDef_100.xml"))
            {
                using (var src = ResourceTypeRegistry.Serialize(ssym))
                {
                    Utility.CopyStream(src, fs);
                }
            }

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

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

            using (var fs = File.OpenWrite("SimpleSymDef_110.xml"))
            {
                using (var src = ResourceTypeRegistry.Serialize(ssym2))
                {
                    Utility.CopyStream(src, fs);
                }
            }

            var csym = ObjectFactory.CreateCompoundSymbol(conn, new Version(1, 0, 0), "CompoundSymbolTest", "Test compound symbol");
            csym.ResourceID = "Library://Samples/Sheboygan/Symbols/Compound.SymbolDefinition";

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

            using (var fs = File.OpenWrite("CompoundSymDef_100.xml"))
            {
                using (var src = ResourceTypeRegistry.Serialize(csym))
                {
                    Utility.CopyStream(src, fs);
                }
            }

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

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

            using (var fs = File.OpenWrite("CompoundSymDef_110.xml"))
            {
                using (var src = ResourceTypeRegistry.Serialize(csym2))
                {
                    Utility.CopyStream(src, fs);
                }
            }
        }
Exemple #3
0
        public void TestMapDefinitionConversions()
        {
            var conn = _mocks.NewMock<IServerConnection>();
            var conv = new ResourceObjectConverter();

            var mdf = ObjectFactory.CreateMapDefinition(conn, new Version(1, 0, 0), "Test Map");
            mdf.ResourceID = "Library://Samples/Sheboygan/Maps/Sheboygan.MapDefinition";

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

            using (var fs = File.OpenWrite("MapDef_100.xml"))
            {
                using (var src = ResourceTypeRegistry.Serialize(mdf))
                {
                    Utility.CopyStream(src, fs);
                }
            }

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

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

            using (var fs = File.OpenWrite("MapDef_230.xml"))
            {
                using (var src = ResourceTypeRegistry.Serialize(mdf2))
                {
                    Utility.CopyStream(src, fs);
                }
            }
        }
Exemple #4
0
        public void TestLoadProcedureConversions()
        {
            var conn = _mocks.NewMock<IServerConnection>();
            var conv = new ResourceObjectConverter();

            var lproc = ObjectFactory.CreateLoadProcedure(conn, LoadType.Sdf);
            lproc.ResourceID = "Library://Samples/Sheboygan/Load/Load.LoadProcedure";

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

            using (var fs = File.OpenWrite("LoadProc_100.xml"))
            {
                using (var src = ResourceTypeRegistry.Serialize(lproc))
                {
                    Utility.CopyStream(src, fs);
                }
            }

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

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

            using (var fs = File.OpenWrite("LoadProc_110.xml"))
            {
                using (var src = ResourceTypeRegistry.Serialize(lproc2))
                {
                    Utility.CopyStream(src, fs);
                }
            }

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

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

            using (var fs = File.OpenWrite("LoadProc_220.xml"))
            {
                using (var src = ResourceTypeRegistry.Serialize(lproc3))
                {
                    Utility.CopyStream(src, fs);
                }
            }
        }
Exemple #5
0
        public void TestLayerDefinitionConversions()
        {
            var conn = _mocks.NewMock<IServerConnection>();
            var conv = new ResourceObjectConverter();
            var ldf = ObjectFactory.CreateDefaultLayer(conn, 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.AreEqual("1.0.0", ldf.GetResourceTypeDescriptor().Version);
            Assert.AreEqual("LayerDefinition-1.0.0.xsd", ldf.GetResourceTypeDescriptor().XsdName);
            Assert.AreEqual("LayerDefinition-1.0.0.xsd", ldf.ValidatingSchema);
            Assert.AreEqual(new Version(1, 0, 0), ldf.ResourceVersion);

            using (var fs = File.OpenWrite("LayerDef_100.xml"))
            {
                using (var src = ResourceTypeRegistry.Serialize(ldf))
                {
                    Utility.CopyStream(src, fs);
                }
            }

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

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

            using (var fs = File.OpenWrite("LayerDef_110.xml"))
            {
                using (var src = ResourceTypeRegistry.Serialize(ldf1))
                {
                    Utility.CopyStream(src, fs);
                }
            }

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

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

            using (var fs = File.OpenWrite("LayerDef_120.xml"))
            {
                using (var src = ResourceTypeRegistry.Serialize(ldf2))
                {
                    Utility.CopyStream(src, fs);
                }
            }

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

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

            using (var fs = File.OpenWrite("LayerDef_130.xml"))
            {
                using (var src = ResourceTypeRegistry.Serialize(ldf3))
                {
                    Utility.CopyStream(src, fs);
                }
            }

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

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

            using (var fs = File.OpenWrite("LayerDef_230.xml"))
            {
                using (var src = ResourceTypeRegistry.Serialize(ldf4))
                {
                    Utility.CopyStream(src, fs);
                }
            }
        }
Exemple #6
0
        public void TestWebLayoutConversions()
        {
            var conn = _mocks.NewMock<IServerConnection>();
            var conv = new ResourceObjectConverter();

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

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

            using (var fs = File.OpenWrite("WebLayout_100.xml"))
            {
                using (var src = ResourceTypeRegistry.Serialize(wl))
                {
                    Utility.CopyStream(src, fs);
                }
            }

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

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

            using (var fs = File.OpenWrite("WebLayout_110.xml"))
            {
                using (var src = ResourceTypeRegistry.Serialize(wl2))
                {
                    Utility.CopyStream(src, fs);
                }
            }
        }