Beispiel #1
0
 private IEditorFactory GetRegisteredEditor(ResourceTypes type, string version)
 {
     var rtd = new ResourceTypeDescriptor(type, version);
     return GetRegisteredEditor(rtd);
 }
 /// <summary>
 /// Gets the resource content version
 /// </summary>
 /// <returns></returns>
 public ResourceTypeDescriptor GetVersion()
 {
     if (_rtd == null)
     {
         _rtd = GetVersionFromXmlStream(_stream);
     }
     return _rtd;
 }
Beispiel #3
0
 private IEditorFactory GetRegisteredEditor(ResourceTypeDescriptor rtd)
 {
     if (_factories.ContainsKey(rtd))
         return _factories[rtd];
     else
         return null;
 }
Beispiel #4
0
        private IEditorViewContent FindEditor(ViewContentManager svc, ResourceTypeDescriptor rtd)
        {
            IEditorViewContent ed = null;
            IEditorFactory fact = GetRegisteredEditor(rtd);

            //No registered editor, use the xml editor fallback
            if (fact == null)
            {
                ed = svc.OpenContent<XmlEditor>(ViewRegion.Document);
            }
            else
            {
                //I LOVE ANONYMOUS DELEGATES!
                ed = svc.OpenContent(ViewRegion.Document, () => { return fact.Create(); });
            }

            if (ed == null)
                ed = svc.OpenContent<XmlEditor>(ViewRegion.Document);

            return ed;
        }
Beispiel #5
0
        public void TestResourceTypeDescriptor()
        {
            var rtd = new ResourceTypeDescriptor(ResourceTypes.ApplicationDefinition, "1.0.0");
            Assert.AreEqual(rtd.XsdName, "ApplicationDefinition-1.0.0.xsd");

            rtd = new ResourceTypeDescriptor(ResourceTypes.DrawingSource, "1.0.0");
            Assert.AreEqual(rtd.XsdName, "DrawingSource-1.0.0.xsd");

            rtd = new ResourceTypeDescriptor(ResourceTypes.FeatureSource, "1.0.0");
            Assert.AreEqual(rtd.XsdName, "FeatureSource-1.0.0.xsd");

            rtd = new ResourceTypeDescriptor(ResourceTypes.LayerDefinition, "1.0.0");
            Assert.AreEqual(rtd.XsdName, "LayerDefinition-1.0.0.xsd");

            rtd = new ResourceTypeDescriptor(ResourceTypes.LayerDefinition, "1.1.0");
            Assert.AreEqual(rtd.XsdName, "LayerDefinition-1.1.0.xsd");

            rtd = new ResourceTypeDescriptor(ResourceTypes.LoadProcedure, "1.0.0");
            Assert.AreEqual(rtd.XsdName, "LoadProcedure-1.0.0.xsd");

            rtd = new ResourceTypeDescriptor(ResourceTypes.MapDefinition, "1.0.0");
            Assert.AreEqual(rtd.XsdName, "MapDefinition-1.0.0.xsd");

            rtd = new ResourceTypeDescriptor(ResourceTypes.DrawingSource, "1.0.0");
            Assert.AreEqual(rtd.XsdName, "DrawingSource-1.0.0.xsd");

            rtd = new ResourceTypeDescriptor(ResourceTypes.PrintLayout, "1.0.0");
            Assert.AreEqual(rtd.XsdName, "PrintLayout-1.0.0.xsd");

            rtd = new ResourceTypeDescriptor(ResourceTypes.SymbolDefinition, "1.0.0");
            Assert.AreEqual(rtd.XsdName, "SymbolDefinition-1.0.0.xsd");

            rtd = new ResourceTypeDescriptor(ResourceTypes.SymbolLibrary, "1.0.0");
            Assert.AreEqual(rtd.XsdName, "SymbolLibrary-1.0.0.xsd");

            rtd = new ResourceTypeDescriptor(ResourceTypes.WebLayout, "1.0.0");
            Assert.AreEqual(rtd.XsdName, "WebLayout-1.0.0.xsd");
        }
Beispiel #6
0
 /// <summary>
 /// Registers a resource serializer
 /// </summary>
 /// <param name="desc">The desc.</param>
 /// <param name="serializeMethod">The serialize method.</param>
 /// <param name="deserializeMethod">The deserialize method.</param>
 public static void RegisterResource(ResourceTypeDescriptor desc, ResourceSerializationCallback serializeMethod, ResourceDeserializationCallback deserializeMethod)
 {
     RegisterResource(desc, new ResourceSerializer() { Deserialize = deserializeMethod, Serialize = serializeMethod });
 }
Beispiel #7
0
        /// <summary>
        /// Registers a resource serializer
        /// </summary>
        /// <param name="desc">The desc.</param>
        /// <param name="serializer">The serializer.</param>
        public static void RegisterResource(ResourceTypeDescriptor desc, ResourceSerializer serializer)
        {
            if (_serializers.ContainsKey(desc))
                throw new ArgumentException(string.Format(Strings.ERR_SERIALIZER_ALREADY_REGISTERED, desc.ResourceType, desc.Version), "desc"); //NOXLATE

            _serializers.Add(desc, serializer);
        }