[mapguide-commits] r4925 - in
sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI: . Commands
ObjectModels Services
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Mon May 24 20:52:56 EDT 2010
Author: jng
Date: 2010-05-24 20:52:54 -0400 (Mon, 24 May 2010)
New Revision: 4925
Modified:
sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/Commands/ExecuteLoadProcedure.cs
sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ObjectModels/ObjectFactory.cs
sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ResourceTypeRegistry.cs
sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ServerConnectionBase.cs
sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/Services/IResourceService.cs
Log:
Remove the IResourceService.CreateDefault<T>() API, instead let ObjectFactory handle all object creation.
Modified: sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/Commands/ExecuteLoadProcedure.cs
===================================================================
--- sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/Commands/ExecuteLoadProcedure.cs 2010-05-24 12:13:09 UTC (rev 4924)
+++ sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/Commands/ExecuteLoadProcedure.cs 2010-05-25 00:52:54 UTC (rev 4925)
@@ -26,6 +26,7 @@
using OSGeo.MapGuide.ObjectModels.Common;
using OSGeo.MapGuide.ObjectModels.LayerDefinition;
using OSGeo.MapGuide.MaestroAPI.Resource;
+using OSGeo.MapGuide.MaestroAPI.ObjectModels;
namespace OSGeo.MapGuide.MaestroAPI.Commands
{
@@ -356,7 +357,7 @@
if (clsDef != null && geom != null)
{
- OSGeo.MapGuide.ObjectModels.LayerDefinition.LayerDefinition ld = this.Parent.ResourceService.CreateResourceObject<LayerDefinition>();
+ OSGeo.MapGuide.ObjectModels.LayerDefinition.LayerDefinition ld = ObjectFactory.CreateLayerDefinition();
//Step 3: Assign default properties
ld.ResourceID = lyrId;
@@ -557,7 +558,7 @@
if (clsDef != null && geom != null)
{
- LayerDefinition ld = this.Parent.ResourceService.CreateResourceObject<LayerDefinition>();
+ LayerDefinition ld = ObjectFactory.CreateLayerDefinition();
//Step 3: Assign default properties
ld.ResourceID = lyrId;
Modified: sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ObjectModels/ObjectFactory.cs
===================================================================
--- sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ObjectModels/ObjectFactory.cs 2010-05-24 12:13:09 UTC (rev 4924)
+++ sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ObjectModels/ObjectFactory.cs 2010-05-25 00:52:54 UTC (rev 4925)
@@ -20,14 +20,70 @@
using System;
using System.Collections.Generic;
using System.Text;
+using OSGeo.MapGuide.MaestroAPI.Resource;
+using OSGeo.MapGuide.ObjectModels.LayerDefinition;
+using OSGeo.MapGuide.ObjectModels.FeatureSource;
+using OSGeo.MapGuide.ObjectModels.MapDefinition;
+using OSGeo.MapGuide.ObjectModels.WebLayout;
+using OSGeo.MapGuide.ObjectModels.SymbolLibrary;
+using OSGeo.MapGuide.ObjectModels.SymbolDefinition;
+using OSGeo.MapGuide.ObjectModels.ApplicationDefinition;
+using OSGeo.MapGuide.ObjectModels.PrintLayout;
+using OSGeo.MapGuide.ObjectModels.LoadProcedure;
namespace OSGeo.MapGuide.MaestroAPI.ObjectModels
{
/// <summary>
- /// Factory class to create MapGuide resource objects
+ /// Factory class to create MapGuide resource objects with either pre-defined or
+ /// sensible default values. This is recommended over creating the objects directly
+ /// as this ensures that there are no null child properties where the XML schema forbids
+ /// it.
/// </summary>
public static class ObjectFactory
{
-
+ public static LayerDefinition CreateLayerDefinition()
+ {
+ return new LayerDefinition();
+ }
+
+ public static FeatureSourceType CreateFeatureSource()
+ {
+ return new FeatureSourceType();
+ }
+
+ public static MapDefinition CreateMapDefinition()
+ {
+ return new MapDefinition();
+ }
+
+ public static WebLayoutType CreateWebLayout()
+ {
+ return new WebLayoutType();
+ }
+
+ public static SimpleSymbolDefinition CreateSimpleSymbol()
+ {
+ return new SimpleSymbolDefinition();
+ }
+
+ public static CompoundSymbolDefinition CreateCompoundSymbol()
+ {
+ return new CompoundSymbolDefinition();
+ }
+
+ public static ApplicationDefinitionType CreateFlexibleLayout()
+ {
+ return new ApplicationDefinitionType();
+ }
+
+ public static PrintLayout CreatePrintLayout()
+ {
+ return new PrintLayout();
+ }
+
+ public static LoadProcedure CreateLoadProcedure()
+ {
+ return new LoadProcedure();
+ }
}
}
Modified: sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ResourceTypeRegistry.cs
===================================================================
--- sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ResourceTypeRegistry.cs 2010-05-24 12:13:09 UTC (rev 4924)
+++ sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ResourceTypeRegistry.cs 2010-05-25 00:52:54 UTC (rev 4925)
@@ -216,10 +216,5 @@
return _serializers[rd].Serialize(res);
}
-
- public static T CreateDefault<T>() where T : IResource
- {
- throw new NotImplementedException();
- }
}
}
Modified: sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ServerConnectionBase.cs
===================================================================
--- sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ServerConnectionBase.cs 2010-05-24 12:13:09 UTC (rev 4924)
+++ sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/ServerConnectionBase.cs 2010-05-25 00:52:54 UTC (rev 4925)
@@ -1525,18 +1525,7 @@
public abstract System.IO.Stream GetTile(string mapdefinition, string baselayergroup, int col, int row, int scaleindex, string format);
-
/// <summary>
- /// Creates a new object of the given type, with standard values inserted
- /// </summary>
- /// <typeparam name="T">The type of the object to create</typeparam>
- /// <returns>A new instance of the object</returns>
- public virtual T CreateResourceObject<T>() where T : IResource
- {
- return ResourceTypeRegistry.CreateDefault<T>();
- }
-
- /// <summary>
/// Performs an aggregate query on all columns in the datasource
/// </summary>
/// <param name="resourceID">The resourceID of the FeatureSource to query</param>
Modified: sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/Services/IResourceService.cs
===================================================================
--- sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/Services/IResourceService.cs 2010-05-24 12:13:09 UTC (rev 4924)
+++ sandbox/maestro-2.5/OSGeo.MapGuide.MaestroAPI/Services/IResourceService.cs 2010-05-25 00:52:54 UTC (rev 4925)
@@ -49,13 +49,6 @@
System.IO.MemoryStream SerializeObject(object o);
void SerializeObject(object o, System.IO.Stream stream);
- /// <summary>
- /// Creates a new object of the given type, with standard values inserted
- /// </summary>
- /// <typeparam name="T">The type of the object to create</typeparam>
- /// <returns>A new instance of the object</returns>
- T CreateResourceObject<T>() where T : IResource;
-
System.IO.MemoryStream GetResourceData(string resourceID, string dataname);
ObjCommon.ResourceDocumentHeaderType GetResourceHeader(string resourceID);
ObjCommon.ResourceFolderHeaderType GetFolderHeader(string resourceID);
More information about the mapguide-commits
mailing list