[mapguide-commits] r5254 - in sandbox/maestro-3.0: ExtendedModels/LayerDefinition-1.1.0 ExtendedModels/LayerDefinition-1.1.0/Properties ExtendedModels/LayerDefinition-1.2.0 ExtendedModels/LayerDefinition-1.2.0/Properties ExtendedModels/LayerDefinition-1.3.0 ExtendedModels/LayerDefinition-1.3.0/Properties Generated Maestro.Base Maestro.Base/Editor Maestro.Base/Properties Maestro.Base/Templates Maestro.Editors/LayerDefinition Maestro.Editors/LayerDefinition/Drawing Maestro.Editors/LayerDefinition/Vector Maestro.Editors/LayerDefinition/Vector/Scales Maestro.Editors/LayerDefinition/Vector/StyleEditors Maestro.Editors/LayerDefinition/Vector/Thematics Maestro.Editors/WebLayout/Commands Maestro.ResourceValidation Maestro.ResourceValidation/Properties MaestroAPITests OSGeo.MapGuide.MaestroAPI OSGeo.MapGuide.MaestroAPI/Commands OSGeo.MapGuide.MaestroAPI/ObjectModels OSGeo.MapGuide.MaestroAPI/Properties OSGeo.MapGuide.MaestroAPI/Resource

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Thu Oct 7 08:42:51 EDT 2010


Author: jng
Date: 2010-10-07 12:42:50 +0000 (Thu, 07 Oct 2010)
New Revision: 5254

Added:
   sandbox/maestro-3.0/Maestro.Base/Templates/DrawingLayerDefinitionItemTemplate.cs
   sandbox/maestro-3.0/Maestro.Base/Templates/RasterLayerDefinitionItemTemplate.cs
   sandbox/maestro-3.0/Maestro.Base/Templates/VectorLayerDefinitionItemTemplate.cs
   sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/ObjectModels/GridLayerDefinitionImpl.cs
   sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/ObjectModels/LayerFactory.cs
   sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/ObjectModels/LayerInterfaceExtensions.cs
   sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/ObjectModels/LayerInterfaces.cs
   sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/ObjectModels/VectorLayerDefinitionImpl.cs
   sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/Resource/BaseLayerDefinitionValidator.cs
Removed:
   sandbox/maestro-3.0/ExtendedModels/LayerDefinition-1.1.0/LayerDefinition.cs
   sandbox/maestro-3.0/ExtendedModels/LayerDefinition-1.2.0/LayerDefinition.cs
   sandbox/maestro-3.0/ExtendedModels/LayerDefinition-1.3.0/LayerDefinition.cs
   sandbox/maestro-3.0/Maestro.Base/Templates/LayerDefinitionItemTemplate.cs
   sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/ObjectModels/LayerDefinition.cs
Modified:
   sandbox/maestro-3.0/ExtendedModels/LayerDefinition-1.1.0/LayerDefinitionValidator.cs
   sandbox/maestro-3.0/ExtendedModels/LayerDefinition-1.1.0/OSGeo.MapGuide.ObjectModels.LayerDefinition-1.1.0.csproj
   sandbox/maestro-3.0/ExtendedModels/LayerDefinition-1.1.0/Properties/Resources.Designer.cs
   sandbox/maestro-3.0/ExtendedModels/LayerDefinition-1.1.0/Properties/Resources.resx
   sandbox/maestro-3.0/ExtendedModels/LayerDefinition-1.2.0/LayerDefinitionValidator.cs
   sandbox/maestro-3.0/ExtendedModels/LayerDefinition-1.2.0/OSGeo.MapGuide.ObjectModels.LayerDefinition-1.2.0.csproj
   sandbox/maestro-3.0/ExtendedModels/LayerDefinition-1.2.0/Properties/Resources.Designer.cs
   sandbox/maestro-3.0/ExtendedModels/LayerDefinition-1.2.0/Properties/Resources.resx
   sandbox/maestro-3.0/ExtendedModels/LayerDefinition-1.3.0/LayerDefinitionValidator.cs
   sandbox/maestro-3.0/ExtendedModels/LayerDefinition-1.3.0/OSGeo.MapGuide.ObjectModels.LayerDefinition-1.3.0.csproj
   sandbox/maestro-3.0/ExtendedModels/LayerDefinition-1.3.0/Properties/Resources.Designer.cs
   sandbox/maestro-3.0/ExtendedModels/LayerDefinition-1.3.0/Properties/Resources.resx
   sandbox/maestro-3.0/Generated/LayerDefinition-1.0.0.designer.cs
   sandbox/maestro-3.0/Generated/LayerDefinition-1.1.0.designer.cs
   sandbox/maestro-3.0/Generated/LayerDefinition-1.2.0.designer.cs
   sandbox/maestro-3.0/Generated/LayerDefinition-1.3.0.designer.cs
   sandbox/maestro-3.0/Maestro.Base/Editor/LayerDefinitionEditor.cs
   sandbox/maestro-3.0/Maestro.Base/Maestro.Base.addin
   sandbox/maestro-3.0/Maestro.Base/Maestro.Base.csproj
   sandbox/maestro-3.0/Maestro.Base/Properties/Resources.Designer.cs
   sandbox/maestro-3.0/Maestro.Base/Properties/Resources.resx
   sandbox/maestro-3.0/Maestro.Editors/LayerDefinition/Drawing/DrawingLayerSettingsCtrl.cs
   sandbox/maestro-3.0/Maestro.Editors/LayerDefinition/LayerPropertiesSectionCtrl.cs
   sandbox/maestro-3.0/Maestro.Editors/LayerDefinition/Vector/FeaturePreviewRender.cs
   sandbox/maestro-3.0/Maestro.Editors/LayerDefinition/Vector/Scales/Condition.cs
   sandbox/maestro-3.0/Maestro.Editors/LayerDefinition/Vector/Scales/ConditionList.cs
   sandbox/maestro-3.0/Maestro.Editors/LayerDefinition/Vector/Scales/ConditionListButtons.cs
   sandbox/maestro-3.0/Maestro.Editors/LayerDefinition/Vector/Scales/ItemStyle.cs
   sandbox/maestro-3.0/Maestro.Editors/LayerDefinition/Vector/Scales/ScaleRange.cs
   sandbox/maestro-3.0/Maestro.Editors/LayerDefinition/Vector/Scales/ScaleRangeConditions.cs
   sandbox/maestro-3.0/Maestro.Editors/LayerDefinition/Vector/Scales/ScaleRangeList.cs
   sandbox/maestro-3.0/Maestro.Editors/LayerDefinition/Vector/StyleEditors/AreaFeatureStyleEditor.cs
   sandbox/maestro-3.0/Maestro.Editors/LayerDefinition/Vector/StyleEditors/FontStyleEditor.cs
   sandbox/maestro-3.0/Maestro.Editors/LayerDefinition/Vector/StyleEditors/LineFeatureStyleEditor.cs
   sandbox/maestro-3.0/Maestro.Editors/LayerDefinition/Vector/StyleEditors/PointFeatureStyleEditor.cs
   sandbox/maestro-3.0/Maestro.Editors/LayerDefinition/Vector/Thematics/ThemeCreator.cs
   sandbox/maestro-3.0/Maestro.Editors/LayerDefinition/Vector/VectorLayerSettingsSectionCtrl.cs
   sandbox/maestro-3.0/Maestro.Editors/LayerDefinition/Vector/VectorLayerStyleSectionCtrl.cs
   sandbox/maestro-3.0/Maestro.Editors/LayerDefinition/VectorLayerEditorCtrl.cs
   sandbox/maestro-3.0/Maestro.Editors/WebLayout/Commands/SearchCmdCtrl.cs
   sandbox/maestro-3.0/Maestro.ResourceValidation/LayerDefinitionValidator.cs
   sandbox/maestro-3.0/Maestro.ResourceValidation/MapDefinitionValidator.cs
   sandbox/maestro-3.0/Maestro.ResourceValidation/Properties/Resources.Designer.cs
   sandbox/maestro-3.0/Maestro.ResourceValidation/Properties/Resources.resx
   sandbox/maestro-3.0/MaestroAPITests/ResourceTests.cs
   sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/Commands/ExecuteLoadProcedure.cs
   sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/OSGeo.MapGuide.MaestroAPI.csproj
   sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/ObjectModels/ObjectFactory.cs
   sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/Properties/Resources.Designer.cs
   sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/Properties/Resources.resx
   sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/ResourceTypeRegistry.cs
Log:
This submission introduces a set of abstract layer definition interfaces which *all* Layer Definition
generated classes (of all versions 1.0 to 1.3) implement.

These interfaces cover everything from the top-level (IVectorLayerDefinition, IRasterLayerDefinition, etc) all the
way down to the detailed stuff (IStroke, IFill, etc)

Current consumers of the layer definition classes now consume these interfaces instead. This involved refactoring
the entire layer definition editor to use interfaces instead of classes with some API design changes to work around the fact
that everything based on layers now revolves around these interfaces.

As already mentioned, all versions (1.0 to 1.3) implement this interface, so theoretically speaking all consumers can work
with any layer definition no matter which version, because they all implement the same set of interfaces, so all versions should
have the baseline set of support and features.

For features introduced in newer versions (eg. Symbology), we simply introduce a newer version of the affected interfaces and
have the classes implement them as well. Newer version layer editors (which are the primary consumer here) can test for support
of these newer version interfaces.

This submission has the potential to break a lot of things, but:

 a) We're in a sandbox, so things can be allowed to break, provided they are fixed in due course :-)
 b) The run of the current test suite w/ these changes gives a green light
 c) The changes in this submission will ultimately make things easier going forward


Deleted: sandbox/maestro-3.0/ExtendedModels/LayerDefinition-1.1.0/LayerDefinition.cs
===================================================================
--- sandbox/maestro-3.0/ExtendedModels/LayerDefinition-1.1.0/LayerDefinition.cs	2010-10-07 10:05:07 UTC (rev 5253)
+++ sandbox/maestro-3.0/ExtendedModels/LayerDefinition-1.1.0/LayerDefinition.cs	2010-10-07 12:42:50 UTC (rev 5254)
@@ -1,266 +0,0 @@
-#region Disclaimer / License
-// Copyright (C) 2010, Jackie Ng
-// http://trac.osgeo.org/mapguide/wiki/maestro, jumpinjackie at gmail.com
-// 
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License, or (at your option) any later version.
-// 
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-// Lesser General Public License for more details.
-// 
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
-// 
-#endregion
-using System;
-using System.Collections.Generic;
-using System.Text;
-using OSGeo.MapGuide.ObjectModels.Common;
-using System.Xml.Serialization;
-using System.ComponentModel;
-using OSGeo.MapGuide.MaestroAPI.Resource;
-using OSGeo.MapGuide.MaestroAPI;
-using Ldf = OSGeo.MapGuide.ObjectModels.LayerDefinition;
-
-namespace OSGeo.MapGuide.ObjectModels.LayerDefinition_1_1_0
-{
-    abstract partial class BaseLayerDefinitionType : Ldf.ISubLayerDefinition
-    {
-        [XmlIgnore]
-        public abstract Ldf.LayerType LayerType { get; }
-    }
-
-    partial class VectorLayerDefinitionType : Ldf.IVectorLayerDefinition
-    {
-        public override Ldf.LayerType LayerType
-        {
-            get { return Ldf.LayerType.Vector; }
-        }
-
-        [XmlIgnore]
-        string Ldf.IVectorLayerDefinition.FeatureSourceID
-        {
-            get { return this.ResourceId; }
-            set { this.ResourceId = value; }
-        }
-
-        [XmlIgnore]
-        string Ldf.IVectorLayerDefinition.FullQualifiedClassName
-        {
-            get { return this.FeatureName; }
-            set { this.FeatureName = value; }
-        }
-
-        [XmlIgnore]
-        string Ldf.IVectorLayerDefinition.GeometryProperty
-        {
-            get { return this.Geometry; }
-            set { this.Geometry = value; }
-        }
-
-        [XmlIgnore]
-        string Ldf.IVectorLayerDefinition.Url
-        {
-            get { return this.Url; }
-            set { this.Url = value; }
-        }
-
-        [XmlIgnore]
-        string Ldf.IVectorLayerDefinition.ToolTip
-        {
-            get { return this.ToolTip; }
-            set { this.ToolTip = value; }
-        }
-
-        [XmlIgnore]
-        string Ldf.IVectorLayerDefinition.Filter
-        {
-            get { return this.Filter; }
-            set { this.Filter = value; }
-        }
-    }
-
-    partial class GridLayerDefinitionType : Ldf.IRasterLayerDefinition
-    {
-        public override Ldf.LayerType LayerType
-        {
-            get { return Ldf.LayerType.Raster; }
-        }
-
-        [XmlIgnore]
-        string Ldf.IRasterLayerDefinition.FeatureSourceID
-        {
-            get { return this.ResourceId; }
-            set { this.ResourceId = value; }
-        }
-
-        [XmlIgnore]
-        string Ldf.IRasterLayerDefinition.FullQualifiedClassName
-        {
-            get
-            {
-                return this.FeatureName;
-            }
-            set
-            {
-                this.FeatureName = value;
-            }
-        }
-
-        [XmlIgnore]
-        string Ldf.IRasterLayerDefinition.GeometryProperty
-        {
-            get
-            {
-                return this.Geometry;
-            }
-            set
-            {
-                this.Geometry = value;
-            }
-        }
-    }
-
-    partial class DrawingLayerDefinitionType : Ldf.IDrawingLayerDefinition
-    {
-        public override Ldf.LayerType LayerType
-        {
-            get { return Ldf.LayerType.Drawing; }
-        }
-
-        [XmlIgnore]
-        string Ldf.IDrawingLayerDefinition.DrawingSourceID
-        {
-            get { return this.ResourceId; }
-            set { this.ResourceId = value; }
-        }
-    }
-
-    partial class VectorScaleRangeType
-    {
-        #region Missing generated stuff
-        [EditorBrowsable(EditorBrowsableState.Never)]
-        private bool minScaleFieldSpecified;
-
-        [System.Xml.Serialization.XmlIgnoreAttribute()]
-        public bool MinScaleSpecified
-        {
-            get
-            {
-                return this.minScaleFieldSpecified;
-            }
-            set
-            {
-                if ((minScaleFieldSpecified.Equals(value) != true))
-                {
-                    this.minScaleFieldSpecified = value;
-                    this.OnPropertyChanged("MinScaleSpecified");
-                }
-            }
-        }
-        #endregion
-    }
-
-    partial class LayerDefinition : Ldf.ILayerDefinition
-    {
-        private static readonly Version RES_VERSION = new Version(1, 1, 0);
-
-        [XmlIgnore]
-        public OSGeo.MapGuide.MaestroAPI.IServerConnection CurrentConnection
-        {
-            get;
-            set;
-        }
-
-        private string _resId;
-
-        [XmlIgnore]
-        public string ResourceID
-        {
-            get
-            {
-                return _resId;
-            }
-            set
-            {
-                if (!ResourceIdentifier.Validate(value))
-                    throw new InvalidOperationException("Not a valid resource identifier"); //LOCALIZE
-
-                var res = new ResourceIdentifier(value);
-                if (res.Extension != ResourceTypes.LayerDefinition.ToString())
-                    throw new InvalidOperationException("Invalid resource identifier for this type of object: " + res.Extension); //LOCALIZE
-
-                _resId = value;
-                this.OnPropertyChanged("ResourceID");
-            }
-        }
-
-        [XmlIgnore]
-        public ResourceTypes ResourceType
-        {
-            get
-            {
-                return ResourceTypes.LayerDefinition;
-            }
-        }
-
-        [XmlIgnore]
-        public Version ResourceVersion
-        {
-            get
-            {
-                return RES_VERSION;
-            }
-        }
-
-        object ICloneable.Clone()
-        {
-            return this.Clone();
-        }
-
-        [XmlAttribute("noNamespaceSchemaLocation", Namespace = "http://www.w3.org/2001/XMLSchema-instance")]
-        public string ValidatingSchema
-        {
-            get { return "LayerDefinition-1.1.0.xsd"; }
-            set { }
-        }
-
-        [XmlIgnore]
-        public bool IsStronglyTyped
-        {
-            get { return true; }
-        }
-
-        /// <summary>
-        /// Returns the spatial extent of the data. 
-        /// This is calculated by asking the underlying featuresource for the minimum rectangle that
-        /// contains all the features in the specified table. If the <paramref name="allowFallbackToContextInformation"/>
-        /// is set to true, and the query fails, the code will attempt to read this information
-        /// from the spatial context information instead.
-        /// </summary>
-        /// <param name="allowFallbackToContextInformation">True to allow reading spatial extents from the spatial context information, if the spatial query fails.</param>
-        /// <returns>The envelope for the data in the table</returns>
-        public Envelope GetSpatialExtent(bool allowFallbackToContextInformation)
-        {
-            if (this.CurrentConnection == null)
-                throw new System.Exception("No server set for object");
-
-            if (this.Item as VectorLayerDefinitionType != null)
-                return this.CurrentConnection.FeatureService.GetSpatialExtent(this.Item.ResourceId, (this.Item as VectorLayerDefinitionType).FeatureName, (this.Item as VectorLayerDefinitionType).Geometry, allowFallbackToContextInformation);
-            else if (this.Item as GridLayerDefinitionType != null)
-                return this.CurrentConnection.FeatureService.GetSpatialExtent(this.Item.ResourceId, (this.Item as GridLayerDefinitionType).FeatureName, (this.Item as GridLayerDefinitionType).Geometry, allowFallbackToContextInformation);
-            else
-                return null;
-        }
-
-        public Ldf.ISubLayerDefinition SubLayer
-        {
-            get { return this.Item; }
-        }
-    }
-}

Modified: sandbox/maestro-3.0/ExtendedModels/LayerDefinition-1.1.0/LayerDefinitionValidator.cs
===================================================================
--- sandbox/maestro-3.0/ExtendedModels/LayerDefinition-1.1.0/LayerDefinitionValidator.cs	2010-10-07 10:05:07 UTC (rev 5253)
+++ sandbox/maestro-3.0/ExtendedModels/LayerDefinition-1.1.0/LayerDefinitionValidator.cs	2010-10-07 12:42:50 UTC (rev 5254)
@@ -26,149 +26,11 @@
 
 namespace OSGeo.MapGuide.ObjectModels.LayerDefinition_1_1_0
 {
-    public class LayerDefinitionValidator : IResourceValidator
+    public class LayerDefinitionValidator : BaseLayerDefinitionValidator
     {
-        public ResourceTypeDescriptor SupportedResourceAndVersion
+        public override ResourceTypeDescriptor SupportedResourceAndVersion
         {
             get { return new ResourceTypeDescriptor(OSGeo.MapGuide.MaestroAPI.ResourceTypes.LayerDefinition, "1.1.0"); }
         }
-
-        public ValidationIssue[] Validate(IResource resource, bool recurse)
-        {
-            if (resource.ResourceType != OSGeo.MapGuide.MaestroAPI.ResourceTypes.LayerDefinition)
-                return null;
-
-            if (resource.ResourceVersion != new Version(1, 1, 0))
-                return null;
-
-            LayerDefinition ldef = resource as LayerDefinition;
-            VectorLayerDefinitionType vldef = ldef.Item as VectorLayerDefinitionType;
-            GridLayerDefinitionType gldef = ldef.Item as GridLayerDefinitionType;
-            DrawingLayerDefinitionType dldef = ldef.Item as DrawingLayerDefinitionType;
-
-            List<ValidationIssue> issues = new List<ValidationIssue>();
-
-            if (ldef.Item == null)
-                issues.Add(new ValidationIssue(resource, ValidationStatus.Error, Properties.Resources.LDF_LayerNullError));
-            else if (vldef == null && gldef == null)
-                issues.Add(new ValidationIssue(resource, ValidationStatus.Warning, Properties.Resources.LDF_DrawingLayerDefinitionNotSupportedWarning));
-
-            if (vldef != null)
-            {
-                if (string.IsNullOrEmpty(vldef.FeatureName))
-                    issues.Add(new ValidationIssue(resource, ValidationStatus.Error, Properties.Resources.LDF_MissingFeatureSourceError));
-                if (string.IsNullOrEmpty(vldef.Geometry))
-                    issues.Add(new ValidationIssue(resource, ValidationStatus.Error, Properties.Resources.LDF_MissingGeometryError));
-
-                if (vldef.VectorScaleRange == null || vldef.VectorScaleRange.Count == 0)
-                    issues.Add(new ValidationIssue(resource, ValidationStatus.Error, Properties.Resources.LDF_MissingScaleRangesError));
-                else
-                {
-                    //Test for overlapping scale ranges
-                    List<KeyValuePair<double, double>> ranges = new List<KeyValuePair<double, double>>();
-                    foreach (VectorScaleRangeType vsr in vldef.VectorScaleRange)
-                        ranges.Add(new KeyValuePair<double, double>(
-                            vsr.MaxScaleSpecified ? vsr.MaxScale : double.PositiveInfinity,
-                            vsr.MinScaleSpecified ? vsr.MinScale : double.NegativeInfinity));
-
-                    double min = double.PositiveInfinity;
-                    double max = double.NegativeInfinity;
-                    foreach (KeyValuePair<double, double> sr in ranges)
-                    {
-                        min = Math.Min(min, sr.Value);
-                        max = Math.Max(max, sr.Key);
-                        if (sr.Key < sr.Value)
-                            issues.Add(new ValidationIssue(resource, ValidationStatus.Error, string.Format(Properties.Resources.LDF_MinAndMaxScaleSwappedError, sr.Value, sr.Key)));
-                    }
-
-                    //TODO: Detect gaps in scale ranges
-                    for (int i = 0; i < ranges.Count; i++)
-                        for (int j = i + 1; j < ranges.Count; j++)
-                            if (ranges[i].Key > ranges[j].Value || ranges[i].Value > ranges[j].Value)
-                                issues.Add(new ValidationIssue(resource, ValidationStatus.Information, string.Format(Properties.Resources.LDF_ScaleRangesOverlapInformation, ranges[i].Value, ranges[i].Key, ranges[j].Value, ranges[j].Key)));
-
-                }
-            }
-            else if (gldef != null)
-            {
-                if (gldef.GridScaleRange == null || gldef.GridScaleRange.Count == 0)
-                    issues.Add(new ValidationIssue(resource, ValidationStatus.Error, Properties.Resources.LDF_MissingScaleRangesError));
-                else if (gldef.GridScaleRange.Count != 1)
-                    issues.Add(new ValidationIssue(resource, ValidationStatus.Warning, Properties.Resources.LDF_MultipleScaleRangesWarning));
-            }
-            else if (dldef != null)
-                issues.Add(new ValidationIssue(resource, ValidationStatus.Warning, Properties.Resources.LDF_DrawingLayerNotSupportedWarning));
-            else
-                issues.Add(new ValidationIssue(resource, ValidationStatus.Warning, Properties.Resources.LDF_UnsupportedLayerTypeWarning));
-
-            if (recurse)
-            {
-                try
-                {
-                    FeatureSourceType fs = (FeatureSourceType)ldef.CurrentConnection.ResourceService.GetResource(ldef.Item.ResourceId);
-                    issues.AddRange(ResourceValidatorSet.Validate(fs, recurse));
-
-                    try
-                    {
-                        if (vldef != null || gldef != null)
-                        {
-                            string schema = vldef == null ? gldef.FeatureName : vldef.FeatureName;
-                            string geometry = vldef == null ? gldef.Geometry : vldef.Geometry;
-
-                            bool foundSchema = false;
-                            bool foundGeometry = false;
-
-                            FeatureSourceDescription desc = fs.Describe();
-                            foreach (FeatureSourceDescription.FeatureSourceSchema scm in desc.Schemas)
-                                if (scm.FullnameDecoded == schema)
-                                {
-                                    foundSchema = true;
-
-                                    foreach (FeatureSetColumn col in scm.Columns)
-                                        if (col.Name == geometry)
-                                        {
-                                            foundGeometry = true;
-                                            break;
-                                        }
-
-
-                                    if (vldef != null && vldef.PropertyMapping != null)
-                                        foreach (NameStringPairType s in vldef.PropertyMapping)
-                                        {
-                                            bool found = false;
-                                            foreach (FeatureSetColumn col in scm.Columns)
-                                                if (col.Name == s.Name)
-                                                {
-                                                    found = true;
-                                                    break;
-                                                }
-
-                                            if (!found)
-                                                issues.Add(new ValidationIssue(resource, ValidationStatus.Error, string.Format(Properties.Resources.LDF_SchemaMissingError, schema, fs.ResourceID)));
-
-                                        }
-
-                                    break;
-                                }
-
-                            if (!foundSchema)
-                                issues.Add(new ValidationIssue(resource, ValidationStatus.Error, string.Format(Properties.Resources.LDF_SchemaMissingError, schema, fs.ResourceID)));
-                            else if (!foundGeometry)
-                                issues.Add(new ValidationIssue(resource, ValidationStatus.Error, string.Format(Properties.Resources.LDF_GeometryMissingError, geometry, schema, fs.ResourceID)));
-                        }
-                    }
-                    catch (Exception)
-                    {
-                        issues.Add(new ValidationIssue(fs, ValidationStatus.Error, string.Format(Properties.Resources.LDF_SchemaAndColumnReadFailedError)));
-                    }
-                }
-                catch (Exception)
-                {
-                    issues.Add(new ValidationIssue(resource, ValidationStatus.Error, string.Format(Properties.Resources.LDF_FeatureSourceLoadError)));
-                }
-            }
-
-            return issues.ToArray();
-        }
     }
 }

Modified: sandbox/maestro-3.0/ExtendedModels/LayerDefinition-1.1.0/OSGeo.MapGuide.ObjectModels.LayerDefinition-1.1.0.csproj
===================================================================
--- sandbox/maestro-3.0/ExtendedModels/LayerDefinition-1.1.0/OSGeo.MapGuide.ObjectModels.LayerDefinition-1.1.0.csproj	2010-10-07 10:05:07 UTC (rev 5253)
+++ sandbox/maestro-3.0/ExtendedModels/LayerDefinition-1.1.0/OSGeo.MapGuide.ObjectModels.LayerDefinition-1.1.0.csproj	2010-10-07 12:42:50 UTC (rev 5254)
@@ -18,7 +18,7 @@
     <DebugType>full</DebugType>
     <Optimize>false</Optimize>
     <OutputPath>bin\Debug\</OutputPath>
-    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <DefineConstants>TRACE;DEBUG;LDF_110</DefineConstants>
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>
   </PropertyGroup>
@@ -26,20 +26,29 @@
     <DebugType>pdbonly</DebugType>
     <Optimize>true</Optimize>
     <OutputPath>bin\Release\</OutputPath>
-    <DefineConstants>TRACE</DefineConstants>
+    <DefineConstants>TRACE;LDF_110</DefineConstants>
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>
   </PropertyGroup>
   <ItemGroup>
     <Reference Include="System" />
     <Reference Include="System.Data" />
+    <Reference Include="System.Drawing" />
     <Reference Include="System.Xml" />
   </ItemGroup>
   <ItemGroup>
     <Compile Include="..\..\Generated\LayerDefinition-1.1.0.designer.cs">
       <Link>LayerDefinition-1.1.0.designer.cs</Link>
     </Compile>
-    <Compile Include="LayerDefinition.cs" />
+    <Compile Include="..\..\OSGeo.MapGuide.MaestroAPI\ObjectModels\GridLayerDefinitionImpl.cs">
+      <Link>GridLayerDefinitionImpl.cs</Link>
+    </Compile>
+    <Compile Include="..\..\OSGeo.MapGuide.MaestroAPI\ObjectModels\LayerFactory.cs">
+      <Link>LayerFactory.cs</Link>
+    </Compile>
+    <Compile Include="..\..\OSGeo.MapGuide.MaestroAPI\ObjectModels\VectorLayerDefinitionImpl.cs">
+      <Link>VectorLayerDefinitionImpl.cs</Link>
+    </Compile>
     <Compile Include="LayerDefinitionValidator.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
     <Compile Include="Properties\Resources.Designer.cs">

Modified: sandbox/maestro-3.0/ExtendedModels/LayerDefinition-1.1.0/Properties/Resources.Designer.cs
===================================================================
--- sandbox/maestro-3.0/ExtendedModels/LayerDefinition-1.1.0/Properties/Resources.Designer.cs	2010-10-07 10:05:07 UTC (rev 5253)
+++ sandbox/maestro-3.0/ExtendedModels/LayerDefinition-1.1.0/Properties/Resources.Designer.cs	2010-10-07 12:42:50 UTC (rev 5254)
@@ -1,7 +1,7 @@
 //------------------------------------------------------------------------------
 // <auto-generated>
 //     This code was generated by a tool.
-//     Runtime Version:2.0.50727.4927
+//     Runtime Version:2.0.50727.4952
 //
 //     Changes to this file may cause incorrect behavior and will be lost if
 //     the code is regenerated.
@@ -59,131 +59,5 @@
                 resourceCulture = value;
             }
         }
-        
-        /// <summary>
-        ///   Looks up a localized string similar to Only vector layers and raster layers are currently validated.
-        /// </summary>
-        internal static string LDF_DrawingLayerDefinitionNotSupportedWarning {
-            get {
-                return ResourceManager.GetString("LDF_DrawingLayerDefinitionNotSupportedWarning", resourceCulture);
-            }
-        }
-        
-        /// <summary>
-        ///   Looks up a localized string similar to Maestro does not support DrawingLayers.
-        /// </summary>
-        internal static string LDF_DrawingLayerNotSupportedWarning {
-            get {
-                return ResourceManager.GetString("LDF_DrawingLayerNotSupportedWarning", resourceCulture);
-            }
-        }
-        
-        /// <summary>
-        ///   Looks up a localized string similar to Failed to load featuresource.
-        /// </summary>
-        internal static string LDF_FeatureSourceLoadError {
-            get {
-                return ResourceManager.GetString("LDF_FeatureSourceLoadError", resourceCulture);
-            }
-        }
-        
-        /// <summary>
-        ///   Looks up a localized string similar to Failed to find geometry column {0} in schema {1} on featuresource {2}.
-        /// </summary>
-        internal static string LDF_GeometryMissingError {
-            get {
-                return ResourceManager.GetString("LDF_GeometryMissingError", resourceCulture);
-            }
-        }
-        
-        /// <summary>
-        ///   Looks up a localized string similar to Layer is missing core information.
-        /// </summary>
-        internal static string LDF_LayerNullError {
-            get {
-                return ResourceManager.GetString("LDF_LayerNullError", resourceCulture);
-            }
-        }
-        
-        /// <summary>
-        ///   Looks up a localized string similar to The minimum scale ({0}) is larger than the maximum scale ({1}).
-        /// </summary>
-        internal static string LDF_MinAndMaxScaleSwappedError {
-            get {
-                return ResourceManager.GetString("LDF_MinAndMaxScaleSwappedError", resourceCulture);
-            }
-        }
-        
-        /// <summary>
-        ///   Looks up a localized string similar to No FeatureSource is assigned to the layer.
-        /// </summary>
-        internal static string LDF_MissingFeatureSourceError {
-            get {
-                return ResourceManager.GetString("LDF_MissingFeatureSourceError", resourceCulture);
-            }
-        }
-        
-        /// <summary>
-        ///   Looks up a localized string similar to No Geometry is assigned to the layer.
-        /// </summary>
-        internal static string LDF_MissingGeometryError {
-            get {
-                return ResourceManager.GetString("LDF_MissingGeometryError", resourceCulture);
-            }
-        }
-        
-        /// <summary>
-        ///   Looks up a localized string similar to No scale ranges are defined, no data can be displayed.
-        /// </summary>
-        internal static string LDF_MissingScaleRangesError {
-            get {
-                return ResourceManager.GetString("LDF_MissingScaleRangesError", resourceCulture);
-            }
-        }
-        
-        /// <summary>
-        ///   Looks up a localized string similar to More than one scale ranges is defined, this is valid, but unsupported by Maestro.
-        /// </summary>
-        internal static string LDF_MultipleScaleRangesWarning {
-            get {
-                return ResourceManager.GetString("LDF_MultipleScaleRangesWarning", resourceCulture);
-            }
-        }
-        
-        /// <summary>
-        ///   Looks up a localized string similar to The scale range {0}-{1} overlaps the range {2}-{3}.
-        /// </summary>
-        internal static string LDF_ScaleRangesOverlapInformation {
-            get {
-                return ResourceManager.GetString("LDF_ScaleRangesOverlapInformation", resourceCulture);
-            }
-        }
-        
-        /// <summary>
-        ///   Looks up a localized string similar to Failed to validate column and schema.
-        /// </summary>
-        internal static string LDF_SchemaAndColumnReadFailedError {
-            get {
-                return ResourceManager.GetString("LDF_SchemaAndColumnReadFailedError", resourceCulture);
-            }
-        }
-        
-        /// <summary>
-        ///   Looks up a localized string similar to Failed to find schema {0} in featuresource {1}.
-        /// </summary>
-        internal static string LDF_SchemaMissingError {
-            get {
-                return ResourceManager.GetString("LDF_SchemaMissingError", resourceCulture);
-            }
-        }
-        
-        /// <summary>
-        ///   Looks up a localized string similar to The layer has no type, or the type is unsupported by Maestro.
-        /// </summary>
-        internal static string LDF_UnsupportedLayerTypeWarning {
-            get {
-                return ResourceManager.GetString("LDF_UnsupportedLayerTypeWarning", resourceCulture);
-            }
-        }
     }
 }

Modified: sandbox/maestro-3.0/ExtendedModels/LayerDefinition-1.1.0/Properties/Resources.resx
===================================================================
--- sandbox/maestro-3.0/ExtendedModels/LayerDefinition-1.1.0/Properties/Resources.resx	2010-10-07 10:05:07 UTC (rev 5253)
+++ sandbox/maestro-3.0/ExtendedModels/LayerDefinition-1.1.0/Properties/Resources.resx	2010-10-07 12:42:50 UTC (rev 5254)
@@ -117,60 +117,4 @@
   <resheader name="writer">
     <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
   </resheader>
-  <data name="LDF_DrawingLayerDefinitionNotSupportedWarning" xml:space="preserve">
-    <value>Only vector layers and raster layers are currently validated</value>
-    <comment>A warning message that is displayed if the layer is not Grid or Vector</comment>
-  </data>
-  <data name="LDF_DrawingLayerNotSupportedWarning" xml:space="preserve">
-    <value>Maestro does not support DrawingLayers</value>
-    <comment>A warning message that is displayed if the layer is a DrawingLayer type</comment>
-  </data>
-  <data name="LDF_FeatureSourceLoadError" xml:space="preserve">
-    <value>Failed to load featuresource</value>
-    <comment>An error message that is displayed if the featuresource fails to load</comment>
-  </data>
-  <data name="LDF_GeometryMissingError" xml:space="preserve">
-    <value>Failed to find geometry column {0} in schema {1} on featuresource {2}</value>
-    <comment>An error message that is displayed if the geometry is not present in the selected schema</comment>
-  </data>
-  <data name="LDF_LayerNullError" xml:space="preserve">
-    <value>Layer is missing core information</value>
-    <comment>An error message that is displayed if the layer has a null reference</comment>
-  </data>
-  <data name="LDF_MinAndMaxScaleSwappedError" xml:space="preserve">
-    <value>The minimum scale ({0}) is larger than the maximum scale ({1})</value>
-    <comment>An error message that is displayed if the scale ranges are reversed</comment>
-  </data>
-  <data name="LDF_MissingFeatureSourceError" xml:space="preserve">
-    <value>No FeatureSource is assigned to the layer</value>
-    <comment>An error message that is displayed if the layer has no FeatureSource</comment>
-  </data>
-  <data name="LDF_MissingGeometryError" xml:space="preserve">
-    <value>No Geometry is assigned to the layer</value>
-    <comment>An error message that is displayed if the layer has no geometry column selected</comment>
-  </data>
-  <data name="LDF_MissingScaleRangesError" xml:space="preserve">
-    <value>No scale ranges are defined, no data can be displayed</value>
-    <comment>An error message that is displayed if there are no scale ranges defined</comment>
-  </data>
-  <data name="LDF_MultipleScaleRangesWarning" xml:space="preserve">
-    <value>More than one scale ranges is defined, this is valid, but unsupported by Maestro</value>
-    <comment>A warning message that is displayed if a raster layer has multiple scale ranges defined</comment>
-  </data>
-  <data name="LDF_ScaleRangesOverlapInformation" xml:space="preserve">
-    <value>The scale range {0}-{1} overlaps the range {2}-{3}</value>
-    <comment>A warning message that is displayed if two scaleranges overlap</comment>
-  </data>
-  <data name="LDF_SchemaAndColumnReadFailedError" xml:space="preserve">
-    <value>Failed to validate column and schema</value>
-    <comment>An error message that is displayed if the schema and column read fails</comment>
-  </data>
-  <data name="LDF_SchemaMissingError" xml:space="preserve">
-    <value>Failed to find schema {0} in featuresource {1}</value>
-    <comment>An error message that is displayed if the selected schema is not present in the FeatureSource</comment>
-  </data>
-  <data name="LDF_UnsupportedLayerTypeWarning" xml:space="preserve">
-    <value>The layer has no type, or the type is unsupported by Maestro</value>
-    <comment>A  warning message that is displayed if the layer type is unknown</comment>
-  </data>
 </root>
\ No newline at end of file

Deleted: sandbox/maestro-3.0/ExtendedModels/LayerDefinition-1.2.0/LayerDefinition.cs
===================================================================
--- sandbox/maestro-3.0/ExtendedModels/LayerDefinition-1.2.0/LayerDefinition.cs	2010-10-07 10:05:07 UTC (rev 5253)
+++ sandbox/maestro-3.0/ExtendedModels/LayerDefinition-1.2.0/LayerDefinition.cs	2010-10-07 12:42:50 UTC (rev 5254)
@@ -1,266 +0,0 @@
-#region Disclaimer / License
-// Copyright (C) 2010, Jackie Ng
-// http://trac.osgeo.org/mapguide/wiki/maestro, jumpinjackie at gmail.com
-// 
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License, or (at your option) any later version.
-// 
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-// Lesser General Public License for more details.
-// 
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
-// 
-#endregion
-using System;
-using System.Collections.Generic;
-using System.Text;
-using OSGeo.MapGuide.ObjectModels.Common;
-using System.Xml.Serialization;
-using System.ComponentModel;
-using OSGeo.MapGuide.MaestroAPI.Resource;
-using OSGeo.MapGuide.MaestroAPI;
-using Ldf = OSGeo.MapGuide.ObjectModels.LayerDefinition;
-
-namespace OSGeo.MapGuide.ObjectModels.LayerDefinition_1_2_0
-{
-    abstract partial class BaseLayerDefinitionType : Ldf.ISubLayerDefinition
-    {
-        [XmlIgnore]
-        public abstract Ldf.LayerType LayerType { get; }
-    }
-
-    partial class VectorLayerDefinitionType : Ldf.IVectorLayerDefinition
-    {
-        public override Ldf.LayerType LayerType
-        {
-            get { return Ldf.LayerType.Vector; }
-        }
-
-        [XmlIgnore]
-        string Ldf.IVectorLayerDefinition.FeatureSourceID
-        {
-            get { return this.ResourceId; }
-            set { this.ResourceId = value; }
-        }
-
-        [XmlIgnore]
-        string Ldf.IVectorLayerDefinition.FullQualifiedClassName
-        {
-            get { return this.FeatureName; }
-            set { this.FeatureName = value; }
-        }
-
-        [XmlIgnore]
-        string Ldf.IVectorLayerDefinition.GeometryProperty
-        {
-            get { return this.Geometry; }
-            set { this.Geometry = value; }
-        }
-
-        [XmlIgnore]
-        string Ldf.IVectorLayerDefinition.Url
-        {
-            get { return this.Url; }
-            set { this.Url = value; }
-        }
-
-        [XmlIgnore]
-        string Ldf.IVectorLayerDefinition.ToolTip
-        {
-            get { return this.ToolTip; }
-            set { this.ToolTip = value; }
-        }
-
-        [XmlIgnore]
-        string Ldf.IVectorLayerDefinition.Filter
-        {
-            get { return this.Filter; }
-            set { this.Filter = value; }
-        }
-    }
-
-    partial class GridLayerDefinitionType : Ldf.IRasterLayerDefinition
-    {
-        public override Ldf.LayerType LayerType
-        {
-            get { return Ldf.LayerType.Raster; }
-        }
-
-        [XmlIgnore]
-        string Ldf.IRasterLayerDefinition.FeatureSourceID
-        {
-            get { return this.ResourceId; }
-            set { this.ResourceId = value; }
-        }
-
-        [XmlIgnore]
-        string Ldf.IRasterLayerDefinition.FullQualifiedClassName
-        {
-            get
-            {
-                return this.FeatureName;
-            }
-            set
-            {
-                this.FeatureName = value;
-            }
-        }
-
-        [XmlIgnore]
-        string Ldf.IRasterLayerDefinition.GeometryProperty
-        {
-            get
-            {
-                return this.Geometry;
-            }
-            set
-            {
-                this.Geometry = value;
-            }
-        }
-    }
-
-    partial class DrawingLayerDefinitionType : Ldf.IDrawingLayerDefinition
-    {
-        public override Ldf.LayerType LayerType
-        {
-            get { return Ldf.LayerType.Drawing; }
-        }
-
-        [XmlIgnore]
-        string Ldf.IDrawingLayerDefinition.DrawingSourceID
-        {
-            get { return this.ResourceId; }
-            set { this.ResourceId = value; }
-        }
-    }
-
-    partial class VectorScaleRangeType
-    {
-        #region Missing generated stuff
-        [EditorBrowsable(EditorBrowsableState.Never)]
-        private bool minScaleFieldSpecified;
-
-        [System.Xml.Serialization.XmlIgnoreAttribute()]
-        public bool MinScaleSpecified
-        {
-            get
-            {
-                return this.minScaleFieldSpecified;
-            }
-            set
-            {
-                if ((minScaleFieldSpecified.Equals(value) != true))
-                {
-                    this.minScaleFieldSpecified = value;
-                    this.OnPropertyChanged("MinScaleSpecified");
-                }
-            }
-        }
-        #endregion
-    }
-
-    partial class LayerDefinition : Ldf.ILayerDefinition
-    {
-        private static readonly Version RES_VERSION = new Version(1, 2, 0);
-
-        [XmlIgnore]
-        public OSGeo.MapGuide.MaestroAPI.IServerConnection CurrentConnection
-        {
-            get;
-            set;
-        }
-
-        private string _resId;
-
-        [XmlIgnore]
-        public string ResourceID
-        {
-            get
-            {
-                return _resId;
-            }
-            set
-            {
-                if (!ResourceIdentifier.Validate(value))
-                    throw new InvalidOperationException("Not a valid resource identifier"); //LOCALIZE
-
-                var res = new ResourceIdentifier(value);
-                if (res.Extension != ResourceTypes.LayerDefinition.ToString())
-                    throw new InvalidOperationException("Invalid resource identifier for this type of object: " + res.Extension); //LOCALIZE
-
-                _resId = value;
-                this.OnPropertyChanged("ResourceID");
-            }
-        }
-
-        [XmlIgnore]
-        public ResourceTypes ResourceType
-        {
-            get
-            {
-                return ResourceTypes.LayerDefinition;
-            }
-        }
-
-        [XmlIgnore]
-        public Version ResourceVersion
-        {
-            get
-            {
-                return RES_VERSION;
-            }
-        }
-
-        object ICloneable.Clone()
-        {
-            return this.Clone();
-        }
-
-        [XmlAttribute("noNamespaceSchemaLocation", Namespace = "http://www.w3.org/2001/XMLSchema-instance")]
-        public string ValidatingSchema
-        {
-            get { return "LayerDefinition-1.2.0.xsd"; }
-            set { }
-        }
-
-        [XmlIgnore]
-        public bool IsStronglyTyped
-        {
-            get { return true; }
-        }
-
-        /// <summary>
-        /// Returns the spatial extent of the data. 
-        /// This is calculated by asking the underlying featuresource for the minimum rectangle that
-        /// contains all the features in the specified table. If the <paramref name="allowFallbackToContextInformation"/>
-        /// is set to true, and the query fails, the code will attempt to read this information
-        /// from the spatial context information instead.
-        /// </summary>
-        /// <param name="allowFallbackToContextInformation">True to allow reading spatial extents from the spatial context information, if the spatial query fails.</param>
-        /// <returns>The envelope for the data in the table</returns>
-        public Envelope GetSpatialExtent(bool allowFallbackToContextInformation)
-        {
-            if (this.CurrentConnection == null)
-                throw new System.Exception("No server set for object");
-
-            if (this.Item as VectorLayerDefinitionType != null)
-                return this.CurrentConnection.FeatureService.GetSpatialExtent(this.Item.ResourceId, (this.Item as VectorLayerDefinitionType).FeatureName, (this.Item as VectorLayerDefinitionType).Geometry, allowFallbackToContextInformation);
-            else if (this.Item as GridLayerDefinitionType != null)
-                return this.CurrentConnection.FeatureService.GetSpatialExtent(this.Item.ResourceId, (this.Item as GridLayerDefinitionType).FeatureName, (this.Item as GridLayerDefinitionType).Geometry, allowFallbackToContextInformation);
-            else
-                return null;
-        }
-
-        public Ldf.ISubLayerDefinition SubLayer
-        {
-            get { return this.Item; }
-        }
-    }
-}

Modified: sandbox/maestro-3.0/ExtendedModels/LayerDefinition-1.2.0/LayerDefinitionValidator.cs
===================================================================
--- sandbox/maestro-3.0/ExtendedModels/LayerDefinition-1.2.0/LayerDefinitionValidator.cs	2010-10-07 10:05:07 UTC (rev 5253)
+++ sandbox/maestro-3.0/ExtendedModels/LayerDefinition-1.2.0/LayerDefinitionValidator.cs	2010-10-07 12:42:50 UTC (rev 5254)
@@ -26,149 +26,11 @@
 
 namespace OSGeo.MapGuide.ObjectModels.LayerDefinition_1_2_0
 {
-    public class LayerDefinitionValidator : IResourceValidator
+    public class LayerDefinitionValidator : BaseLayerDefinitionValidator
     {
-        public ResourceTypeDescriptor SupportedResourceAndVersion
+        public override ResourceTypeDescriptor SupportedResourceAndVersion
         {
             get { return new ResourceTypeDescriptor(OSGeo.MapGuide.MaestroAPI.ResourceTypes.LayerDefinition, "1.2.0"); }
         }
-
-        public ValidationIssue[] Validate(IResource resource, bool recurse)
-        {
-            if (resource.ResourceType != OSGeo.MapGuide.MaestroAPI.ResourceTypes.LayerDefinition)
-                return null;
-
-            if (resource.ResourceVersion != new Version(1, 2, 0))
-                return null;
-
-            LayerDefinition ldef = resource as LayerDefinition;
-            VectorLayerDefinitionType vldef = ldef.Item as VectorLayerDefinitionType;
-            GridLayerDefinitionType gldef = ldef.Item as GridLayerDefinitionType;
-            DrawingLayerDefinitionType dldef = ldef.Item as DrawingLayerDefinitionType;
-
-            List<ValidationIssue> issues = new List<ValidationIssue>();
-
-            if (ldef.Item == null)
-                issues.Add(new ValidationIssue(resource, ValidationStatus.Error, Properties.Resources.LDF_LayerNullError));
-            else if (vldef == null && gldef == null)
-                issues.Add(new ValidationIssue(resource, ValidationStatus.Warning, Properties.Resources.LDF_DrawingLayerDefinitionNotSupportedWarning));
-
-            if (vldef != null)
-            {
-                if (string.IsNullOrEmpty(vldef.FeatureName))
-                    issues.Add(new ValidationIssue(resource, ValidationStatus.Error, Properties.Resources.LDF_MissingFeatureSourceError));
-                if (string.IsNullOrEmpty(vldef.Geometry))
-                    issues.Add(new ValidationIssue(resource, ValidationStatus.Error, Properties.Resources.LDF_MissingGeometryError));
-
-                if (vldef.VectorScaleRange == null || vldef.VectorScaleRange.Count == 0)
-                    issues.Add(new ValidationIssue(resource, ValidationStatus.Error, Properties.Resources.LDF_MissingScaleRangesError));
-                else
-                {
-                    //Test for overlapping scale ranges
-                    List<KeyValuePair<double, double>> ranges = new List<KeyValuePair<double, double>>();
-                    foreach (VectorScaleRangeType vsr in vldef.VectorScaleRange)
-                        ranges.Add(new KeyValuePair<double, double>(
-                            vsr.MaxScaleSpecified ? vsr.MaxScale : double.PositiveInfinity,
-                            vsr.MinScaleSpecified ? vsr.MinScale : double.NegativeInfinity));
-
-                    double min = double.PositiveInfinity;
-                    double max = double.NegativeInfinity;
-                    foreach (KeyValuePair<double, double> sr in ranges)
-                    {
-                        min = Math.Min(min, sr.Value);
-                        max = Math.Max(max, sr.Key);
-                        if (sr.Key < sr.Value)
-                            issues.Add(new ValidationIssue(resource, ValidationStatus.Error, string.Format(Properties.Resources.LDF_MinAndMaxScaleSwappedError, sr.Value, sr.Key)));
-                    }
-
-                    //TODO: Detect gaps in scale ranges
-                    for (int i = 0; i < ranges.Count; i++)
-                        for (int j = i + 1; j < ranges.Count; j++)
-                            if (ranges[i].Key > ranges[j].Value || ranges[i].Value > ranges[j].Value)
-                                issues.Add(new ValidationIssue(resource, ValidationStatus.Information, string.Format(Properties.Resources.LDF_ScaleRangesOverlapInformation, ranges[i].Value, ranges[i].Key, ranges[j].Value, ranges[j].Key)));
-
-                }
-            }
-            else if (gldef != null)
-            {
-                if (gldef.GridScaleRange == null || gldef.GridScaleRange.Count == 0)
-                    issues.Add(new ValidationIssue(resource, ValidationStatus.Error, Properties.Resources.LDF_MissingScaleRangesError));
-                else if (gldef.GridScaleRange.Count != 1)
-                    issues.Add(new ValidationIssue(resource, ValidationStatus.Warning, Properties.Resources.LDF_MultipleScaleRangesWarning));
-            }
-            else if (dldef != null)
-                issues.Add(new ValidationIssue(resource, ValidationStatus.Warning, Properties.Resources.LDF_DrawingLayerNotSupportedWarning));
-            else
-                issues.Add(new ValidationIssue(resource, ValidationStatus.Warning, Properties.Resources.LDF_UnsupportedLayerTypeWarning));
-
-            if (recurse)
-            {
-                try
-                {
-                    FeatureSourceType fs = (FeatureSourceType)ldef.CurrentConnection.ResourceService.GetResource(ldef.Item.ResourceId);
-                    issues.AddRange(ResourceValidatorSet.Validate(fs, recurse));
-
-                    try
-                    {
-                        if (vldef != null || gldef != null)
-                        {
-                            string schema = vldef == null ? gldef.FeatureName : vldef.FeatureName;
-                            string geometry = vldef == null ? gldef.Geometry : vldef.Geometry;
-
-                            bool foundSchema = false;
-                            bool foundGeometry = false;
-
-                            FeatureSourceDescription desc = fs.Describe();
-                            foreach (FeatureSourceDescription.FeatureSourceSchema scm in desc.Schemas)
-                                if (scm.FullnameDecoded == schema)
-                                {
-                                    foundSchema = true;
-
-                                    foreach (FeatureSetColumn col in scm.Columns)
-                                        if (col.Name == geometry)
-                                        {
-                                            foundGeometry = true;
-                                            break;
-                                        }
-
-
-                                    if (vldef != null && vldef.PropertyMapping != null)
-                                        foreach (NameStringPairType s in vldef.PropertyMapping)
-                                        {
-                                            bool found = false;
-                                            foreach (FeatureSetColumn col in scm.Columns)
-                                                if (col.Name == s.Name)
-                                                {
-                                                    found = true;
-                                                    break;
-                                                }
-
-                                            if (!found)
-                                                issues.Add(new ValidationIssue(resource, ValidationStatus.Error, string.Format(Properties.Resources.LDF_SchemaMissingError, schema, fs.ResourceID)));
-
-                                        }
-
-                                    break;
-                                }
-
-                            if (!foundSchema)
-                                issues.Add(new ValidationIssue(resource, ValidationStatus.Error, string.Format(Properties.Resources.LDF_SchemaMissingError, schema, fs.ResourceID)));
-                            else if (!foundGeometry)
-                                issues.Add(new ValidationIssue(resource, ValidationStatus.Error, string.Format(Properties.Resources.LDF_GeometryMissingError, geometry, schema, fs.ResourceID)));
-                        }
-                    }
-                    catch (Exception)
-                    {
-                        issues.Add(new ValidationIssue(fs, ValidationStatus.Error, string.Format(Properties.Resources.LDF_SchemaAndColumnReadFailedError)));
-                    }
-                }
-                catch (Exception)
-                {
-                    issues.Add(new ValidationIssue(resource, ValidationStatus.Error, string.Format(Properties.Resources.LDF_FeatureSourceLoadError)));
-                }
-            }
-
-            return issues.ToArray();
-        }
     }
 }

Modified: sandbox/maestro-3.0/ExtendedModels/LayerDefinition-1.2.0/OSGeo.MapGuide.ObjectModels.LayerDefinition-1.2.0.csproj
===================================================================
--- sandbox/maestro-3.0/ExtendedModels/LayerDefinition-1.2.0/OSGeo.MapGuide.ObjectModels.LayerDefinition-1.2.0.csproj	2010-10-07 10:05:07 UTC (rev 5253)
+++ sandbox/maestro-3.0/ExtendedModels/LayerDefinition-1.2.0/OSGeo.MapGuide.ObjectModels.LayerDefinition-1.2.0.csproj	2010-10-07 12:42:50 UTC (rev 5254)
@@ -18,7 +18,7 @@
     <DebugType>full</DebugType>
     <Optimize>false</Optimize>
     <OutputPath>bin\Debug\</OutputPath>
-    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <DefineConstants>TRACE;DEBUG;LDF_120</DefineConstants>
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>
   </PropertyGroup>
@@ -26,20 +26,29 @@
     <DebugType>pdbonly</DebugType>
     <Optimize>true</Optimize>
     <OutputPath>bin\Release\</OutputPath>
-    <DefineConstants>TRACE</DefineConstants>
+    <DefineConstants>TRACE;LDF_120</DefineConstants>
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>
   </PropertyGroup>
   <ItemGroup>
     <Reference Include="System" />
     <Reference Include="System.Data" />
+    <Reference Include="System.Drawing" />
     <Reference Include="System.Xml" />
   </ItemGroup>
   <ItemGroup>
     <Compile Include="..\..\Generated\LayerDefinition-1.2.0.designer.cs">
       <Link>LayerDefinition-1.2.0.designer.cs</Link>
     </Compile>
-    <Compile Include="LayerDefinition.cs" />
+    <Compile Include="..\..\OSGeo.MapGuide.MaestroAPI\ObjectModels\GridLayerDefinitionImpl.cs">
+      <Link>GridLayerDefinitionImpl.cs</Link>
+    </Compile>
+    <Compile Include="..\..\OSGeo.MapGuide.MaestroAPI\ObjectModels\LayerFactory.cs">
+      <Link>LayerFactory.cs</Link>
+    </Compile>
+    <Compile Include="..\..\OSGeo.MapGuide.MaestroAPI\ObjectModels\VectorLayerDefinitionImpl.cs">
+      <Link>VectorLayerDefinitionImpl.cs</Link>
+    </Compile>
     <Compile Include="LayerDefinitionValidator.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
     <Compile Include="Properties\Resources.Designer.cs">

Modified: sandbox/maestro-3.0/ExtendedModels/LayerDefinition-1.2.0/Properties/Resources.Designer.cs
===================================================================
--- sandbox/maestro-3.0/ExtendedModels/LayerDefinition-1.2.0/Properties/Resources.Designer.cs	2010-10-07 10:05:07 UTC (rev 5253)
+++ sandbox/maestro-3.0/ExtendedModels/LayerDefinition-1.2.0/Properties/Resources.Designer.cs	2010-10-07 12:42:50 UTC (rev 5254)
@@ -1,7 +1,7 @@
 //------------------------------------------------------------------------------
 // <auto-generated>
 //     This code was generated by a tool.
-//     Runtime Version:2.0.50727.4927
+//     Runtime Version:2.0.50727.4952
 //
 //     Changes to this file may cause incorrect behavior and will be lost if
 //     the code is regenerated.
@@ -59,131 +59,5 @@
                 resourceCulture = value;
             }
         }
-        
-        /// <summary>
-        ///   Looks up a localized string similar to Only vector layers and raster layers are currently validated.
-        /// </summary>
-        internal static string LDF_DrawingLayerDefinitionNotSupportedWarning {
-            get {
-                return ResourceManager.GetString("LDF_DrawingLayerDefinitionNotSupportedWarning", resourceCulture);
-            }
-        }
-        
-        /// <summary>
-        ///   Looks up a localized string similar to Maestro does not support DrawingLayers.
-        /// </summary>
-        internal static string LDF_DrawingLayerNotSupportedWarning {
-            get {
-                return ResourceManager.GetString("LDF_DrawingLayerNotSupportedWarning", resourceCulture);
-            }
-        }
-        
-        /// <summary>
-        ///   Looks up a localized string similar to Failed to load featuresource.
-        /// </summary>
-        internal static string LDF_FeatureSourceLoadError {
-            get {
-                return ResourceManager.GetString("LDF_FeatureSourceLoadError", resourceCulture);
-            }
-        }
-        
-        /// <summary>
-        ///   Looks up a localized string similar to Failed to find geometry column {0} in schema {1} on featuresource {2}.
-        /// </summary>
-        internal static string LDF_GeometryMissingError {
-            get {
-                return ResourceManager.GetString("LDF_GeometryMissingError", resourceCulture);
-            }
-        }
-        
-        /// <summary>
-        ///   Looks up a localized string similar to Layer is missing core information.
-        /// </summary>
-        internal static string LDF_LayerNullError {
-            get {
-                return ResourceManager.GetString("LDF_LayerNullError", resourceCulture);
-            }
-        }
-        
-        /// <summary>
-        ///   Looks up a localized string similar to The minimum scale ({0}) is larger than the maximum scale ({1}).
-        /// </summary>
-        internal static string LDF_MinAndMaxScaleSwappedError {
-            get {
-                return ResourceManager.GetString("LDF_MinAndMaxScaleSwappedError", resourceCulture);
-            }
-        }
-        
-        /// <summary>
-        ///   Looks up a localized string similar to No FeatureSource is assigned to the layer.
-        /// </summary>
-        internal static string LDF_MissingFeatureSourceError {
-            get {
-                return ResourceManager.GetString("LDF_MissingFeatureSourceError", resourceCulture);
-            }
-        }
-        
-        /// <summary>
-        ///   Looks up a localized string similar to No Geometry is assigned to the layer.
-        /// </summary>
-        internal static string LDF_MissingGeometryError {
-            get {
-                return ResourceManager.GetString("LDF_MissingGeometryError", resourceCulture);
-            }
-        }
-        
-        /// <summary>
-        ///   Looks up a localized string similar to No scale ranges are defined, no data can be displayed.
-        /// </summary>
-        internal static string LDF_MissingScaleRangesError {
-            get {
-                return ResourceManager.GetString("LDF_MissingScaleRangesError", resourceCulture);
-            }
-        }
-        
-        /// <summary>
-        ///   Looks up a localized string similar to More than one scale ranges is defined, this is valid, but unsupported by Maestro.
-        /// </summary>
-        internal static string LDF_MultipleScaleRangesWarning {
-            get {
-                return ResourceManager.GetString("LDF_MultipleScaleRangesWarning", resourceCulture);
-            }
-        }
-        
-        /// <summary>
-        ///   Looks up a localized string similar to The scale range {0}-{1} overlaps the range {2}-{3}.
-        /// </summary>
-        internal static string LDF_ScaleRangesOverlapInformation {
-            get {
-                return ResourceManager.GetString("LDF_ScaleRangesOverlapInformation", resourceCulture);
-            }
-        }
-        
-        /// <summary>
-        ///   Looks up a localized string similar to Failed to validate column and schema.
-        /// </summary>
-        internal static string LDF_SchemaAndColumnReadFailedError {
-            get {
-                return ResourceManager.GetString("LDF_SchemaAndColumnReadFailedError", resourceCulture);
-            }
-        }
-        
-        /// <summary>
-        ///   Looks up a localized string similar to Failed to find schema {0} in featuresource {1}.
-        /// </summary>
-        internal static string LDF_SchemaMissingError {
-            get {
-                return ResourceManager.GetString("LDF_SchemaMissingError", resourceCulture);
-            }
-        }
-        
-        /// <summary>
-        ///   Looks up a localized string similar to The layer has no type, or the type is unsupported by Maestro.
-        /// </summary>
-        internal static string LDF_UnsupportedLayerTypeWarning {
-            get {
-                return ResourceManager.GetString("LDF_UnsupportedLayerTypeWarning", resourceCulture);
-            }
-        }
     }
 }

Modified: sandbox/maestro-3.0/ExtendedModels/LayerDefinition-1.2.0/Properties/Resources.resx
===================================================================
--- sandbox/maestro-3.0/ExtendedModels/LayerDefinition-1.2.0/Properties/Resources.resx	2010-10-07 10:05:07 UTC (rev 5253)
+++ sandbox/maestro-3.0/ExtendedModels/LayerDefinition-1.2.0/Properties/Resources.resx	2010-10-07 12:42:50 UTC (rev 5254)
@@ -117,60 +117,4 @@
   <resheader name="writer">
     <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
   </resheader>
-  <data name="LDF_DrawingLayerDefinitionNotSupportedWarning" xml:space="preserve">
-    <value>Only vector layers and raster layers are currently validated</value>
-    <comment>A warning message that is displayed if the layer is not Grid or Vector</comment>
-  </data>
-  <data name="LDF_DrawingLayerNotSupportedWarning" xml:space="preserve">
-    <value>Maestro does not support DrawingLayers</value>
-    <comment>A warning message that is displayed if the layer is a DrawingLayer type</comment>
-  </data>
-  <data name="LDF_FeatureSourceLoadError" xml:space="preserve">
-    <value>Failed to load featuresource</value>
-    <comment>An error message that is displayed if the featuresource fails to load</comment>
-  </data>
-  <data name="LDF_GeometryMissingError" xml:space="preserve">
-    <value>Failed to find geometry column {0} in schema {1} on featuresource {2}</value>
-    <comment>An error message that is displayed if the geometry is not present in the selected schema</comment>
-  </data>
-  <data name="LDF_LayerNullError" xml:space="preserve">
-    <value>Layer is missing core information</value>
-    <comment>An error message that is displayed if the layer has a null reference</comment>
-  </data>
-  <data name="LDF_MinAndMaxScaleSwappedError" xml:space="preserve">
-    <value>The minimum scale ({0}) is larger than the maximum scale ({1})</value>
-    <comment>An error message that is displayed if the scale ranges are reversed</comment>
-  </data>
-  <data name="LDF_MissingFeatureSourceError" xml:space="preserve">
-    <value>No FeatureSource is assigned to the layer</value>
-    <comment>An error message that is displayed if the layer has no FeatureSource</comment>
-  </data>
-  <data name="LDF_MissingGeometryError" xml:space="preserve">
-    <value>No Geometry is assigned to the layer</value>
-    <comment>An error message that is displayed if the layer has no geometry column selected</comment>
-  </data>
-  <data name="LDF_MissingScaleRangesError" xml:space="preserve">
-    <value>No scale ranges are defined, no data can be displayed</value>
-    <comment>An error message that is displayed if there are no scale ranges defined</comment>
-  </data>
-  <data name="LDF_MultipleScaleRangesWarning" xml:space="preserve">
-    <value>More than one scale ranges is defined, this is valid, but unsupported by Maestro</value>
-    <comment>A warning message that is displayed if a raster layer has multiple scale ranges defined</comment>
-  </data>
-  <data name="LDF_ScaleRangesOverlapInformation" xml:space="preserve">
-    <value>The scale range {0}-{1} overlaps the range {2}-{3}</value>
-    <comment>A warning message that is displayed if two scaleranges overlap</comment>
-  </data>
-  <data name="LDF_SchemaAndColumnReadFailedError" xml:space="preserve">
-    <value>Failed to validate column and schema</value>
-    <comment>An error message that is displayed if the schema and column read fails</comment>
-  </data>
-  <data name="LDF_SchemaMissingError" xml:space="preserve">
-    <value>Failed to find schema {0} in featuresource {1}</value>
-    <comment>An error message that is displayed if the selected schema is not present in the FeatureSource</comment>
-  </data>
-  <data name="LDF_UnsupportedLayerTypeWarning" xml:space="preserve">
-    <value>The layer has no type, or the type is unsupported by Maestro</value>
-    <comment>A  warning message that is displayed if the layer type is unknown</comment>
-  </data>
 </root>
\ No newline at end of file

Deleted: sandbox/maestro-3.0/ExtendedModels/LayerDefinition-1.3.0/LayerDefinition.cs
===================================================================
--- sandbox/maestro-3.0/ExtendedModels/LayerDefinition-1.3.0/LayerDefinition.cs	2010-10-07 10:05:07 UTC (rev 5253)
+++ sandbox/maestro-3.0/ExtendedModels/LayerDefinition-1.3.0/LayerDefinition.cs	2010-10-07 12:42:50 UTC (rev 5254)
@@ -1,266 +0,0 @@
-#region Disclaimer / License
-// Copyright (C) 2010, Jackie Ng
-// http://trac.osgeo.org/mapguide/wiki/maestro, jumpinjackie at gmail.com
-// 
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License, or (at your option) any later version.
-// 
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-// Lesser General Public License for more details.
-// 
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
-// 
-#endregion
-using System;
-using System.Collections.Generic;
-using System.Text;
-using OSGeo.MapGuide.ObjectModels.Common;
-using System.Xml.Serialization;
-using System.ComponentModel;
-using OSGeo.MapGuide.MaestroAPI.Resource;
-using OSGeo.MapGuide.MaestroAPI;
-using Ldf = OSGeo.MapGuide.ObjectModels.LayerDefinition;
-
-namespace OSGeo.MapGuide.ObjectModels.LayerDefinition_1_3_0
-{
-    abstract partial class BaseLayerDefinitionType : Ldf.ISubLayerDefinition
-    {
-        [XmlIgnore]
-        public abstract Ldf.LayerType LayerType { get; }
-    }
-
-    partial class VectorLayerDefinitionType : Ldf.IVectorLayerDefinition
-    {
-        public override Ldf.LayerType LayerType
-        {
-            get { return Ldf.LayerType.Vector; }
-        }
-
-        [XmlIgnore]
-        string Ldf.IVectorLayerDefinition.FeatureSourceID
-        {
-            get { return this.ResourceId; }
-            set { this.ResourceId = value; }
-        }
-
-        [XmlIgnore]
-        string Ldf.IVectorLayerDefinition.FullQualifiedClassName
-        {
-            get { return this.FeatureName; }
-            set { this.FeatureName = value; }
-        }
-
-        [XmlIgnore]
-        string Ldf.IVectorLayerDefinition.GeometryProperty
-        {
-            get { return this.Geometry; }
-            set { this.Geometry = value; }
-        }
-
-        [XmlIgnore]
-        string Ldf.IVectorLayerDefinition.Url
-        {
-            get { return this.Url; }
-            set { this.Url = value; }
-        }
-
-        [XmlIgnore]
-        string Ldf.IVectorLayerDefinition.ToolTip
-        {
-            get { return this.ToolTip; }
-            set { this.ToolTip = value; }
-        }
-
-        [XmlIgnore]
-        string Ldf.IVectorLayerDefinition.Filter
-        {
-            get { return this.Filter; }
-            set { this.Filter = value; }
-        }
-    }
-
-    partial class GridLayerDefinitionType : Ldf.IRasterLayerDefinition
-    {
-        public override Ldf.LayerType LayerType
-        {
-            get { return Ldf.LayerType.Raster; }
-        }
-
-        [XmlIgnore]
-        string Ldf.IRasterLayerDefinition.FeatureSourceID
-        {
-            get { return this.ResourceId; }
-            set { this.ResourceId = value; }
-        }
-
-        [XmlIgnore]
-        string Ldf.IRasterLayerDefinition.FullQualifiedClassName
-        {
-            get
-            {
-                return this.FeatureName;
-            }
-            set
-            {
-                this.FeatureName = value;
-            }
-        }
-
-        [XmlIgnore]
-        string Ldf.IRasterLayerDefinition.GeometryProperty
-        {
-            get
-            {
-                return this.Geometry;
-            }
-            set
-            {
-                this.Geometry = value;
-            }
-        }
-    }
-
-    partial class DrawingLayerDefinitionType : Ldf.IDrawingLayerDefinition
-    {
-        public override Ldf.LayerType LayerType
-        {
-            get { return Ldf.LayerType.Drawing; }
-        }
-
-        [XmlIgnore]
-        string Ldf.IDrawingLayerDefinition.DrawingSourceID
-        {
-            get { return this.ResourceId; }
-            set { this.ResourceId = value; }
-        }
-    }
-
-    partial class VectorScaleRangeType
-    {
-        #region Missing generated stuff
-        [EditorBrowsable(EditorBrowsableState.Never)]
-        private bool minScaleFieldSpecified;
-
-        [System.Xml.Serialization.XmlIgnoreAttribute()]
-        public bool MinScaleSpecified
-        {
-            get
-            {
-                return this.minScaleFieldSpecified;
-            }
-            set
-            {
-                if ((minScaleFieldSpecified.Equals(value) != true))
-                {
-                    this.minScaleFieldSpecified = value;
-                    this.OnPropertyChanged("MinScaleSpecified");
-                }
-            }
-        }
-        #endregion
-    }
-
-    partial class LayerDefinition : Ldf.ILayerDefinition
-    {
-        private static readonly Version RES_VERSION = new Version(1, 3, 0);
-
-        [XmlIgnore]
-        public OSGeo.MapGuide.MaestroAPI.IServerConnection CurrentConnection
-        {
-            get;
-            set;
-        }
-
-        private string _resId;
-
-        [XmlIgnore]
-        public string ResourceID
-        {
-            get
-            {
-                return _resId;
-            }
-            set
-            {
-                if (!ResourceIdentifier.Validate(value))
-                    throw new InvalidOperationException("Not a valid resource identifier"); //LOCALIZE
-
-                var res = new ResourceIdentifier(value);
-                if (res.Extension != ResourceTypes.LayerDefinition.ToString())
-                    throw new InvalidOperationException("Invalid resource identifier for this type of object: " + res.Extension); //LOCALIZE
-
-                _resId = value;
-                this.OnPropertyChanged("ResourceID");
-            }
-        }
-
-        [XmlIgnore]
-        public ResourceTypes ResourceType
-        {
-            get
-            {
-                return ResourceTypes.LayerDefinition;
-            }
-        }
-
-        [XmlIgnore]
-        public Version ResourceVersion
-        {
-            get
-            {
-                return RES_VERSION;
-            }
-        }
-
-        object ICloneable.Clone()
-        {
-            return this.Clone();
-        }
-
-        [XmlAttribute("noNamespaceSchemaLocation", Namespace = "http://www.w3.org/2001/XMLSchema-instance")]
-        public string ValidatingSchema
-        {
-            get { return "LayerDefinition-1.3.0.xsd"; }
-            set { }
-        }
-
-        [XmlIgnore]
-        public bool IsStronglyTyped
-        {
-            get { return true; }
-        }
-
-        /// <summary>
-        /// Returns the spatial extent of the data. 
-        /// This is calculated by asking the underlying featuresource for the minimum rectangle that
-        /// contains all the features in the specified table. If the <paramref name="allowFallbackToContextInformation"/>
-        /// is set to true, and the query fails, the code will attempt to read this information
-        /// from the spatial context information instead.
-        /// </summary>
-        /// <param name="allowFallbackToContextInformation">True to allow reading spatial extents from the spatial context information, if the spatial query fails.</param>
-        /// <returns>The envelope for the data in the table</returns>
-        public Envelope GetSpatialExtent(bool allowFallbackToContextInformation)
-        {
-            if (this.CurrentConnection == null)
-                throw new System.Exception("No server set for object");
-
-            if (this.Item as VectorLayerDefinitionType != null)
-                return this.CurrentConnection.FeatureService.GetSpatialExtent(this.Item.ResourceId, (this.Item as VectorLayerDefinitionType).FeatureName, (this.Item as VectorLayerDefinitionType).Geometry, allowFallbackToContextInformation);
-            else if (this.Item as GridLayerDefinitionType != null)
-                return this.CurrentConnection.FeatureService.GetSpatialExtent(this.Item.ResourceId, (this.Item as GridLayerDefinitionType).FeatureName, (this.Item as GridLayerDefinitionType).Geometry, allowFallbackToContextInformation);
-            else
-                return null;
-        }
-
-        public Ldf.ISubLayerDefinition SubLayer
-        {
-            get { return this.Item; }
-        }
-    }
-}

Modified: sandbox/maestro-3.0/ExtendedModels/LayerDefinition-1.3.0/LayerDefinitionValidator.cs
===================================================================
--- sandbox/maestro-3.0/ExtendedModels/LayerDefinition-1.3.0/LayerDefinitionValidator.cs	2010-10-07 10:05:07 UTC (rev 5253)
+++ sandbox/maestro-3.0/ExtendedModels/LayerDefinition-1.3.0/LayerDefinitionValidator.cs	2010-10-07 12:42:50 UTC (rev 5254)
@@ -26,149 +26,11 @@
 
 namespace OSGeo.MapGuide.ObjectModels.LayerDefinition_1_3_0
 {
-    public class LayerDefinitionValidator : IResourceValidator
+    public class LayerDefinitionValidator : BaseLayerDefinitionValidator
     {
-        public ResourceTypeDescriptor SupportedResourceAndVersion
+        public override ResourceTypeDescriptor SupportedResourceAndVersion
         {
             get { return new ResourceTypeDescriptor(OSGeo.MapGuide.MaestroAPI.ResourceTypes.LayerDefinition, "1.3.0"); }
         }
-
-        public ValidationIssue[] Validate(IResource resource, bool recurse)
-        {
-            if (resource.ResourceType != OSGeo.MapGuide.MaestroAPI.ResourceTypes.LayerDefinition)
-                return null;
-
-            if (resource.ResourceVersion != new Version(1, 3, 0))
-                return null;
-
-            LayerDefinition ldef = resource as LayerDefinition;
-            VectorLayerDefinitionType vldef = ldef.Item as VectorLayerDefinitionType;
-            GridLayerDefinitionType gldef = ldef.Item as GridLayerDefinitionType;
-            DrawingLayerDefinitionType dldef = ldef.Item as DrawingLayerDefinitionType;
-
-            List<ValidationIssue> issues = new List<ValidationIssue>();
-
-            if (ldef.Item == null)
-                issues.Add(new ValidationIssue(resource, ValidationStatus.Error, Properties.Resources.LDF_LayerNullError));
-            else if (vldef == null && gldef == null)
-                issues.Add(new ValidationIssue(resource, ValidationStatus.Warning, Properties.Resources.LDF_DrawingLayerDefinitionNotSupportedWarning));
-
-            if (vldef != null)
-            {
-                if (string.IsNullOrEmpty(vldef.FeatureName))
-                    issues.Add(new ValidationIssue(resource, ValidationStatus.Error, Properties.Resources.LDF_MissingFeatureSourceError));
-                if (string.IsNullOrEmpty(vldef.Geometry))
-                    issues.Add(new ValidationIssue(resource, ValidationStatus.Error, Properties.Resources.LDF_MissingGeometryError));
-
-                if (vldef.VectorScaleRange == null || vldef.VectorScaleRange.Count == 0)
-                    issues.Add(new ValidationIssue(resource, ValidationStatus.Error, Properties.Resources.LDF_MissingScaleRangesError));
-                else
-                {
-                    //Test for overlapping scale ranges
-                    List<KeyValuePair<double, double>> ranges = new List<KeyValuePair<double, double>>();
-                    foreach (VectorScaleRangeType vsr in vldef.VectorScaleRange)
-                        ranges.Add(new KeyValuePair<double, double>(
-                            vsr.MaxScaleSpecified ? vsr.MaxScale : double.PositiveInfinity,
-                            vsr.MinScaleSpecified ? vsr.MinScale : double.NegativeInfinity));
-
-                    double min = double.PositiveInfinity;
-                    double max = double.NegativeInfinity;
-                    foreach (KeyValuePair<double, double> sr in ranges)
-                    {
-                        min = Math.Min(min, sr.Value);
-                        max = Math.Max(max, sr.Key);
-                        if (sr.Key < sr.Value)
-                            issues.Add(new ValidationIssue(resource, ValidationStatus.Error, string.Format(Properties.Resources.LDF_MinAndMaxScaleSwappedError, sr.Value, sr.Key)));
-                    }
-
-                    //TODO: Detect gaps in scale ranges
-                    for (int i = 0; i < ranges.Count; i++)
-                        for (int j = i + 1; j < ranges.Count; j++)
-                            if (ranges[i].Key > ranges[j].Value || ranges[i].Value > ranges[j].Value)
-                                issues.Add(new ValidationIssue(resource, ValidationStatus.Information, string.Format(Properties.Resources.LDF_ScaleRangesOverlapInformation, ranges[i].Value, ranges[i].Key, ranges[j].Value, ranges[j].Key)));
-
-                }
-            }
-            else if (gldef != null)
-            {
-                if (gldef.GridScaleRange == null || gldef.GridScaleRange.Count == 0)
-                    issues.Add(new ValidationIssue(resource, ValidationStatus.Error, Properties.Resources.LDF_MissingScaleRangesError));
-                else if (gldef.GridScaleRange.Count != 1)
-                    issues.Add(new ValidationIssue(resource, ValidationStatus.Warning, Properties.Resources.LDF_MultipleScaleRangesWarning));
-            }
-            else if (dldef != null)
-                issues.Add(new ValidationIssue(resource, ValidationStatus.Warning, Properties.Resources.LDF_DrawingLayerNotSupportedWarning));
-            else
-                issues.Add(new ValidationIssue(resource, ValidationStatus.Warning, Properties.Resources.LDF_UnsupportedLayerTypeWarning));
-
-            if (recurse)
-            {
-                try
-                {
-                    FeatureSourceType fs = (FeatureSourceType)ldef.CurrentConnection.ResourceService.GetResource(ldef.Item.ResourceId);
-                    issues.AddRange(ResourceValidatorSet.Validate(fs, recurse));
-
-                    try
-                    {
-                        if (vldef != null || gldef != null)
-                        {
-                            string schema = vldef == null ? gldef.FeatureName : vldef.FeatureName;
-                            string geometry = vldef == null ? gldef.Geometry : vldef.Geometry;
-
-                            bool foundSchema = false;
-                            bool foundGeometry = false;
-
-                            FeatureSourceDescription desc = fs.Describe();
-                            foreach (FeatureSourceDescription.FeatureSourceSchema scm in desc.Schemas)
-                                if (scm.FullnameDecoded == schema)
-                                {
-                                    foundSchema = true;
-
-                                    foreach (FeatureSetColumn col in scm.Columns)
-                                        if (col.Name == geometry)
-                                        {
-                                            foundGeometry = true;
-                                            break;
-                                        }
-
-
-                                    if (vldef != null && vldef.PropertyMapping != null)
-                                        foreach (NameStringPairType s in vldef.PropertyMapping)
-                                        {
-                                            bool found = false;
-                                            foreach (FeatureSetColumn col in scm.Columns)
-                                                if (col.Name == s.Name)
-                                                {
-                                                    found = true;
-                                                    break;
-                                                }
-
-                                            if (!found)
-                                                issues.Add(new ValidationIssue(resource, ValidationStatus.Error, string.Format(Properties.Resources.LDF_SchemaMissingError, schema, fs.ResourceID)));
-
-                                        }
-
-                                    break;
-                                }
-
-                            if (!foundSchema)
-                                issues.Add(new ValidationIssue(resource, ValidationStatus.Error, string.Format(Properties.Resources.LDF_SchemaMissingError, schema, fs.ResourceID)));
-                            else if (!foundGeometry)
-                                issues.Add(new ValidationIssue(resource, ValidationStatus.Error, string.Format(Properties.Resources.LDF_GeometryMissingError, geometry, schema, fs.ResourceID)));
-                        }
-                    }
-                    catch (Exception)
-                    {
-                        issues.Add(new ValidationIssue(fs, ValidationStatus.Error, string.Format(Properties.Resources.LDF_SchemaAndColumnReadFailedError)));
-                    }
-                }
-                catch (Exception)
-                {
-                    issues.Add(new ValidationIssue(resource, ValidationStatus.Error, string.Format(Properties.Resources.LDF_FeatureSourceLoadError)));
-                }
-            }
-
-            return issues.ToArray();
-        }
     }
 }

Modified: sandbox/maestro-3.0/ExtendedModels/LayerDefinition-1.3.0/OSGeo.MapGuide.ObjectModels.LayerDefinition-1.3.0.csproj
===================================================================
--- sandbox/maestro-3.0/ExtendedModels/LayerDefinition-1.3.0/OSGeo.MapGuide.ObjectModels.LayerDefinition-1.3.0.csproj	2010-10-07 10:05:07 UTC (rev 5253)
+++ sandbox/maestro-3.0/ExtendedModels/LayerDefinition-1.3.0/OSGeo.MapGuide.ObjectModels.LayerDefinition-1.3.0.csproj	2010-10-07 12:42:50 UTC (rev 5254)
@@ -18,7 +18,7 @@
     <DebugType>full</DebugType>
     <Optimize>false</Optimize>
     <OutputPath>bin\Debug\</OutputPath>
-    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <DefineConstants>TRACE;DEBUG;LDF_130</DefineConstants>
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>
   </PropertyGroup>
@@ -26,20 +26,29 @@
     <DebugType>pdbonly</DebugType>
     <Optimize>true</Optimize>
     <OutputPath>bin\Release\</OutputPath>
-    <DefineConstants>TRACE</DefineConstants>
+    <DefineConstants>TRACE;LDF_130</DefineConstants>
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>
   </PropertyGroup>
   <ItemGroup>
     <Reference Include="System" />
     <Reference Include="System.Data" />
+    <Reference Include="System.Drawing" />
     <Reference Include="System.Xml" />
   </ItemGroup>
   <ItemGroup>
     <Compile Include="..\..\Generated\LayerDefinition-1.3.0.designer.cs">
       <Link>LayerDefinition-1.3.0.designer.cs</Link>
     </Compile>
-    <Compile Include="LayerDefinition.cs" />
+    <Compile Include="..\..\OSGeo.MapGuide.MaestroAPI\ObjectModels\GridLayerDefinitionImpl.cs">
+      <Link>GridLayerDefinitionImpl.cs</Link>
+    </Compile>
+    <Compile Include="..\..\OSGeo.MapGuide.MaestroAPI\ObjectModels\LayerFactory.cs">
+      <Link>LayerFactory.cs</Link>
+    </Compile>
+    <Compile Include="..\..\OSGeo.MapGuide.MaestroAPI\ObjectModels\VectorLayerDefinitionImpl.cs">
+      <Link>VectorLayerDefinitionImpl.cs</Link>
+    </Compile>
     <Compile Include="LayerDefinitionValidator.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
     <Compile Include="Properties\Resources.Designer.cs">

Modified: sandbox/maestro-3.0/ExtendedModels/LayerDefinition-1.3.0/Properties/Resources.Designer.cs
===================================================================
--- sandbox/maestro-3.0/ExtendedModels/LayerDefinition-1.3.0/Properties/Resources.Designer.cs	2010-10-07 10:05:07 UTC (rev 5253)
+++ sandbox/maestro-3.0/ExtendedModels/LayerDefinition-1.3.0/Properties/Resources.Designer.cs	2010-10-07 12:42:50 UTC (rev 5254)
@@ -1,7 +1,7 @@
 //------------------------------------------------------------------------------
 // <auto-generated>
 //     This code was generated by a tool.
-//     Runtime Version:2.0.50727.4927
+//     Runtime Version:2.0.50727.4952
 //
 //     Changes to this file may cause incorrect behavior and will be lost if
 //     the code is regenerated.
@@ -59,131 +59,5 @@
                 resourceCulture = value;
             }
         }
-        
-        /// <summary>
-        ///   Looks up a localized string similar to Only vector layers and raster layers are currently validated.
-        /// </summary>
-        internal static string LDF_DrawingLayerDefinitionNotSupportedWarning {
-            get {
-                return ResourceManager.GetString("LDF_DrawingLayerDefinitionNotSupportedWarning", resourceCulture);
-            }
-        }
-        
-        /// <summary>
-        ///   Looks up a localized string similar to Maestro does not support DrawingLayers.
-        /// </summary>
-        internal static string LDF_DrawingLayerNotSupportedWarning {
-            get {
-                return ResourceManager.GetString("LDF_DrawingLayerNotSupportedWarning", resourceCulture);
-            }
-        }
-        
-        /// <summary>
-        ///   Looks up a localized string similar to Failed to load featuresource.
-        /// </summary>
-        internal static string LDF_FeatureSourceLoadError {
-            get {
-                return ResourceManager.GetString("LDF_FeatureSourceLoadError", resourceCulture);
-            }
-        }
-        
-        /// <summary>
-        ///   Looks up a localized string similar to Failed to find geometry column {0} in schema {1} on featuresource {2}.
-        /// </summary>
-        internal static string LDF_GeometryMissingError {
-            get {
-                return ResourceManager.GetString("LDF_GeometryMissingError", resourceCulture);
-            }
-        }
-        
-        /// <summary>
-        ///   Looks up a localized string similar to Layer is missing core information.
-        /// </summary>
-        internal static string LDF_LayerNullError {
-            get {
-                return ResourceManager.GetString("LDF_LayerNullError", resourceCulture);
-            }
-        }
-        
-        /// <summary>
-        ///   Looks up a localized string similar to The minimum scale ({0}) is larger than the maximum scale ({1}).
-        /// </summary>
-        internal static string LDF_MinAndMaxScaleSwappedError {
-            get {
-                return ResourceManager.GetString("LDF_MinAndMaxScaleSwappedError", resourceCulture);
-            }
-        }
-        
-        /// <summary>
-        ///   Looks up a localized string similar to No FeatureSource is assigned to the layer.
-        /// </summary>
-        internal static string LDF_MissingFeatureSourceError {
-            get {
-                return ResourceManager.GetString("LDF_MissingFeatureSourceError", resourceCulture);
-            }
-        }
-        
-        /// <summary>
-        ///   Looks up a localized string similar to No Geometry is assigned to the layer.
-        /// </summary>
-        internal static string LDF_MissingGeometryError {
-            get {
-                return ResourceManager.GetString("LDF_MissingGeometryError", resourceCulture);
-            }
-        }
-        
-        /// <summary>
-        ///   Looks up a localized string similar to No scale ranges are defined, no data can be displayed.
-        /// </summary>
-        internal static string LDF_MissingScaleRangesError {
-            get {
-                return ResourceManager.GetString("LDF_MissingScaleRangesError", resourceCulture);
-            }
-        }
-        
-        /// <summary>
-        ///   Looks up a localized string similar to More than one scale ranges is defined, this is valid, but unsupported by Maestro.
-        /// </summary>
-        internal static string LDF_MultipleScaleRangesWarning {
-            get {
-                return ResourceManager.GetString("LDF_MultipleScaleRangesWarning", resourceCulture);
-            }
-        }
-        
-        /// <summary>
-        ///   Looks up a localized string similar to The scale range {0}-{1} overlaps the range {2}-{3}.
-        /// </summary>
-        internal static string LDF_ScaleRangesOverlapInformation {
-            get {
-                return ResourceManager.GetString("LDF_ScaleRangesOverlapInformation", resourceCulture);
-            }
-        }
-        
-        /// <summary>
-        ///   Looks up a localized string similar to Failed to validate column and schema.
-        /// </summary>
-        internal static string LDF_SchemaAndColumnReadFailedError {
-            get {
-                return ResourceManager.GetString("LDF_SchemaAndColumnReadFailedError", resourceCulture);
-            }
-        }
-        
-        /// <summary>
-        ///   Looks up a localized string similar to Failed to find schema {0} in featuresource {1}.
-        /// </summary>
-        internal static string LDF_SchemaMissingError {
-            get {
-                return ResourceManager.GetString("LDF_SchemaMissingError", resourceCulture);
-            }
-        }
-        
-        /// <summary>
-        ///   Looks up a localized string similar to The layer has no type, or the type is unsupported by Maestro.
-        /// </summary>
-        internal static string LDF_UnsupportedLayerTypeWarning {
-            get {
-                return ResourceManager.GetString("LDF_UnsupportedLayerTypeWarning", resourceCulture);
-            }
-        }
     }
 }

Modified: sandbox/maestro-3.0/ExtendedModels/LayerDefinition-1.3.0/Properties/Resources.resx
===================================================================
--- sandbox/maestro-3.0/ExtendedModels/LayerDefinition-1.3.0/Properties/Resources.resx	2010-10-07 10:05:07 UTC (rev 5253)
+++ sandbox/maestro-3.0/ExtendedModels/LayerDefinition-1.3.0/Properties/Resources.resx	2010-10-07 12:42:50 UTC (rev 5254)
@@ -117,60 +117,4 @@
   <resheader name="writer">
     <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
   </resheader>
-  <data name="LDF_DrawingLayerDefinitionNotSupportedWarning" xml:space="preserve">
-    <value>Only vector layers and raster layers are currently validated</value>
-    <comment>A warning message that is displayed if the layer is not Grid or Vector</comment>
-  </data>
-  <data name="LDF_DrawingLayerNotSupportedWarning" xml:space="preserve">
-    <value>Maestro does not support DrawingLayers</value>
-    <comment>A warning message that is displayed if the layer is a DrawingLayer type</comment>
-  </data>
-  <data name="LDF_FeatureSourceLoadError" xml:space="preserve">
-    <value>Failed to load featuresource</value>
-    <comment>An error message that is displayed if the featuresource fails to load</comment>
-  </data>
-  <data name="LDF_GeometryMissingError" xml:space="preserve">
-    <value>Failed to find geometry column {0} in schema {1} on featuresource {2}</value>
-    <comment>An error message that is displayed if the geometry is not present in the selected schema</comment>
-  </data>
-  <data name="LDF_LayerNullError" xml:space="preserve">
-    <value>Layer is missing core information</value>
-    <comment>An error message that is displayed if the layer has a null reference</comment>
-  </data>
-  <data name="LDF_MinAndMaxScaleSwappedError" xml:space="preserve">
-    <value>The minimum scale ({0}) is larger than the maximum scale ({1})</value>
-    <comment>An error message that is displayed if the scale ranges are reversed</comment>
-  </data>
-  <data name="LDF_MissingFeatureSourceError" xml:space="preserve">
-    <value>No FeatureSource is assigned to the layer</value>
-    <comment>An error message that is displayed if the layer has no FeatureSource</comment>
-  </data>
-  <data name="LDF_MissingGeometryError" xml:space="preserve">
-    <value>No Geometry is assigned to the layer</value>
-    <comment>An error message that is displayed if the layer has no geometry column selected</comment>
-  </data>
-  <data name="LDF_MissingScaleRangesError" xml:space="preserve">
-    <value>No scale ranges are defined, no data can be displayed</value>
-    <comment>An error message that is displayed if there are no scale ranges defined</comment>
-  </data>
-  <data name="LDF_MultipleScaleRangesWarning" xml:space="preserve">
-    <value>More than one scale ranges is defined, this is valid, but unsupported by Maestro</value>
-    <comment>A warning message that is displayed if a raster layer has multiple scale ranges defined</comment>
-  </data>
-  <data name="LDF_ScaleRangesOverlapInformation" xml:space="preserve">
-    <value>The scale range {0}-{1} overlaps the range {2}-{3}</value>
-    <comment>A warning message that is displayed if two scaleranges overlap</comment>
-  </data>
-  <data name="LDF_SchemaAndColumnReadFailedError" xml:space="preserve">
-    <value>Failed to validate column and schema</value>
-    <comment>An error message that is displayed if the schema and column read fails</comment>
-  </data>
-  <data name="LDF_SchemaMissingError" xml:space="preserve">
-    <value>Failed to find schema {0} in featuresource {1}</value>
-    <comment>An error message that is displayed if the selected schema is not present in the FeatureSource</comment>
-  </data>
-  <data name="LDF_UnsupportedLayerTypeWarning" xml:space="preserve">
-    <value>The layer has no type, or the type is unsupported by Maestro</value>
-    <comment>A  warning message that is displayed if the layer type is unknown</comment>
-  </data>
 </root>
\ No newline at end of file

Modified: sandbox/maestro-3.0/Generated/LayerDefinition-1.0.0.designer.cs
===================================================================
--- sandbox/maestro-3.0/Generated/LayerDefinition-1.0.0.designer.cs	2010-10-07 10:05:07 UTC (rev 5253)
+++ sandbox/maestro-3.0/Generated/LayerDefinition-1.0.0.designer.cs	2010-10-07 12:42:50 UTC (rev 5254)
@@ -4,7 +4,7 @@
 //    <NameSpace>OSGeo.MapGuide.ObjectModels.LayerDefinition</NameSpace><Collection>BindingList</Collection><codeType>CSharp</codeType><EnableDataBinding>True</EnableDataBinding><EnableLasyLoading>False</EnableLasyLoading><HidePrivateFieldInIDE>True</HidePrivateFieldInIDE><EnableSummaryComment>True</EnableSummaryComment><IncludeSerializeMethod>True</IncludeSerializeMethod><UseBaseClass>False</UseBaseClass><GenerateCloneMethod>True</GenerateCloneMethod><GenerateDataContracts>False</GenerateDataContracts><CodeBaseTag>Net20</CodeBaseTag><SerializeMethodName>Serialize</SerializeMethodName><DeserializeMethodName>Deserialize</DeserializeMethodName><SaveToFileMethodName>SaveToFile</SaveToFileMethodName><LoadFromFileMethodName>LoadFromFile</LoadFromFileMethodName><GenerateXMLAttributes>True</GenerateXMLAttributes><AutomaticProperties>False</AutomaticProperties><DisableDebug>False</DisableDebug><CustomUsings></CustomUsings><ExcludeIncludedTypes>False</ExcludeIncludedTypes><EnableInit
 ializeFields>False</EnableInitializeFields>
 //  </auto-generated>
 // ------------------------------------------------------------------------------
-namespace OSGeo.MapGuide.ObjectModels.LayerDefinition {
+namespace OSGeo.MapGuide.ObjectModels.LayerDefinition_1_0_0 {
     using System;
     using System.Diagnostics;
     using System.Xml.Serialization;
@@ -12,6 +12,7 @@
     using System.Xml.Schema;
     using System.ComponentModel;
     using System.IO;
+    using OSGeo.MapGuide.ObjectModels.LayerDefinition;
     
     
     /// <summary>
@@ -2821,20 +2822,6 @@
     
     [System.CodeDom.Compiler.GeneratedCodeAttribute("Xsd2Code", "3.3.0.33572")]
     [System.SerializableAttribute()]
-    public enum BackgroundStyleType {
-        
-        /// <remarks/>
-        Transparent,
-        
-        /// <remarks/>
-        Opaque,
-        
-        /// <remarks/>
-        Ghosted,
-    }
-    
-    [System.CodeDom.Compiler.GeneratedCodeAttribute("Xsd2Code", "3.3.0.33572")]
-    [System.SerializableAttribute()]
     [System.Diagnostics.DebuggerStepThroughAttribute()]
     [System.ComponentModel.DesignerCategoryAttribute("code")]
     [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)]
@@ -3386,52 +3373,9 @@
         }
         #endregion
     }
-    
+   
     [System.CodeDom.Compiler.GeneratedCodeAttribute("Xsd2Code", "3.3.0.33572")]
     [System.SerializableAttribute()]
-    public enum LengthUnitType {
-        
-        /// <remarks/>
-        Millimeters,
-        
-        /// <remarks/>
-        Centimeters,
-        
-        /// <remarks/>
-        Meters,
-        
-        /// <remarks/>
-        Kilometers,
-        
-        /// <remarks/>
-        Inches,
-        
-        /// <remarks/>
-        Feet,
-        
-        /// <remarks/>
-        Yards,
-        
-        /// <remarks/>
-        Miles,
-        
-        /// <remarks/>
-        Points,
-    }
-    
-    [System.CodeDom.Compiler.GeneratedCodeAttribute("Xsd2Code", "3.3.0.33572")]
-    [System.SerializableAttribute()]
-    public enum SizeContextType {
-        
-        /// <remarks/>
-        MappingUnits,
-        
-        /// <remarks/>
-        DeviceUnits,
-    }
-    
-    [System.CodeDom.Compiler.GeneratedCodeAttribute("Xsd2Code", "3.3.0.33572")]
-    [System.SerializableAttribute()]
     [System.Diagnostics.DebuggerStepThroughAttribute()]
     [System.ComponentModel.DesignerCategoryAttribute("code")]
     [System.Xml.Serialization.XmlRootAttribute(Namespace="", IsNullable=true)]
@@ -5292,29 +5236,6 @@
     
     [System.CodeDom.Compiler.GeneratedCodeAttribute("Xsd2Code", "3.3.0.33572")]
     [System.SerializableAttribute()]
-    public enum ShapeType {
-        
-        /// <remarks/>
-        Square,
-        
-        /// <remarks/>
-        Circle,
-        
-        /// <remarks/>
-        Triangle,
-        
-        /// <remarks/>
-        Star,
-        
-        /// <remarks/>
-        Cross,
-        
-        /// <remarks/>
-        X,
-    }
-    
-    [System.CodeDom.Compiler.GeneratedCodeAttribute("Xsd2Code", "3.3.0.33572")]
-    [System.SerializableAttribute()]
     [System.Diagnostics.DebuggerStepThroughAttribute()]
     [System.ComponentModel.DesignerCategoryAttribute("code")]
     [System.Xml.Serialization.XmlRootAttribute(Namespace="", IsNullable=true)]
@@ -6679,21 +6600,6 @@
         #endregion
     }
     
-    [System.CodeDom.Compiler.GeneratedCodeAttribute("Xsd2Code", "3.3.0.33572")]
-    [System.SerializableAttribute()]
-    [System.Xml.Serialization.XmlTypeAttribute(IncludeInSchema=false)]
-    public enum ItemChoiceType {
-        
-        /// <remarks/>
-        Band,
-        
-        /// <remarks/>
-        Bands,
-        
-        /// <remarks/>
-        ExplicitColor,
-    }
-    
     [System.Xml.Serialization.XmlIncludeAttribute(typeof(AreaSymbolizationFillType))]
     [System.CodeDom.Compiler.GeneratedCodeAttribute("Xsd2Code", "3.3.0.33572")]
     [System.SerializableAttribute()]
@@ -10490,15 +10396,4 @@
         }
         #endregion
     }
-    
-    [System.CodeDom.Compiler.GeneratedCodeAttribute("Xsd2Code", "3.3.0.33572")]
-    [System.SerializableAttribute()]
-    public enum FeatureNameType {
-        
-        /// <remarks/>
-        FeatureClass,
-        
-        /// <remarks/>
-        NamedExtension,
-    }
 }

Modified: sandbox/maestro-3.0/Generated/LayerDefinition-1.1.0.designer.cs
===================================================================
--- sandbox/maestro-3.0/Generated/LayerDefinition-1.1.0.designer.cs	2010-10-07 10:05:07 UTC (rev 5253)
+++ sandbox/maestro-3.0/Generated/LayerDefinition-1.1.0.designer.cs	2010-10-07 12:42:50 UTC (rev 5254)
@@ -13,8 +13,8 @@
     using System.Xml.Schema;
     using System.ComponentModel;
     using System.IO;
+    using OSGeo.MapGuide.ObjectModels.LayerDefinition;
     
-    
     [System.CodeDom.Compiler.GeneratedCodeAttribute("Xsd2Code", "3.3.0.33572")]
     [System.SerializableAttribute()]
     [System.Diagnostics.DebuggerStepThroughAttribute()]
@@ -9002,20 +9002,6 @@
     
     [System.CodeDom.Compiler.GeneratedCodeAttribute("Xsd2Code", "3.3.0.33572")]
     [System.SerializableAttribute()]
-    public enum BackgroundStyleType {
-        
-        /// <remarks/>
-        Transparent,
-        
-        /// <remarks/>
-        Opaque,
-        
-        /// <remarks/>
-        Ghosted,
-    }
-    
-    [System.CodeDom.Compiler.GeneratedCodeAttribute("Xsd2Code", "3.3.0.33572")]
-    [System.SerializableAttribute()]
     [System.Diagnostics.DebuggerStepThroughAttribute()]
     [System.ComponentModel.DesignerCategoryAttribute("code")]
     [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)]
@@ -9570,49 +9556,6 @@
     
     [System.CodeDom.Compiler.GeneratedCodeAttribute("Xsd2Code", "3.3.0.33572")]
     [System.SerializableAttribute()]
-    public enum LengthUnitType {
-        
-        /// <remarks/>
-        Millimeters,
-        
-        /// <remarks/>
-        Centimeters,
-        
-        /// <remarks/>
-        Meters,
-        
-        /// <remarks/>
-        Kilometers,
-        
-        /// <remarks/>
-        Inches,
-        
-        /// <remarks/>
-        Feet,
-        
-        /// <remarks/>
-        Yards,
-        
-        /// <remarks/>
-        Miles,
-        
-        /// <remarks/>
-        Points,
-    }
-    
-    [System.CodeDom.Compiler.GeneratedCodeAttribute("Xsd2Code", "3.3.0.33572")]
-    [System.SerializableAttribute()]
-    public enum SizeContextType {
-        
-        /// <remarks/>
-        MappingUnits,
-        
-        /// <remarks/>
-        DeviceUnits,
-    }
-    
-    [System.CodeDom.Compiler.GeneratedCodeAttribute("Xsd2Code", "3.3.0.33572")]
-    [System.SerializableAttribute()]
     [System.Diagnostics.DebuggerStepThroughAttribute()]
     [System.ComponentModel.DesignerCategoryAttribute("code")]
     [System.Xml.Serialization.XmlRootAttribute(Namespace="", IsNullable=true)]
@@ -11473,29 +11416,6 @@
     
     [System.CodeDom.Compiler.GeneratedCodeAttribute("Xsd2Code", "3.3.0.33572")]
     [System.SerializableAttribute()]
-    public enum ShapeType {
-        
-        /// <remarks/>
-        Square,
-        
-        /// <remarks/>
-        Circle,
-        
-        /// <remarks/>
-        Triangle,
-        
-        /// <remarks/>
-        Star,
-        
-        /// <remarks/>
-        Cross,
-        
-        /// <remarks/>
-        X,
-    }
-    
-    [System.CodeDom.Compiler.GeneratedCodeAttribute("Xsd2Code", "3.3.0.33572")]
-    [System.SerializableAttribute()]
     [System.Diagnostics.DebuggerStepThroughAttribute()]
     [System.ComponentModel.DesignerCategoryAttribute("code")]
     [System.Xml.Serialization.XmlRootAttribute(Namespace="", IsNullable=true)]
@@ -12877,21 +12797,6 @@
     
     [System.CodeDom.Compiler.GeneratedCodeAttribute("Xsd2Code", "3.3.0.33572")]
     [System.SerializableAttribute()]
-    [System.Xml.Serialization.XmlTypeAttribute(IncludeInSchema=false)]
-    public enum ItemChoiceType {
-        
-        /// <remarks/>
-        Band,
-        
-        /// <remarks/>
-        Bands,
-        
-        /// <remarks/>
-        ExplicitColor,
-    }
-    
-    [System.CodeDom.Compiler.GeneratedCodeAttribute("Xsd2Code", "3.3.0.33572")]
-    [System.SerializableAttribute()]
     [System.Diagnostics.DebuggerStepThroughAttribute()]
     [System.ComponentModel.DesignerCategoryAttribute("code")]
     [System.Xml.Serialization.XmlRootAttribute(Namespace="", IsNullable=true)]
@@ -13258,17 +13163,6 @@
     
     [System.CodeDom.Compiler.GeneratedCodeAttribute("Xsd2Code", "3.3.0.33572")]
     [System.SerializableAttribute()]
-    public enum FeatureNameType {
-        
-        /// <remarks/>
-        FeatureClass,
-        
-        /// <remarks/>
-        NamedExtension,
-    }
-    
-    [System.CodeDom.Compiler.GeneratedCodeAttribute("Xsd2Code", "3.3.0.33572")]
-    [System.SerializableAttribute()]
     [System.Diagnostics.DebuggerStepThroughAttribute()]
     [System.ComponentModel.DesignerCategoryAttribute("code")]
     [System.Xml.Serialization.XmlRootAttribute(Namespace="", IsNullable=true)]

Modified: sandbox/maestro-3.0/Generated/LayerDefinition-1.2.0.designer.cs
===================================================================
--- sandbox/maestro-3.0/Generated/LayerDefinition-1.2.0.designer.cs	2010-10-07 10:05:07 UTC (rev 5253)
+++ sandbox/maestro-3.0/Generated/LayerDefinition-1.2.0.designer.cs	2010-10-07 12:42:50 UTC (rev 5254)
@@ -13,8 +13,8 @@
     using System.Xml.Schema;
     using System.ComponentModel;
     using System.IO;
+    using OSGeo.MapGuide.ObjectModels.LayerDefinition;
     
-    
     [System.CodeDom.Compiler.GeneratedCodeAttribute("Xsd2Code", "3.3.0.33572")]
     [System.SerializableAttribute()]
     [System.Diagnostics.DebuggerStepThroughAttribute()]
@@ -9168,20 +9168,6 @@
     
     [System.CodeDom.Compiler.GeneratedCodeAttribute("Xsd2Code", "3.3.0.33572")]
     [System.SerializableAttribute()]
-    public enum BackgroundStyleType {
-        
-        /// <remarks/>
-        Transparent,
-        
-        /// <remarks/>
-        Opaque,
-        
-        /// <remarks/>
-        Ghosted,
-    }
-    
-    [System.CodeDom.Compiler.GeneratedCodeAttribute("Xsd2Code", "3.3.0.33572")]
-    [System.SerializableAttribute()]
     [System.Diagnostics.DebuggerStepThroughAttribute()]
     [System.ComponentModel.DesignerCategoryAttribute("code")]
     [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)]
@@ -9736,49 +9722,6 @@
     
     [System.CodeDom.Compiler.GeneratedCodeAttribute("Xsd2Code", "3.3.0.33572")]
     [System.SerializableAttribute()]
-    public enum LengthUnitType {
-        
-        /// <remarks/>
-        Millimeters,
-        
-        /// <remarks/>
-        Centimeters,
-        
-        /// <remarks/>
-        Meters,
-        
-        /// <remarks/>
-        Kilometers,
-        
-        /// <remarks/>
-        Inches,
-        
-        /// <remarks/>
-        Feet,
-        
-        /// <remarks/>
-        Yards,
-        
-        /// <remarks/>
-        Miles,
-        
-        /// <remarks/>
-        Points,
-    }
-    
-    [System.CodeDom.Compiler.GeneratedCodeAttribute("Xsd2Code", "3.3.0.33572")]
-    [System.SerializableAttribute()]
-    public enum SizeContextType {
-        
-        /// <remarks/>
-        MappingUnits,
-        
-        /// <remarks/>
-        DeviceUnits,
-    }
-    
-    [System.CodeDom.Compiler.GeneratedCodeAttribute("Xsd2Code", "3.3.0.33572")]
-    [System.SerializableAttribute()]
     [System.Diagnostics.DebuggerStepThroughAttribute()]
     [System.ComponentModel.DesignerCategoryAttribute("code")]
     [System.Xml.Serialization.XmlRootAttribute(Namespace="", IsNullable=true)]
@@ -11639,29 +11582,6 @@
     
     [System.CodeDom.Compiler.GeneratedCodeAttribute("Xsd2Code", "3.3.0.33572")]
     [System.SerializableAttribute()]
-    public enum ShapeType {
-        
-        /// <remarks/>
-        Square,
-        
-        /// <remarks/>
-        Circle,
-        
-        /// <remarks/>
-        Triangle,
-        
-        /// <remarks/>
-        Star,
-        
-        /// <remarks/>
-        Cross,
-        
-        /// <remarks/>
-        X,
-    }
-    
-    [System.CodeDom.Compiler.GeneratedCodeAttribute("Xsd2Code", "3.3.0.33572")]
-    [System.SerializableAttribute()]
     [System.Diagnostics.DebuggerStepThroughAttribute()]
     [System.ComponentModel.DesignerCategoryAttribute("code")]
     [System.Xml.Serialization.XmlRootAttribute(Namespace="", IsNullable=true)]
@@ -13043,21 +12963,6 @@
     
     [System.CodeDom.Compiler.GeneratedCodeAttribute("Xsd2Code", "3.3.0.33572")]
     [System.SerializableAttribute()]
-    [System.Xml.Serialization.XmlTypeAttribute(IncludeInSchema=false)]
-    public enum ItemChoiceType {
-        
-        /// <remarks/>
-        Band,
-        
-        /// <remarks/>
-        Bands,
-        
-        /// <remarks/>
-        ExplicitColor,
-    }
-    
-    [System.CodeDom.Compiler.GeneratedCodeAttribute("Xsd2Code", "3.3.0.33572")]
-    [System.SerializableAttribute()]
     [System.Diagnostics.DebuggerStepThroughAttribute()]
     [System.ComponentModel.DesignerCategoryAttribute("code")]
     [System.Xml.Serialization.XmlRootAttribute(Namespace="", IsNullable=true)]

Modified: sandbox/maestro-3.0/Generated/LayerDefinition-1.3.0.designer.cs
===================================================================
--- sandbox/maestro-3.0/Generated/LayerDefinition-1.3.0.designer.cs	2010-10-07 10:05:07 UTC (rev 5253)
+++ sandbox/maestro-3.0/Generated/LayerDefinition-1.3.0.designer.cs	2010-10-07 12:42:50 UTC (rev 5254)
@@ -12,8 +12,8 @@
     using System.Xml.Schema;
     using System.ComponentModel;
     using System.IO;
+    using OSGeo.MapGuide.ObjectModels.LayerDefinition;
     
-    
     [System.CodeDom.Compiler.GeneratedCodeAttribute("Xsd2Code", "3.3.0.33572")]
     [System.SerializableAttribute()]
     [System.Diagnostics.DebuggerStepThroughAttribute()]
@@ -9167,20 +9167,6 @@
     
     [System.CodeDom.Compiler.GeneratedCodeAttribute("Xsd2Code", "3.3.0.33572")]
     [System.SerializableAttribute()]
-    public enum BackgroundStyleType {
-        
-        /// <remarks/>
-        Transparent,
-        
-        /// <remarks/>
-        Opaque,
-        
-        /// <remarks/>
-        Ghosted,
-    }
-    
-    [System.CodeDom.Compiler.GeneratedCodeAttribute("Xsd2Code", "3.3.0.33572")]
-    [System.SerializableAttribute()]
     [System.Diagnostics.DebuggerStepThroughAttribute()]
     [System.ComponentModel.DesignerCategoryAttribute("code")]
     [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)]
@@ -9735,49 +9721,6 @@
     
     [System.CodeDom.Compiler.GeneratedCodeAttribute("Xsd2Code", "3.3.0.33572")]
     [System.SerializableAttribute()]
-    public enum LengthUnitType {
-        
-        /// <remarks/>
-        Millimeters,
-        
-        /// <remarks/>
-        Centimeters,
-        
-        /// <remarks/>
-        Meters,
-        
-        /// <remarks/>
-        Kilometers,
-        
-        /// <remarks/>
-        Inches,
-        
-        /// <remarks/>
-        Feet,
-        
-        /// <remarks/>
-        Yards,
-        
-        /// <remarks/>
-        Miles,
-        
-        /// <remarks/>
-        Points,
-    }
-    
-    [System.CodeDom.Compiler.GeneratedCodeAttribute("Xsd2Code", "3.3.0.33572")]
-    [System.SerializableAttribute()]
-    public enum SizeContextType {
-        
-        /// <remarks/>
-        MappingUnits,
-        
-        /// <remarks/>
-        DeviceUnits,
-    }
-    
-    [System.CodeDom.Compiler.GeneratedCodeAttribute("Xsd2Code", "3.3.0.33572")]
-    [System.SerializableAttribute()]
     [System.Diagnostics.DebuggerStepThroughAttribute()]
     [System.ComponentModel.DesignerCategoryAttribute("code")]
     [System.Xml.Serialization.XmlRootAttribute(Namespace="", IsNullable=true)]
@@ -11638,29 +11581,6 @@
     
     [System.CodeDom.Compiler.GeneratedCodeAttribute("Xsd2Code", "3.3.0.33572")]
     [System.SerializableAttribute()]
-    public enum ShapeType {
-        
-        /// <remarks/>
-        Square,
-        
-        /// <remarks/>
-        Circle,
-        
-        /// <remarks/>
-        Triangle,
-        
-        /// <remarks/>
-        Star,
-        
-        /// <remarks/>
-        Cross,
-        
-        /// <remarks/>
-        X,
-    }
-    
-    [System.CodeDom.Compiler.GeneratedCodeAttribute("Xsd2Code", "3.3.0.33572")]
-    [System.SerializableAttribute()]
     [System.Diagnostics.DebuggerStepThroughAttribute()]
     [System.ComponentModel.DesignerCategoryAttribute("code")]
     [System.Xml.Serialization.XmlRootAttribute(Namespace="", IsNullable=true)]
@@ -13042,21 +12962,6 @@
     
     [System.CodeDom.Compiler.GeneratedCodeAttribute("Xsd2Code", "3.3.0.33572")]
     [System.SerializableAttribute()]
-    [System.Xml.Serialization.XmlTypeAttribute(IncludeInSchema=false)]
-    public enum ItemChoiceType {
-        
-        /// <remarks/>
-        Band,
-        
-        /// <remarks/>
-        Bands,
-        
-        /// <remarks/>
-        ExplicitColor,
-    }
-    
-    [System.CodeDom.Compiler.GeneratedCodeAttribute("Xsd2Code", "3.3.0.33572")]
-    [System.SerializableAttribute()]
     [System.Diagnostics.DebuggerStepThroughAttribute()]
     [System.ComponentModel.DesignerCategoryAttribute("code")]
     [System.Xml.Serialization.XmlRootAttribute(Namespace="", IsNullable=true)]

Modified: sandbox/maestro-3.0/Maestro.Base/Editor/LayerDefinitionEditor.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Base/Editor/LayerDefinitionEditor.cs	2010-10-07 10:05:07 UTC (rev 5253)
+++ sandbox/maestro-3.0/Maestro.Base/Editor/LayerDefinitionEditor.cs	2010-10-07 12:42:50 UTC (rev 5254)
@@ -42,19 +42,19 @@
             InitializeComponent();
         }
 
-        private LayerDefinition _res;
+        private ILayerDefinition _res;
         private IEditorService _edsvc;
 
         protected override void Bind(Maestro.Editors.IEditorService service)
         {
             _edsvc = service;
             _edsvc.BeforeSave += new CancelEventHandler(OnBeforeSave);
-            _res = service.GetEditedResource() as LayerDefinition;
+            _res = service.GetEditedResource() as ILayerDefinition;
             Debug.Assert(_res != null);
 
-            var vl = _res.Item as VectorLayerDefinitionType;
-            var gl = _res.Item as GridLayerDefinitionType;
-            var dl = _res.Item as DrawingLayerDefinitionType;
+            var vl = _res.SubLayer as IVectorLayerDefinition;
+            var gl = _res.SubLayer as IRasterLayerDefinition;
+            var dl = _res.SubLayer as IDrawingLayerDefinition;
             if (vl != null)
             {
                 var ed = new VectorLayerEditorCtrl();

Modified: sandbox/maestro-3.0/Maestro.Base/Maestro.Base.addin
===================================================================
--- sandbox/maestro-3.0/Maestro.Base/Maestro.Base.addin	2010-10-07 10:05:07 UTC (rev 5253)
+++ sandbox/maestro-3.0/Maestro.Base/Maestro.Base.addin	2010-10-07 12:42:50 UTC (rev 5254)
@@ -45,7 +45,9 @@
         <Class id="FlexLayout100" class="Maestro.Base.Templates.ApplicationDefinitionItemTemplate" />
         <Class id="DrawingSource100" class="Maestro.Base.Templates.DrawingSourceItemTemplate" />
         <Class id="FeatureSource100" class="Maestro.Base.Templates.FeatureSourceItemTemplate" />
-        <Class id="LayerDefinition100" class="Maestro.Base.Templates.LayerDefinitionItemTemplate" />
+        <Class id="VectorLayerDefinition100" class="Maestro.Base.Templates.VectorLayerDefinitionItemTemplate" />
+        <Class id="RasterLayerDefinition100" class="Maestro.Base.Templates.RasterLayerDefinitionItemTemplate" />
+        <Class id="DrawingLayerDefinition100" class="Maestro.Base.Templates.DrawingLayerDefinitionItemTemplate" />
         <Class id="MapDefinition100" class="Maestro.Base.Templates.MapDefinitionItemTemplate" />
         <Class id="PrintLayout100" class="Maestro.Base.Templates.PrintLayoutItemTemplate" />
         <Class id="SdfLoadProcedure100" class="Maestro.Base.Templates.SdfLoadProcedureItemTemplate" />

Modified: sandbox/maestro-3.0/Maestro.Base/Maestro.Base.csproj
===================================================================
--- sandbox/maestro-3.0/Maestro.Base/Maestro.Base.csproj	2010-10-07 10:05:07 UTC (rev 5253)
+++ sandbox/maestro-3.0/Maestro.Base/Maestro.Base.csproj	2010-10-07 12:42:50 UTC (rev 5254)
@@ -166,10 +166,12 @@
     <Compile Include="Services\UrlLauncherService.cs" />
     <Compile Include="Services\ViewContentManager.cs" />
     <Compile Include="Templates\ApplicationDefinitionItemTemplate.cs" />
+    <Compile Include="Templates\DrawingLayerDefinitionItemTemplate.cs" />
     <Compile Include="Templates\DrawingSourceItemTemplate.cs" />
     <Compile Include="Templates\FeatureSourceItemTemplate.cs" />
     <Compile Include="Templates\ItemTemplate.cs" />
-    <Compile Include="Templates\LayerDefinitionItemTemplate.cs" />
+    <Compile Include="Templates\RasterLayerDefinitionItemTemplate.cs" />
+    <Compile Include="Templates\VectorLayerDefinitionItemTemplate.cs" />
     <Compile Include="Templates\MapDefinitionItemTemplate.cs" />
     <Compile Include="Templates\PrintLayoutItemTemplate.cs" />
     <Compile Include="Templates\SdfLoadProcedureItemTemplate.cs" />

Modified: sandbox/maestro-3.0/Maestro.Base/Properties/Resources.Designer.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Base/Properties/Resources.Designer.cs	2010-10-07 10:05:07 UTC (rev 5253)
+++ sandbox/maestro-3.0/Maestro.Base/Properties/Resources.Designer.cs	2010-10-07 12:42:50 UTC (rev 5254)
@@ -1316,6 +1316,24 @@
         }
         
         /// <summary>
+        ///   Looks up a localized string similar to Create a new Drawing Layer Definition.
+        /// </summary>
+        internal static string TPL_DLDF_DESC {
+            get {
+                return ResourceManager.GetString("TPL_DLDF_DESC", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to Drawing Layer Definition.
+        /// </summary>
+        internal static string TPL_DLDF_NAME {
+            get {
+                return ResourceManager.GetString("TPL_DLDF_NAME", resourceCulture);
+            }
+        }
+        
+        /// <summary>
         ///   Looks up a localized string similar to Create a new Drawing Source.
         /// </summary>
         internal static string TPL_DS_DESC {
@@ -1352,24 +1370,6 @@
         }
         
         /// <summary>
-        ///   Looks up a localized string similar to Create a new Layer Definition.
-        /// </summary>
-        internal static string TPL_LDF_DESC {
-            get {
-                return ResourceManager.GetString("TPL_LDF_DESC", resourceCulture);
-            }
-        }
-        
-        /// <summary>
-        ///   Looks up a localized string similar to Layer Definition.
-        /// </summary>
-        internal static string TPL_LDF_NAME {
-            get {
-                return ResourceManager.GetString("TPL_LDF_NAME", resourceCulture);
-            }
-        }
-        
-        /// <summary>
         ///   Looks up a localized string similar to Create a new SDF Load Procedure.
         /// </summary>
         internal static string TPL_LP_SDF_DESC {
@@ -1442,6 +1442,24 @@
         }
         
         /// <summary>
+        ///   Looks up a localized string similar to Create a new Raster Layer Definition.
+        /// </summary>
+        internal static string TPL_RLDF_DESC {
+            get {
+                return ResourceManager.GetString("TPL_RLDF_DESC", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to Raster Layer Definition.
+        /// </summary>
+        internal static string TPL_RLDF_NAME {
+            get {
+                return ResourceManager.GetString("TPL_RLDF_NAME", resourceCulture);
+            }
+        }
+        
+        /// <summary>
         ///   Looks up a localized string similar to Create a new Simple Symbol Definition.
         /// </summary>
         internal static string TPL_SSD_DESC {
@@ -1469,6 +1487,24 @@
         }
         
         /// <summary>
+        ///   Looks up a localized string similar to Create a new Vector Layer Definition.
+        /// </summary>
+        internal static string TPL_VLDF_DESC {
+            get {
+                return ResourceManager.GetString("TPL_VLDF_DESC", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to Vector Layer Definition.
+        /// </summary>
+        internal static string TPL_VLDF_NAME {
+            get {
+                return ResourceManager.GetString("TPL_VLDF_NAME", resourceCulture);
+            }
+        }
+        
+        /// <summary>
         ///   Looks up a localized string similar to Create a new Web Layout.
         /// </summary>
         internal static string TPL_WL_DESC {

Modified: sandbox/maestro-3.0/Maestro.Base/Properties/Resources.resx
===================================================================
--- sandbox/maestro-3.0/Maestro.Base/Properties/Resources.resx	2010-10-07 10:05:07 UTC (rev 5253)
+++ sandbox/maestro-3.0/Maestro.Base/Properties/Resources.resx	2010-10-07 12:42:50 UTC (rev 5254)
@@ -418,11 +418,11 @@
   <data name="TPL_FS_NAME" xml:space="preserve">
     <value>Feature Source</value>
   </data>
-  <data name="TPL_LDF_DESC" xml:space="preserve">
-    <value>Create a new Layer Definition</value>
+  <data name="TPL_VLDF_DESC" xml:space="preserve">
+    <value>Create a new Vector Layer Definition</value>
   </data>
-  <data name="TPL_LDF_NAME" xml:space="preserve">
-    <value>Layer Definition</value>
+  <data name="TPL_VLDF_NAME" xml:space="preserve">
+    <value>Vector Layer Definition</value>
   </data>
   <data name="TPL_LP_SDF_DESC" xml:space="preserve">
     <value>Create a new SDF Load Procedure</value>
@@ -682,4 +682,16 @@
   <data name="Global.ErrorText" xml:space="preserve">
     <value>Error</value>
   </data>
+  <data name="TPL_DLDF_DESC" xml:space="preserve">
+    <value>Create a new Drawing Layer Definition</value>
+  </data>
+  <data name="TPL_DLDF_NAME" xml:space="preserve">
+    <value>Drawing Layer Definition</value>
+  </data>
+  <data name="TPL_RLDF_DESC" xml:space="preserve">
+    <value>Create a new Raster Layer Definition</value>
+  </data>
+  <data name="TPL_RLDF_NAME" xml:space="preserve">
+    <value>Raster Layer Definition</value>
+  </data>
 </root>
\ No newline at end of file

Added: sandbox/maestro-3.0/Maestro.Base/Templates/DrawingLayerDefinitionItemTemplate.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Base/Templates/DrawingLayerDefinitionItemTemplate.cs	                        (rev 0)
+++ sandbox/maestro-3.0/Maestro.Base/Templates/DrawingLayerDefinitionItemTemplate.cs	2010-10-07 12:42:50 UTC (rev 5254)
@@ -0,0 +1,46 @@
+#region Disclaimer / License
+// Copyright (C) 2010, Jackie Ng
+// http://trac.osgeo.org/mapguide/wiki/maestro, jumpinjackie at gmail.com
+// 
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// 
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+// 
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+// 
+#endregion
+using System;
+using System.Collections.Generic;
+using System.Text;
+using Res = Maestro.Base.Properties.Resources;
+using OSGeo.MapGuide.MaestroAPI;
+using OSGeo.MapGuide.MaestroAPI.ObjectModels;
+using OSGeo.MapGuide.MaestroAPI.Resource;
+
+namespace Maestro.Base.Templates
+{
+    public class DrawingLayerDefinitionItemTemplate : ItemTemplate
+    {
+        public DrawingLayerDefinitionItemTemplate()
+        {
+            Category = Res.TPL_CATEGORY_DEFAULT;
+            Icon = Res.layer;
+            Description = Res.TPL_DLDF_DESC;
+            Name = Res.TPL_DLDF_NAME;
+            ResourceType = ResourceTypes.LayerDefinition.ToString();
+        }
+
+        public override IResource CreateItem(IServerConnection conn)
+        {
+            return ObjectFactory.CreateDefaultLayer(conn, OSGeo.MapGuide.ObjectModels.LayerDefinition.LayerType.Drawing, new Version(1, 0, 0));
+        }
+    }
+}

Deleted: sandbox/maestro-3.0/Maestro.Base/Templates/LayerDefinitionItemTemplate.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Base/Templates/LayerDefinitionItemTemplate.cs	2010-10-07 10:05:07 UTC (rev 5253)
+++ sandbox/maestro-3.0/Maestro.Base/Templates/LayerDefinitionItemTemplate.cs	2010-10-07 12:42:50 UTC (rev 5254)
@@ -1,47 +0,0 @@
-#region Disclaimer / License
-// Copyright (C) 2010, Jackie Ng
-// http://trac.osgeo.org/mapguide/wiki/maestro, jumpinjackie at gmail.com
-// 
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License, or (at your option) any later version.
-// 
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-// Lesser General Public License for more details.
-// 
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
-// 
-#endregion
-using System;
-using System.Collections.Generic;
-using System.Text;
-using OSGeo.MapGuide.MaestroAPI;
-using OSGeo.MapGuide.MaestroAPI.Services;
-using Res = Maestro.Base.Properties.Resources;
-using OSGeo.MapGuide.MaestroAPI.Resource;
-using OSGeo.MapGuide.MaestroAPI.ObjectModels;
-
-namespace Maestro.Base.Templates
-{
-    public class LayerDefinitionItemTemplate : ItemTemplate
-    {
-        public LayerDefinitionItemTemplate()
-        {
-            Category = Res.TPL_CATEGORY_DEFAULT;
-            Icon = Res.layer;
-            Description = Res.TPL_LDF_DESC;
-            Name = Res.TPL_LDF_NAME;
-            ResourceType = ResourceTypes.LayerDefinition.ToString();
-        }
-
-        public override IResource CreateItem(IServerConnection conn)
-        {
-            return ObjectFactory.CreateLayerDefinition(conn);
-        }
-    }
-}

Added: sandbox/maestro-3.0/Maestro.Base/Templates/RasterLayerDefinitionItemTemplate.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Base/Templates/RasterLayerDefinitionItemTemplate.cs	                        (rev 0)
+++ sandbox/maestro-3.0/Maestro.Base/Templates/RasterLayerDefinitionItemTemplate.cs	2010-10-07 12:42:50 UTC (rev 5254)
@@ -0,0 +1,46 @@
+#region Disclaimer / License
+// Copyright (C) 2010, Jackie Ng
+// http://trac.osgeo.org/mapguide/wiki/maestro, jumpinjackie at gmail.com
+// 
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// 
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+// 
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+// 
+#endregion
+using System;
+using System.Collections.Generic;
+using System.Text;
+using OSGeo.MapGuide.MaestroAPI.Resource;
+using Res = Maestro.Base.Properties.Resources;
+using OSGeo.MapGuide.MaestroAPI;
+using OSGeo.MapGuide.MaestroAPI.ObjectModels;
+
+namespace Maestro.Base.Templates
+{
+    public class RasterLayerDefinitionItemTemplate : ItemTemplate
+    {
+        public RasterLayerDefinitionItemTemplate()
+        {
+            Category = Res.TPL_CATEGORY_DEFAULT;
+            Icon = Res.layer;
+            Description = Res.TPL_RLDF_DESC;
+            Name = Res.TPL_RLDF_NAME;
+            ResourceType = ResourceTypes.LayerDefinition.ToString();
+        }
+
+        public override IResource CreateItem(IServerConnection conn)
+        {
+            return ObjectFactory.CreateDefaultLayer(conn, OSGeo.MapGuide.ObjectModels.LayerDefinition.LayerType.Raster, new Version(1, 0, 0));
+        }
+    }
+}

Copied: sandbox/maestro-3.0/Maestro.Base/Templates/VectorLayerDefinitionItemTemplate.cs (from rev 5242, sandbox/maestro-3.0/Maestro.Base/Templates/LayerDefinitionItemTemplate.cs)
===================================================================
--- sandbox/maestro-3.0/Maestro.Base/Templates/VectorLayerDefinitionItemTemplate.cs	                        (rev 0)
+++ sandbox/maestro-3.0/Maestro.Base/Templates/VectorLayerDefinitionItemTemplate.cs	2010-10-07 12:42:50 UTC (rev 5254)
@@ -0,0 +1,47 @@
+#region Disclaimer / License
+// Copyright (C) 2010, Jackie Ng
+// http://trac.osgeo.org/mapguide/wiki/maestro, jumpinjackie at gmail.com
+// 
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// 
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+// 
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+// 
+#endregion
+using System;
+using System.Collections.Generic;
+using System.Text;
+using OSGeo.MapGuide.MaestroAPI;
+using OSGeo.MapGuide.MaestroAPI.Services;
+using Res = Maestro.Base.Properties.Resources;
+using OSGeo.MapGuide.MaestroAPI.Resource;
+using OSGeo.MapGuide.MaestroAPI.ObjectModels;
+
+namespace Maestro.Base.Templates
+{
+    public class VectorLayerDefinitionItemTemplate : ItemTemplate
+    {
+        public VectorLayerDefinitionItemTemplate()
+        {
+            Category = Res.TPL_CATEGORY_DEFAULT;
+            Icon = Res.layer;
+            Description = Res.TPL_VLDF_DESC;
+            Name = Res.TPL_VLDF_NAME;
+            ResourceType = ResourceTypes.LayerDefinition.ToString();
+        }
+
+        public override IResource CreateItem(IServerConnection conn)
+        {
+            return ObjectFactory.CreateDefaultLayer(conn, OSGeo.MapGuide.ObjectModels.LayerDefinition.LayerType.Vector, new Version(1, 0, 0));
+        }
+    }
+}

Modified: sandbox/maestro-3.0/Maestro.Editors/LayerDefinition/Drawing/DrawingLayerSettingsCtrl.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Editors/LayerDefinition/Drawing/DrawingLayerSettingsCtrl.cs	2010-10-07 10:05:07 UTC (rev 5253)
+++ sandbox/maestro-3.0/Maestro.Editors/LayerDefinition/Drawing/DrawingLayerSettingsCtrl.cs	2010-10-07 12:42:50 UTC (rev 5254)
@@ -39,17 +39,17 @@
         }
 
         private IEditorService _service;
-        private DrawingLayerDefinitionType _dlayer;
+        private IDrawingLayerDefinition _dlayer;
 
         public void Bind(IEditorService service)
         {
             _service = service;
             _service.RegisterCustomNotifier(this);
 
-            var lyr = service.GetEditedResource() as OSGeo.MapGuide.ObjectModels.LayerDefinition.LayerDefinition;
+            var lyr = service.GetEditedResource() as ILayerDefinition;
             Debug.Assert(lyr != null);
 
-            _dlayer = lyr.Item as DrawingLayerDefinitionType;
+            _dlayer = lyr.SubLayer as IDrawingLayerDefinition;
             Debug.Assert(_dlayer != null);
 
             txtDrawingSource.DataBindings.Add("Text", _dlayer, "ResourceId");

Modified: sandbox/maestro-3.0/Maestro.Editors/LayerDefinition/LayerPropertiesSectionCtrl.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Editors/LayerDefinition/LayerPropertiesSectionCtrl.cs	2010-10-07 10:05:07 UTC (rev 5253)
+++ sandbox/maestro-3.0/Maestro.Editors/LayerDefinition/LayerPropertiesSectionCtrl.cs	2010-10-07 12:42:50 UTC (rev 5254)
@@ -21,32 +21,33 @@
         }
 
         private IEditorService _edsvc;
-        private BindingList<NameStringPairType> _props;
+        private IList<INameStringPair> _props;
 
-        private OSGeo.MapGuide.ObjectModels.LayerDefinition.VectorLayerDefinitionType _vl;
+        private ILayerDefinition _parent;
+        private IVectorLayerDefinition _vl;
 
         public override void Bind(IEditorService service)
         {
             _edsvc = service;
             _edsvc.RegisterCustomNotifier(this);
 
-            var res = service.GetEditedResource() as OSGeo.MapGuide.ObjectModels.LayerDefinition.LayerDefinition;
-            Debug.Assert(res != null);
+            _parent = service.GetEditedResource() as ILayerDefinition;
+            Debug.Assert(_parent != null);
 
-            _vl = res.Item as OSGeo.MapGuide.ObjectModels.LayerDefinition.VectorLayerDefinitionType;
+            _vl = _parent.SubLayer as IVectorLayerDefinition;
             Debug.Assert(_vl != null);
 
             _props = _vl.PropertyMapping;
             //Modifying the visibility constitutes a change in the resource
-            _props.ListChanged += OnPropertyListChanged;
+            //_props.ListChanged += OnPropertyListChanged;
             PopulatePropertyList();
             _vl.PropertyChanged += OnVectorLayerPropertyChanged;
         }
 
         protected override void UnsubscribeEventHandlers()
         {
-            if (_props != null)
-                _props.ListChanged -= OnPropertyListChanged;
+            //if (_props != null)
+            //    _props.ListChanged -= OnPropertyListChanged;
 
             if (_vl != null)
                 _vl.PropertyChanged -= OnVectorLayerPropertyChanged;
@@ -54,10 +55,10 @@
             base.UnsubscribeEventHandlers();
         }
 
-        void OnPropertyListChanged(object sender, ListChangedEventArgs e)
-        {
-            OnResourceChanged();
-        }
+        //void OnPropertyListChanged(object sender, ListChangedEventArgs e)
+        //{
+        //    OnResourceChanged();
+        //}
 
         void OnVectorLayerPropertyChanged(object sender, PropertyChangedEventArgs e)
         {
@@ -136,7 +137,7 @@
 
         private void OnPropertyMappingChanged(bool state, string propertyName, string displayName)
         {
-            NameStringPairType nsp = null;
+            INameStringPair nsp = null;
             foreach (var item in _props)
             {
                 if (item.Name == propertyName)
@@ -150,7 +151,7 @@
             {
                 if (nsp == null)
                 {
-                    _props.Add(new NameStringPairType() { Name = propertyName, Value = displayName });
+                    _props.Add(_parent.CreatePair(propertyName, displayName));
                 }
             }
             else //Turned off

Modified: sandbox/maestro-3.0/Maestro.Editors/LayerDefinition/Vector/FeaturePreviewRender.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Editors/LayerDefinition/Vector/FeaturePreviewRender.cs	2010-10-07 10:05:07 UTC (rev 5253)
+++ sandbox/maestro-3.0/Maestro.Editors/LayerDefinition/Vector/FeaturePreviewRender.cs	2010-10-07 12:42:50 UTC (rev 5254)
@@ -35,7 +35,7 @@
 		private static ImageStylePicker.NamedImage[] m_lineStyles = null;
 
 
-		public static void RenderPreviewArea(Graphics g, Rectangle size, AreaSymbolizationFillType item)
+		public static void RenderPreviewArea(Graphics g, Rectangle size, IAreaSymbolizationFill item)
 		{
 			if (item == null)
 			{
@@ -112,7 +112,7 @@
 
 		}
 
-		public static void RenderPreviewLine(Graphics g, Rectangle size, IEnumerable<StrokeType> item)
+		public static void RenderPreviewLine(Graphics g, Rectangle size, IEnumerable<IStroke> item)
 		{
 			if (item == null)
 			{
@@ -123,7 +123,7 @@
             try
             {
                 //TODO: Implement line dash
-                foreach (StrokeType st in item)
+                foreach (IStroke st in item)
                 {
                     using (Pen p = new Pen(string.IsNullOrEmpty(st.Color) ? Color.White : Utility.ParseHTMLColor(st.Color), /*float.Parse(st.Thickness)*/ 1)) //TODO: Calculate appropriate thickness
                     {
@@ -136,7 +136,7 @@
             }
 		}
 
-		public static void RenderPreviewFont(Graphics g, Rectangle size, TextSymbolType item)
+		public static void RenderPreviewFont(Graphics g, Rectangle size, ITextSymbol item)
 		{
 			Font font;
 			Color foreground;
@@ -203,7 +203,7 @@
             }
 		}
 
-		public static void RenderPreviewFontSymbol(Graphics g, Rectangle size, FontSymbolType item)
+		public static void RenderPreviewFontSymbol(Graphics g, Rectangle size, IFontSymbol item)
 		{
 			Font font;
 			Color foreground;
@@ -225,11 +225,11 @@
                     foreground = Utility.ParseHTMLColor(item.ForegroundColor);
 
                 FontStyle fs = FontStyle.Regular;
-                if (item.Bold == true && item.BoldSpecified)
+                if (item.Bold.HasValue && item.Bold.Value)
                     fs |= FontStyle.Bold;
-                if (item.Italic == true && item.ItalicSpecified)
+                if (item.Italic.HasValue && item.Italic.Value)
                     fs |= FontStyle.Italic;
-                if (item.Underlined == true && item.UnderlinedSpecified)
+                if (item.Underlined.HasValue && item.Underlined.Value)
                     fs |= FontStyle.Underline;
                 font = new Font(font, fs);
 
@@ -244,7 +244,7 @@
 				g.DrawString(text, font, b, center);
 		}
 
-		public static void RenderPreviewPoint(Graphics g, Rectangle size, MarkSymbolType item)
+		public static void RenderPreviewPoint(Graphics g, Rectangle size, IMarkSymbol item)
 		{
 			if (item == null)
 			{

Modified: sandbox/maestro-3.0/Maestro.Editors/LayerDefinition/Vector/Scales/Condition.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Editors/LayerDefinition/Vector/Scales/Condition.cs	2010-10-07 10:05:07 UTC (rev 5253)
+++ sandbox/maestro-3.0/Maestro.Editors/LayerDefinition/Vector/Scales/Condition.cs	2010-10-07 12:42:50 UTC (rev 5254)
@@ -31,9 +31,9 @@
 {
     public partial class Condition : UserControl
     {
-        private PointRuleType m_prt;
-        private LineRuleType m_lrt;
-        private AreaRuleType m_art;
+        private IPointRule m_prt;
+        private ILineRule m_lrt;
+        private IAreaRule m_art;
         private bool m_isUpdating = false;
 
         public event EventHandler ItemDeleted;
@@ -57,26 +57,26 @@
             InitializeComponent();
         }
 
-        public void SetItem(PointRuleType prt)
+        public void SetItem(IPointRule prt)
         {
             SetItemInternal(prt);
         }
 
-        public void SetItem(LineRuleType lrt)
+        public void SetItem(ILineRule lrt)
         {
             SetItemInternal(lrt);
         }
 
-        public void SetItem(AreaRuleType art)
+        public void SetItem(IAreaRule art)
         {
             SetItemInternal(art);
         }
 
         private void SetItemInternal(object item)
         {
-            m_prt = item as PointRuleType;
-            m_lrt = item as LineRuleType;
-            m_art = item as AreaRuleType;
+            m_prt = item as IPointRule;
+            m_lrt = item as ILineRule;
+            m_art = item as IAreaRule;
 
             try
             {
@@ -85,21 +85,21 @@
                 {
                     RuleCondition.Text = m_prt.Filter;
                     LegendLabel.Text = m_prt.LegendLabel;
-                    FeatureStyle.SetItem(m_prt, m_prt.Item);
+                    FeatureStyle.SetItem(m_prt, m_prt.PointSymbolization2D);
                     LabelStyle.SetItem(m_prt, m_prt.Label);
                 }
                 else if (m_lrt != null)
                 {
                     RuleCondition.Text = m_lrt.Filter;
                     LegendLabel.Text = m_lrt.LegendLabel;
-                    FeatureStyle.SetItem(m_lrt, m_lrt.Items);
+                    FeatureStyle.SetItem(m_lrt, m_lrt.Strokes);
                     LabelStyle.SetItem(m_lrt, m_lrt.Label);
                 }
                 else if (m_art != null)
                 {
                     RuleCondition.Text = m_art.Filter;
                     LegendLabel.Text = m_art.LegendLabel;
-                    FeatureStyle.SetItem(m_art, m_art.Item);
+                    FeatureStyle.SetItem(m_art, m_art.AreaSymbolization2D);
                     LabelStyle.SetItem(m_art, m_art.Label);
                 }
             }

Modified: sandbox/maestro-3.0/Maestro.Editors/LayerDefinition/Vector/Scales/ConditionList.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Editors/LayerDefinition/Vector/Scales/ConditionList.cs	2010-10-07 10:05:07 UTC (rev 5253)
+++ sandbox/maestro-3.0/Maestro.Editors/LayerDefinition/Vector/Scales/ConditionList.cs	2010-10-07 12:42:50 UTC (rev 5254)
@@ -31,11 +31,11 @@
 {
     public partial class ConditionList : UserControl
     {
-        private PointTypeStyleType m_point;
-        private LineTypeStyleType m_line;
-        private AreaTypeStyleType m_area;
+        private IPointVectorStyle m_point;
+        private ILineVectorStyle m_line;
+        private IAreaVectorStyle m_area;
 
-        private VectorScaleRangeType m_parent;
+        private IVectorScaleRange m_parent;
         private object m_selectedItem;
 
         public event EventHandler SelectionChanged;
@@ -59,17 +59,17 @@
             InitializeComponent();
         }
 
-        public void SetItem(VectorScaleRangeType parent, PointTypeStyleType point)
+        public void SetItem(IVectorScaleRange parent, IPointVectorStyle point)
         {
             SetItemInternal(parent, point);
         }
 
-        public void SetItem(VectorScaleRangeType parent, LineTypeStyleType line)
+        public void SetItem(IVectorScaleRange parent, ILineVectorStyle line)
         {
             SetItemInternal(parent, line);
         }
 
-        public void SetItem(VectorScaleRangeType parent, AreaTypeStyleType area)
+        public void SetItem(IVectorScaleRange parent, IAreaVectorStyle area)
         {
             SetItemInternal(parent, area);
         }
@@ -92,12 +92,12 @@
             }
         }
 
-        private void SetItemInternal(VectorScaleRangeType parent, object item)
+        private void SetItemInternal(IVectorScaleRange parent, object item)
         {
             m_parent = parent;
-            m_point = item as PointTypeStyleType;
-            m_line = item as LineTypeStyleType;
-            m_area = item as AreaTypeStyleType;
+            m_point = item as IPointVectorStyle;
+            m_line = item as ILineVectorStyle;
+            m_area = item as IAreaVectorStyle;
 
             this.Controls.Clear();
 
@@ -108,22 +108,18 @@
 
                 if (m_point != null)
                 {
-                    if (m_point.PointRule != null)
-                        foreach (PointRuleType prt in m_point.PointRule)
-                            AddRuleControl(prt);
+                    foreach (IPointRule prt in m_point.Rules)
+                        AddRuleControl(prt);
                 }
                 else if (m_line != null)
                 {
-                    if (m_line.LineRule != null)
-                        foreach (LineRuleType lrt in m_line.LineRule)
-                            AddRuleControl(lrt);
+                    foreach (ILineRule lrt in m_line.Rules)
+                        AddRuleControl(lrt);
                 }
                 else if (m_area != null)
                 {
-                    if (m_area != null)
-                        if (m_area.AreaRule != null)
-                            foreach (AreaRuleType art in m_area.AreaRule)
-                                AddRuleControl(art);
+                    foreach (IAreaRule art in m_area.Rules)
+                        AddRuleControl(art);
                 }
             }
             finally
@@ -140,12 +136,12 @@
 
             Condition c = new Condition();
 
-            if (rule as PointRuleType != null)
-                c.SetItem(rule as PointRuleType);
-            else if (rule as LineRuleType != null)
-                c.SetItem(rule as LineRuleType);
-            else if (rule as AreaRuleType != null)
-                c.SetItem(rule as AreaRuleType);
+            if (rule as IPointRule != null)
+                c.SetItem(rule as IPointRule);
+            else if (rule as ILineRule != null)
+                c.SetItem(rule as ILineRule);
+            else if (rule as IAreaRule != null)
+                c.SetItem(rule as IAreaRule);
 
             c.Owner = m_owner;
             c.Dock = DockStyle.Top;
@@ -202,38 +198,58 @@
         void Rule_ItemDeleted(object sender, EventArgs e)
         {
             foreach (Condition c in this.Controls)
+            {
                 if (c.Item == sender)
                 {
                     this.Controls.Remove(c);
                     break;
                 }
+            }
 
             if (m_point != null)
             {
-                for (int i = 0; i < m_point.PointRule.Count; i++)
-                    if (m_point.PointRule[i] == sender)
+                IPointRule remove = null;
+                foreach (var pr in m_point.Rules)
+                {
+                    if (pr == sender)
                     {
-                        m_point.PointRule.RemoveAt(i);
+                        remove = pr;
                         break;
                     }
+                }
+
+                if (remove != null)
+                    m_point.RemoveRule(remove);
             }
             else if (m_line != null)
             {
-                for (int i = 0; i < m_line.LineRule.Count; i++)
-                    if (m_line.LineRule[i] == sender)
+                ILineRule remove = null;
+                foreach (var lr in m_line.Rules)
+                {
+                    if (lr == sender)
                     {
-                        m_line.LineRule.RemoveAt(i);
+                        remove = lr;
                         break;
                     }
+                }
+
+                if (remove != null)
+                    m_line.RemoveRule(remove);
             }
             else if (m_area != null)
             {
-                for (int i = 0; i < m_area.AreaRule.Count; i++)
-                    if (m_area.AreaRule[i] == sender)
+                IAreaRule remove = null;
+                foreach (var ar in m_area.Rules)
+                {
+                    if (ar == sender)
                     {
-                        m_area.AreaRule.RemoveAt(i);
+                        remove = ar;
                         break;
                     }
+                }
+
+                if (remove != null)
+                    m_area.RemoveRule(remove);
             }
 
             SignalItemChanged();
@@ -265,11 +281,11 @@
 
                 System.Collections.IList ic = null;
                 if (m_point != null)
-                    ic = m_point.PointRule;
+                    ic = (System.Collections.IList)m_point.Rules;
                 else if (m_line != null)
-                    ic = m_line.LineRule;
+                    ic = (System.Collections.IList)m_line.Rules;
                 else if (m_area != null)
-                    ic = m_area.AreaRule;
+                    ic = (System.Collections.IList)m_area.Rules;
 
                 pos = ic.IndexOf(selectedRule);
                 if ((!down && pos > 0) || (down && pos < ic.Count - 1 && pos > 0))

Modified: sandbox/maestro-3.0/Maestro.Editors/LayerDefinition/Vector/Scales/ConditionListButtons.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Editors/LayerDefinition/Vector/Scales/ConditionListButtons.cs	2010-10-07 10:05:07 UTC (rev 5253)
+++ sandbox/maestro-3.0/Maestro.Editors/LayerDefinition/Vector/Scales/ConditionListButtons.cs	2010-10-07 12:42:50 UTC (rev 5254)
@@ -34,11 +34,11 @@
 {
     public partial class ConditionListButtons : UserControl
     {
-        private PointTypeStyleType m_point;
-        private LineTypeStyleType m_line;
-        private AreaTypeStyleType m_area;
+        private IPointVectorStyle m_point;
+        private ILineVectorStyle m_line;
+        private IAreaVectorStyle m_area;
 
-        private VectorScaleRangeType m_parent;
+        private IVectorScaleRange m_parent;
         private object m_lastSelection;
         private object m_currentSelection;
 
@@ -56,12 +56,19 @@
             }
         }
 
-        public ConditionListButtons()
+        private ILayerElementFactory _factory;
+
+        internal ConditionListButtons()
         {
             InitializeComponent();
             conditionList.SelectionChanged += new EventHandler(conditionList_SelectionChanged);
         }
 
+        public ConditionListButtons(ILayerElementFactory factory) : this()
+        {
+            _factory = factory;
+        }
+
         private void conditionList_SelectionChanged(object sender, EventArgs e)
         {
             m_lastSelection = m_currentSelection;
@@ -69,31 +76,31 @@
             CopyRuleButton.Enabled = MoveRuleUpButton.Enabled = MoveRuleDownButton.Enabled = m_currentSelection != null || m_lastSelection != null;        
         }
 
-        public void SetItem(VectorScaleRangeType parent, PointTypeStyleType point)
+        public void SetItem(IVectorScaleRange parent, IPointVectorStyle point)
         {
             SetItemInternal(parent, point);
             conditionList.SetItem(parent, point);
         }
 
-        public void SetItem(VectorScaleRangeType parent, LineTypeStyleType line)
+        public void SetItem(IVectorScaleRange parent, ILineVectorStyle line)
         {
             SetItemInternal(parent, line);
             conditionList.SetItem(parent, line);
         }
 
-        public void SetItem(VectorScaleRangeType parent, AreaTypeStyleType area)
+        public void SetItem(IVectorScaleRange parent, IAreaVectorStyle area)
         {
             SetItemInternal(parent, area);
             conditionList.SetItem(parent, area);
         }
 
 
-        private void SetItemInternal(VectorScaleRangeType parent, object item)
+        private void SetItemInternal(IVectorScaleRange parent, object item)
         {
             m_parent = parent;
-            m_point = item as PointTypeStyleType;
-            m_line = item as LineTypeStyleType;
-            m_area = item as AreaTypeStyleType;
+            m_point = item as IPointVectorStyle;
+            m_line = item as ILineVectorStyle;
+            m_area = item as IAreaVectorStyle;
 
         }
 
@@ -106,21 +113,21 @@
         {
             if (m_point != null)
             {
-                PointRuleType prt = ObjectFactory.CreatePointRule();
-                m_point.PointRule.Add(prt);
+                IPointRule prt = _factory.CreateDefaultPointRule();
                 conditionList.AddRuleControl(prt).Focus();
+                m_point.AddRule(prt);
             }
             else if (m_line != null)
             {
-                LineRuleType lrt = ObjectFactory.CreateLineRule();
-                m_line.LineRule.Add(lrt);
-                conditionList.AddRuleControl(lrt).Focus(); ;
+                ILineRule lrt = _factory.CreateDefaultLineRule();
+                conditionList.AddRuleControl(lrt).Focus();
+                m_line.AddRule(lrt);
             }
             else if (m_area != null)
             {
-                AreaRuleType art = ObjectFactory.CreateAreaRule();
-                m_area.AreaRule.Add(art);
+                IAreaRule art = _factory.CreateDefaultAreaRule();
                 conditionList.AddRuleControl(art).Focus();
+                m_area.AddRule(art);
 
             }
 
@@ -143,7 +150,7 @@
 
                 ILayerDefinition layer = (ILayerDefinition)m_owner.Editor.GetEditedResource();
                 IVectorLayerDefinition vl = (IVectorLayerDefinition)layer.SubLayer;
-                var cls = m_owner.Editor.FeatureService.GetFeatureSourceSchema(vl.FeatureSourceID, vl.FullQualifiedClassName);
+                var cls = m_owner.Editor.FeatureService.GetFeatureSourceSchema(vl.ResourceId, vl.FeatureName);
                 ThemeCreator dlg = new ThemeCreator(
                     m_owner.Editor, 
                     layer,
@@ -177,21 +184,15 @@
 
             if (m_point != null)
             {
-                if (m_point.PointRule == null)
-                    m_point.PointRule = new BindingList<PointRuleType>();
-                m_point.PointRule.Add((PointRuleType)rule);
+                m_point.AddRule((IPointRule)rule);
             }
             else if (m_line != null)
             {
-                if (m_line.LineRule == null)
-                    m_line.LineRule = new BindingList<LineRuleType>();
-                m_line.LineRule.Add((LineRuleType)rule);
+                m_line.AddRule((ILineRule)rule);
             }
             else if (m_area != null)
             {
-                if (m_area.AreaRule == null)
-                    m_area.AreaRule = new BindingList<AreaRuleType>();
-                m_area.AreaRule.Add((AreaRuleType)rule);
+                m_area.AddRule((IAreaRule)rule);
             }
             else
                 return;

Modified: sandbox/maestro-3.0/Maestro.Editors/LayerDefinition/Vector/Scales/ItemStyle.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Editors/LayerDefinition/Vector/Scales/ItemStyle.cs	2010-10-07 10:05:07 UTC (rev 5253)
+++ sandbox/maestro-3.0/Maestro.Editors/LayerDefinition/Vector/Scales/ItemStyle.cs	2010-10-07 12:42:50 UTC (rev 5254)
@@ -32,10 +32,10 @@
 {
     public partial class ItemStyle : UserControl
     {
-        private TextSymbolType m_label;
-        private PointSymbolization2DType m_point;
-        private IList<StrokeType> m_line;
-        private AreaSymbolizationFillType m_area;
+        private ITextSymbol m_label;
+        private IPointSymbolization2D m_point;
+        private IList<IStroke> m_line;
+        private IAreaSymbolizationFill m_area;
 
         private object m_parent;
 
@@ -54,30 +54,37 @@
             set { m_owner = value; }
         }
 
-        public ItemStyle()
+        internal ItemStyle()
         {
             InitializeComponent();
         }
 
-        public void SetItem(object parent, TextSymbolType label)
+        private ILayerElementFactory _factory;
+
+        public ItemStyle(ILayerElementFactory factory)
         {
+            _factory = factory;
+        }
+
+        public void SetItem(object parent, ITextSymbol label)
+        {
             isLabel = true;
             SetItemInternal(parent, label);
         }
 
-        public void SetItem(PointRuleType parent, PointSymbolization2DType point)
+        public void SetItem(IPointRule parent, IPointSymbolization2D point)
         {
             isPoint = true;
             SetItemInternal(parent, point);
         }
 
-        public void SetItem(LineRuleType parent, IList<StrokeType> line)
+        public void SetItem(ILineRule parent, IEnumerable<IStroke> line)
         {
             isLine = true;
             SetItemInternal(parent, line);
         }
 
-        public void SetItem(AreaRuleType parent, AreaSymbolizationFillType area)
+        public void SetItem(IAreaRule parent, IAreaSymbolizationFill area)
         {
             isArea = true;
             SetItemInternal(parent, area);
@@ -86,11 +93,14 @@
         private void SetItemInternal(object parent, object item)
         {
             m_parent = parent;
-            m_label = item as TextSymbolType;
-            m_point = item as PointSymbolization2DType;
-            m_line = item as IList<StrokeType>;
-            m_area = item as AreaSymbolizationFillType;
+            m_label = item as ITextSymbol;
+            m_point = item as IPointSymbolization2D;
+            m_area = item as IAreaSymbolizationFill;
 
+            if (item is IEnumerable<IStroke>)
+                m_line = new List<IStroke>((IEnumerable<IStroke>)item);
+            else
+                m_line = null;
         }
 
         private void previewPicture_Paint(object sender, PaintEventArgs e)
@@ -103,10 +113,10 @@
             }
             else if (m_point != null)
             {
-				if (((PointSymbolization2DType)m_point).Item.GetType() == typeof(MarkSymbolType))
-					FeaturePreviewRender.RenderPreviewPoint(e.Graphics, rect, m_point.Item as MarkSymbolType);
-				else if (((PointSymbolization2DType)m_point).Item.GetType() == typeof(FontSymbolType))
-					FeaturePreviewRender.RenderPreviewFontSymbol(e.Graphics, rect, m_point.Item as FontSymbolType);
+                if (((IPointSymbolization2D)m_point).Symbol.Type == PointSymbolType.Mark)
+					FeaturePreviewRender.RenderPreviewPoint(e.Graphics, rect, m_point.Symbol as IMarkSymbol);
+                else if (((IPointSymbolization2D)m_point).Symbol.Type == PointSymbolType.Font)
+                    FeaturePreviewRender.RenderPreviewFontSymbol(e.Graphics, rect, m_point.Symbol as IFontSymbol);
 			}
             else if (m_line != null)
             {
@@ -126,22 +136,22 @@
             if (isLabel)
             {
                 uc = new FontStyleEditor(m_owner.Editor, m_owner.Schema, m_owner.FeatureSourceId);
-                ((FontStyleEditor)uc).Item = (TextSymbolType)Utility.DeepCopy(m_label);
+                ((FontStyleEditor)uc).Item = (ITextSymbol)Utility.DeepCopy(m_label);
             }
             else if (isPoint)
             {
                 uc = new PointFeatureStyleEditor(m_owner.Editor, m_owner.Schema, m_owner.FeatureSourceId);
-                ((PointFeatureStyleEditor)uc).Item = (PointSymbolization2DType)Utility.XmlDeepCopy(m_point);
+                ((PointFeatureStyleEditor)uc).Item = (IPointSymbolization2D)Utility.XmlDeepCopy(m_point);
             }
             else if (isLine)
             {
-                uc = new LineFeatureStyleEditor(m_owner.Editor, m_owner.Schema, m_owner.FeatureSourceId);
-                ((LineFeatureStyleEditor)uc).Item = (IList<StrokeType>)Utility.XmlDeepCopy(m_line);
+                uc = new LineFeatureStyleEditor(m_owner.Editor, m_owner.Schema, m_owner.FeatureSourceId, _factory);
+                ((LineFeatureStyleEditor)uc).Item = (IList<IStroke>)Utility.XmlDeepCopy(m_line);
             }
             else if (isArea)
             {
                 uc = new AreaFeatureStyleEditor(m_owner.Editor, m_owner.Schema, m_owner.FeatureSourceId);
-                ((AreaFeatureStyleEditor)uc).Item = (AreaSymbolizationFillType)Utility.XmlDeepCopy(m_area);
+                ((AreaFeatureStyleEditor)uc).Item = (IAreaSymbolizationFill)Utility.XmlDeepCopy(m_area);
             }
 
             if (uc != null)
@@ -155,12 +165,12 @@
                     if (isLabel)
                     {
                         m_label = ((FontStyleEditor)uc).Item;
-                        if (m_parent as PointRuleType != null)
-                            ((PointRuleType)m_parent).Label = m_label;
-                        else if (m_parent as LineRuleType != null)
-                            ((LineRuleType)m_parent).Label = m_label;
-                        else if (m_parent as AreaRuleType != null)
-                            ((AreaRuleType)m_parent).Label = m_label;
+                        if (m_parent as IPointRule != null)
+                            ((IPointRule)m_parent).Label = m_label;
+                        else if (m_parent as ILineRule != null)
+                            ((ILineRule)m_parent).Label = m_label;
+                        else if (m_parent as IAreaRule != null)
+                            ((IAreaRule)m_parent).Label = m_label;
 
                         if (ItemChanged != null)
                             ItemChanged(m_label, null);
@@ -168,21 +178,21 @@
                     else if (isPoint)
                     {
                         m_point = ((PointFeatureStyleEditor)uc).Item;
-                        ((PointRuleType)m_parent).Item = m_point;
+                        ((IPointRule)m_parent).PointSymbolization2D = m_point;
                         if (ItemChanged != null)
                             ItemChanged(m_point, null);
                     }
                     else if (isLine)
                     {
                         m_line = ((LineFeatureStyleEditor)uc).Item;
-                        ((LineRuleType)m_parent).Items = (BindingList<StrokeType>)m_line;
+                        ((ILineRule)m_parent).SetStrokes(m_line);
                         if (ItemChanged != null)
                             ItemChanged(m_line, null);
                     }
                     else if (isArea)
                     {
                         m_area = ((AreaFeatureStyleEditor)uc).Item;
-                        ((AreaRuleType)m_parent).Item = m_area; ;
+                        ((IAreaRule)m_parent).AreaSymbolization2D = m_area;
                         if (ItemChanged != null)
                             ItemChanged(m_area, null);
                     }

Modified: sandbox/maestro-3.0/Maestro.Editors/LayerDefinition/Vector/Scales/ScaleRange.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Editors/LayerDefinition/Vector/Scales/ScaleRange.cs	2010-10-07 10:05:07 UTC (rev 5253)
+++ sandbox/maestro-3.0/Maestro.Editors/LayerDefinition/Vector/Scales/ScaleRange.cs	2010-10-07 12:42:50 UTC (rev 5254)
@@ -32,7 +32,7 @@
 {
     public partial class ScaleRange : UserControl
     {
-        private VectorScaleRangeType m_vsc;
+        private IVectorScaleRange m_vsc;
         private bool m_isUpdating = false;
 
         public event EventHandler ItemChanged;
@@ -57,16 +57,16 @@
             InitializeComponent();
         }
 
-        public VectorScaleRangeType Item { get { return m_vsc; } }
+        public IVectorScaleRange Item { get { return m_vsc; } }
 
-        public void SetItem(VectorScaleRangeType vsc)
+        public void SetItem(IVectorScaleRange vsc)
         {
             try
             {
                 m_isUpdating = true;
                 m_vsc = vsc;
-                MaxScale.Text = m_vsc.MaxScaleSpecified ? m_vsc.MaxScale.ToString(Thread.CurrentThread.CurrentUICulture) : Properties.Resources.InfiniteValue;
-                MinScale.Text = m_vsc.MinScaleSpecified ? m_vsc.MinScale.ToString(Thread.CurrentThread.CurrentUICulture) : Properties.Resources.InfiniteValue;
+                MaxScale.Text = m_vsc.MaxScale.HasValue ? m_vsc.MaxScale.Value.ToString(Thread.CurrentThread.CurrentUICulture) : Properties.Resources.InfiniteValue;
+                MinScale.Text = m_vsc.MinScale.HasValue ? m_vsc.MinScale.Value.ToString(Thread.CurrentThread.CurrentUICulture) : Properties.Resources.InfiniteValue;
 
                 scaleRangeConditions.SetItem(m_vsc);
             }
@@ -82,7 +82,7 @@
                 return;
 
             if (MinScale.SelectedIndex == 0)
-                m_vsc.MinScaleSpecified = false;
+                m_vsc.MinScale = null;
 
             if (ItemChanged != null)
                 ItemChanged(m_vsc, null);
@@ -94,7 +94,7 @@
                 return;
 
             if (MaxScale.SelectedIndex == 0)
-                m_vsc.MaxScaleSpecified = false;
+                m_vsc.MaxScale = null;
 
             if (ItemChanged != null)
                 ItemChanged(m_vsc, null);
@@ -109,7 +109,6 @@
 
             if (double.TryParse(MinScale.Text, System.Globalization.NumberStyles.Number, System.Threading.Thread.CurrentThread.CurrentUICulture, out o))
             {
-                m_vsc.MinScaleSpecified = true;
                 m_vsc.MinScale = o;
                 errorProvider.SetError(MinScale, null);
             }
@@ -129,7 +128,6 @@
 
             if (double.TryParse(MaxScale.Text, System.Globalization.NumberStyles.Number, System.Threading.Thread.CurrentThread.CurrentUICulture, out o))
             {
-                m_vsc.MaxScaleSpecified = true;
                 m_vsc.MaxScale = o;
                 errorProvider.SetError(MaxScale, null);
             }

Modified: sandbox/maestro-3.0/Maestro.Editors/LayerDefinition/Vector/Scales/ScaleRangeConditions.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Editors/LayerDefinition/Vector/Scales/ScaleRangeConditions.cs	2010-10-07 10:05:07 UTC (rev 5253)
+++ sandbox/maestro-3.0/Maestro.Editors/LayerDefinition/Vector/Scales/ScaleRangeConditions.cs	2010-10-07 12:42:50 UTC (rev 5254)
@@ -34,7 +34,7 @@
     {
         public event EventHandler ItemChanged;
 
-        private VectorScaleRangeType m_vsc;
+        private IVectorScaleRange m_vsc;
         private bool m_isUpdating = false;
         private bool m_hasUnsupportedItems = false;
 
@@ -54,13 +54,21 @@
             }
         }
 
-        public ScaleRangeConditions()
+        internal ScaleRangeConditions()
         {
             InitializeComponent();
         }
 
-        public void SetItem(VectorScaleRangeType vsc)
+        private ILayerElementFactory _factory;
+
+        public ScaleRangeConditions(ILayerElementFactory factory)
+            : this()
         {
+            _factory = factory;
+        }
+
+        public void SetItem(IVectorScaleRange vsc)
+        {
             try
             {
                 m_isUpdating = true;
@@ -70,28 +78,28 @@
                 bool hasLines = false;
                 bool hasAreas = false;
                 m_hasUnsupportedItems = false;
-                if (m_vsc.Items != null)
-                    foreach (object o in m_vsc.Items)
-                    {
-                        if (o as PointTypeStyleType != null)
-                        {
-                            hasPoints = true;
-                            pointConditionList.SetItem(m_vsc, o as PointTypeStyleType);
-                        }
-                        else if (o as LineTypeStyleType != null)
-                        {
-                            hasLines = true;
-                            lineConditionList.SetItem(m_vsc, o as LineTypeStyleType);
-                        }
-                        else if (o as AreaTypeStyleType != null)
-                        {
-                            hasAreas = true;
-                            areaConditionList.SetItem(m_vsc, o as AreaTypeStyleType);
-                        }
-                        else
-                            m_hasUnsupportedItems = true;
-                    }
 
+                var ps = m_vsc.PointStyle;
+                var ls = m_vsc.LineStyle;
+                var ars = m_vsc.AreaStyle;
+                if (ps != null)
+                {
+                    hasPoints = true;
+                    pointConditionList.SetItem(m_vsc, ps);
+                }
+                else if (ls != null)
+                {
+                    hasLines = true;
+                    lineConditionList.SetItem(m_vsc, ls);
+                }
+                else if (ars != null)
+                {
+                    hasAreas = true;
+                    areaConditionList.SetItem(m_vsc, ars);
+                }
+                else
+                    m_hasUnsupportedItems = true;
+
                 DisplayPoints.Checked = hasPoints;
                 DisplayLines.Checked = hasLines;
                 DisplayAreas.Checked = hasAreas;
@@ -108,12 +116,9 @@
 
             if (DisplayPoints.Checked)
             {
-                if (m_vsc.Items == null)
-                    m_vsc.Items = new BindingList<object>();
-
                 if (DisplayPoints.Tag != null)
                 {
-                    m_vsc.PointStyle = (PointTypeStyleType)DisplayPoints.Tag;
+                    m_vsc.PointStyle = (IPointVectorStyle)DisplayPoints.Tag;
                     DisplayPoints.Tag = null;
                 }
 
@@ -121,7 +126,7 @@
 
                 if (!hasPoint)
                 {
-                    var pst = ObjectFactory.CreateDefaultPointStyle();
+                    var pst = _factory.CreateDefaultPointStyle();
                     m_vsc.PointStyle = pst;
                     pointConditionList.SetItem(m_vsc, pst);
                 }
@@ -145,12 +150,9 @@
 
             if (DisplayLines.Checked)
             {
-                if (m_vsc.Items == null)
-                    m_vsc.Items = new BindingList<object>();
-
                 if (DisplayLines.Tag != null)
                 {
-                    m_vsc.LineStyle = (LineTypeStyleType)DisplayLines.Tag;
+                    m_vsc.LineStyle = (ILineVectorStyle)DisplayLines.Tag;
                     DisplayLines.Tag = null;
                 }
 
@@ -158,7 +160,7 @@
 
                 if (!hasLine)
                 {
-                    var ls = ObjectFactory.CreateDefaultLineStyle();
+                    var ls = _factory.CreateDefaultLineStyle();
                     m_vsc.LineStyle = ls;
                     lineConditionList.SetItem(m_vsc, ls);
                 }
@@ -181,12 +183,9 @@
 
             if (DisplayAreas.Checked)
             {
-                if (m_vsc.Items == null)
-                    m_vsc.Items = new BindingList<object>();
-
                 if (DisplayAreas.Tag != null)
                 {
-                    m_vsc.AreaStyle = (AreaTypeStyleType)DisplayAreas.Tag;
+                    m_vsc.AreaStyle = (IAreaVectorStyle)DisplayAreas.Tag;
                     DisplayAreas.Tag = null;
                 }
 
@@ -194,7 +193,7 @@
 
                 if (!hasArea)
                 {
-                    var ast = ObjectFactory.CreateDefaultAreaStyle();
+                    var ast = _factory.CreateDefaultAreaStyle();
                     m_vsc.AreaStyle = ast;
                     areaConditionList.SetItem(m_vsc, ast);
                 }

Modified: sandbox/maestro-3.0/Maestro.Editors/LayerDefinition/Vector/Scales/ScaleRangeList.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Editors/LayerDefinition/Vector/Scales/ScaleRangeList.cs	2010-10-07 10:05:07 UTC (rev 5253)
+++ sandbox/maestro-3.0/Maestro.Editors/LayerDefinition/Vector/Scales/ScaleRangeList.cs	2010-10-07 12:42:50 UTC (rev 5254)
@@ -33,10 +33,10 @@
 {
     public partial class ScaleRangeList : UserControl
     {
-        private VectorLayerDefinitionType m_vldef;
+        private IVectorLayerDefinition m_vldef;
         public event EventHandler ItemChanged;
         public event EventHandler SelectionChanged;
-        private VectorScaleRangeType m_selectedItem;
+        private IVectorScaleRange m_selectedItem;
         private VectorLayerEditorCtrl m_owner;
 
         public bool HasUnsupportedItems
@@ -68,21 +68,21 @@
             InitializeComponent();
         }
 
-        public VectorLayerDefinitionType Item
+        public IVectorLayerDefinition Item
         {
             get { return m_vldef; }
         }
 
-        public void SetItem(VectorLayerDefinitionType vldef)
+        public void SetItem(IVectorLayerDefinition vldef)
         {
             ControlList.Controls.Clear();
             m_vldef = vldef;
 
-            foreach (VectorScaleRangeType sc in m_vldef.VectorScaleRange)
+            foreach (IVectorScaleRange sc in m_vldef.VectorScaleRange)
                 AddScaleRange(sc);
         }
 
-        public VectorScaleRangeType SelectedItem
+        public IVectorScaleRange SelectedItem
         {
             get
             {
@@ -90,7 +90,7 @@
             }
         }
 
-        public ScaleRange AddScaleRange(VectorScaleRangeType sc)
+        public ScaleRange AddScaleRange(IVectorScaleRange sc)
         {
             ScaleRange sr = new ScaleRange();
             sr.Owner = m_owner;
@@ -130,7 +130,7 @@
                 ItemChanged(m_vldef, null);
         }
 
-        public void RemoveScaleRange(VectorScaleRangeType sc)
+        public void RemoveScaleRange(IVectorScaleRange sc)
         {
             foreach(ScaleRange sr in ControlList.Controls)
                 if (sr.Item == sc)

Modified: sandbox/maestro-3.0/Maestro.Editors/LayerDefinition/Vector/StyleEditors/AreaFeatureStyleEditor.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Editors/LayerDefinition/Vector/StyleEditors/AreaFeatureStyleEditor.cs	2010-10-07 10:05:07 UTC (rev 5253)
+++ sandbox/maestro-3.0/Maestro.Editors/LayerDefinition/Vector/StyleEditors/AreaFeatureStyleEditor.cs	2010-10-07 12:42:50 UTC (rev 5254)
@@ -58,14 +58,14 @@
 		private System.Data.DataColumn dataColumn5;
 		private System.Data.DataColumn dataColumn6;
 
-		private AreaSymbolizationFillType m_item;
+		private IAreaSymbolizationFill m_item;
 		private FillStyleEditor fillStyleEditor;
 		private LineStyleEditor lineStyleEditor;
 		private System.Windows.Forms.ComboBox sizeUnitsCombo;
 		private bool m_inUpdate = false;
 
-		private FillType previousFill = null;
-		private StrokeType previousStroke = null;
+		private IFill previousFill = null;
+		private IStroke previousStroke = null;
 
 		public event EventHandler Changed;
 
@@ -73,6 +73,7 @@
         private FeatureSourceDescription.FeatureSourceSchema m_schema;
         private string m_featureSource;
         private string m_providername;
+        private ILayerElementFactory _factory;
 
         public AreaFeatureStyleEditor(IEditorService editor, FeatureSourceDescription.FeatureSourceSchema schema, string featureSource)
             : this()
@@ -80,6 +81,7 @@
             m_editor = editor;
             m_schema = schema;
 
+            _factory = (ILayerElementFactory)editor.GetEditedResource();
             var fs = (FeatureSourceType)m_editor.ResourceService.GetResource(featureSource);
 
             m_providername = fs.Provider;
@@ -348,7 +350,7 @@
 			FeaturePreviewRender.RenderPreviewArea(e.Graphics, new Rectangle(1, 1, previewPicture.Width - 4, previewPicture.Height - 4), m_item);
 		}
 
-		public AreaSymbolizationFillType Item 
+		public IAreaSymbolizationFill Item 
 		{
 			get { return m_item; }
 			set
@@ -375,7 +377,7 @@
 				return;
 
 			if (fillStyleEditor.displayFill.Checked)
-				m_item.Fill = previousFill == null ? ObjectFactory.CreateDefaultFill() : previousFill;
+				m_item.Fill = previousFill == null ? _factory.CreateDefaultFill() : previousFill;
 			else
 			{
 				if (m_item.Fill != null)
@@ -415,7 +417,7 @@
 				return;
 
 			if (lineStyleEditor.displayLine.Checked)
-				m_item.Stroke = previousStroke == null ? ObjectFactory.CreateDefaultStroke() : previousStroke;
+                m_item.Stroke = previousStroke == null ? _factory.CreateDefaultStroke() : previousStroke;
 			else
 			{
 				if (m_item.Stroke != null)

Modified: sandbox/maestro-3.0/Maestro.Editors/LayerDefinition/Vector/StyleEditors/FontStyleEditor.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Editors/LayerDefinition/Vector/StyleEditors/FontStyleEditor.cs	2010-10-07 10:05:07 UTC (rev 5253)
+++ sandbox/maestro-3.0/Maestro.Editors/LayerDefinition/Vector/StyleEditors/FontStyleEditor.cs	2010-10-07 12:42:50 UTC (rev 5254)
@@ -90,7 +90,7 @@
 		/// </summary>
 		private System.ComponentModel.Container components = null;
 
-		private TextSymbolType m_item;
+		private ITextSymbol m_item;
 		internal System.Windows.Forms.Label verticalLabel;
 		internal System.Windows.Forms.Label horizontalLabel;
         private CheckBox DisplayLabel;
@@ -107,6 +107,8 @@
         private string m_featureSource;
         private string m_providername;
 
+        private ILayerElementFactory _factory;
+
         public FontStyleEditor(IEditorService editor, FeatureSourceDescription.FeatureSourceSchema schema, string featureSource)
             : this()
         {
@@ -115,6 +117,8 @@
 
             var fs = (FeatureSourceType)editor.ResourceService.GetResource(featureSource);
 
+            _factory = (ILayerElementFactory)editor.GetEditedResource();
+
             m_providername = fs.Provider;
             m_featureSource = featureSource;
 
@@ -176,7 +180,7 @@
                 backgroundColor.CurrentColor = Utility.ParseHTMLColor(m_item.BackgroundColor);
 				backgroundTypeCombo.SelectedValue = m_item.BackgroundStyle.ToString();
                 rotationCombo.SelectedIndex = -1;
-                rotationCombo.Text = m_item.Rotation;
+                rotationCombo.Text = m_item.Rotation.HasValue ? m_item.Rotation.ToString() : "";
                 if (m_item.HorizontalAlignment != null)
                 {
                     horizontalCombo.SelectedValue = m_item.HorizontalAlignment;
@@ -773,7 +777,7 @@
 		{
             if (sizeCombo.SelectedIndex == sizeCombo.Items.Count - 1)
             {
-                string current = m_item.SizeX;
+                string current = m_item.SizeX.HasValue ? m_item.SizeX.ToString() : string.Empty;
                 string expr = m_editor.EditExpression(current, m_schema, m_providername, m_featureSource);
                 if (!string.IsNullOrEmpty(expr))
                     current = expr;
@@ -892,7 +896,7 @@
 		{
             if (rotationCombo.SelectedIndex == rotationCombo.Items.Count - 1)
             {
-                string current = m_item.Rotation;
+                string current = m_item.Rotation.HasValue ? m_item.Rotation.Value.ToString() : string.Empty;
                 string expr = m_editor.EditExpression(current, m_schema, m_providername, m_featureSource);
                 if (!string.IsNullOrEmpty(expr))
                     current = expr;
@@ -902,10 +906,18 @@
             }
             else if (rotationCombo.SelectedIndex != -1)
             {
-                m_item.Rotation = (string)rotationCombo.SelectedValue;
+                m_item.Rotation = StringToDouble((string)rotationCombo.SelectedValue);
             }
         }
 
+        static double? StringToDouble(string value)
+        {
+            double d;
+            if (double.TryParse(value, out d))
+                return d;
+            return null;
+        }
+
 		private void previewPicture_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
 		{
 			FeaturePreviewRender.RenderPreviewFont(e.Graphics, new Rectangle(1, 1, previewPicture.Width - 2, previewPicture.Height - 2), m_item);
@@ -928,7 +940,7 @@
                 Changed(this, new EventArgs());
         }
 
-		public TextSymbolType Item
+        public ITextSymbol Item
 		{
 			get { return m_item; }
 			set 
@@ -948,10 +960,10 @@
 
             if (DisplayLabel.Checked)
             {
-                if (DisplayLabel.Tag as TextSymbolType != null)
-                    this.Item = DisplayLabel.Tag as TextSymbolType;
+                if (DisplayLabel.Tag as ITextSymbol != null)
+                    this.Item = DisplayLabel.Tag as ITextSymbol;
                 if (m_item == null)
-                    this.Item = ObjectFactory.CreateDefaultTextSymbol();
+                    this.Item = _factory.CreateDefaultTextSymbol();
             }
             else
             {
@@ -967,7 +979,7 @@
                 return;
 
             //TODO: Validate
-            m_item.SizeX = m_item.SizeY = sizeCombo.Text;
+            m_item.SizeX = m_item.SizeY = StringToDouble(sizeCombo.Text);
             previewPicture.Refresh();
 
             if (Changed != null)
@@ -1033,7 +1045,7 @@
                 return;
 
             //TODO: Validate
-            m_item.Rotation = rotationCombo.Text;
+            m_item.Rotation = StringToDouble(rotationCombo.Text);
             previewPicture.Refresh();
 
             if (Changed != null)

Modified: sandbox/maestro-3.0/Maestro.Editors/LayerDefinition/Vector/StyleEditors/LineFeatureStyleEditor.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Editors/LayerDefinition/Vector/StyleEditors/LineFeatureStyleEditor.cs	2010-10-07 10:05:07 UTC (rev 5253)
+++ sandbox/maestro-3.0/Maestro.Editors/LayerDefinition/Vector/StyleEditors/LineFeatureStyleEditor.cs	2010-10-07 12:42:50 UTC (rev 5254)
@@ -53,7 +53,7 @@
 		private System.Windows.Forms.ComboBox sizeContextCombo;
 		private LineStyleEditor lineStyleEditor;
 		
-		private IList<StrokeType> m_item = null;
+		private IList<IStroke> m_item = null;
 		private System.Windows.Forms.Panel compositePanel;
 		private System.Windows.Forms.GroupBox lineGroup;
 		private System.Windows.Forms.GroupBox sizeGroup;
@@ -76,13 +76,16 @@
         private FeatureSourceDescription.FeatureSourceSchema m_schema;
         private string m_featureSource;
         private string m_providername;
+        private ILayerElementFactory _factory;
 
-        public LineFeatureStyleEditor(IEditorService editor, FeatureSourceDescription.FeatureSourceSchema schema, string featureSource)
+        public LineFeatureStyleEditor(IEditorService editor, FeatureSourceDescription.FeatureSourceSchema schema, string featureSource, ILayerElementFactory factory)
             : this()
         {
             m_editor = editor;
             m_schema = schema;
 
+            _factory = (ILayerElementFactory)editor.GetEditedResource();
+
             var fs = (FeatureSourceType)editor.ResourceService.GetResource(featureSource);
 
             m_providername = fs.Provider;
@@ -114,7 +117,7 @@
 
 				lineStyles.Items.Clear();
 				if (applyLineStyle.Checked)
-					foreach(StrokeType st in m_item)
+                    foreach (IStroke st in m_item)
 						lineStyles.Items.Add(st);
 
 				compositeLines.Checked = lineStyles.Items.Count > 1;
@@ -137,7 +140,7 @@
 			try
 			{
 				m_inUpdate = true;
-				StrokeType st = this.CurrentStrokeType;
+                IStroke st = this.CurrentStrokeType;
 				sizeGroup.Enabled = 
 				lineGroup.Enabled =
 				previewGroup.Enabled =
@@ -174,16 +177,16 @@
 
 		}
 
-		private StrokeType CurrentStrokeType
+        private IStroke CurrentStrokeType
 		{
 			get 
 			{
 				if (lineStyles.Items.Count == 0)
 					return null;
 				else if (lineStyles.Items.Count == 1 || lineStyles.SelectedIndex <= 0)
-					return (StrokeType)lineStyles.Items[0];
+                    return (IStroke)lineStyles.Items[0];
 				else
-					return (StrokeType)lineStyles.SelectedItem;
+                    return (IStroke)lineStyles.SelectedItem;
 			}
 		}
 
@@ -492,7 +495,7 @@
 				Changed(this, new EventArgs());
 		}
 
-		public IList<StrokeType> Item
+        public IList<IStroke> Item
 		{
 			get { return m_item; }
 			set
@@ -566,17 +569,17 @@
                 if (!applyLineStyle.Checked)
                 {
                     applyLineStyle.Tag = m_item;
-                    m_item = new BindingList<StrokeType>();
+                    m_item = new BindingList<IStroke>();
                 }
                 else
                 {
-                    m_item = applyLineStyle.Tag as IList<StrokeType>;
+                    m_item = applyLineStyle.Tag as IList<IStroke>;
 
                     if (m_item == null)
-                        m_item = new BindingList<StrokeType>();
+                        m_item = new BindingList<IStroke>();
 
                     if (m_item.Count == 0)
-                        m_item.Add(ObjectFactory.CreateDefaultStroke());
+                        m_item.Add(_factory.CreateDefaultStroke());
 
                     UpdateDisplay();
                 }
@@ -611,8 +614,8 @@
             
             if (e.Index >= 0 && e.Index < lineStyles.Items.Count)
 			{
-                var col = new BindingList<StrokeType>();
-				col.Add((StrokeType) lineStyles.Items[e.Index]);
+                var col = new BindingList<IStroke>();
+				col.Add((IStroke) lineStyles.Items[e.Index]);
 				FeaturePreviewRender.RenderPreviewLine(e.Graphics, new Rectangle(e.Bounds.Left + 1, e.Bounds.Top + 1, e.Bounds.Width - 2, e.Bounds.Height - 2), col);		
 			}
 		}
@@ -631,7 +634,7 @@
 
         private void AddStyleButton_Click(object sender, EventArgs e)
         {
-            m_item.Add(ObjectFactory.CreateDefaultStroke());
+            m_item.Add(_factory.CreateDefaultStroke());
             UpdateDisplay();
             lineStyles.SelectedIndex = lineStyles.Items.Count - 1;
         }

Modified: sandbox/maestro-3.0/Maestro.Editors/LayerDefinition/Vector/StyleEditors/PointFeatureStyleEditor.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Editors/LayerDefinition/Vector/StyleEditors/PointFeatureStyleEditor.cs	2010-10-07 10:05:07 UTC (rev 5253)
+++ sandbox/maestro-3.0/Maestro.Editors/LayerDefinition/Vector/StyleEditors/PointFeatureStyleEditor.cs	2010-10-07 12:42:50 UTC (rev 5254)
@@ -30,6 +30,7 @@
 using System.Globalization;
 using OSGeo.MapGuide.ObjectModels;
 using OSGeo.MapGuide.MaestroAPI.ObjectModels;
+using System.Threading;
 
 namespace Maestro.Editors.LayerDefinition.Vector.StyleEditors
 {
@@ -72,15 +73,15 @@
 		private System.Windows.Forms.ComboBox Symbol;
 		private LineStyleEditor lineStyleEditor;
 
-		private PointSymbolization2DType m_item;
-        private MarkSymbolType m_lastMark = null;
-        private FontSymbolType m_lastFont = null;
+		private IPointSymbolization2D m_item;
+        private IMarkSymbol m_lastMark = null;
+        private IFontSymbol m_lastFont = null;
 
 		private bool m_inUpdate = false;
 
-		private FillType previousFill = null;
+		private IFill previousFill = null;
         private CheckBox DisplayPoints;
-		private StrokeType previousEdge = null;
+		private IStroke previousEdge = null;
 		private GroupBox groupBoxFont;
 		private ComboBox fontCombo;
 		private Label label10;
@@ -111,6 +112,7 @@
         private FeatureSourceDescription.FeatureSourceSchema m_schema;
         private string m_featureSource;
         private string m_providername;
+        private ILayerElementFactory _factory;
 
         public PointFeatureStyleEditor(IEditorService editor, FeatureSourceDescription.FeatureSourceSchema schema, string featureSource)
             : this()
@@ -118,10 +120,13 @@
             m_editor = editor;
             m_schema = schema;
 
+            _factory = (ILayerElementFactory)editor.GetEditedResource();
             var fs = (FeatureSourceType)editor.ResourceService.GetResource(featureSource);
 
             m_providername = fs.Provider;
             m_featureSource = featureSource;
+
+            m_item = _factory.CreateDefaultPointSymbolization2D();
         }
 
 		private PointFeatureStyleEditor()
@@ -149,9 +154,6 @@
             lineStyleEditor.thicknessCombo.TextChanged += new EventHandler(thicknessCombo_TextChanged);
 			lineStyleEditor.colorCombo.CurrentColorChanged +=new EventHandler(colorCombo_CurrentColorChanged);
 			lineStyleEditor.fillCombo.SelectedIndexChanged +=new EventHandler(fillCombo_Line_SelectedIndexChanged);
-
-			m_item = new PointSymbolization2DType();
-			m_item.Item = new MarkSymbolType();
 		}
 
 		private void setUIForMarkSymbol(bool enabled)
@@ -180,35 +182,32 @@
 
                 DisplayPoints.Checked = true;
 
-				if (m_item.Item == null)
-					m_item.Item = new MarkSymbolType();
+                if (m_item.Symbol == null)
+                    m_item.Symbol = _factory.CreateDefaultMarkSymbol();
 
 				// shared values
-				WidthText.Text = m_item.Item.SizeX;
-				HeigthText.Text = m_item.Item.SizeY;
+                WidthText.Text = DoubleToString(m_item.Symbol.SizeX);
+                HeigthText.Text = DoubleToString(m_item.Symbol.SizeY);
                 RotationBox.SelectedIndex = -1;
-				RotationBox.Text = m_item.Item.Rotation;
+                RotationBox.Text = DoubleToString(m_item.Symbol.Rotation);
 
-				SizeUnits.SelectedValue = m_item.Item.Unit;
-				SizeContext.SelectedValue = m_item.Item.SizeContext.ToString();
+                SizeUnits.SelectedValue = m_item.Symbol.Unit;
+                SizeContext.SelectedValue = m_item.Symbol.SizeContext.ToString();
 
 				// specifics
-				if (m_item.Item.GetType() == typeof(MarkSymbolType))
+				if (m_item.Symbol.Type == PointSymbolType.Mark)
 				{
-					MaintainAspectRatio.Checked = m_item.Item.MaintainAspect;
+                    MaintainAspectRatio.Checked = m_item.Symbol.MaintainAspect;
 					double d;
-					if (double.TryParse(m_item.Item.InsertionPointX, NumberStyles.Float, CultureInfo.InvariantCulture, out d))
-						ReferenceX.Text = d.ToString(System.Threading.Thread.CurrentThread.CurrentUICulture);
-					else
-						ReferenceX.Text = m_item.Item.InsertionPointX;
+                    ReferenceX.Text = DoubleToString(m_item.Symbol.InsertionPointX);
 
                     //if (double.TryParse(m_item.Item.InsertionPointY, NumberStyles.Float, CultureInfo.InvariantCulture, out d))
                     //    ReferenceY.Text = d.ToString(System.Threading.Thread.CurrentThread.CurrentUICulture);
                     //else
                     //    ReferenceY.Text = m_item.Item.InsertionPointY;
-                    ReferenceY.Text = m_item.Item.InsertionPointY.ToString(System.Threading.Thread.CurrentThread.CurrentUICulture);
+                    ReferenceY.Text = DoubleToString(m_item.Symbol.InsertionPointY);
 
-					MarkSymbolType t = (MarkSymbolType)m_item.Item;
+                    IMarkSymbol t = (IMarkSymbol)m_item.Symbol;
 					Symbol.SelectedValue = t.Shape.ToString();
 
 					fillStyleEditor.displayFill.Checked = t.Fill != null;
@@ -234,9 +233,9 @@
 
 					setUIForMarkSymbol(true);
 				}
-				else if (m_item.Item.GetType() == typeof(FontSymbolType))
+				else if (m_item.Symbol.Type == PointSymbolType.Font)
 				{
-					FontSymbolType f = (FontSymbolType)m_item.Item;
+					IFontSymbol f = (IFontSymbol)m_item.Symbol;
 
 					// TODO: Dislike this hard coding, but with association from 'Shape' the 'Font...' string cannot be found or set from the Symbol combobox
 					Symbol.SelectedIndex = 6;
@@ -249,9 +248,9 @@
                     if (comboBoxCharacter.Text != f.Character)
                         comboBoxCharacter.Text = f.Character;
 
-                    FontBoldButton.Checked = f.Bold && f.BoldSpecified;
-                    FontItalicButton.Checked = f.Italic && f.ItalicSpecified;
-                    FontUnderlineButton.Checked = f.Underlined && f.UnderlinedSpecified;
+                    FontBoldButton.Checked = f.Bold.HasValue && f.Bold.Value;
+                    FontItalicButton.Checked = f.Italic.HasValue && f.Italic.Value;
+                    FontUnderlineButton.Checked = f.Underlined.HasValue && f.Underlined.Value;
 
                     if (string.IsNullOrEmpty(f.ForegroundColor))
                         colorFontForeground.CurrentColor = Color.Black;
@@ -783,10 +782,10 @@
 		private void previewPicture_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
 		{
             e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
-			if (m_item != null && m_item.Item as MarkSymbolType != null)
-				FeaturePreviewRender.RenderPreviewPoint(e.Graphics, new Rectangle(1, 1, previewPicture.Width - 2, previewPicture.Height - 2), (MarkSymbolType)m_item.Item);
-			else if (m_item != null && m_item.Item as FontSymbolType != null)
-				FeaturePreviewRender.RenderPreviewFontSymbol(e.Graphics, new Rectangle(1, 1, previewPicture.Width - 2, previewPicture.Height - 2), (FontSymbolType)m_item.Item);
+			if (m_item != null && m_item.Symbol.Type == PointSymbolType.Mark)
+				FeaturePreviewRender.RenderPreviewPoint(e.Graphics, new Rectangle(1, 1, previewPicture.Width - 2, previewPicture.Height - 2), (IMarkSymbol)m_item.Symbol);
+			else if (m_item != null && m_item.Symbol.Type == PointSymbolType.Font)
+                FeaturePreviewRender.RenderPreviewFontSymbol(e.Graphics, new Rectangle(1, 1, previewPicture.Width - 2, previewPicture.Height - 2), (IFontSymbol)m_item.Symbol);
 			else
                 FeaturePreviewRender.RenderPreviewPoint(e.Graphics, new Rectangle(1, 1, previewPicture.Width - 2, previewPicture.Height - 2), null);
 		}
@@ -808,20 +807,20 @@
                     break;
                 }
 
-            if (m_item.Item is MarkSymbolType)
-                m_lastMark = (MarkSymbolType)m_item.Item;
-            else if (m_item.Item is FontSymbolType)
-                m_lastFont = (FontSymbolType)m_item.Item;
+            if (m_item.Symbol.Type == PointSymbolType.Mark)
+                m_lastMark = (IMarkSymbol)m_item.Symbol;
+            else if (m_item.Symbol.Type == PointSymbolType.Font)
+                m_lastFont = (IFontSymbol)m_item.Symbol;
 
             if (isSymbol)
             {
-                bool update = m_item.Item != m_lastMark;
+                bool update = m_item.Symbol != m_lastMark;
 
                 if (m_lastMark == null)
-                    m_lastMark = new MarkSymbolType();
+                    m_lastMark = _factory.CreateDefaultMarkSymbol();
 
                 m_lastMark.Shape = selectedShape;
-                m_item.Item = m_lastMark;
+                m_item.Symbol = m_lastMark;
                 
                 setUIForMarkSymbol(true);
                 if (update)
@@ -832,19 +831,19 @@
 			    // user wants to change away FROM a valid 'Mark' symbol type
 			    // if ("Font..." == Symbol.SelectedText)
 
-                bool update = m_item.Item != m_lastFont;
+                bool update = m_item.Symbol != m_lastFont;
 
                 if (m_lastFont == null)
                 {
-                    m_lastFont = new FontSymbolType();
+                    m_lastFont = _factory.CreateDefaultFontSymbol();
                     m_lastFont.SizeContext = SizeContextType.DeviceUnits;
-                    m_lastFont.Rotation = "0";
-                    m_lastFont.SizeX = "10";
-                    m_lastFont.SizeY = "10";
+                    m_lastFont.Rotation = 0.0;
+                    m_lastFont.SizeX = 10;
+                    m_lastFont.SizeY = 10;
                     m_lastFont.Unit = LengthUnitType.Points;
                 }
 
-                m_item.Item = m_lastFont;
+                m_item.Symbol = m_lastFont;
                 setUIForMarkSymbol(false);
                 if (update)
                     UpdateDisplay();
@@ -865,10 +864,10 @@
 			if (m_inUpdate)
 				return;
 
-            if (m_item.Item.GetType() == typeof(MarkSymbolType))
-                ((MarkSymbolType)m_item.Item).SizeContext = (SizeContextType)Enum.Parse((typeof(SizeContextType)), (string)SizeContext.SelectedValue);
-            else if (m_item.Item.GetType() == typeof(FontSymbolType))
-                ((FontSymbolType)m_item.Item).SizeContext = (SizeContextType)Enum.Parse((typeof(SizeContextType)), (string)SizeContext.SelectedValue);
+            if (m_item.Symbol.Type == PointSymbolType.Mark)
+                ((IMarkSymbol)m_item.Symbol).SizeContext = (SizeContextType)Enum.Parse((typeof(SizeContextType)), (string)SizeContext.SelectedValue);
+            else if (m_item.Symbol.Type == PointSymbolType.Font)
+                ((IFontSymbol)m_item.Symbol).SizeContext = (SizeContextType)Enum.Parse((typeof(SizeContextType)), (string)SizeContext.SelectedValue);
 			previewPicture.Refresh();
 			if (Changed != null)
 				Changed(this, new EventArgs());
@@ -879,10 +878,8 @@
 			if (m_inUpdate)
 				return;
 
-			if (m_item.Item.GetType() == typeof(MarkSymbolType))
-				((MarkSymbolType)m_item.Item).Unit = (LengthUnitType)Enum.Parse(typeof(LengthUnitType), (string)SizeUnits.SelectedValue);
-			else if (m_item.Item.GetType() == typeof(FontSymbolType))
-				((FontSymbolType)m_item.Item).Unit = (LengthUnitType)Enum.Parse(typeof(LengthUnitType), (string)SizeUnits.SelectedValue);
+			if (m_item.Symbol.Type == PointSymbolType.Mark || m_item.Symbol.Type == PointSymbolType.Font)
+                m_item.Symbol.Unit = (LengthUnitType)Enum.Parse(typeof(LengthUnitType), (string)SizeUnits.SelectedValue);
 			previewPicture.Refresh();
 			if (Changed != null)
 				Changed(this, new EventArgs());
@@ -919,10 +916,8 @@
             if (WidthText.SelectedIndex == WidthText.Items.Count - 1)
             {
                 string current = null;
-                if (m_item.Item.GetType() == typeof(MarkSymbolType))
-                    current = ((MarkSymbolType)m_item.Item).SizeX;
-                else if (m_item.Item.GetType() == typeof(FontSymbolType))
-                    current = ((FontSymbolType)m_item.Item).SizeX;
+                if (m_item.Symbol.Type == PointSymbolType.Mark || m_item.Symbol.Type == PointSymbolType.Font)
+                    current = DoubleToString(m_item.Symbol.SizeX);
 
                 string expr = null;
                 if (current != null)
@@ -945,10 +940,8 @@
             if (HeigthText.SelectedIndex == HeigthText.Items.Count - 1)
             {
                 string current = null;
-                if (m_item.Item.GetType() == typeof(MarkSymbolType))
-                    current = ((MarkSymbolType)m_item.Item).SizeY;
-                else if (m_item.Item.GetType() == typeof(FontSymbolType))
-                    current = ((FontSymbolType)m_item.Item).SizeY;
+                if (m_item.Symbol.Type == PointSymbolType.Mark || m_item.Symbol.Type == PointSymbolType.Font)
+                    current = DoubleToString(m_item.Symbol.SizeY);
 
                 string expr = null;
                 if (current != null)
@@ -968,15 +961,15 @@
 			if (m_inUpdate)
 				return;
 
-            if (m_item.Item.GetType() == typeof(MarkSymbolType))
+            if (m_item.Symbol.Type == PointSymbolType.Mark)
             {
                 double d;
                 if (ReferenceX.Text.Trim().Length == 0)
-                    ((MarkSymbolType)m_item.Item).InsertionPointY = 0.5;
+                    m_item.Symbol.InsertionPointY = 0.5;
                 else if (double.TryParse(ReferenceX.Text, System.Globalization.NumberStyles.Float, System.Threading.Thread.CurrentThread.CurrentUICulture, out d) || double.TryParse(ReferenceX.Text, System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture, out d))
-                    ((MarkSymbolType)m_item.Item).InsertionPointX = Math.Min(Math.Max(0.0, d), 1.0).ToString(System.Globalization.CultureInfo.InvariantCulture);
+                    m_item.Symbol.InsertionPointX = StringToDouble(Math.Min(Math.Max(0.0, d), 1.0).ToString(System.Globalization.CultureInfo.InvariantCulture));
                 else
-                    ((MarkSymbolType)m_item.Item).InsertionPointX = ReferenceX.Text;
+                    m_item.Symbol.InsertionPointX = StringToDouble(ReferenceX.Text);
             }
 			previewPicture.Refresh();		
 			if (Changed != null)
@@ -988,13 +981,13 @@
 			if (m_inUpdate)
 				return;
 
-            if (m_item.Item.GetType() == typeof(MarkSymbolType))
+            if (m_item.Symbol.Type == PointSymbolType.Mark)
             {
                 double d;
                 if (double.TryParse(ReferenceY.Text, System.Globalization.NumberStyles.Float, System.Threading.Thread.CurrentThread.CurrentUICulture, out d) || double.TryParse(ReferenceY.Text, System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture, out d))
-                    ((MarkSymbolType)m_item.Item).InsertionPointY = Math.Min(Math.Max(0.0, d), 1.0);
+                    m_item.Symbol.InsertionPointY = Math.Min(Math.Max(0.0, d), 1.0);
                 else
-                    ((MarkSymbolType)m_item.Item).InsertionPointY = 0.5;
+                    m_item.Symbol.InsertionPointY = 0.5;
             }
 			previewPicture.Refresh();		
 			if (Changed != null)
@@ -1009,10 +1002,8 @@
             if (RotationBox.SelectedIndex == RotationBox.Items.Count - 1)
             {
                 string current = null;
-                if (m_item.Item.GetType() == typeof(MarkSymbolType))
-                    current = ((MarkSymbolType)m_item.Item).Rotation;
-                else if (m_item.Item.GetType() == typeof(FontSymbolType))
-                    current = ((FontSymbolType)m_item.Item).Rotation;
+                if (m_item.Symbol.Type == PointSymbolType.Mark || m_item.Symbol.Type == PointSymbolType.Font)
+                    current = DoubleToString(m_item.Symbol.Rotation);
 
                 string expr = null;
                 if (current != null)
@@ -1027,10 +1018,8 @@
             }
             else if (RotationBox.SelectedIndex != -1)
             {
-                if (m_item.Item.GetType() == typeof(MarkSymbolType))
-                    ((MarkSymbolType)m_item.Item).Rotation = (string)RotationBox.SelectedValue;
-                else if (m_item.Item.GetType() == typeof(FontSymbolType))
-                    ((FontSymbolType)m_item.Item).Rotation = (string)RotationBox.SelectedValue;
+                if (m_item.Symbol.Type == PointSymbolType.Mark || m_item.Symbol.Type == PointSymbolType.Font)
+                    m_item.Symbol.Rotation = StringToDouble((string)RotationBox.SelectedValue);
 
                 //RotationBox.SelectedIndex = -1;
             }
@@ -1042,14 +1031,14 @@
 			if (m_inUpdate)
 				return;
 
-			if (m_item.Item.GetType() == typeof(MarkSymbolType))
+			if (m_item.Symbol.Type == PointSymbolType.Mark)
 				if (fillStyleEditor.displayFill.Checked)
-					((MarkSymbolType) m_item.Item).Fill = previousFill == null ? ObjectFactory.CreateDefaultFill() : previousFill;
+					((IMarkSymbol) m_item.Symbol).Fill = previousFill == null ? _factory.CreateDefaultFill() : previousFill;
 				else
 				{
-					if (((MarkSymbolType) m_item.Item).Fill != null)
-						previousFill = ((MarkSymbolType) m_item.Item).Fill;
-					((MarkSymbolType) m_item.Item).Fill = null;
+                    if (((IMarkSymbol)m_item.Symbol).Fill != null)
+                        previousFill = ((IMarkSymbol)m_item.Symbol).Fill;
+                    ((IMarkSymbol)m_item.Symbol).Fill = null;
 				}
 			previewPicture.Refresh();
 			if (Changed != null)
@@ -1061,14 +1050,14 @@
 			if (m_inUpdate)
 				return;
 
-			if (m_item.Item.GetType() == typeof(MarkSymbolType))
+			if (m_item.Symbol.Type == PointSymbolType.Mark)
 				if (lineStyleEditor.displayLine.Checked)
-					((MarkSymbolType) m_item.Item).Edge = previousEdge == null ? ObjectFactory.CreateDefaultStroke() : previousEdge;
+					((IMarkSymbol) m_item.Symbol).Edge = previousEdge == null ? _factory.CreateDefaultStroke() : previousEdge;
 				else
 				{
-					if (((MarkSymbolType) m_item.Item).Edge != null)
-						previousEdge = ((MarkSymbolType) m_item.Item).Edge;
-					((MarkSymbolType) m_item.Item).Edge = null;
+                    if (((IMarkSymbol)m_item.Symbol).Edge != null)
+                        previousEdge = ((IMarkSymbol)m_item.Symbol).Edge;
+                    ((IMarkSymbol)m_item.Symbol).Edge = null;
 				}
 			previewPicture.Refresh();
 			if (Changed != null)
@@ -1080,8 +1069,8 @@
 			if (m_inUpdate)
 				return;
 
-			if (m_item.Item.GetType() == typeof(MarkSymbolType))
-				((MarkSymbolType) m_item.Item).Fill.FillPattern = fillStyleEditor.fillCombo.Text;
+			if (m_item.Symbol.Type == PointSymbolType.Mark)
+				((IMarkSymbol) m_item.Symbol).Fill.FillPattern = fillStyleEditor.fillCombo.Text;
 			previewPicture.Refresh();
 			if (Changed != null)
 				Changed(this, new EventArgs());
@@ -1092,8 +1081,8 @@
 			if (m_inUpdate)
 				return;
 
-            if (m_item.Item.GetType() == typeof(MarkSymbolType))
-                ((MarkSymbolType)m_item.Item).Fill.ForegroundColor = Utility.SerializeHTMLColor(fillStyleEditor.foregroundColor.CurrentColor, true);
+            if (m_item.Symbol.Type == PointSymbolType.Mark)
+                ((IMarkSymbol)m_item.Symbol).Fill.ForegroundColor = Utility.SerializeHTMLColor(fillStyleEditor.foregroundColor.CurrentColor, true);
 			previewPicture.Refresh();
 			if (Changed != null)
 				Changed(this, new EventArgs());
@@ -1104,8 +1093,8 @@
 			if (m_inUpdate)
 				return;
 
-            if (m_item.Item.GetType() == typeof(MarkSymbolType))
-                ((MarkSymbolType)m_item.Item).Fill.BackgroundColor = Utility.SerializeHTMLColor(fillStyleEditor.backgroundColor.CurrentColor, true);
+            if (m_item.Symbol.Type == PointSymbolType.Mark)
+                ((IMarkSymbol)m_item.Symbol).Fill.BackgroundColor = Utility.SerializeHTMLColor(fillStyleEditor.backgroundColor.CurrentColor, true);
 			previewPicture.Refresh();
 			if (Changed != null)
 				Changed(this, new EventArgs());
@@ -1118,8 +1107,8 @@
                 return;
 
             //TODO: Validate
-            if (m_item.Item.GetType() == typeof(MarkSymbolType))
-                ((MarkSymbolType)m_item.Item).Edge.Thickness = lineStyleEditor.thicknessCombo.Text;
+            if (m_item.Symbol.Type == PointSymbolType.Mark)
+                ((IMarkSymbol)m_item.Symbol).Edge.Thickness = lineStyleEditor.thicknessCombo.Text;
             previewPicture.Refresh();
             if (Changed != null)
                 Changed(this, new EventArgs());
@@ -1131,8 +1120,8 @@
 				return;
 
                 string current = null;
-                if (m_item.Item.GetType() == typeof(MarkSymbolType))
-                    current = ((MarkSymbolType)m_item.Item).Edge.Thickness;
+                if (m_item.Symbol.Type == PointSymbolType.Mark)
+                    current = ((IMarkSymbol)m_item.Symbol).Edge.Thickness;
 
                 string expr = null;
                 if (current != null)
@@ -1151,8 +1140,8 @@
 			if (m_inUpdate)
 				return;
 
-            if (m_item.Item.GetType() == typeof(MarkSymbolType))
-                ((MarkSymbolType)m_item.Item).Edge.Color = Utility.SerializeHTMLColor(lineStyleEditor.colorCombo.CurrentColor, true);
+            if (m_item.Symbol.Type == PointSymbolType.Mark)
+                ((IMarkSymbol)m_item.Symbol).Edge.Color = Utility.SerializeHTMLColor(lineStyleEditor.colorCombo.CurrentColor, true);
 			previewPicture.Refresh();
 			if (Changed != null)
 				Changed(this, new EventArgs());
@@ -1163,8 +1152,8 @@
 			if (m_inUpdate)
 				return;
 
-			if (m_item.Item.GetType() == typeof(MarkSymbolType))
-				((MarkSymbolType) m_item.Item).Edge.LineStyle = lineStyleEditor.fillCombo.Text;
+			if (m_item.Symbol.Type == PointSymbolType.Mark)
+                ((IMarkSymbol)m_item.Symbol).Edge.LineStyle = lineStyleEditor.fillCombo.Text;
 			previewPicture.Refresh();
 			if (Changed != null)
 				Changed(this, new EventArgs());
@@ -1175,8 +1164,8 @@
 			if (m_inUpdate)
 				return;
 
-            if (m_item.Item.GetType() == typeof(FontSymbolType))
-                ((FontSymbolType)m_item.Item).ForegroundColor = Utility.SerializeHTMLColor(colorFontForeground.CurrentColor, true);
+            if (m_item.Symbol.Type == PointSymbolType.Font)
+                ((IFontSymbol)m_item.Symbol).ForegroundColor = Utility.SerializeHTMLColor(colorFontForeground.CurrentColor, true);
 
             previewPicture.Refresh();
 			if (Changed != null)
@@ -1189,9 +1178,9 @@
 				return;
 
 			//TODO: Validate
-			if (!(m_item.Item is FontSymbolType))
+            if (!(m_item.Symbol is IFontSymbol))
 				return;
-			((FontSymbolType)m_item.Item).FontName = fontCombo.Text;
+            ((IFontSymbol)m_item.Symbol).FontName = fontCombo.Text;
 
 			comboBoxCharacter.Items.Clear();
 			try
@@ -1219,10 +1208,11 @@
 				return;
 
 			//TODO: Validate
-			if (m_item.Item.GetType() != typeof(FontSymbolType))
+			if (m_item.Symbol.Type != PointSymbolType.Font)
 				return;
-			((FontSymbolType)m_item.Item).Character = comboBoxCharacter.Text;
 
+			((IFontSymbol)m_item.Symbol).Character = comboBoxCharacter.Text;
+
 			previewPicture.Refresh();
 			if (Changed != null)
 				Changed(this, new EventArgs());
@@ -1234,7 +1224,7 @@
 		}
 
 
-		public PointSymbolization2DType Item
+		public IPointSymbolization2D Item
 		{
 			get { return m_item; }
 			set 
@@ -1254,10 +1244,10 @@
 
             if (DisplayPoints.Checked)
             {
-                if (DisplayPoints.Tag as PointSymbolization2DType != null)
-                    this.Item = DisplayPoints.Tag as PointSymbolization2DType;
+                if (DisplayPoints.Tag as IPointSymbolization2D != null)
+                    this.Item = DisplayPoints.Tag as IPointSymbolization2D;
                 if (m_item == null)
-                    this.Item = new PointSymbolization2DType();
+                    this.Item = _factory.CreateDefaultPointSymbolization2D();
             }
             else
             {
@@ -1266,16 +1256,28 @@
             }
         }
 
+        static string DoubleToString(double? value)
+        {
+            return value.HasValue ? value.Value.ToString() : null;
+        }
+
+        static double? StringToDouble(string value)
+        {
+            double d;
+            if (double.TryParse(value, out d))
+                return d;
+
+            return null;
+        }
+
         private void WidthText_TextChanged(object sender, EventArgs e)
         {
             if (m_inUpdate || WidthText.SelectedIndex != -1)
                 return;
 
             //TODO: Validate
-            if (m_item.Item.GetType() == typeof(MarkSymbolType))
-                ((MarkSymbolType)m_item.Item).SizeX = WidthText.Text;
-            else if (m_item.Item.GetType() == typeof(FontSymbolType))
-                ((FontSymbolType)m_item.Item).SizeX = WidthText.Text;
+            if (m_item.Symbol.Type == PointSymbolType.Mark || m_item.Symbol.Type == PointSymbolType.Font)
+                m_item.Symbol.SizeX = StringToDouble(WidthText.Text);
             previewPicture.Refresh();
             if (Changed != null)
                 Changed(this, new EventArgs());
@@ -1287,10 +1289,10 @@
                 return;
 
             //TODO: Validate
-            if (m_item.Item.GetType() == typeof(MarkSymbolType))
-                ((MarkSymbolType)m_item.Item).SizeY = HeigthText.Text;
-            else if (m_item.Item.GetType() == typeof(FontSymbolType))
-                ((FontSymbolType)m_item.Item).SizeY = HeigthText.Text;
+            if (m_item.Symbol.Type == PointSymbolType.Mark)
+                m_item.Symbol.SizeY = StringToDouble(HeigthText.Text);
+            else if (m_item.Symbol.Type == PointSymbolType.Font)
+                m_item.Symbol.SizeY = StringToDouble(HeigthText.Text);
             previewPicture.Refresh();
             if (Changed != null)
                 Changed(this, new EventArgs());
@@ -1302,10 +1304,10 @@
                 return;
 
             //TODO: Validate
-            if (m_item.Item.GetType() == typeof(MarkSymbolType))
-                ((MarkSymbolType)m_item.Item).Rotation = RotationBox.Text;
-            else if (m_item.Item.GetType() == typeof(FontSymbolType))
-                ((FontSymbolType)m_item.Item).Rotation = RotationBox.Text;
+            if (m_item.Symbol.Type == PointSymbolType.Mark)
+                m_item.Symbol.Rotation = StringToDouble(RotationBox.Text);
+            else if (m_item.Symbol.Type == PointSymbolType.Font)
+                m_item.Symbol.Rotation = StringToDouble(RotationBox.Text);
             previewPicture.Refresh();
             if (Changed != null)
                 Changed(this, new EventArgs());
@@ -1314,8 +1316,8 @@
 		private void ReferenceY_Leave(object sender, EventArgs e)
         {
             //double d;
-            //if (m_item.Item is MarkSymbolType)
-            //    if (!double.TryParse(((MarkSymbolType)m_item.Item).InsertionPointY, System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture, out d))
+            //if (m_item.Item is IMarkSymbol)
+            //    if (!double.TryParse(((IMarkSymbol)m_item.Item).InsertionPointY, System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture, out d))
             //        MessageBox.Show(this, Properties.Resources.InsertionPointYError, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
 
@@ -1324,10 +1326,10 @@
             if (m_inUpdate)
                 return;
 
-            if (m_item.Item is FontSymbolType)
+            if (m_item.Symbol.Type == PointSymbolType.Font)
             {
-                ((FontSymbolType)m_item.Item).Bold = FontBoldButton.Checked;
-                ((FontSymbolType)m_item.Item).BoldSpecified = true;
+                var fs = (IFontSymbol)m_item.Symbol;
+                fs.Bold = FontBoldButton.Checked;
             }
 
             previewPicture.Refresh();
@@ -1340,10 +1342,10 @@
             if (m_inUpdate)
                 return;
 
-            if (m_item.Item is FontSymbolType)
+            if (m_item.Symbol.Type == PointSymbolType.Font)
             {
-                ((FontSymbolType)m_item.Item).Italic = FontItalicButton.Checked;
-                ((FontSymbolType)m_item.Item).ItalicSpecified = true;
+                var fs = (IFontSymbol)m_item.Symbol;
+                fs.Italic = FontItalicButton.Checked;
             }
 
             previewPicture.Refresh();
@@ -1356,10 +1358,10 @@
             if (m_inUpdate)
                 return;
 
-            if (m_item.Item is FontSymbolType)
+            if (m_item.Symbol.Type == PointSymbolType.Font)
             {
-                ((FontSymbolType)m_item.Item).Underlined = FontUnderlineButton.Checked;
-                ((FontSymbolType)m_item.Item).UnderlinedSpecified = true;
+                var fs = (IFontSymbol)m_item.Symbol;
+                fs.Underlined = FontUnderlineButton.Checked;
             }
 
             previewPicture.Refresh();

Modified: sandbox/maestro-3.0/Maestro.Editors/LayerDefinition/Vector/Thematics/ThemeCreator.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Editors/LayerDefinition/Vector/Thematics/ThemeCreator.cs	2010-10-07 10:05:07 UTC (rev 5253)
+++ sandbox/maestro-3.0/Maestro.Editors/LayerDefinition/Vector/Thematics/ThemeCreator.cs	2010-10-07 12:42:50 UTC (rev 5254)
@@ -75,6 +75,8 @@
             NUMERIC_TYPES = new Type[] { typeof(byte), typeof(int), typeof(float), typeof(double) };
         }
 
+        private ILayerElementFactory _factory;
+
         public ThemeCreator(IEditorService editor, ILayerDefinition layer, FeatureSourceDescription.FeatureSourceSchema schema, object ruleCollection)
             : this()
         {
@@ -83,6 +85,8 @@
             m_schema = schema;
             m_ruleCollection = ruleCollection;
 
+            _factory = (ILayerElementFactory)editor.GetEditedResource();
+
             ColorBrewerColorSet.SetCustomRender(new CustomCombo.RenderCustomItem(DrawColorSetPreview));
         }
 
@@ -228,7 +232,7 @@
                     try
                     {
                         IVectorLayerDefinition vl = (IVectorLayerDefinition)m_layer.SubLayer;
-                        using (FeatureSetReader rd = m_editor.FeatureService.QueryFeatureSource(vl.FeatureSourceID, m_schema.FullnameDecoded, filter, new string[] { col.Name }))
+                        using (FeatureSetReader rd = m_editor.FeatureService.QueryFeatureSource(vl.ResourceId, m_schema.FullnameDecoded, filter, new string[] { col.Name }))
                         {
                             while (rd.Read() && m_values.Count < 100000) //No more than 100.000 records in memory
                             {
@@ -687,61 +691,65 @@
                         return;
                 }
 
-                if (m_ruleCollection is PointTypeStyleType)
+                if (m_ruleCollection is IPointVectorStyle)
                 {
-                    PointTypeStyleType col = m_ruleCollection as PointTypeStyleType;
+                    IPointVectorStyle col = m_ruleCollection as IPointVectorStyle;
 
                     if (OverwriteRules.Checked)
-                        col.PointRule.Clear();
+                        col.RemoveAllRules();
 
                     foreach (RuleItem entry in rules)
                     {
-                        PointRuleType r = ObjectFactory.CreatePointRule();
+                        IPointRule r = _factory.CreateDefaultPointRule();
                         r.Filter = entry.Filter;
                         r.LegendLabel = entry.Label;
-                        if (r.Item.Item is MarkSymbolType)
+                        var sym = r.PointSymbolization2D.Symbol;
+                        if (sym.Type == PointSymbolType.Mark)
                         {
-                            ((MarkSymbolType)r.Item.Item).Fill.ForegroundColor = Utility.SerializeHTMLColor(entry.Color, true);
+                            ((IMarkSymbol)sym).Fill.ForegroundColor = Utility.SerializeHTMLColor(entry.Color, true);
                         }
-                        else if (r.Item.Item is FontSymbolType)
+                        else if (sym.Type == PointSymbolType.Font)
                         {
-                            ((FontSymbolType)r.Item.Item).ForegroundColor = Utility.SerializeHTMLColor(entry.Color, true);
+                            ((IFontSymbol)sym).ForegroundColor = Utility.SerializeHTMLColor(entry.Color, true);
                         }
 
-                        col.PointRule.Add(r);
+                        col.AddRule(r);
                     }
                 }
-                else if (m_ruleCollection is LineTypeStyleType)
+                else if (m_ruleCollection is ILineVectorStyle)
                 {
-                    LineTypeStyleType col = m_ruleCollection as LineTypeStyleType;
+                    ILineVectorStyle col = m_ruleCollection as ILineVectorStyle;
 
                     if (OverwriteRules.Checked)
-                        col.LineRule.Clear();
+                        col.RemoveAllRules();
 
                     foreach (RuleItem entry in rules)
                     {
-                        LineRuleType l = ObjectFactory.CreateLineRule();
+                        var l = _factory.CreateDefaultLineRule();
                         l.Filter = entry.Filter;
                         l.LegendLabel = entry.Label;
-                        l.Items[0].Color = Utility.SerializeHTMLColor(entry.Color, true);
-
-                        col.LineRule.Add(l);
+                        foreach (var st in l.Strokes)
+                        {
+                            st.Color = Utility.SerializeHTMLColor(entry.Color, true);
+                        }
+                        col.AddRule(l);
                     }
                 }
-                else if (m_ruleCollection is AreaTypeStyleType)
+                else if (m_ruleCollection is IAreaVectorStyle)
                 {
-                    AreaTypeStyleType col = m_ruleCollection as AreaTypeStyleType;
+                    IAreaVectorStyle col = m_ruleCollection as IAreaVectorStyle;
 
                     if (OverwriteRules.Checked)
-                        col.AreaRule.Clear();
+                        col.RemoveAllRules();
 
                     foreach (RuleItem entry in rules)
                     {
-                        AreaRuleType r = ObjectFactory.CreateAreaRule();
+                        var r = _factory.CreateDefaultAreaRule();
                         r.Filter = entry.Filter;
                         r.LegendLabel = entry.Label;
-                        r.Item.Fill.ForegroundColor = Utility.SerializeHTMLColor(entry.Color, true);
-                        col.AreaRule.Add(r);
+                        r.AreaSymbolization2D.Fill.ForegroundColor = Utility.SerializeHTMLColor(entry.Color, true);
+
+                        col.AddRule(r);
                     }
                 }
 
@@ -780,23 +788,23 @@
         {
             IVectorLayerDefinition vl = (IVectorLayerDefinition)m_layer.SubLayer;
             UserControl uc = null;
-            if (m_ruleCollection is PointTypeStyleType)
+            if (m_ruleCollection is IPointVectorStyle)
             {
-                uc = new PointFeatureStyleEditor(m_editor, m_schema, vl.FeatureSourceID);
-                ((PointFeatureStyleEditor)uc).Item = (PointSymbolization2DType)Utility.XmlDeepCopy(m_defaultItem);
+                uc = new PointFeatureStyleEditor(m_editor, m_schema, vl.ResourceId);
+                ((PointFeatureStyleEditor)uc).Item = (IPointSymbolization2D)Utility.XmlDeepCopy(m_defaultItem);
                 ((PointFeatureStyleEditor)uc).SetupForTheming();
             }
-            else if (m_ruleCollection is LineTypeStyleType)
+            else if (m_ruleCollection is ILineVectorStyle)
             {
-                uc = new LineFeatureStyleEditor(m_editor, m_schema, vl.FeatureSourceID);
-                var rule = ObjectFactory.CreateLineRule();
-                ((LineFeatureStyleEditor)uc).Item = rule.Items;
+                uc = new LineFeatureStyleEditor(m_editor, m_schema, vl.ResourceId, _factory);
+                var rule = _factory.CreateDefaultLineRule();
+                ((LineFeatureStyleEditor)uc).Item = new List<IStroke>(rule.Strokes);
                 ((LineFeatureStyleEditor)uc).SetupForTheming();
             }
-            else if (m_ruleCollection is AreaTypeStyleType)
+            else if (m_ruleCollection is IAreaVectorStyle)
             {
-                uc = new AreaFeatureStyleEditor(m_editor, m_schema, vl.FeatureSourceID);
-                ((AreaFeatureStyleEditor)uc).Item = (AreaSymbolizationFillType)Utility.XmlDeepCopy(m_defaultItem);
+                uc = new AreaFeatureStyleEditor(m_editor, m_schema, vl.ResourceId);
+                ((AreaFeatureStyleEditor)uc).Item = (IAreaSymbolizationFill)Utility.XmlDeepCopy(m_defaultItem);
                 ((AreaFeatureStyleEditor)uc).SetupForTheming();
             }
 
@@ -809,11 +817,11 @@
 
                 if (dlg.ShowDialog(this) == DialogResult.OK)
                 {
-                    if (m_ruleCollection is PointTypeStyleType)
+                    if (m_ruleCollection is IPointVectorStyle)
                         m_defaultItem = ((PointFeatureStyleEditor)uc).Item;
-                    else if (m_ruleCollection is LineTypeStyleType)
+                    else if (m_ruleCollection is ILineVectorStyle)
                         m_defaultItem = ((LineFeatureStyleEditor)uc).Item;
-                    else if (m_ruleCollection is AreaTypeStyleType)
+                    else if (m_ruleCollection is IAreaVectorStyle)
                         m_defaultItem = ((AreaFeatureStyleEditor)uc).Item;
                 }
             }

Modified: sandbox/maestro-3.0/Maestro.Editors/LayerDefinition/Vector/VectorLayerSettingsSectionCtrl.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Editors/LayerDefinition/Vector/VectorLayerSettingsSectionCtrl.cs	2010-10-07 10:05:07 UTC (rev 5253)
+++ sandbox/maestro-3.0/Maestro.Editors/LayerDefinition/Vector/VectorLayerSettingsSectionCtrl.cs	2010-10-07 12:42:50 UTC (rev 5254)
@@ -30,6 +30,7 @@
 using Maestro.Editors.Generic;
 using OSGeo.MapGuide.ObjectModels.FeatureSource;
 using Maestro.Editors.Common;
+using OSGeo.MapGuide.ObjectModels.LayerDefinition;
 
 namespace Maestro.Editors.LayerDefinition.Vector
 {
@@ -43,17 +44,17 @@
 
         private IEditorService _edsvc;
 
-        private OSGeo.MapGuide.ObjectModels.LayerDefinition.VectorLayerDefinitionType _vl;
+        private IVectorLayerDefinition _vl;
 
         public override void Bind(IEditorService service)
         {
             _edsvc = service;
             _edsvc.RegisterCustomNotifier(this);
 
-            var res = service.GetEditedResource() as OSGeo.MapGuide.ObjectModels.LayerDefinition.LayerDefinition;
+            var res = service.GetEditedResource() as ILayerDefinition;
             Debug.Assert(res != null);
 
-            _vl = res.Item as OSGeo.MapGuide.ObjectModels.LayerDefinition.VectorLayerDefinitionType;
+            _vl = res.SubLayer as IVectorLayerDefinition;
             Debug.Assert(_vl != null);
 
             TextBoxBinder.BindText(txtFeatureSource, _vl, "ResourceId");

Modified: sandbox/maestro-3.0/Maestro.Editors/LayerDefinition/Vector/VectorLayerStyleSectionCtrl.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Editors/LayerDefinition/Vector/VectorLayerStyleSectionCtrl.cs	2010-10-07 10:05:07 UTC (rev 5253)
+++ sandbox/maestro-3.0/Maestro.Editors/LayerDefinition/Vector/VectorLayerStyleSectionCtrl.cs	2010-10-07 12:42:50 UTC (rev 5254)
@@ -40,14 +40,17 @@
             InitializeComponent();
         }
 
-        private VectorLayerDefinitionType _vl;
+        private ILayerElementFactory _factory;
+        private IVectorLayerDefinition _vl;
         private IEditorService _edsvc;
 
         public override void Bind(IEditorService service)
         {
             _edsvc = service;
             _edsvc.RegisterCustomNotifier(this);
-            _vl = (VectorLayerDefinitionType)((ILayerDefinition)service.GetEditedResource()).SubLayer;
+            var res = (ILayerDefinition)service.GetEditedResource();
+            _vl = (IVectorLayerDefinition)res.SubLayer;
+            _factory = (ILayerElementFactory)res;
 
             scaleRangeList.SetItem(_vl);
             scaleRangeList.ResizeAuto();
@@ -62,14 +65,14 @@
 
         private void btnAdd_Click(object sender, EventArgs e)
         {
-            AddScaleRange(ObjectFactory.CreateVectorScaleRange());
+            AddScaleRange(_factory.CreateVectorScaleRange());
         }
 
         private void btnDelete_Click(object sender, EventArgs e)
         {
             if (scaleRangeList.SelectedItem == null)
                 return;
-            VectorScaleRangeType vsc = scaleRangeList.SelectedItem;
+            IVectorScaleRange vsc = scaleRangeList.SelectedItem;
             scaleRangeList.RemoveScaleRange(scaleRangeList.SelectedItem);
             _vl.VectorScaleRange.Remove(scaleRangeList.SelectedItem);
 
@@ -92,14 +95,19 @@
             if (_vl.VectorScaleRange == null || _vl.VectorScaleRange.Count == 0)
                 return;
 
-            List<VectorScaleRangeType> ranges = new List<VectorScaleRangeType>();
-            foreach (VectorScaleRangeType sc in _vl.VectorScaleRange)
+            List<IVectorScaleRange> ranges = new List<IVectorScaleRange>();
+            foreach (IVectorScaleRange sc in _vl.VectorScaleRange)
+            {
                 ranges.Add(sc);
+            }
+
             ranges.Sort(new ScaleRangeSorter());
 
             _vl.VectorScaleRange.Clear();
-            foreach (VectorScaleRangeType sc in ranges)
+            foreach (IVectorScaleRange sc in ranges)
+            {
                 _vl.VectorScaleRange.Add(sc);
+            }
 
             //Refresh display
             scaleRangeList.SetItem(_vl);
@@ -111,19 +119,19 @@
         /// <summary>
         /// Sort helper used to sort the scale ranges
         /// </summary>
-        private class ScaleRangeSorter : IComparer, IComparer<VectorScaleRangeType>
+        private class ScaleRangeSorter : IComparer, IComparer<IVectorScaleRange>
         {
             public int Compare(object x, object y)
             {
-                if (x is VectorScaleRangeType && y is VectorScaleRangeType)
+                if (x is IVectorScaleRange && y is IVectorScaleRange)
                 {
-                    VectorScaleRangeType vx = (VectorScaleRangeType)x;
-                    VectorScaleRangeType vy = (VectorScaleRangeType)y;
+                    IVectorScaleRange vx = (IVectorScaleRange)x;
+                    IVectorScaleRange vy = (IVectorScaleRange)y;
 
-                    double minX = vx.MinScaleSpecified ? vx.MinScale : 0;
-                    double maxX = vx.MaxScaleSpecified ? vx.MaxScale : double.MaxValue;
-                    double minY = vy.MinScaleSpecified ? vy.MinScale : 0;
-                    double maxY = vy.MaxScaleSpecified ? vy.MaxScale : double.MaxValue;
+                    double minX = vx.MinScale.HasValue ? vx.MinScale.Value : 0;
+                    double maxX = vx.MaxScale.HasValue ? vx.MaxScale.Value : double.MaxValue;
+                    double minY = vy.MinScale.HasValue ? vy.MinScale.Value : 0;
+                    double maxY = vy.MaxScale.HasValue ? vy.MaxScale.Value : double.MaxValue;
 
                     if (minX == minY)
                         if (maxX == maxY)
@@ -137,13 +145,13 @@
                     return 0;
             }
 
-            public int Compare(VectorScaleRangeType x, VectorScaleRangeType y)
+            public int Compare(IVectorScaleRange x, IVectorScaleRange y)
             {
                 return this.Compare((object)x, (object)y);
             }
         }
 
-        private void AddScaleRange(VectorScaleRangeType vsc)
+        private void AddScaleRange(IVectorScaleRange vsc)
         {
             if (_vl == null)
                 return;

Modified: sandbox/maestro-3.0/Maestro.Editors/LayerDefinition/VectorLayerEditorCtrl.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Editors/LayerDefinition/VectorLayerEditorCtrl.cs	2010-10-07 10:05:07 UTC (rev 5253)
+++ sandbox/maestro-3.0/Maestro.Editors/LayerDefinition/VectorLayerEditorCtrl.cs	2010-10-07 12:42:50 UTC (rev 5254)
@@ -42,9 +42,9 @@
 
         internal string EditExpression(string expr)
         {
-            var fs = (FeatureSourceType)_edsvc.ResourceService.GetResource(_vl.FeatureSourceID);
+            var fs = (FeatureSourceType)_edsvc.ResourceService.GetResource(_vl.ResourceId);
 
-            return _edsvc.EditExpression(expr, fs.GetClass(_vl.FullQualifiedClassName), fs.Provider, _vl.FeatureSourceID);
+            return _edsvc.EditExpression(expr, fs.GetClass(_vl.FeatureName), fs.Provider, _vl.ResourceId);
         }
 
         internal void UpdateDisplay()

Modified: sandbox/maestro-3.0/Maestro.Editors/WebLayout/Commands/SearchCmdCtrl.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.Editors/WebLayout/Commands/SearchCmdCtrl.cs	2010-10-07 10:05:07 UTC (rev 5253)
+++ sandbox/maestro-3.0/Maestro.Editors/WebLayout/Commands/SearchCmdCtrl.cs	2010-10-07 12:42:50 UTC (rev 5254)
@@ -108,9 +108,9 @@
                 var ldf = (ILayerDefinition)_edsvc.ResourceService.GetResource(layer.ResourceId);
                 var vl = (IVectorLayerDefinition)ldf.SubLayer;
 
-                var fs = (FeatureSourceType)_edsvc.ResourceService.GetResource(vl.FeatureSourceID);
+                var fs = (FeatureSourceType)_edsvc.ResourceService.GetResource(vl.ResourceId);
                 
-                string expr = _edsvc.EditExpression(txtFilter.Text, _cls, fs.Provider, vl.FeatureSourceID);
+                string expr = _edsvc.EditExpression(txtFilter.Text, _cls, fs.Provider, vl.ResourceId);
                 if (expr != null)
                 {
                     txtFilter.Text = expr;
@@ -136,7 +136,7 @@
                 var ldf = (ILayerDefinition)_edsvc.ResourceService.GetResource(layer.ResourceId);
                 var vl = (IVectorLayerDefinition)ldf.SubLayer;
 
-                _cls = _edsvc.FeatureService.GetFeatureSourceSchema(vl.FeatureSourceID, vl.FullQualifiedClassName);
+                _cls = _edsvc.FeatureService.GetFeatureSourceSchema(vl.ResourceId, vl.FeatureName);
 
                 COL_PROPERTY.DisplayMember = "Name";
                 COL_PROPERTY.DataSource = _cls.Columns;

Modified: sandbox/maestro-3.0/Maestro.ResourceValidation/LayerDefinitionValidator.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.ResourceValidation/LayerDefinitionValidator.cs	2010-10-07 10:05:07 UTC (rev 5253)
+++ sandbox/maestro-3.0/Maestro.ResourceValidation/LayerDefinitionValidator.cs	2010-10-07 12:42:50 UTC (rev 5254)
@@ -27,153 +27,10 @@
 
 namespace Maestro.ResourceValidation
 {
-    public class LayerDefinitionValidator : IResourceValidator
+    public class LayerDefinitionValidator : BaseLayerDefinitionValidator
     {
-        public virtual ValidationIssue[] Validate(IResource resource, bool recurse)
+        public override ResourceTypeDescriptor SupportedResourceAndVersion
         {
-            if (resource.ResourceType != OSGeo.MapGuide.MaestroAPI.ResourceTypes.LayerDefinition)
-                return null;
-
-            if (resource.ResourceVersion != new Version(1, 0, 0))
-                return null;
-
-            return ValidateBase(resource, recurse);
-        }
-
-        private static ValidationIssue[] ValidateBase(IResource resource, bool recurse)
-        {
-            LayerDefinition ldef = resource as LayerDefinition;
-            VectorLayerDefinitionType vldef = ldef.Item as VectorLayerDefinitionType;
-            GridLayerDefinitionType gldef = ldef.Item as GridLayerDefinitionType;
-            DrawingLayerDefinitionType dldef = ldef.Item as DrawingLayerDefinitionType;
-
-            List<ValidationIssue> issues = new List<ValidationIssue>();
-
-            if (ldef.Item == null)
-                issues.Add(new ValidationIssue(resource, ValidationStatus.Error, Properties.Resources.LDF_LayerNullError));
-            else if (vldef == null && gldef == null)
-                issues.Add(new ValidationIssue(resource, ValidationStatus.Warning, Properties.Resources.LDF_DrawingLayerDefinitionNotSupportedWarning));
-
-            if (vldef != null)
-            {
-                if (string.IsNullOrEmpty(vldef.FeatureName))
-                    issues.Add(new ValidationIssue(resource, ValidationStatus.Error, Properties.Resources.LDF_MissingFeatureSourceError));
-                if (string.IsNullOrEmpty(vldef.Geometry))
-                    issues.Add(new ValidationIssue(resource, ValidationStatus.Error, Properties.Resources.LDF_MissingGeometryError));
-
-                if (vldef.VectorScaleRange == null || vldef.VectorScaleRange.Count == 0)
-                    issues.Add(new ValidationIssue(resource, ValidationStatus.Error, Properties.Resources.LDF_MissingScaleRangesError));
-                else
-                {
-                    //Test for overlapping scale ranges
-                    List<KeyValuePair<double, double>> ranges = new List<KeyValuePair<double, double>>();
-                    foreach (VectorScaleRangeType vsr in vldef.VectorScaleRange)
-                        ranges.Add(new KeyValuePair<double, double>(
-                            vsr.MaxScaleSpecified ? vsr.MaxScale : double.PositiveInfinity,
-                            vsr.MinScaleSpecified ? vsr.MinScale : double.NegativeInfinity));
-
-                    double min = double.PositiveInfinity;
-                    double max = double.NegativeInfinity;
-                    foreach (KeyValuePair<double, double> sr in ranges)
-                    {
-                        min = Math.Min(min, sr.Value);
-                        max = Math.Max(max, sr.Key);
-                        if (sr.Key < sr.Value)
-                            issues.Add(new ValidationIssue(resource, ValidationStatus.Error, string.Format(Properties.Resources.LDF_MinAndMaxScaleSwappedError, sr.Value, sr.Key)));
-                    }
-
-                    //TODO: Detect gaps in scale ranges
-                    for (int i = 0; i < ranges.Count; i++)
-                        for (int j = i + 1; j < ranges.Count; j++)
-                            if (ranges[i].Key > ranges[j].Value || ranges[i].Value > ranges[j].Value)
-                                issues.Add(new ValidationIssue(resource, ValidationStatus.Information, string.Format(Properties.Resources.LDF_ScaleRangesOverlapInformation, ranges[i].Value, ranges[i].Key, ranges[j].Value, ranges[j].Key)));
-
-                }
-            }
-            else if (gldef != null)
-            {
-                if (gldef.GridScaleRange == null || gldef.GridScaleRange.Count == 0)
-                    issues.Add(new ValidationIssue(resource, ValidationStatus.Error, Properties.Resources.LDF_MissingScaleRangesError));
-                else if (gldef.GridScaleRange.Count != 1)
-                    issues.Add(new ValidationIssue(resource, ValidationStatus.Warning, Properties.Resources.LDF_MultipleScaleRangesWarning));
-            }
-            else if (dldef != null)
-                issues.Add(new ValidationIssue(resource, ValidationStatus.Warning, Properties.Resources.LDF_DrawingLayerNotSupportedWarning));
-            else
-                issues.Add(new ValidationIssue(resource, ValidationStatus.Warning, Properties.Resources.LDF_UnsupportedLayerTypeWarning));
-
-            if (recurse)
-            {
-                try
-                {
-                    FeatureSourceType fs = (FeatureSourceType)ldef.CurrentConnection.ResourceService.GetResource(ldef.Item.ResourceId);
-                    issues.AddRange(ResourceValidatorSet.Validate(fs, recurse));
-
-                    try
-                    {
-                        if (vldef != null || gldef != null)
-                        {
-                            string schema = vldef == null ? gldef.FeatureName : vldef.FeatureName;
-                            string geometry = vldef == null ? gldef.Geometry : vldef.Geometry;
-
-                            bool foundSchema = false;
-                            bool foundGeometry = false;
-
-                            FeatureSourceDescription desc = fs.Describe();
-                            foreach (FeatureSourceDescription.FeatureSourceSchema scm in desc.Schemas)
-                                if (scm.FullnameDecoded == schema)
-                                {
-                                    foundSchema = true;
-
-                                    foreach (FeatureSetColumn col in scm.Columns)
-                                        if (col.Name == geometry)
-                                        {
-                                            foundGeometry = true;
-                                            break;
-                                        }
-
-
-                                    if (vldef != null && vldef.PropertyMapping != null)
-                                        foreach (NameStringPairType s in vldef.PropertyMapping)
-                                        {
-                                            bool found = false;
-                                            foreach (FeatureSetColumn col in scm.Columns)
-                                                if (col.Name == s.Name)
-                                                {
-                                                    found = true;
-                                                    break;
-                                                }
-
-                                            if (!found)
-                                                issues.Add(new ValidationIssue(resource, ValidationStatus.Error, string.Format(Properties.Resources.LDF_SchemaMissingError, schema, fs.ResourceID)));
-
-                                        }
-
-                                    break;
-                                }
-
-                            if (!foundSchema)
-                                issues.Add(new ValidationIssue(resource, ValidationStatus.Error, string.Format(Properties.Resources.LDF_SchemaMissingError, schema, fs.ResourceID)));
-                            else if (!foundGeometry)
-                                issues.Add(new ValidationIssue(resource, ValidationStatus.Error, string.Format(Properties.Resources.LDF_GeometryMissingError, geometry, schema, fs.ResourceID)));
-                        }
-                    }
-                    catch (Exception)
-                    {
-                        issues.Add(new ValidationIssue(fs, ValidationStatus.Error, string.Format(Properties.Resources.LDF_SchemaAndColumnReadFailedError)));
-                    }
-                }
-                catch (Exception)
-                {
-                    issues.Add(new ValidationIssue(resource, ValidationStatus.Error, string.Format(Properties.Resources.LDF_FeatureSourceLoadError)));
-                }
-            }
-
-            return issues.ToArray();
-        }
-
-        public virtual ResourceTypeDescriptor SupportedResourceAndVersion
-        {
             get { return new ResourceTypeDescriptor(ResourceTypes.LayerDefinition, "1.0.0"); }
         }
     }

Modified: sandbox/maestro-3.0/Maestro.ResourceValidation/MapDefinitionValidator.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.ResourceValidation/MapDefinitionValidator.cs	2010-10-07 10:05:07 UTC (rev 5253)
+++ sandbox/maestro-3.0/Maestro.ResourceValidation/MapDefinitionValidator.cs	2010-10-07 12:42:50 UTC (rev 5254)
@@ -95,7 +95,7 @@
                         {
                             try
                             {
-                                FeatureSourceType fs = (FeatureSourceType)layer.CurrentConnection.ResourceService.GetResource(vl.FeatureSourceID);
+                                FeatureSourceType fs = (FeatureSourceType)layer.CurrentConnection.ResourceService.GetResource(vl.ResourceId);
                                 //The layer recurses on the FeatureSource
                                 //issues.AddRange(Validation.Validate(fs, true));
 
@@ -123,9 +123,9 @@
                                             skipGeomCheck = true;
                                         }
 
-                                        if (vl.GeometryProperty != null && !skipGeomCheck)
+                                        if (vl.Geometry != null && !skipGeomCheck)
                                         {
-                                            var env = fs.GetSpatialExtent(vl.FullQualifiedClassName, vl.GeometryProperty);
+                                            var env = fs.GetSpatialExtent(vl.FeatureName, vl.Geometry);
                                             if (!env.Intersects(mapEnv))
                                                 issues.Add(new ValidationIssue(fs, ValidationStatus.Warning, string.Format(Properties.Resources.MDF_DataOutsideMapWarning, fs.ResourceID)));
                                         }

Modified: sandbox/maestro-3.0/Maestro.ResourceValidation/Properties/Resources.Designer.cs
===================================================================
--- sandbox/maestro-3.0/Maestro.ResourceValidation/Properties/Resources.Designer.cs	2010-10-07 10:05:07 UTC (rev 5253)
+++ sandbox/maestro-3.0/Maestro.ResourceValidation/Properties/Resources.Designer.cs	2010-10-07 12:42:50 UTC (rev 5254)
@@ -187,132 +187,6 @@
         }
         
         /// <summary>
-        ///   Looks up a localized string similar to Only vector layers and raster layers are currently validated.
-        /// </summary>
-        internal static string LDF_DrawingLayerDefinitionNotSupportedWarning {
-            get {
-                return ResourceManager.GetString("LDF_DrawingLayerDefinitionNotSupportedWarning", resourceCulture);
-            }
-        }
-        
-        /// <summary>
-        ///   Looks up a localized string similar to Maestro does not support DrawingLayers.
-        /// </summary>
-        internal static string LDF_DrawingLayerNotSupportedWarning {
-            get {
-                return ResourceManager.GetString("LDF_DrawingLayerNotSupportedWarning", resourceCulture);
-            }
-        }
-        
-        /// <summary>
-        ///   Looks up a localized string similar to Failed to load featuresource.
-        /// </summary>
-        internal static string LDF_FeatureSourceLoadError {
-            get {
-                return ResourceManager.GetString("LDF_FeatureSourceLoadError", resourceCulture);
-            }
-        }
-        
-        /// <summary>
-        ///   Looks up a localized string similar to Failed to find geometry column {0} in schema {1} on featuresource {2}.
-        /// </summary>
-        internal static string LDF_GeometryMissingError {
-            get {
-                return ResourceManager.GetString("LDF_GeometryMissingError", resourceCulture);
-            }
-        }
-        
-        /// <summary>
-        ///   Looks up a localized string similar to Layer is missing core information.
-        /// </summary>
-        internal static string LDF_LayerNullError {
-            get {
-                return ResourceManager.GetString("LDF_LayerNullError", resourceCulture);
-            }
-        }
-        
-        /// <summary>
-        ///   Looks up a localized string similar to The minimum scale ({0}) is larger than the maximum scale ({1}).
-        /// </summary>
-        internal static string LDF_MinAndMaxScaleSwappedError {
-            get {
-                return ResourceManager.GetString("LDF_MinAndMaxScaleSwappedError", resourceCulture);
-            }
-        }
-        
-        /// <summary>
-        ///   Looks up a localized string similar to No FeatureSource is assigned to the layer.
-        /// </summary>
-        internal static string LDF_MissingFeatureSourceError {
-            get {
-                return ResourceManager.GetString("LDF_MissingFeatureSourceError", resourceCulture);
-            }
-        }
-        
-        /// <summary>
-        ///   Looks up a localized string similar to No Geometry is assigned to the layer.
-        /// </summary>
-        internal static string LDF_MissingGeometryError {
-            get {
-                return ResourceManager.GetString("LDF_MissingGeometryError", resourceCulture);
-            }
-        }
-        
-        /// <summary>
-        ///   Looks up a localized string similar to No scale ranges are defined, no data can be displayed.
-        /// </summary>
-        internal static string LDF_MissingScaleRangesError {
-            get {
-                return ResourceManager.GetString("LDF_MissingScaleRangesError", resourceCulture);
-            }
-        }
-        
-        /// <summary>
-        ///   Looks up a localized string similar to More than one scale ranges is defined, this is valid, but unsupported by Maestro.
-        /// </summary>
-        internal static string LDF_MultipleScaleRangesWarning {
-            get {
-                return ResourceManager.GetString("LDF_MultipleScaleRangesWarning", resourceCulture);
-            }
-        }
-        
-        /// <summary>
-        ///   Looks up a localized string similar to The scale range {0}-{1} overlaps the range {2}-{3}.
-        /// </summary>
-        internal static string LDF_ScaleRangesOverlapInformation {
-            get {
-                return ResourceManager.GetString("LDF_ScaleRangesOverlapInformation", resourceCulture);
-            }
-        }
-        
-        /// <summary>
-        ///   Looks up a localized string similar to Failed to validate column and schema.
-        /// </summary>
-        internal static string LDF_SchemaAndColumnReadFailedError {
-            get {
-                return ResourceManager.GetString("LDF_SchemaAndColumnReadFailedError", resourceCulture);
-            }
-        }
-        
-        /// <summary>
-        ///   Looks up a localized string similar to Failed to find schema {0} in featuresource {1}.
-        /// </summary>
-        internal static string LDF_SchemaMissingError {
-            get {
-                return ResourceManager.GetString("LDF_SchemaMissingError", resourceCulture);
-            }
-        }
-        
-        /// <summary>
-        ///   Looks up a localized string similar to The layer has no type, or the type is unsupported by Maestro.
-        /// </summary>
-        internal static string LDF_UnsupportedLayerTypeWarning {
-            get {
-                return ResourceManager.GetString("LDF_UnsupportedLayerTypeWarning", resourceCulture);
-            }
-        }
-        
-        /// <summary>
         ///   Looks up a localized string similar to Convert to SDF option is not supported by Maestro.
         /// </summary>
         internal static string LPROC_ConvertToSdf3NotSupported {

Modified: sandbox/maestro-3.0/Maestro.ResourceValidation/Properties/Resources.resx
===================================================================
--- sandbox/maestro-3.0/Maestro.ResourceValidation/Properties/Resources.resx	2010-10-07 10:05:07 UTC (rev 5253)
+++ sandbox/maestro-3.0/Maestro.ResourceValidation/Properties/Resources.resx	2010-10-07 12:42:50 UTC (rev 5254)
@@ -173,62 +173,6 @@
     <value>Failed to read spatial context: {0}</value>
     <comment>An error message that is displayed if the spatial context could not be read</comment>
   </data>
-  <data name="LDF_DrawingLayerDefinitionNotSupportedWarning" xml:space="preserve">
-    <value>Only vector layers and raster layers are currently validated</value>
-    <comment>A warning message that is displayed if the layer is not Grid or Vector</comment>
-  </data>
-  <data name="LDF_DrawingLayerNotSupportedWarning" xml:space="preserve">
-    <value>Maestro does not support DrawingLayers</value>
-    <comment>A warning message that is displayed if the layer is a DrawingLayer type</comment>
-  </data>
-  <data name="LDF_FeatureSourceLoadError" xml:space="preserve">
-    <value>Failed to load featuresource</value>
-    <comment>An error message that is displayed if the featuresource fails to load</comment>
-  </data>
-  <data name="LDF_GeometryMissingError" xml:space="preserve">
-    <value>Failed to find geometry column {0} in schema {1} on featuresource {2}</value>
-    <comment>An error message that is displayed if the geometry is not present in the selected schema</comment>
-  </data>
-  <data name="LDF_LayerNullError" xml:space="preserve">
-    <value>Layer is missing core information</value>
-    <comment>An error message that is displayed if the layer has a null reference</comment>
-  </data>
-  <data name="LDF_MinAndMaxScaleSwappedError" xml:space="preserve">
-    <value>The minimum scale ({0}) is larger than the maximum scale ({1})</value>
-    <comment>An error message that is displayed if the scale ranges are reversed</comment>
-  </data>
-  <data name="LDF_MissingFeatureSourceError" xml:space="preserve">
-    <value>No FeatureSource is assigned to the layer</value>
-    <comment>An error message that is displayed if the layer has no FeatureSource</comment>
-  </data>
-  <data name="LDF_MissingGeometryError" xml:space="preserve">
-    <value>No Geometry is assigned to the layer</value>
-    <comment>An error message that is displayed if the layer has no geometry column selected</comment>
-  </data>
-  <data name="LDF_MissingScaleRangesError" xml:space="preserve">
-    <value>No scale ranges are defined, no data can be displayed</value>
-    <comment>An error message that is displayed if there are no scale ranges defined</comment>
-  </data>
-  <data name="LDF_MultipleScaleRangesWarning" xml:space="preserve">
-    <value>More than one scale ranges is defined, this is valid, but unsupported by Maestro</value>
-    <comment>A warning message that is displayed if a raster layer has multiple scale ranges defined</comment>
-  </data>
-  <data name="LDF_ScaleRangesOverlapInformation" xml:space="preserve">
-    <value>The scale range {0}-{1} overlaps the range {2}-{3}</value>
-    <comment>A warning message that is displayed if two scaleranges overlap</comment>
-  </data>
-  <data name="LDF_SchemaAndColumnReadFailedError" xml:space="preserve">
-    <value>Failed to validate column and schema</value>
-    <comment>An error message that is displayed if the schema and column read fails</comment>
-  </data>
-  <data name="LDF_SchemaMissingError" xml:space="preserve">
-    <value>Failed to find schema {0} in featuresource {1}</value>
-    <comment>An error message that is displayed if the selected schema is not present in the FeatureSource</comment>
-  </data>
-  <data name="LDF_UnsupportedLayerTypeWarning" xml:space="preserve">
-    <value>The layer has no type, or the type is unsupported by Maestro</value>
-    <comment>A  warning message that is displayed if the layer type is unknown</comment>
-  </data>
   <data name="LPROC_ConvertToSdf3NotSupported" xml:space="preserve">
     <value>Convert to SDF option is not supported by Maestro</value>
     <comment>A warning message about the lack of SDF conversion support</comment>

Modified: sandbox/maestro-3.0/MaestroAPITests/ResourceTests.cs
===================================================================
--- sandbox/maestro-3.0/MaestroAPITests/ResourceTests.cs	2010-10-07 10:05:07 UTC (rev 5253)
+++ sandbox/maestro-3.0/MaestroAPITests/ResourceTests.cs	2010-10-07 12:42:50 UTC (rev 5254)
@@ -48,6 +48,8 @@
         public void TestCloning()
         {
             //Generated classes have built in Clone() methods. Verify they check out
+            _mocks = new Mockery();
+            var conn = _mocks.NewMock<IServerConnection>();
 
             var app = new ApplicationDefinitionType();
             var app2 = app.Clone();
@@ -57,7 +59,7 @@
             var fs2 = fs.Clone();
             Assert.AreNotSame(fs, fs2);
 
-            var ld = new LayerDefinition();
+            var ld = ObjectFactory.CreateDefaultLayer(conn, LayerType.Vector, new Version(1, 0, 0));
             var ld2 = ld.Clone();
             Assert.AreNotSame(ld, ld2);
 
@@ -460,6 +462,7 @@
         public void TestNoConversionOnIdenticalVersion()
         {
             //Verify origial reference is returned if we're converting a resource to the same version
+            _mocks = new Mockery();
             var conn = _mocks.NewMock<IServerConnection>();
 
             var conv = new ResourceConverter(new List<IResourceConverter>());
@@ -473,7 +476,7 @@
             var fs2 = conv.Upgrade(fs, targetVer);
             Assert.AreSame(fs, fs2);
 
-            var ld = ObjectFactory.CreateLayerDefinition(conn);
+            var ld = ObjectFactory.CreateDefaultLayer(conn, LayerType.Vector, new Version(1, 0, 0));
             var ld2 = conv.Upgrade(ld, targetVer);
             Assert.AreSame(ld, ld2);
 

Modified: sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/Commands/ExecuteLoadProcedure.cs
===================================================================
--- sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/Commands/ExecuteLoadProcedure.cs	2010-10-07 10:05:07 UTC (rev 5253)
+++ sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/Commands/ExecuteLoadProcedure.cs	2010-10-07 12:42:50 UTC (rev 5254)
@@ -368,11 +368,11 @@
 
                                 if (clsDef != null && geom != null)
                                 {
-                                    OSGeo.MapGuide.ObjectModels.LayerDefinition.LayerDefinition ld = ObjectFactory.CreateMonoChromaticVectorLayer(this.Parent);
+                                    var ld = ObjectFactory.CreateDefaultLayer(this.Parent, LayerType.Vector, new Version(1, 0, 0));
 
                                     //Step 3: Assign default properties
                                     ld.ResourceID = lyrId;
-                                    VectorLayerDefinitionType vld = ld.Item as VectorLayerDefinitionType;
+                                    var vld = ld.SubLayer as IVectorLayerDefinition;
                                     vld.ResourceId = fsId;
                                     vld.FeatureName = clsDef.FullnameDecoded;
                                     vld.Geometry = geom.Name;
@@ -386,36 +386,21 @@
 
                                         var scale = vld.VectorScaleRange[0];
 
+                                        var remove = new List<string>();
                                         if (!geomTypes.Contains(GeometryMetadata.GEOM_TYPE_POINT))
                                         {
-                                            for (int i = scale.Items.Count - 1; i >= 0; i--)
-                                            {
-                                                if (typeof(PointTypeStyleType).IsAssignableFrom(scale.Items[i].GetType()))
-                                                {
-                                                    scale.Items.RemoveAt(i);
-                                                }
-                                            }
+                                            remove.Add(GeometryMetadata.GEOM_TYPE_POINT);
                                         }
                                         if (!geomTypes.Contains(GeometryMetadata.GEOM_TYPE_CURVE))
                                         {
-                                            for (int i = scale.Items.Count - 1; i >= 0; i--)
-                                            {
-                                                if (typeof(LineTypeStyleType).IsAssignableFrom(scale.Items[i].GetType()))
-                                                {
-                                                    scale.Items.RemoveAt(i);
-                                                }
-                                            }
+                                            remove.Add(GeometryMetadata.GEOM_TYPE_CURVE);
                                         }
                                         if (!geomTypes.Contains(GeometryMetadata.GEOM_TYPE_SURFACE))
                                         {
-                                            for (int i = scale.Items.Count - 1; i >= 0; i--)
-                                            {
-                                                if (typeof(AreaTypeStyleType).IsAssignableFrom(scale.Items[i].GetType()))
-                                                {
-                                                    scale.Items.RemoveAt(i);
-                                                }
-                                            }
+                                            remove.Add(GeometryMetadata.GEOM_TYPE_SURFACE);
                                         }
+
+                                        scale.RemoveStyles(remove);
                                     }
 
                                     this.Parent.ResourceService.SaveResource(ld);
@@ -610,11 +595,11 @@
 
                                 if (clsDef != null && geom != null)
                                 {
-                                    LayerDefinition ld = ObjectFactory.CreateMonoChromaticVectorLayer(this.Parent);
+                                    var ld = ObjectFactory.CreateDefaultLayer(this.Parent, LayerType.Vector, new Version(1, 0, 0));
 
                                     //Step 3: Assign default properties
                                     ld.ResourceID = lyrId;
-                                    VectorLayerDefinitionType vld = ld.Item as VectorLayerDefinitionType;
+                                    var vld = ld.SubLayer as IVectorLayerDefinition;
                                     vld.ResourceId = fsId;
                                     vld.FeatureName = clsDef.Fullname;
                                     vld.Geometry = geom.Name;
@@ -628,36 +613,21 @@
 
                                         var scale = vld.VectorScaleRange[0];
 
+                                        var remove = new List<string>();
                                         if (!geomTypes.Contains(GeometryMetadata.GEOM_TYPE_POINT))
                                         {
-                                            for (int i = scale.Items.Count - 1; i >= 0; i--)
-                                            {
-                                                if (typeof(PointTypeStyleType).IsAssignableFrom(scale.Items[i].GetType()))
-                                                {
-                                                    scale.Items.RemoveAt(i);
-                                                }
-                                            }
+                                            remove.Add(GeometryMetadata.GEOM_TYPE_POINT);
                                         }
                                         if (!geomTypes.Contains(GeometryMetadata.GEOM_TYPE_CURVE))
                                         {
-                                            for (int i = scale.Items.Count - 1; i >= 0; i--)
-                                            {
-                                                if (typeof(LineTypeStyleType).IsAssignableFrom(scale.Items[i].GetType()))
-                                                {
-                                                    scale.Items.RemoveAt(i);
-                                                }
-                                            }
+                                            remove.Add(GeometryMetadata.GEOM_TYPE_CURVE);
                                         }
                                         if (!geomTypes.Contains(GeometryMetadata.GEOM_TYPE_SURFACE))
                                         {
-                                            for (int i = scale.Items.Count - 1; i >= 0; i--)
-                                            {
-                                                if (typeof(AreaTypeStyleType).IsAssignableFrom(scale.Items[i].GetType()))
-                                                {
-                                                    scale.Items.RemoveAt(i);
-                                                }
-                                            }
+                                            remove.Add(GeometryMetadata.GEOM_TYPE_SURFACE);
                                         }
+
+                                        scale.RemoveStyles(remove);
                                     }
 
                                     this.Parent.ResourceService.SaveResource(ld);

Modified: sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/OSGeo.MapGuide.MaestroAPI.csproj
===================================================================
--- sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/OSGeo.MapGuide.MaestroAPI.csproj	2010-10-07 10:05:07 UTC (rev 5253)
+++ sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/OSGeo.MapGuide.MaestroAPI.csproj	2010-10-07 12:42:50 UTC (rev 5254)
@@ -18,7 +18,7 @@
     <DebugType>full</DebugType>
     <Optimize>false</Optimize>
     <OutputPath>bin\Debug\</OutputPath>
-    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <DefineConstants>TRACE;DEBUG;LDF_100, WL_100, MDF_100, SYM_100, LP_100</DefineConstants>
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>
   </PropertyGroup>
@@ -26,7 +26,7 @@
     <DebugType>pdbonly</DebugType>
     <Optimize>true</Optimize>
     <OutputPath>bin\Release\</OutputPath>
-    <DefineConstants>TRACE</DefineConstants>
+    <DefineConstants>TRACE;LDF_100, WL_100, MDF_100, SYM_100, LP_100</DefineConstants>
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>
   </PropertyGroup>
@@ -189,10 +189,14 @@
     <Compile Include="Mapping\RuntimeMapBase.cs" />
     <Compile Include="ObjectModels\ApplicationDefinition.cs" />
     <Compile Include="ObjectModels\DrawingSource.cs" />
+    <Compile Include="ObjectModels\GridLayerDefinitionImpl.cs" />
     <Compile Include="ObjectModels\IDynamicInvokable.cs" />
     <Compile Include="ObjectModels\Envelope.cs" />
     <Compile Include="ObjectModels\FeatureSource.cs" />
-    <Compile Include="ObjectModels\LayerDefinition.cs" />
+    <Compile Include="ObjectModels\LayerFactory.cs" />
+    <Compile Include="ObjectModels\VectorLayerDefinitionImpl.cs" />
+    <Compile Include="ObjectModels\LayerInterfaceExtensions.cs" />
+    <Compile Include="ObjectModels\LayerInterfaces.cs" />
     <Compile Include="ObjectModels\LoadProcedure.cs" />
     <Compile Include="ObjectModels\MapDefinition.cs" />
     <Compile Include="ObjectModels\ObjectFactory.cs" />
@@ -212,6 +216,7 @@
       <DependentUpon>Resources.resx</DependentUpon>
     </Compile>
     <Compile Include="ResourceTypeRegistry.cs" />
+    <Compile Include="Resource\BaseLayerDefinitionValidator.cs" />
     <Compile Include="Resource\Conversion\IResourceConverter.cs" />
     <Compile Include="Resource\Conversion\ResourceConverter.cs" />
     <Compile Include="Resource\Conversion\ResourceUpgrader.cs" />

Added: sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/ObjectModels/GridLayerDefinitionImpl.cs
===================================================================
--- sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/ObjectModels/GridLayerDefinitionImpl.cs	                        (rev 0)
+++ sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/ObjectModels/GridLayerDefinitionImpl.cs	2010-10-07 12:42:50 UTC (rev 5254)
@@ -0,0 +1,588 @@
+#region Disclaimer / License
+// Copyright (C) 2010, Jackie Ng
+// http://trac.osgeo.org/mapguide/wiki/maestro, jumpinjackie at gmail.com
+// 
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// 
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+// 
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+// 
+#endregion
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Xml.Serialization;
+
+#if LDF_110
+namespace OSGeo.MapGuide.ObjectModels.LayerDefinition_1_1_0
+#elif LDF_120
+namespace OSGeo.MapGuide.ObjectModels.LayerDefinition_1_2_0
+#elif LDF_130
+namespace OSGeo.MapGuide.ObjectModels.LayerDefinition_1_3_0
+#else
+namespace OSGeo.MapGuide.ObjectModels.LayerDefinition_1_0_0
+#endif
+{
+    using OSGeo.MapGuide.ObjectModels.LayerDefinition;
+
+    partial class GridLayerDefinitionType : IRasterLayerDefinition
+    {
+        public override LayerType LayerType
+        {
+            get { return LayerType.Raster; }
+        }
+
+        [XmlIgnore]
+        string ISubLayerDefinition.ResourceId
+        {
+            get { return this.ResourceId; }
+            set { this.ResourceId = value; }
+        }
+
+        [XmlIgnore]
+        string IRasterLayerDefinition.FeatureName
+        {
+            get
+            {
+                return this.FeatureName;
+            }
+            set
+            {
+                this.FeatureName = value;
+            }
+        }
+
+        [XmlIgnore]
+        string IRasterLayerDefinition.Geometry
+        {
+            get
+            {
+                return this.Geometry;
+            }
+            set
+            {
+                this.Geometry = value;
+            }
+        }
+
+        ICollection<IGridScaleRange> IRasterLayerDefinition.GridScaleRange
+        {
+            get { return (ICollection<IGridScaleRange>)this.GridScaleRange; }
+        }
+    }
+
+    partial class ChannelBandType : IChannelBand
+    {
+        [XmlIgnore]
+        string IChannelBand.Band
+        {
+            get
+            {
+                return this.Band;
+            }
+            set
+            {
+                this.Band = value;
+            }
+        }
+
+        [XmlIgnore]
+        double? IChannelBand.LowBand
+        {
+            get
+            {
+                return this.LowBandSpecified ? new Nullable<double>(this.LowBand) : null;
+            }
+            set
+            {
+                if (value.HasValue)
+                {
+                    this.LowBand = value.Value;
+                    this.LowBandSpecified = true;
+                }
+                else
+                {
+                    this.LowBandSpecified = false;
+                }
+            }
+        }
+
+        [XmlIgnore]
+        double? IChannelBand.HighBand
+        {
+            get
+            {
+                return this.HighBandSpecified ? new Nullable<double>(this.HighBand) : null;
+            }
+            set
+            {
+                if (value.HasValue)
+                {
+                    this.HighBand = value.Value;
+                    this.HighBandSpecified = true;
+                }
+                else
+                {
+                    this.HighBandSpecified = false;
+                }
+            }
+        }
+
+        [XmlIgnore]
+        byte IChannelBand.LowChannel
+        {
+            get
+            {
+                return this.LowChannel;
+            }
+            set
+            {
+                this.LowChannel = value;
+            }
+        }
+
+        [XmlIgnore]
+        byte IChannelBand.HighChannel
+        {
+            get
+            {
+                return this.HighChannel;
+            }
+            set
+            {
+                this.HighChannel = value;
+            }
+        }
+    }
+
+    partial class GridColorBandsType : IGridColorBands
+    {
+        [XmlIgnore]
+        IChannelBand IGridColorBands.RedBand
+        {
+            get
+            {
+                return this.RedBand;
+            }
+            set
+            {
+                this.RedBand = (ChannelBandType)value;
+            }
+        }
+
+        [XmlIgnore]
+        IChannelBand IGridColorBands.GreenBand
+        {
+            get
+            {
+                return this.GreenBand;
+            }
+            set
+            {
+                this.GreenBand = (ChannelBandType)value;
+            }
+        }
+
+        [XmlIgnore]
+        IChannelBand IGridColorBands.BlueBand
+        {
+            get
+            {
+                return this.BlueBand;
+            }
+            set
+            {
+                this.BlueBand = (ChannelBandType)value;
+            }
+        }
+    }
+
+    //Class that addresses the shoddy impedence mismatch between the xsd
+    //and the generated code
+    internal abstract class ExplicitColorBase : IExplicitColor
+    {
+        public abstract ItemChoiceType Type { get; }
+    }
+
+    //Class that addresses the shoddy impedence mismatch between the xsd
+    //and the generated code
+    internal class ExplicitColorBand : ExplicitColorBase, IExplicitColorBand
+    {
+        public string Band { get; set; }
+
+        public override ItemChoiceType Type
+        {
+            get { return ItemChoiceType.Band; }
+        }
+    }
+
+    //Class that addresses the shoddy impedence mismatch between the xsd
+    //and the generated code
+    internal class ExplicitColor : ExplicitColorBase, IExplictColorValue
+    {
+        public string Value { get; set; }
+
+        public override ItemChoiceType Type
+        {
+            get { return ItemChoiceType.ExplicitColor; }
+        }
+    }
+
+    //Class that addresses the shoddy impedence mismatch between the xsd
+    //and the generated code
+    internal class ExplicitColorBands : ExplicitColorBase, IExplicitColorBands
+    {
+        public IGridColorBands Bands { get; set; }
+
+        public override ItemChoiceType Type
+        {
+            get { return ItemChoiceType.Bands; }
+        }
+    }
+
+
+    partial class GridColorType : IGridColor
+    {
+        IExplicitColor IGridColor.ExplicitColor
+        {
+            get
+            {
+                return ParseItem();
+            }
+            set
+            {
+                switch (this.ItemElementName)
+                {
+                    case ItemChoiceType.Band:
+                        this.Item = ((ExplicitColorBand)value).Band;
+                        break;
+                    case ItemChoiceType.Bands:
+                        this.Item = ((ExplicitColorBands)value).Bands;
+                        break;
+                    case ItemChoiceType.ExplicitColor:
+                        this.Item = ((ExplicitColor)value).Value;
+                        break;
+                }
+            }
+        }
+
+        private IExplicitColor ParseItem()
+        {
+            if (this.Item == null)
+                return null;
+
+            switch (this.ItemElementName)
+            {
+                case ItemChoiceType.Band:
+                    return new ExplicitColorBand() { Band = (string)this.Item };
+                case ItemChoiceType.Bands:
+                    return new ExplicitColorBands() { Bands = (IGridColorBands)this.Item };
+                case ItemChoiceType.ExplicitColor:
+                    return new ExplicitColor() { Value = (string)this.Item };
+            }
+
+            throw new Exception(); //Should never get here
+        }
+    }
+
+    partial class GridColorRuleType : IGridColorRule
+    {
+        string IGridColorRule.LegendLabel
+        {
+            get
+            {
+                return this.LegendLabel;
+            }
+            set
+            {
+                this.LegendLabel = value;
+            }
+        }
+
+        string IGridColorRule.Filter
+        {
+            get
+            {
+                return this.Filter;
+            }
+            set
+            {
+                this.Filter = value;
+            }
+        }
+
+        ITextSymbol IGridColorRule.Label
+        {
+            get
+            {
+                return this.Label;
+            }
+            set
+            {
+                this.Label = (TextSymbolType)value;
+            }
+        }
+
+        IGridColor IGridColorRule.Color
+        {
+            get
+            {
+                return this.Color;
+            }
+            set
+            {
+                this.Color = (GridColorType)value;
+            }
+        }
+    }
+
+    partial class HillShadeType : IHillShade
+    {
+
+        string IHillShade.Band
+        {
+            get
+            {
+                return this.Band;
+            }
+            set
+            {
+                this.Band = value;
+            }
+        }
+
+        double IHillShade.Azimuth
+        {
+            get
+            {
+                return this.Azimuth;
+            }
+            set
+            {
+                this.Azimuth = value;
+            }
+        }
+
+        double IHillShade.Altitude
+        {
+            get
+            {
+                return this.Altitude;
+            }
+            set
+            {
+                this.Altitude = value;
+            }
+        }
+
+        double IHillShade.ScaleFactor
+        {
+            get
+            {
+                return this.ScaleFactor;
+            }
+            set
+            {
+                this.ScaleFactor = value;
+            }
+        }
+    }
+
+    partial class GridColorStyleType : IGridColorStyle
+    {
+        IHillShade IGridColorStyle.HillShade
+        {
+            get
+            {
+                return this.HillShade;
+            }
+            set
+            {
+                this.HillShade = (HillShadeType)value;
+            }
+        }
+
+        string IGridColorStyle.TransparencyColor
+        {
+            get
+            {
+                return this.TransparencyColor == null ? string.Empty : this.TransparencyColor.ToString();
+            }
+            set
+            {
+                this.TransparencyColor = value;
+            }
+        }
+
+        double IGridColorStyle.BrightnessFactor
+        {
+            get
+            {
+                return this.BrightnessFactor;
+            }
+            set
+            {
+                this.BrightnessFactor = value;
+            }
+        }
+
+        double IGridColorStyle.ConstrastFactor
+        {
+            get
+            {
+                return this.ContrastFactor;
+            }
+            set
+            {
+                this.ContrastFactor = value;
+            }
+        }
+
+        IList<IGridColorRule> IGridColorStyle.ColorRule
+        {
+            get { return (IList<IGridColorRule>)this.ColorRule; }
+        }
+
+        void IGridColorStyle.AddColorRule(IGridColorRule rule)
+        {
+            if (this.ColorRule == null)
+                this.ColorRule = new System.ComponentModel.BindingList<GridColorRuleType>();
+
+            this.ColorRule.Add((GridColorRuleType)rule);
+        }
+    }
+
+    partial class GridSurfaceStyleType : IGridSurfaceStyle
+    {
+
+        string IGridSurfaceStyle.Band
+        {
+            get
+            {
+                return this.Band;
+            }
+            set
+            {
+                this.Band = value;
+            }
+        }
+
+        double IGridSurfaceStyle.ZeroValue
+        {
+            get
+            {
+                return this.ZeroValue;
+            }
+            set
+            {
+                this.ZeroValue = value;
+            }
+        }
+
+        double IGridSurfaceStyle.ScaleFactor
+        {
+            get
+            {
+                return this.ScaleFactor;
+            }
+            set
+            {
+                this.ScaleFactor = value;
+            }
+        }
+
+        string IGridSurfaceStyle.DefaultColor
+        {
+            get
+            {
+                return this.DefaultColor;
+            }
+            set
+            {
+                this.DefaultColor = value;
+            }
+        }
+    }
+
+    partial class GridScaleRangeType : IGridScaleRange
+    {
+        double? IGridScaleRange.MinScale
+        {
+            get
+            {
+                return this.MinScale;
+            }
+            set
+            {
+                if (value.HasValue)
+                    this.MinScale = value.Value;
+            }
+        }
+
+        double? IGridScaleRange.MaxScale
+        {
+            get
+            {
+                return this.MaxScaleSpecified ? new Nullable<double>(this.MaxScale) : null;
+            }
+            set
+            {
+                if (value.HasValue)
+                {
+                    this.MaxScale = value.Value;
+                    this.MaxScaleSpecified = true;
+                }
+                else
+                {
+                    this.MaxScaleSpecified = false;
+                }
+            }
+        }
+
+        IGridSurfaceStyle IGridScaleRange.SurfaceStyle
+        {
+            get
+            {
+                return this.SurfaceStyle;
+            }
+            set
+            {
+                this.SurfaceStyle = (GridSurfaceStyleType)value;
+            }
+        }
+
+        IGridColorStyle IGridScaleRange.ColorStyle
+        {
+            get
+            {
+                return this.ColorStyle;
+            }
+            set
+            {
+                this.ColorStyle = (GridColorStyleType)value;
+            }
+        }
+
+        double IGridScaleRange.RebuildFactor
+        {
+            get
+            {
+                return this.RebuildFactor;
+            }
+            set
+            {
+                this.RebuildFactor = value;
+            }
+        }
+    }
+
+}

Deleted: sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/ObjectModels/LayerDefinition.cs
===================================================================
--- sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/ObjectModels/LayerDefinition.cs	2010-10-07 10:05:07 UTC (rev 5253)
+++ sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/ObjectModels/LayerDefinition.cs	2010-10-07 12:42:50 UTC (rev 5254)
@@ -1,600 +0,0 @@
-#region Disclaimer / License
-// Copyright (C) 2010, Jackie Ng
-// http://trac.osgeo.org/mapguide/wiki/maestro, jumpinjackie at gmail.com
-// 
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License, or (at your option) any later version.
-// 
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-// Lesser General Public License for more details.
-// 
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
-// 
-#endregion
-using System;
-using System.Collections.Generic;
-using System.Text;
-using OSGeo.MapGuide.MaestroAPI.Resource;
-using System.Xml.Serialization;
-using OSGeo.MapGuide.MaestroAPI;
-using OSGeo.MapGuide.ObjectModels.Common;
-using System.ComponentModel;
-using OSGeo.MapGuide.MaestroAPI.Services;
-using OSGeo.MapGuide.MaestroAPI.ObjectModels;
-using OSGeo.MapGuide.ObjectModels.FeatureSource;
-
-namespace OSGeo.MapGuide.ObjectModels.LayerDefinition
-{
-    public enum LayerType
-    {
-        Drawing,
-        Vector,
-        Raster
-    }
-
-    public interface ILayerDefinition : IResource
-    {
-        ISubLayerDefinition SubLayer { get; }
-    }
-
-    public static class LayerDefinitionExtensions
-    {
-        public static string GetCoordinateSystemWkt(this ILayerDefinition layer)
-        {
-            Check.NotNull(layer, "layer");
-            if (layer.CurrentConnection == null)
-                throw new System.Exception("No server set for object");
-
-            var conn = layer.CurrentConnection;
-            switch (layer.SubLayer.LayerType)
-            {
-                case LayerType.Raster:
-                    {
-                        var rl = (IRasterLayerDefinition)layer.SubLayer;
-                        var fs = (FeatureSourceType)conn.ResourceService.GetResource(rl.FeatureSourceID);
-                        var scList = fs.GetSpatialInfo(true);
-                        if (scList.SpatialContext.Count > 0)
-                            return scList.SpatialContext[0].CoordinateSystemWkt;
-                    }
-                    break;
-                case LayerType.Vector:
-                    {
-                        var vl = (IVectorLayerDefinition)layer.SubLayer;
-                        var fs = (FeatureSourceType)conn.ResourceService.GetResource(vl.FeatureSourceID);
-                        var scList = fs.GetSpatialInfo(true);
-                        if (scList.SpatialContext.Count > 0)
-                            return scList.SpatialContext[0].CoordinateSystemWkt;
-                    }
-                    break;
-                case LayerType.Drawing:
-                    {
-                        int[] services = conn.Capabilities.SupportedServices;
-                        if (Array.IndexOf(services, (int)ServiceType.Drawing) >= 0)
-                        {
-                            var sheet = ((IDrawingLayerDefinition)layer.SubLayer).Sheet;
-                            var dws = (DrawingSource)conn.ResourceService.GetResource(((IDrawingLayerDefinition)layer.SubLayer).DrawingSourceID);
-
-                            var csCat = conn.CoordinateSystemCatalog;
-                            return csCat.ConvertCoordinateSystemCodeToWkt(dws.CoordinateSpace);
-                        }
-                    }
-                    break;
-            }
-            return string.Empty;
-        }
-
-        /// <summary>
-        /// Returns the spatial extent of the data. 
-        /// This is calculated by asking the underlying featuresource for the minimum rectangle that
-        /// contains all the features in the specified table. If the <paramref name="allowFallbackToContextInformation"/>
-        /// is set to true, and the query fails, the code will attempt to read this information
-        /// from the spatial context information instead.
-        /// </summary>
-        /// <param name="allowFallbackToContextInformation">True to allow reading spatial extents from the spatial context information, if the spatial query fails.</param>
-        /// <returns>The envelope for the data in the table</returns>
-        public static Envelope GetSpatialExtent(this ILayerDefinition layer, bool allowFallbackToContextInformation)
-        {
-            Check.NotNull(layer, "layer");
-            if (layer.CurrentConnection == null)
-                throw new System.Exception("No server set for object");
-
-            var conn = layer.CurrentConnection;
-            switch (layer.SubLayer.LayerType)
-            {
-                case LayerType.Vector:
-                    return conn.FeatureService.GetSpatialExtent(((IVectorLayerDefinition)layer.SubLayer).FeatureSourceID, ((IVectorLayerDefinition)layer.SubLayer).FullQualifiedClassName, ((IVectorLayerDefinition)layer.SubLayer).GeometryProperty);
-                case LayerType.Raster:
-                    return conn.FeatureService.GetSpatialExtent(((IRasterLayerDefinition)layer.SubLayer).FeatureSourceID, ((IRasterLayerDefinition)layer.SubLayer).FullQualifiedClassName, ((IRasterLayerDefinition)layer.SubLayer).GeometryProperty);
-                default:
-                    {
-                        int[] services = conn.Capabilities.SupportedServices;
-                        if (Array.IndexOf(services, (int)ServiceType.Drawing) >= 0)
-                        {
-                            var sheet = ((IDrawingLayerDefinition)layer.SubLayer).Sheet;
-                            var dws = (DrawingSource)conn.ResourceService.GetResource(((IDrawingLayerDefinition)layer.SubLayer).DrawingSourceID);
-
-                            //find matching sheet
-                            foreach (var sht in dws.Sheet)
-                            {
-                                if (sheet.Equals(sht.Name))
-                                {
-                                    return ObjectFactory.CreateEnvelope(sht.Extent.MinX, sht.Extent.MinY, sht.Extent.MaxX, sht.Extent.MaxY);
-                                }
-                            }
-                        }
-                        return null;
-                    }
-            }
-        }
-    }
-
-    public interface ISubLayerDefinition
-    {
-        LayerType LayerType { get; } 
-    }
-
-    public interface IVectorLayerDefinition : ISubLayerDefinition
-    {
-        string FeatureSourceID { get; set; }
-
-        string FullQualifiedClassName { get; set; }
-
-        string GeometryProperty { get; set; }
-
-        string Url { get; set; }
-
-        string ToolTip { get; set; }
-
-        string Filter { get; set; }
-    }
-
-    public static class LayerExtensionMethods
-    {
-        /// <summary>
-        /// Gets the referenced schema of this vector layer
-        /// </summary>
-        /// <param name="vl"></param>
-        /// <returns></returns>
-        public static string GetSchema(this IVectorLayerDefinition vl)
-        {
-            if (string.IsNullOrEmpty(vl.FullQualifiedClassName) || !vl.FullQualifiedClassName.Contains(":"))
-                return string.Empty;
-            else
-                return vl.FullQualifiedClassName.Split(':')[0];
-        }
-    }
-
-    public interface IRasterLayerDefinition : ISubLayerDefinition
-    {
-        string FullQualifiedClassName { get; set; }
-
-        string GeometryProperty { get; set; }
-
-        string FeatureSourceID { get; set; }
-    }
-
-    public interface IDrawingLayerDefinition : ISubLayerDefinition
-    {
-        string Sheet { get; set; }
-
-        string LayerFilter { get; set; }
-
-        double MinScale { get; set; }
-
-        double MaxScale { get; set; }
-
-        string DrawingSourceID { get; set; }
-    }
-
-    public interface ILayerRule
-    {
-        string Filter { get; set; }
-
-        string LegendLabel { get; set; }
-    }
-
-    abstract partial class BaseLayerDefinitionType : ISubLayerDefinition
-    {
-        [XmlIgnore]
-        public abstract LayerType LayerType { get; }
-    }
-
-    partial class VectorLayerDefinitionType : IVectorLayerDefinition
-    {
-        public override LayerType LayerType
-        {
-            get { return LayerType.Vector; }
-        }
-
-        [XmlIgnore]
-        string IVectorLayerDefinition.FeatureSourceID
-        {
-            get { return this.ResourceId; }
-            set { this.ResourceId = value; }
-        }
-
-        [XmlIgnore]
-        string IVectorLayerDefinition.FullQualifiedClassName
-        {
-            get { return this.FeatureName; }
-            set { this.FeatureName = value; }
-        }
-
-        [XmlIgnore]
-        string IVectorLayerDefinition.GeometryProperty
-        {
-            get { return this.Geometry; }
-            set { this.Geometry = value; }
-        }
-
-        [XmlIgnore]
-        string IVectorLayerDefinition.Url
-        {
-            get { return this.Url; }
-            set { this.Url = value; }
-        }
-
-        [XmlIgnore]
-        string IVectorLayerDefinition.ToolTip
-        {
-            get { return this.ToolTip; }
-            set { this.ToolTip = value; }
-        }
-
-        [XmlIgnore]
-        string IVectorLayerDefinition.Filter
-        {
-            get { return this.Filter; }
-            set { this.Filter = value; }
-        }
-    }
-
-    partial class GridLayerDefinitionType : IRasterLayerDefinition
-    {
-        public override LayerType LayerType
-        {
-            get { return LayerType.Raster; }
-        }
-
-        [XmlIgnore]
-        string IRasterLayerDefinition.FeatureSourceID
-        {
-            get { return this.ResourceId; }
-            set { this.ResourceId = value; }
-        }
-
-        [XmlIgnore]
-        string IRasterLayerDefinition.FullQualifiedClassName
-        {
-            get
-            {
-                return this.FeatureName;
-            }
-            set
-            {
-                this.FeatureName = value;
-            }
-        }
-
-        [XmlIgnore]
-        string IRasterLayerDefinition.GeometryProperty
-        {
-            get
-            {
-                return this.Geometry;
-            }
-            set
-            {
-                this.Geometry = value;
-            }
-        }
-    }
-
-    partial class DrawingLayerDefinitionType : IDrawingLayerDefinition
-    {
-        public override LayerType LayerType
-        {
-            get { return LayerType.Drawing; }
-        }
-
-        [XmlIgnore]
-        string IDrawingLayerDefinition.DrawingSourceID
-        {
-            get { return this.ResourceId; }
-            set { this.ResourceId = value; }
-        }
-    }
-
-    partial class VectorScaleRangeType
-    {
-        #region Missing generated stuff
-        [EditorBrowsable(EditorBrowsableState.Never)]
-        private bool minScaleFieldSpecified;
-
-        [System.Xml.Serialization.XmlIgnoreAttribute()]
-        public bool MinScaleSpecified
-        {
-            get
-            {
-                return this.minScaleFieldSpecified;
-            }
-            set
-            {
-                if ((minScaleFieldSpecified.Equals(value) != true))
-                {
-                    this.minScaleFieldSpecified = value;
-                    this.OnPropertyChanged("MinScaleSpecified");
-                }
-            }
-        }
-        #endregion
-
-        [XmlIgnore]
-        public AreaTypeStyleType AreaStyle
-        {
-            get
-            {
-                foreach (var item in this.itemsField)
-                {
-                    if (typeof(AreaTypeStyleType).IsAssignableFrom(item.GetType()))
-                        return (AreaTypeStyleType)item;
-                }
-
-                return null;
-            }
-            set
-            {
-                //Remove old one if it exists
-                var item = this.AreaStyle;
-                if (item != null)
-                {
-                    this.itemsField.Remove(item);
-                }
-                //Put the new one in if it is not null
-                if (value != null)
-                {
-                    this.itemsField.Add(value);   
-                }
-            }
-        }
-
-        [XmlIgnore]
-        public LineTypeStyleType LineStyle
-        {
-            get
-            {
-                foreach (var item in this.itemsField)
-                {
-                    if (typeof(LineTypeStyleType).IsAssignableFrom(item.GetType()))
-                        return (LineTypeStyleType)item;
-                }
-
-                return null;
-            }
-            set
-            {
-                //Remove old one if it exists
-                var item = this.LineStyle;
-                if (item != null)
-                {
-                    this.itemsField.Remove(item);
-                }
-                //Put the new one in if it is not null
-                if (value != null)
-                {
-                    this.itemsField.Add(value);
-                }
-            }
-        }
-        
-        [XmlIgnore]
-        public PointTypeStyleType PointStyle
-        {
-            get
-            {
-                foreach (var item in this.itemsField)
-                {
-                    if (typeof(PointTypeStyleType).IsAssignableFrom(item.GetType()))
-                        return (PointTypeStyleType)item;
-                }
-
-                return null;
-            }
-            set
-            {
-                //Remove old one if it exists
-                var item = this.PointStyle;
-                if (item != null)
-                {
-                    this.itemsField.Remove(item);
-                }
-                //Put the new one in if it is not null
-                if (value != null)
-                {
-                    this.itemsField.Add(value);
-                }
-            }
-        }
-    }
-
-    partial class LayerDefinition : ILayerDefinition
-    {
-        //internal LayerDefinition() { } 
-
-        private static readonly Version RES_VERSION = new Version(1, 0, 0);
-
-        [XmlIgnore]
-        public OSGeo.MapGuide.MaestroAPI.IServerConnection CurrentConnection
-        {
-            get;
-            set;
-        }
-
-        private string _resId;
-
-        [XmlIgnore]
-        public string ResourceID
-        {
-            get
-            {
-                return _resId;
-            }
-            set
-            {
-                if (!ResourceIdentifier.Validate(value))
-                    throw new InvalidOperationException("Not a valid resource identifier"); //LOCALIZE
-
-                var res = new ResourceIdentifier(value);
-                if (res.Extension != ResourceTypes.LayerDefinition.ToString())
-                    throw new InvalidOperationException("Invalid resource identifier for this type of object: " + res.Extension); //LOCALIZE
-
-                _resId = value;
-                this.OnPropertyChanged("ResourceID");
-            }
-        }
-
-        [XmlIgnore]
-        public ResourceTypes ResourceType
-        {
-            get
-            {
-                return ResourceTypes.LayerDefinition;
-            }
-        }
-
-        [XmlIgnore]
-        public Version ResourceVersion
-        {
-            get
-            {
-                return RES_VERSION;
-            }
-        }
-
-        object ICloneable.Clone()
-        {
-            return this.Clone();
-        }
-
-        [XmlAttribute("noNamespaceSchemaLocation", Namespace = "http://www.w3.org/2001/XMLSchema-instance")]
-        public string ValidatingSchema 
-        {
-            get { return "LayerDefinition-1.0.0.xsd"; }
-            set { }
-        }
-
-        [XmlIgnore]
-        public bool IsStronglyTyped
-        {
-            get { return true; }
-        }
-
-        public ISubLayerDefinition SubLayer
-        {
-            get { return this.Item; }
-        }
-    }
-
-    partial class StrokeType
-    {
-        internal StrokeType() { }
-    }
-
-    partial class FillType
-    {
-        internal FillType() { } 
-    }
-
-    partial class AreaRuleType : ILayerRule
-    {
-        [XmlIgnore]
-        string ILayerRule.Filter
-        {
-            get
-            {
-                return this.Filter;
-            }
-            set
-            {
-                this.Filter = value;
-            }
-        }
-
-        [XmlIgnore]
-        string ILayerRule.LegendLabel
-        {
-            get
-            {
-                return this.LegendLabel;
-            }
-            set
-            {
-                this.LegendLabel = value;
-            }
-        }
-    }
-
-    partial class PointRuleType : ILayerRule
-    {
-        [XmlIgnore]
-        string ILayerRule.Filter
-        {
-            get
-            {
-                return this.Filter;
-            }
-            set
-            {
-                this.Filter = value;
-            }
-        }
-
-        [XmlIgnore]
-        string ILayerRule.LegendLabel
-        {
-            get
-            {
-                return this.LegendLabel;
-            }
-            set
-            {
-                this.LegendLabel = value;
-            }
-        }
-    }
-
-    partial class LineRuleType : ILayerRule
-    {
-        [XmlIgnore]
-        string ILayerRule.Filter
-        {
-            get
-            {
-                return this.Filter;
-            }
-            set
-            {
-                this.Filter = value;
-            }
-        }
-
-        [XmlIgnore]
-        string ILayerRule.LegendLabel
-        {
-            get
-            {
-                return this.LegendLabel;
-            }
-            set
-            {
-                this.LegendLabel = value;
-            }
-        }
-    }
-}

Added: sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/ObjectModels/LayerFactory.cs
===================================================================
--- sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/ObjectModels/LayerFactory.cs	                        (rev 0)
+++ sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/ObjectModels/LayerFactory.cs	2010-10-07 12:42:50 UTC (rev 5254)
@@ -0,0 +1,269 @@
+#region Disclaimer / License
+// Copyright (C) 2010, Jackie Ng
+// http://trac.osgeo.org/mapguide/wiki/maestro, jumpinjackie at gmail.com
+// 
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// 
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+// 
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+// 
+#endregion
+using System;
+using System.Collections.Generic;
+using System.Text;
+using OSGeo.MapGuide.ObjectModels.LayerDefinition;
+using OSGeo.MapGuide.MaestroAPI;
+using System.Drawing;
+
+#if LDF_110
+namespace OSGeo.MapGuide.ObjectModels.LayerDefinition_1_1_0
+#elif LDF_120
+namespace OSGeo.MapGuide.ObjectModels.LayerDefinition_1_2_0
+#elif LDF_130
+namespace OSGeo.MapGuide.ObjectModels.LayerDefinition_1_3_0
+#else
+namespace OSGeo.MapGuide.ObjectModels.LayerDefinition_1_0_0
+#endif
+{
+    partial class LayerDefinition : ILayerElementFactory
+    {
+        public static ILayerDefinition CreateDefault(LayerType type)
+        {
+            var lyr = new LayerDefinition();
+            switch (type)
+            { 
+                case LayerType.Drawing:
+                    lyr.CreateDrawingLayer();
+                    break;
+                case LayerType.Raster:
+                    lyr.CreateRasterLayer();
+                    break;
+                case LayerType.Vector:
+                    lyr.CreateVectorLayer();
+                    break;
+            }
+            return lyr;
+        }
+
+        public void CreateVectorLayer()
+        {
+            var vl = new VectorLayerDefinitionType();
+
+            vl.VectorScaleRange = new System.ComponentModel.BindingList<VectorScaleRangeType>();
+            var defaultRange = new VectorScaleRangeType()
+            {
+                Items = new System.ComponentModel.BindingList<object>(),
+                AreaStyle = CreateDefaultAreaStyle(),
+                LineStyle = CreateDefaultLineStyle(),
+                PointStyle = CreateDefaultPointStyle()
+            };
+            defaultRange.AreaStyle.AddRule(CreateDefaultAreaRule());
+            defaultRange.LineStyle.AddRule(CreateDefaultLineRule());
+            defaultRange.PointStyle.AddRule(CreateDefaultPointRule());
+            vl.VectorScaleRange.Add(defaultRange);
+
+            this.Item = vl;
+        }
+
+        public void CreateRasterLayer()
+        {
+            this.Item = new GridLayerDefinitionType();
+        }
+
+        public void CreateDrawingLayer()
+        {
+            this.Item = new DrawingLayerDefinitionType();
+        }
+
+        /// <summary>
+        /// Creates a fill
+        /// </summary>
+        /// <param name="p"></param>
+        /// <param name="color"></param>
+        /// <param name="color_3"></param>
+        /// <returns></returns>
+        public IFill CreateFill(string pattern, System.Drawing.Color background, System.Drawing.Color foreground)
+        {
+            return new FillType()
+            {
+                BackgroundColor = Utility.SerializeHTMLColor(background, true),
+                FillPattern = pattern,
+                ForegroundColor = Utility.SerializeHTMLColor(foreground, true)
+            };
+        }
+
+        /// <summary>
+        /// Creates a line stroke with default settings
+        /// </summary>
+        /// <param name="color"></param>
+        /// <returns></returns>
+        public IStroke CreateStroke(System.Drawing.Color color)
+        {
+            return new StrokeType()
+            {
+                Color = Utility.SerializeHTMLColor(color, true),
+                LineStyle = "Solid",
+                Thickness = "1",
+                Unit = LengthUnitType.Points
+            };
+        }
+
+        public IStroke CreateDefaultStroke()
+        {
+            return CreateStroke(Color.Black);
+        }
+
+        public IPointVectorStyle CreateDefaultPointStyle()
+        {
+            return new PointTypeStyleType()
+            {
+                PointRule = new System.ComponentModel.BindingList<PointRuleType>()
+            };
+        }
+
+        public ILineVectorStyle CreateDefaultLineStyle()
+        {
+            return new LineTypeStyleType()
+            {
+                LineRule = new System.ComponentModel.BindingList<LineRuleType>()
+            };
+        }
+
+        public IAreaVectorStyle CreateDefaultAreaStyle()
+        {
+            return new AreaTypeStyleType()
+            {
+                AreaRule = new System.ComponentModel.BindingList<AreaRuleType>()
+            };
+        }
+
+        public IVectorScaleRange CreateVectorScaleRange()
+        {
+            return new VectorScaleRangeType()
+            {
+                Items = new System.ComponentModel.BindingList<object>(),
+                AreaStyle = CreateDefaultAreaStyle(),
+                LineStyle = CreateDefaultLineStyle(),
+                PointStyle = CreateDefaultPointStyle()
+            };
+        }
+
+        public IFill CreateDefaultFill()
+        {
+            return CreateFill("Solid", Color.White, Color.Black);
+        }
+
+        public IMarkSymbol CreateDefaultMarkSymbol()
+        {
+            IMarkSymbol sym = new MarkSymbolType()
+            {
+                
+                SizeContext = SizeContextType.DeviceUnits,
+                MaintainAspect = true,
+                Shape = ShapeType.Square,
+                Rotation = "0",
+                SizeX = "10",
+                SizeY = "10",
+                Unit = LengthUnitType.Points
+            };
+            sym.Edge = CreateDefaultStroke();
+            sym.Fill = CreateDefaultFill();
+            return sym;
+        }
+
+        public IFontSymbol CreateDefaultFontSymbol()
+        {
+            IFontSymbol sym = new FontSymbolType()
+            {
+                SizeContext = SizeContextType.DeviceUnits,
+                MaintainAspect = true,
+                FontName = "Arial",
+                Rotation = "0",
+                SizeX = "10",
+                SizeY = "10",
+                Unit = LengthUnitType.Points
+            };
+            sym.SetForegroundColor(Color.Black);
+            return sym;
+        }
+
+        public IPointSymbolization2D CreateDefaultPointSymbolization2D()
+        {
+            IPointSymbolization2D sym = new PointSymbolization2DType();
+            sym.Symbol = CreateDefaultMarkSymbol();
+            return sym;
+        }
+
+        public IPointRule CreateDefaultPointRule()
+        {
+            IPointRule pr = new PointRuleType()
+            {
+                LegendLabel = ""
+            };
+            pr.PointSymbolization2D = CreateDefaultPointSymbolization2D();
+            return pr;
+        }
+
+        public IAreaRule CreateDefaultAreaRule()
+        {
+            IAreaRule ar = new AreaRuleType()
+            {
+                LegendLabel = ""
+            };
+            ar.AreaSymbolization2D = CreateDefaultAreaSymbolization2D();
+            return ar;
+        }
+
+        private IAreaSymbolizationFill CreateDefaultAreaSymbolization2D()
+        {
+            IAreaSymbolizationFill fill = new AreaSymbolizationFillType();
+            fill.Fill = CreateDefaultFill();
+            fill.Stroke = CreateDefaultStroke();
+
+            return fill;
+        }
+
+        public ILineRule CreateDefaultLineRule()
+        {
+            ILineRule lr = new LineRuleType()
+            {
+                LegendLabel = "",
+                Items = new System.ComponentModel.BindingList<StrokeType>()
+            };
+            lr.AddStroke(CreateDefaultStroke());
+            return lr;
+        }
+
+        public ITextSymbol CreateDefaultTextSymbol()
+        {
+            return new TextSymbolType()
+            {
+                AdvancedPlacement = null,
+                BackgroundColor = Utility.SerializeHTMLColor(Color.White, true),
+                BackgroundStyle = BackgroundStyleType.Transparent,
+                Bold = "false",
+                FontName = "Arial",
+                ForegroundColor = Utility.SerializeHTMLColor(Color.Black, true),
+                HorizontalAlignment = "'Center'",
+                Italic = "false",
+                Rotation = "0",
+                SizeContext = SizeContextType.DeviceUnits,
+                SizeX = "10",
+                SizeY = "10",
+                Text = "",
+                Underlined = "false",
+                Unit = LengthUnitType.Points,
+                VerticalAlignment = "'Baseline'"
+            };
+        }
+    }
+}

Added: sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/ObjectModels/LayerInterfaceExtensions.cs
===================================================================
--- sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/ObjectModels/LayerInterfaceExtensions.cs	                        (rev 0)
+++ sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/ObjectModels/LayerInterfaceExtensions.cs	2010-10-07 12:42:50 UTC (rev 5254)
@@ -0,0 +1,296 @@
+#region Disclaimer / License
+// Copyright (C) 2010, Jackie Ng
+// http://trac.osgeo.org/mapguide/wiki/maestro, jumpinjackie at gmail.com
+// 
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// 
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+// 
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+// 
+#endregion
+using System;
+using System.Collections.Generic;
+using System.Text;
+using OSGeo.MapGuide.MaestroAPI;
+using OSGeo.MapGuide.ObjectModels.FeatureSource;
+using System.Drawing;
+using OSGeo.MapGuide.ObjectModels.Common;
+using OSGeo.MapGuide.MaestroAPI.Services;
+using OSGeo.MapGuide.MaestroAPI.ObjectModels;
+
+namespace OSGeo.MapGuide.ObjectModels.LayerDefinition
+{
+    public static class BlockSymbolExtensions
+    {
+        public static void SetBlockColor(this IBlockSymbol sym, Color c)
+        {
+            Check.NotNull(sym, "sym");
+            sym.BlockColor = Utility.SerializeHTMLColor(c, true);
+        }
+
+        public static void SetLayerColor(this IBlockSymbol sym, Color c)
+        {
+            Check.NotNull(sym, "sym");
+            sym.LayerColor = Utility.SerializeHTMLColor(c, true);
+        }
+    }
+
+    public static class FontSymbolExtensions
+    {
+        /// <summary>
+        /// Applies properties (name, italic, bold, underline) from the characteristics of the specified font
+        /// </summary>
+        /// <param name="sym"></param>
+        /// <param name="f"></param>
+        public static void Apply(this IFontSymbol sym, Font f)
+        {
+            Check.NotNull(sym, "sym");
+            sym.FontName = f.Name;
+            sym.Italic = f.Italic;
+            sym.Bold = f.Bold;
+            sym.Underlined = f.Underline;
+        }
+
+        public static void SetForegroundColor(this IFontSymbol sym, Color c)
+        {
+            Check.NotNull(sym, "sym");
+            sym.ForegroundColor = Utility.SerializeHTMLColor(c, true);
+        }
+    }
+
+    public static class VectorScaleRangeExtensions
+    {
+        /// <summary>
+        /// Purge the specified scale range of the following styles
+        /// </summary>
+        /// <param name="range"></param>
+        /// <param name="geomTypes">The geometry types to remove</param>
+        public static void RemoveStyles(this IVectorScaleRange range, IEnumerable<string> geomTypes)
+        {
+            Check.NotNull(range, "range");
+            Check.NotNull(geomTypes, "geomTypes");
+
+            List<IVectorStyle> remove = new List<IVectorStyle>();
+
+            foreach (var geomType in geomTypes)
+            {
+                if (geomTypes.Equals(GeometryMetadata.GEOM_TYPE_CURVE))
+                {
+                    range.LineStyle = null;
+                }
+                else if (geomTypes.Equals(GeometryMetadata.GEOM_TYPE_POINT))
+                {
+                    range.PointStyle = null;
+                }
+                else if (geomTypes.Equals(GeometryMetadata.GEOM_TYPE_SURFACE))
+                {
+                    range.AreaStyle = null;
+                }
+            }
+        }
+
+        public static void RemoveStyles(this IVectorScaleRange range, params string[] geomTypes)
+        {
+            range.RemoveStyles(geomTypes);
+        }
+    }
+
+    public static class LayerDefinitionExtensions
+    {
+        public static string GetCoordinateSystemWkt(this ILayerDefinition layer)
+        {
+            Check.NotNull(layer, "layer");
+            if (layer.CurrentConnection == null)
+                throw new System.Exception("No server set for object");
+
+            var conn = layer.CurrentConnection;
+            switch (layer.SubLayer.LayerType)
+            {
+                case LayerType.Raster:
+                    {
+                        var rl = (IRasterLayerDefinition)layer.SubLayer;
+                        var fs = (FeatureSourceType)conn.ResourceService.GetResource(rl.ResourceId);
+                        var scList = fs.GetSpatialInfo(true);
+                        if (scList.SpatialContext.Count > 0)
+                            return scList.SpatialContext[0].CoordinateSystemWkt;
+                    }
+                    break;
+                case LayerType.Vector:
+                    {
+                        var vl = (IVectorLayerDefinition)layer.SubLayer;
+                        var fs = (FeatureSourceType)conn.ResourceService.GetResource(vl.ResourceId);
+                        var scList = fs.GetSpatialInfo(true);
+                        if (scList.SpatialContext.Count > 0)
+                            return scList.SpatialContext[0].CoordinateSystemWkt;
+                    }
+                    break;
+                case LayerType.Drawing:
+                    {
+                        int[] services = conn.Capabilities.SupportedServices;
+                        if (Array.IndexOf(services, (int)ServiceType.Drawing) >= 0)
+                        {
+                            var sheet = ((IDrawingLayerDefinition)layer.SubLayer).Sheet;
+                            var dws = (DrawingSource)conn.ResourceService.GetResource(((IDrawingLayerDefinition)layer.SubLayer).ResourceId);
+
+                            var csCat = conn.CoordinateSystemCatalog;
+                            return csCat.ConvertCoordinateSystemCodeToWkt(dws.CoordinateSpace);
+                        }
+                    }
+                    break;
+            }
+            return string.Empty;
+        }
+
+        /// <summary>
+        /// Returns the spatial extent of the data. 
+        /// This is calculated by asking the underlying featuresource for the minimum rectangle that
+        /// contains all the features in the specified table. If the <paramref name="allowFallbackToContextInformation"/>
+        /// is set to true, and the query fails, the code will attempt to read this information
+        /// from the spatial context information instead.
+        /// </summary>
+        /// <param name="allowFallbackToContextInformation">True to allow reading spatial extents from the spatial context information, if the spatial query fails.</param>
+        /// <returns>The envelope for the data in the table</returns>
+        public static Envelope GetSpatialExtent(this ILayerDefinition layer, bool allowFallbackToContextInformation)
+        {
+            Check.NotNull(layer, "layer");
+            if (layer.CurrentConnection == null)
+                throw new System.Exception("No server set for object");
+
+            var conn = layer.CurrentConnection;
+            switch (layer.SubLayer.LayerType)
+            {
+                case LayerType.Vector:
+                    return conn.FeatureService.GetSpatialExtent(layer.SubLayer.ResourceId, ((IVectorLayerDefinition)layer.SubLayer).FeatureName, ((IVectorLayerDefinition)layer.SubLayer).Geometry);
+                case LayerType.Raster:
+                    return conn.FeatureService.GetSpatialExtent(layer.SubLayer.ResourceId, ((IRasterLayerDefinition)layer.SubLayer).FeatureName, ((IRasterLayerDefinition)layer.SubLayer).Geometry);
+                default:
+                    {
+                        int[] services = conn.Capabilities.SupportedServices;
+                        if (Array.IndexOf(services, (int)ServiceType.Drawing) >= 0)
+                        {
+                            var sheet = ((IDrawingLayerDefinition)layer.SubLayer).Sheet;
+                            var dws = (DrawingSource)conn.ResourceService.GetResource(((IDrawingLayerDefinition)layer.SubLayer).ResourceId);
+
+                            //find matching sheet
+                            foreach (var sht in dws.Sheet)
+                            {
+                                if (sheet.Equals(sht.Name))
+                                {
+                                    return ObjectFactory.CreateEnvelope(sht.Extent.MinX, sht.Extent.MinY, sht.Extent.MaxX, sht.Extent.MaxY);
+                                }
+                            }
+                        }
+                        return null;
+                    }
+            }
+        }
+    }
+
+    public static class LayerExtensionMethods
+    {
+        /// <summary>
+        /// Gets the referenced schema of this vector layer
+        /// </summary>
+        /// <param name="vl"></param>
+        /// <returns></returns>
+        public static string GetSchema(this IVectorLayerDefinition vl)
+        {
+            if (string.IsNullOrEmpty(vl.FeatureName) || !vl.FeatureName.Contains(":"))
+                return string.Empty;
+            else
+                return vl.FeatureName.Split(':')[0];
+        }
+    }
+
+    public static class W2DSymbolTypeExtensions
+    {
+        public static void SetFillColor(this IW2DSymbol sym, Color c)
+        {
+            Check.NotNull(sym, "sym");
+            sym.FillColor = Utility.SerializeHTMLColor(c, true);
+        }
+
+        public static void SetLineColor(this IW2DSymbol sym, Color c)
+        {
+            Check.NotNull(sym, "sym");
+            sym.LineColor = Utility.SerializeHTMLColor(c, true);
+        }
+
+        public static void SetTextColor(this IW2DSymbol sym, Color c)
+        {
+            Check.NotNull(sym, "sym");
+            sym.TextColor = Utility.SerializeHTMLColor(c, true);
+        }
+    }
+
+    public static class TextSymbolExtensions
+    {
+        public static void SetForegroundColor(this ITextSymbol sym, Color c)
+        {
+            Check.NotNull(sym, "sym");
+            sym.ForegroundColor = Utility.SerializeHTMLColor(c, true);
+        }
+
+        public static void SetBackgroundColor(this ITextSymbol sym, Color c)
+        {
+            Check.NotNull(sym, "sym");
+            sym.BackgroundColor = Utility.SerializeHTMLColor(c, true);
+        }
+
+        /// <summary>
+        /// Applies properties (name, italic, bold, underline) from the characteristics of the specified font
+        /// </summary>
+        /// <param name="sym"></param>
+        /// <param name="f"></param>
+        public static void Apply(this ITextSymbol sym, Font f)
+        {
+            Check.NotNull(sym, "sym");
+            sym.FontName = f.Name;
+            sym.Italic = f.Italic.ToString();
+            sym.Bold = f.Bold.ToString();
+            sym.Underlined = f.Underline.ToString();
+        }
+    }
+
+    public static class FillExtensions
+    {
+        public static void SetBackgroundColor(this IFill fil, Color c)
+        {
+            Check.NotNull(fil, "fil");
+            fil.BackgroundColor = Utility.SerializeHTMLColor(c, true);
+        }
+
+        public static void SetForegroundColor(this IFill fil, Color c)
+        {
+            Check.NotNull(fil, "fil");
+            fil.ForegroundColor = Utility.SerializeHTMLColor(c, true);
+        }
+    }
+
+    public static class GridColorStyleExtensions
+    {
+        public static void SetTransparencyColor(this IGridColorStyle style, Color c)
+        {
+            Check.NotNull(style, "style");
+            style.TransparencyColor = Utility.SerializeHTMLColor(c, true);
+        }
+    }
+
+    public static class GridSurfaceStyleExtensions
+    {
+        public static void SetDefaultColor(this IGridSurfaceStyle style, Color c)
+        {
+            Check.NotNull(style, "style");
+            style.DefaultColor = Utility.SerializeHTMLColor(c, true);
+        }
+    }
+}

Added: sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/ObjectModels/LayerInterfaces.cs
===================================================================
--- sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/ObjectModels/LayerInterfaces.cs	                        (rev 0)
+++ sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/ObjectModels/LayerInterfaces.cs	2010-10-07 12:42:50 UTC (rev 5254)
@@ -0,0 +1,893 @@
+#region Disclaimer / License
+// Copyright (C) 2010, Jackie Ng
+// http://trac.osgeo.org/mapguide/wiki/maestro, jumpinjackie at gmail.com
+// 
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// 
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+// 
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+// 
+#endregion
+using System;
+using System.Collections.Generic;
+using System.Text;
+using OSGeo.MapGuide.ObjectModels.LayerDefinition;
+using System.Drawing;
+using OSGeo.MapGuide.MaestroAPI.Resource;
+using OSGeo.MapGuide.ObjectModels.FeatureSource;
+using OSGeo.MapGuide.ObjectModels.Common;
+using OSGeo.MapGuide.MaestroAPI.Services;
+using OSGeo.MapGuide.MaestroAPI;
+using OSGeo.MapGuide.MaestroAPI.ObjectModels;
+using System.ComponentModel;
+
+namespace OSGeo.MapGuide.ObjectModels.LayerDefinition
+{
+    #region core enums
+
+    [System.SerializableAttribute()]
+    public enum LengthUnitType
+    {
+
+        /// <remarks/>
+        Millimeters,
+
+        /// <remarks/>
+        Centimeters,
+
+        /// <remarks/>
+        Meters,
+
+        /// <remarks/>
+        Kilometers,
+
+        /// <remarks/>
+        Inches,
+
+        /// <remarks/>
+        Feet,
+
+        /// <remarks/>
+        Yards,
+
+        /// <remarks/>
+        Miles,
+
+        /// <remarks/>
+        Points,
+    }
+
+    [System.SerializableAttribute()]
+    public enum SizeContextType
+    {
+
+        /// <remarks/>
+        MappingUnits,
+
+        /// <remarks/>
+        DeviceUnits,
+    }
+
+    [System.SerializableAttribute()]
+    public enum ShapeType
+    {
+
+        /// <remarks/>
+        Square,
+
+        /// <remarks/>
+        Circle,
+
+        /// <remarks/>
+        Triangle,
+
+        /// <remarks/>
+        Star,
+
+        /// <remarks/>
+        Cross,
+
+        /// <remarks/>
+        X,
+    }
+
+    [System.SerializableAttribute()]
+    public enum BackgroundStyleType
+    {
+
+        /// <remarks/>
+        Transparent,
+
+        /// <remarks/>
+        Opaque,
+
+        /// <remarks/>
+        Ghosted,
+    }
+
+    [System.SerializableAttribute()]
+    public enum FeatureNameType
+    {
+
+        /// <remarks/>
+        FeatureClass,
+
+        /// <remarks/>
+        NamedExtension,
+    }
+
+    [System.SerializableAttribute()]
+    [System.Xml.Serialization.XmlTypeAttribute(IncludeInSchema = false)]
+    public enum ItemChoiceType
+    {
+
+        /// <remarks/>
+        Band,
+
+        /// <remarks/>
+        Bands,
+
+        /// <remarks/>
+        ExplicitColor,
+    }
+
+    #endregion
+
+    #region core
+
+    public enum LayerType
+    {
+        Drawing,
+        Vector,
+        Raster
+    }
+
+    public interface ILayerElementFactory
+    {
+        INameStringPair CreatePair(string name, string value);
+        IAreaRule CreateDefaultAreaRule();
+        IAreaVectorStyle CreateDefaultAreaStyle();
+        IFill CreateDefaultFill();
+        ILineVectorStyle CreateDefaultLineStyle();
+        IMarkSymbol CreateDefaultMarkSymbol();
+        IPointVectorStyle CreateDefaultPointStyle();
+        IPointSymbolization2D CreateDefaultPointSymbolization2D();
+        IStroke CreateDefaultStroke();
+        ITextSymbol CreateDefaultTextSymbol();
+        IFill CreateFill(string pattern, System.Drawing.Color background, System.Drawing.Color foreground);
+        ILineRule CreateDefaultLineRule();
+        IPointRule CreateDefaultPointRule();
+        IStroke CreateStroke(System.Drawing.Color color);
+        IVectorScaleRange CreateVectorScaleRange();
+
+        IFontSymbol CreateDefaultFontSymbol();
+    }
+
+    public interface ILayerDefinition : IResource, ILayerElementFactory
+    {
+        ISubLayerDefinition SubLayer { get; }
+    }
+
+    public interface ISubLayerDefinition : INotifyPropertyChanged
+    {
+        LayerType LayerType { get; }
+
+        string ResourceId { get; set; }
+    }
+
+    public interface IVectorLayerDefinition : ISubLayerDefinition
+    {
+        string FeatureName { get; set; }
+
+        string Geometry { get; set; }
+
+        string Url { get; set; }
+
+        string ToolTip { get; set; }
+
+        string Filter { get; set; }
+
+        IList<IVectorScaleRange> VectorScaleRange { get; }
+
+        IList<INameStringPair> PropertyMapping { get; }
+    }
+
+    public interface IRasterLayerDefinition : ISubLayerDefinition
+    {
+        string FeatureName { get; set; }
+
+        string Geometry { get; set; }
+
+        ICollection<IGridScaleRange> GridScaleRange { get; }
+    }
+
+    //If only all layers were as simple as this one...
+
+    public interface IDrawingLayerDefinition : ISubLayerDefinition
+    {
+        /// <summary>
+        /// Gets or sets the sheet of the DWF to user
+        /// </summary>
+        string Sheet { get; set; }
+
+        /// <summary>
+        /// Gets or sets the layers to show from the specified sheet. Shows all layers if this is not specified
+        /// </summary>
+        string LayerFilter { get; set; }
+
+        /// <summary>
+        /// Gets or sets the zoomed in part of the scale range. Defaults to 0 if not specified. Inclusive
+        /// </summary>
+        double MinScale { get; set; }
+
+        /// <summary>
+        /// Gets or sets the zoomed out part of the scale range. Defaults to the application's maximum value if not specified. Exclusive
+        /// </summary>
+        double MaxScale { get; set; }
+    }
+
+    #endregion
+
+    #region vector layer
+
+    /// <summary>
+    /// The stylization to be applied to the vector features for a given scale range
+    /// </summary>
+    public interface IVectorScaleRange
+    {
+        /// <summary>
+        /// The zoomed in part of the scale range. Defaults to 0 if not specified. Inclusive
+        /// </summary>
+        double? MinScale { get; set; }
+
+        /// <summary>
+        /// The zoomed out part of the scale range. Defaults to the application's maximum value if not specified. Exclusive
+        /// </summary>
+        double? MaxScale { get; set; }
+
+        /// <summary>
+        /// Gets or sets the area style for this scale range
+        /// </summary>
+        IAreaVectorStyle AreaStyle { get; set; }
+
+        /// <summary>
+        /// Gets or sets the point style for this scale range
+        /// </summary>
+        IPointVectorStyle PointStyle { get; set; }
+
+        /// <summary>
+        /// Gets or sets the line style for this scale range
+        /// </summary>
+        ILineVectorStyle LineStyle { get; set; }
+
+        /// <summary>
+        /// Creates a clone of this instance
+        /// </summary>
+        /// <returns></returns>
+        IVectorScaleRange Clone();
+    }
+
+    public interface INameStringPair
+    {
+        string Name { get; set; }
+        string Value { get; set; }
+    }
+
+    /// <summary>
+    /// base interface for all style specifications
+    /// </summary>
+    public interface IVectorStyle
+    {
+        /// <summary>
+        /// Gets the type of this style specification
+        /// </summary>
+        StyleType StyleType { get; }
+    }
+
+    /// <summary>
+    /// Indicates the type of geometry this style specification is for
+    /// </summary>
+    public enum StyleType
+    {
+        Area,
+        Line,
+        Point
+    }
+
+    /// <summary>
+    /// Style specification for a area geometry layer
+    /// </summary>
+    public interface IAreaVectorStyle : IVectorStyle, IDynamicInvokable
+    {
+        /// <summary>
+        /// Enumerates the rules in this specification
+        /// </summary>
+        IEnumerable<IAreaRule> Rules { get; }
+
+        /// <summary>
+        /// Adds a rule to this specification
+        /// </summary>
+        /// <param name="rule"></param>
+        void AddRule(IAreaRule rule);
+
+        /// <summary>
+        /// Removes a rule from this specification
+        /// </summary>
+        /// <param name="rule"></param>
+        void RemoveRule(IAreaRule rule);
+
+        void RemoveAllRules();
+    }
+
+    /// <summary>
+    /// Style specification for a line geometry layer
+    /// </summary>
+    public interface ILineVectorStyle : IVectorStyle, IDynamicInvokable
+    {
+        /// <summary>
+        /// Enumerates the rules in this specification
+        /// </summary>
+        IEnumerable<ILineRule> Rules { get; }
+
+        /// <summary>
+        /// Adds a rule to this specification
+        /// </summary>
+        /// <param name="rule"></param>
+        void AddRule(ILineRule rule);
+
+        /// <summary>
+        /// Removes a rule from this specification
+        /// </summary>
+        /// <param name="rule"></param>
+        void RemoveRule(ILineRule rule);
+
+        void RemoveAllRules();
+    }
+
+    /// <summary>
+    /// Style specification for a point geometry layer
+    /// </summary>
+    public interface IPointVectorStyle : IVectorStyle, IDynamicInvokable
+    {
+        /// <summary>
+        /// Gets or sets whether to create a text layer
+        /// </summary>
+        bool DisplayAsText { get; set; }
+
+        /// <summary>
+        /// Gets or sets whether to allow labels from any map layer (including the current layer) to obscure features on the current layer
+        /// </summary>
+        bool AllowOverpost { get; set; }
+
+        /// <summary>
+        /// Enumerates the rules for this specification
+        /// </summary>
+        IEnumerable<IPointRule> Rules { get; }
+
+        /// <summary>
+        /// Adds a rule to this specification
+        /// </summary>
+        /// <param name="rule"></param>
+        void AddRule(IPointRule rule);
+
+        /// <summary>
+        /// Removes a rule from this specification
+        /// </summary>
+        /// <param name="rule"></param>
+        void RemoveRule(IPointRule rule);
+
+        void RemoveAllRules();
+    }
+
+    /// <summary>
+    /// Base interface for style rules of all geometric types
+    /// </summary>
+    public interface IVectorRule : IDynamicInvokable
+    {
+        /// <summary>
+        /// Gets or sets the label for the rule to be displayed in the legend
+        /// </summary>
+        string LegendLabel { get; set; }
+
+        /// <summary>
+        /// Gets or sets the filter for this rule
+        /// </summary>
+        string Filter { get; set; }
+
+        /// <summary>
+        /// Gets or sets the the label
+        /// </summary>
+        ITextSymbol Label { get; set; }
+    }
+
+    /// <summary>
+    /// A style rule for the point geometry type
+    /// </summary>
+    public interface IPointRule : IVectorRule
+    {
+        /// <summary>
+        /// Gets or sets the symbolization settings for this point rule
+        /// </summary>
+        IPointSymbolization2D PointSymbolization2D { get; set; }
+    }
+
+    /// <summary>
+    /// A style rule for the line geometry type
+    /// </summary>
+    public interface ILineRule : IVectorRule
+    {
+        /// <summary>
+        /// Gets the symbolization settings for this line rule
+        /// </summary>
+        IEnumerable<IStroke> Strokes { get; }
+
+        void SetStrokes(IEnumerable<IStroke> strokes);
+
+        void AddStroke(IStroke stroke);
+
+        void RemoveStroke(IStroke stroke);
+    }
+
+    /// <summary>
+    /// A style rule for the area/polygon geometry type
+    /// </summary>
+    public interface IAreaRule : IVectorRule
+    {
+        /// <summary>
+        /// Gets or sets the polygon stylization settings 
+        /// </summary>
+        IAreaSymbolizationFill AreaSymbolization2D { get; set; }
+    }
+
+    /// <summary>
+    /// Encapsulates the stylization of a line
+    /// </summary>
+    public interface IStroke
+    {
+        string LineStyle { get; set; }
+
+        string Thickness { get; set; }
+
+        string Color { get; set; }
+
+        LengthUnitType Unit { get; set; }
+    }
+
+    /// <summary>
+    /// Symbolization characteristics for areas.
+    /// </summary>
+    public interface IAreaSymbolizationFill
+    {
+        /// <summary>
+        /// Gets or sets the style of the polygon fill.
+        /// </summary>
+        IFill Fill { get; set; }
+
+        /// <summary>
+        /// Gets or sets the style of the polygon edge
+        /// </summary>
+        IStroke Stroke { get; set; }
+    }
+
+    public enum PointSymbolType
+    {
+        Text,
+        /// <summary>
+        /// A predefined shape such as a square or circle.
+        /// </summary>
+        Mark,
+        /// <summary>
+        /// A raster or image symbol.  Note that these do not scale well, but sometimes this is all that you have.  Supported formats are application specific.
+        /// </summary>
+        Image,
+        /// <summary>
+        /// A symbol specified using a font character
+        /// </summary>
+        Font,
+        /// <summary>
+        /// A vector symbol defined using a W2D stream
+        /// </summary>
+        W2D,
+        /// <summary>
+        /// A vector symbol specifed from a block
+        /// </summary>
+        Block
+    }
+
+    /// <summary>
+    /// Defines common properties for all symbols
+    /// </summary>
+    public interface ISymbol
+    {
+        /// <summary>
+        /// Gets the type of symbol
+        /// </summary>
+        PointSymbolType Type { get; }
+
+        /// <summary>
+        /// Gets or sets the units that the sizes are specified in
+        /// </summary>
+        LengthUnitType Unit { get; set; }
+
+        /// <summary>
+        /// Gets or sets whether the sizes are with respect to the earth or the user's display device
+        /// </summary>
+        SizeContextType SizeContext { get; set; }
+
+        /// <summary>
+        /// Gets or sets the width of the symbol. This is a double FDO expression. Does not apply to font symbols
+        /// </summary>
+        double? SizeX { get; set; }
+
+        /// <summary>
+        /// Gets or sets the height of the symbol. This is a double FDO expression.
+        /// </summary>
+        double? SizeY { get; set; }
+
+        /// <summary>
+        /// Gets or sets the amount to rotate the symbol in degrees. This is a double FDO expression. Does not apply to line labels
+        /// </summary>
+        double? Rotation { get; set; }
+
+        /// <summary>
+        /// Hint for the UI only. When the user enters a constant size for the width or height, the other dimension should be adjusted accordingly.  Does not apply to font symbols or labels.
+        /// </summary>
+        bool MaintainAspect { get; set; }
+
+        /// <summary>
+        /// Gets or sets the X offset for the symbol specified in symbol space.  Does not apply to labels.
+        /// </summary>
+        double? InsertionPointX { get; set; }
+
+        /// <summary>
+        /// Gets or sets the Y offset for the symbol specified in symbol space.  Does not apply to labels.
+        /// </summary>
+        double? InsertionPointY { get; set; }
+    }
+
+    public interface IAdvancedPlacement
+    {
+        double ScaleLimit { get; set; }
+    }
+
+    public interface ITextSymbol : ISymbol
+    {
+        string Text { get; set; }
+
+        string FontName { get; set; }
+
+        string ForegroundColor { get; set; }
+
+        string BackgroundColor { get; set; }
+
+        BackgroundStyleType BackgroundStyle { get; set; }
+
+        string HorizontalAlignment { get; set; }
+
+        string VerticalAlignment { get; set; }
+
+        string Bold { get; set; }
+
+        string Italic { get; set; }
+
+        string Underlined { get; set; }
+
+        IAdvancedPlacement AdvancedPlacement { get; set; }
+    }
+
+    /// <summary>
+    /// Stylization of a predefined shape (ShapeType)
+    /// </summary>
+    public interface IMarkSymbol : ISymbol
+    {
+        ShapeType Shape { get; set; }
+
+        IFill Fill { get; set; }
+
+        IStroke Edge { get; set; }
+    }
+
+    /// <summary>
+    /// Symbols that are specified by a font and character.
+    /// </summary>
+    public interface IFontSymbol : ISymbol
+    {
+        /// <summary>
+        /// Gets or sets the name of the font. If the font is not installed, the actual font used is application dependent.
+        /// </summary>
+        string FontName { get; set; }
+
+        string Character { get; set; }
+
+        bool? Bold { get; set; }
+
+        bool? Italic { get; set; }
+
+        bool? Underlined { get; set; }
+
+        string ForegroundColor { get; set; }
+    }
+
+    public interface IW2DSymbol : ISymbol
+    {
+        ISymbolReference W2DSymbol { get; set; }
+
+        string FillColor { get; set; }
+
+        string LineColor { get; set; }
+
+        string TextColor { get; set; }
+    }
+
+    /// <summary>
+    /// Symbols that are comprised of a raster.
+    /// </summary>
+    public interface IImageSymbol : ISymbol
+    {
+        IBaseImageSymbol Image { get; set; }
+    }
+
+    public enum ImageSymbolReferenceType
+    {
+        SymbolReference,
+        Inline
+    }
+
+    public interface IBaseImageSymbol
+    {
+        ImageSymbolReferenceType Type { get; }
+    }
+
+    /// <summary>
+    /// Represents a reference to a symbol library item image
+    /// </summary>
+    public interface ISymbolReference : IBaseImageSymbol
+    {
+        string ResourceId { get; set; }
+
+        string LibraryItemName { get; set; }
+    }
+
+    /// <summary>
+    /// Represents an inline symbol image
+    /// </summary>
+    public interface IInlineImageSymbol : IBaseImageSymbol
+    {
+        /// <summary>
+        /// Gets or sets the BinHex data for image
+        /// </summary>
+        byte[] Content { get; set; }
+    }
+
+    /// <summary>
+    /// Represents a block symbol
+    /// </summary>
+    public interface IBlockSymbol : ISymbol
+    {
+        string DrawingName { get; set; }
+
+        string BlockName { get; set; }
+
+        string BlockColor { get; set; }
+
+        string LayerColor { get; set; }
+    }
+
+    /// <summary>
+    /// Symbolization characteristics for points.
+    /// </summary>
+    public interface IPointSymbolization2D
+    {
+        ISymbol Symbol { get; set; }
+    }
+
+    public interface IFill
+    {
+        string FillPattern { get; set; }
+
+        string BackgroundColor { get; set; }
+
+        string ForegroundColor { get; set; }
+    }
+
+    #endregion
+
+    #region raster layer
+
+    /// <summary>
+    /// Defines how to scale numbers into a color channel
+    /// </summary>
+    public interface IChannelBand
+    {
+        /// <summary>
+        /// Gets or sets the name of the band
+        /// </summary>
+        string Band { get; set; }
+
+        /// <summary>
+        /// Gets or sets the low band value. Default is low value found in band.  Band values less than this are snapped to this number
+        /// </summary>
+        double? LowBand { get; set; }
+
+        /// <summary>
+        /// Gets or sets the high band value. Default is high value found in band.  Band values greater than this are snapped to this number
+        /// </summary>
+        double? HighBand { get; set; }
+
+        /// <summary>
+        /// Gets or sets the low channel value. Default is 0.  Range is 0:255.  LowBand is mapped to this number.  LowChannel can be greater than HighChannel
+        /// </summary>
+        byte LowChannel { get; set; }
+
+        /// <summary>
+        /// Gets or sets the high channel value. Default is 255.  Range is 0:255
+        /// </summary>
+        byte HighChannel { get; set; }
+    }
+
+    /// <summary>
+    /// Specifies a color using distinct RGB values
+    /// </summary>
+    public interface IGridColorBands
+    {
+        IChannelBand RedBand { get; set; }
+
+        IChannelBand GreenBand { get; set; }
+
+        IChannelBand BlueBand { get; set; }
+    }
+
+    public interface IExplicitColor
+    {
+        ItemChoiceType Type { get; }
+    }
+
+    public interface IExplictColorValue : IExplicitColor
+    {
+        string Value { get; }
+    }
+
+    public interface IExplicitColorBand : IExplicitColor
+    {
+        string Band { get; }
+    }
+
+    public interface IExplicitColorBands : IExplicitColor
+    {
+        IGridColorBands Bands { get; }
+    }
+
+    public interface IGridColor
+    {
+        IExplicitColor ExplicitColor { get; set; }
+    }
+
+    public interface IGridColorRule
+    {
+        /// <summary>
+        /// Gets or sets the label for the rule to be displayed in the legend
+        /// </summary>
+        string LegendLabel { get; set; }
+
+        /// <summary>
+        /// Gets or sets a filter for the rule.  This is a boolean FDO expression.  Any features that pass this filter are styled using this rule's stylization
+        /// </summary>
+        string Filter { get; set; }
+
+        /// <summary>
+        /// Gets or sets a label for the rule.  Does not apply to GridColorRule
+        /// </summary>
+        ITextSymbol Label { get; set; }
+
+        IGridColor Color { get; set; }
+    }
+
+    /// <summary>
+    /// Specifies how to shade given a band and a light source
+    /// </summary>
+    public interface IHillShade
+    {
+        /// <summary>
+        /// Gets or sets the name of the band used for the computation
+        /// </summary>
+        string Band { get; set; }
+
+        /// <summary>
+        /// Gets or sets the azimuth of the sun in degrees
+        /// </summary>
+        double Azimuth { get; set; }
+
+        /// <summary>
+        /// Gets or sets the altitude of the sun in degrees
+        /// </summary>
+        double Altitude { get; set; }
+
+        /// <summary>
+        /// Gets or sets the scale factor applied to the band prior to computing hillshade.  Defaults to 1 if not specified
+        /// </summary>
+        double ScaleFactor { get; set; }
+    }
+
+    public interface IGridColorStyle
+    {
+        IHillShade HillShade { get; set; }
+
+        /// <summary>
+        /// Gets or sets the transparency color. If a pixel color prior to factoring in HillShade is this value then the pixel is transparent
+        /// </summary>
+        string TransparencyColor { get; set; }
+
+        /// <summary>
+        /// Gets or sets the brightness factor
+        /// </summary>
+        double BrightnessFactor { get; set; }
+
+        /// <summary>
+        /// Gets or sets the contrast factor
+        /// </summary>
+        double ConstrastFactor { get; set; }
+
+        IList<IGridColorRule> ColorRule { get; }
+
+        void AddColorRule(IGridColorRule rule);
+    }
+
+    public interface IGridSurfaceStyle
+    {
+        /// <summary>
+        /// Gets or sets the band to use for 3D data
+        /// </summary>
+        string Band { get; set; }
+
+        /// <summary>
+        /// Gets or sets the value that determines which input value is mapped to zero elevation.  Defaults to 0 if not specified
+        /// </summary>
+        double ZeroValue { get; set; }
+
+        /// <summary>
+        /// Gets or sets the value that determines how to scale the inputs into a consistent elevation.  Defaults to 1 if not specified
+        /// </summary>
+        double ScaleFactor { get; set; }
+
+        /// <summary>
+        /// Gets or sets the default color to use if no ColorStyle is defined at a pixel
+        /// </summary>
+        string DefaultColor { get; set; }
+    }
+
+    public interface IGridScaleRange
+    {
+        /// <summary>
+        /// Gets or sets the zoomed in part of the scale range.  Defaults to 0 if not specified.  Inclusive
+        /// </summary>
+        double? MinScale { get; set; }
+
+        /// <summary>
+        /// Gets or sets the zoomed out part of the scale range.  Defaults to the application's maximum value if not specified.  Exclusive
+        /// </summary>
+        double? MaxScale { get; set; }
+
+        /// <summary>
+        /// Defines the height field of the grid
+        /// </summary>
+        IGridSurfaceStyle SurfaceStyle { get; set; }
+
+        IGridColorStyle ColorStyle { get; set; }
+
+        /// <summary>
+        /// When the user has zoomed in by this amount, a request for more detailed raster data is made
+        /// </summary>
+        double RebuildFactor { get; set; }
+    }
+
+    #endregion
+}

Modified: sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/ObjectModels/ObjectFactory.cs
===================================================================
--- sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/ObjectModels/ObjectFactory.cs	2010-10-07 10:05:07 UTC (rev 5253)
+++ sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/ObjectModels/ObjectFactory.cs	2010-10-07 12:42:50 UTC (rev 5254)
@@ -36,6 +36,8 @@
 
 namespace OSGeo.MapGuide.MaestroAPI.ObjectModels
 {
+    public delegate ILayerDefinition LayerCreatorFunc(LayerType type);
+
     /// <summary>
     /// Factory class to create MapGuide resource objects with either pre-defined or
     /// sensible default values. This is recommended over creating the objects directly
@@ -44,40 +46,29 @@
     /// </summary>
     public static class ObjectFactory
     {
-        public static LayerDefinition CreateMonoChromaticVectorLayer(IServerConnection owner)
+        private static Dictionary<Version, LayerCreatorFunc> _layerFactories;
+
+        static ObjectFactory()
         {
+            _layerFactories = new Dictionary<Version,LayerCreatorFunc>();
+            _layerFactories.Add(
+                new Version(1, 0, 0),
+                new LayerCreatorFunc(OSGeo.MapGuide.ObjectModels.LayerDefinition_1_0_0.LayerDefinition.CreateDefault));
+        }
+
+        public static ILayerDefinition CreateDefaultLayer(IServerConnection owner, LayerType type, Version version)
+        {
             Check.NotNull(owner, "owner");
 
-            var layer = new LayerDefinition();
+            if (!_layerFactories.ContainsKey(version))
+                throw new ArgumentException("Unknown layer version: " + version.ToString()); //LOCALIZEME
+
+            var layer = _layerFactories[version](type);
             layer.CurrentConnection = owner;
             
-            var vl = new VectorLayerDefinitionType();
-            layer.Item = vl;
-
-            vl.VectorScaleRange = new System.ComponentModel.BindingList<VectorScaleRangeType>();
-            var defaultRange = new VectorScaleRangeType()
-            {
-                Items = new System.ComponentModel.BindingList<object>(),
-                AreaStyle = CreateDefaultAreaStyle(),
-                LineStyle = CreateDefaultLineStyle(),
-                PointStyle = CreateDefaultPointStyle()
-            };
-            defaultRange.AreaStyle.AreaRule.Add(CreateAreaRule());
-            defaultRange.LineStyle.LineRule.Add(CreateLineRule());
-            defaultRange.PointStyle.PointRule.Add(CreatePointRule());
-            vl.VectorScaleRange.Add(defaultRange);
-
             return layer;
         }
 
-        //TODO: Split into CreateVector/CreateRaster/CreateDrawing ?
-        public static LayerDefinition CreateLayerDefinition(IServerConnection owner)
-        {
-            Check.NotNull(owner, "owner");
-
-            return new LayerDefinition() { CurrentConnection = owner };
-        }
-
         public static DrawingSource CreateDrawingSource(IServerConnection owner)
         {
             Check.NotNull(owner, "owner");
@@ -799,165 +790,6 @@
             };
         }
 
-        /// <summary>
-        /// Creates a fill
-        /// </summary>
-        /// <param name="p"></param>
-        /// <param name="color"></param>
-        /// <param name="color_3"></param>
-        /// <returns></returns>
-        public static FillType CreateFill(string pattern, System.Drawing.Color background, System.Drawing.Color foreground)
-        {
-            return new FillType()
-            {
-                BackgroundColor = Utility.SerializeHTMLColor(background, true),
-                FillPattern = pattern,
-                ForegroundColor = Utility.SerializeHTMLColor(foreground, true)
-            };
-        }
-
-        /// <summary>
-        /// Creates a line stroke with default settings
-        /// </summary>
-        /// <param name="color"></param>
-        /// <returns></returns>
-        public static StrokeType CreateStroke(System.Drawing.Color color)
-        {
-            return new StrokeType()
-            {
-                Color = Utility.SerializeHTMLColor(color, true),
-                LineStyle = "Solid",
-                Thickness = "1",
-                Unit = LengthUnitType.Points
-            };
-        }
-
-        public static StrokeType CreateDefaultStroke()
-        {
-            return CreateStroke(Color.Black);
-        }
-
-        public static PointTypeStyleType CreateDefaultPointStyle()
-        {
-            return new PointTypeStyleType()
-            {
-                PointRule = new System.ComponentModel.BindingList<PointRuleType>()
-            };
-        }
-
-        public static LineTypeStyleType CreateDefaultLineStyle()
-        {
-            return new LineTypeStyleType()
-            {
-                LineRule = new System.ComponentModel.BindingList<LineRuleType>()
-            };
-        }
-
-        public static AreaTypeStyleType CreateDefaultAreaStyle()
-        {
-            return new AreaTypeStyleType()
-            {
-                AreaRule = new System.ComponentModel.BindingList<AreaRuleType>()
-            };
-        }
-
-        public static VectorScaleRangeType CreateVectorScaleRange()
-        {
-            return new VectorScaleRangeType()
-            {
-                Items = new System.ComponentModel.BindingList<object>(),
-                AreaStyle = CreateDefaultAreaStyle(),
-                LineStyle = CreateDefaultLineStyle(),
-                PointStyle = CreateDefaultPointStyle()
-            };
-        }
-
-        public static FillType CreateDefaultFill()
-        {
-            return CreateFill("Solid", Color.White, Color.Black);
-        }
-
-        public static MarkSymbolType CreateDefaultMarkSymbol()
-        {
-            return new MarkSymbolType()
-            {
-                Edge = CreateDefaultStroke(),
-                Fill = CreateDefaultFill(),
-                SizeContext = SizeContextType.DeviceUnits,
-                MaintainAspect = true,
-                Shape = ShapeType.Square,
-                Rotation = "0",
-                SizeX = "10",
-                SizeY = "10",
-                Unit = LengthUnitType.Points
-            };
-        }
-
-        public static PointSymbolization2DType CreateDefaultPointSymbolization2D()
-        {
-            return new PointSymbolization2DType()
-            {
-                Item = CreateDefaultMarkSymbol()
-            };
-        }
-
-        public static PointRuleType CreatePointRule()
-        {
-            return new PointRuleType()
-            {
-                LegendLabel = "",
-                Item = CreateDefaultPointSymbolization2D()
-            };
-        }
-
-        public static AreaRuleType CreateAreaRule()
-        {
-            return new AreaRuleType()
-            {
-                LegendLabel = "",
-                Item = new AreaSymbolizationFillType()
-                {
-                    Fill = CreateDefaultFill(),
-                    Stroke = CreateDefaultStroke()
-                }
-            };
-        }
-
-        public static LineRuleType CreateLineRule()
-        {
-            return new LineRuleType()
-            {
-                LegendLabel = "",
-                Items = new System.ComponentModel.BindingList<StrokeType>()
-                {
-                    CreateDefaultStroke()
-                }
-            };
-        }
-
-        public static TextSymbolType CreateDefaultTextSymbol()
-        {
-            return new TextSymbolType()
-            {
-                AdvancedPlacement = null,
-                BackgroundColor = Utility.SerializeHTMLColor(Color.White, true),
-                BackgroundStyle = BackgroundStyleType.Transparent,
-                Bold = "false",
-                FontName = "Arial",
-                ForegroundColor = Utility.SerializeHTMLColor(Color.Black, true),
-                HorizontalAlignment = "'Center'",
-                Italic = "false",
-                Rotation = "0",
-                SizeContext = SizeContextType.DeviceUnits,
-                SizeX = "10",
-                SizeY = "10",
-                Text = "",
-                Underlined = "false",
-                Unit = LengthUnitType.Points,
-                VerticalAlignment = "'Baseline'"
-            };
-        }
-
         public static InvokeURLCommandType CreateInvokeUrlCommand()
         {
             return new InvokeURLCommandType()

Copied: sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/ObjectModels/VectorLayerDefinitionImpl.cs (from rev 5242, sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/ObjectModels/LayerDefinition.cs)
===================================================================
--- sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/ObjectModels/VectorLayerDefinitionImpl.cs	                        (rev 0)
+++ sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/ObjectModels/VectorLayerDefinitionImpl.cs	2010-10-07 12:42:50 UTC (rev 5254)
@@ -0,0 +1,1386 @@
+#region Disclaimer / License
+// Copyright (C) 2010, Jackie Ng
+// http://trac.osgeo.org/mapguide/wiki/maestro, jumpinjackie at gmail.com
+// 
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// 
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+// 
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+// 
+#endregion
+using System;
+using System.Collections.Generic;
+using System.Text;
+using OSGeo.MapGuide.MaestroAPI.Resource;
+using System.Xml.Serialization;
+using OSGeo.MapGuide.MaestroAPI;
+using OSGeo.MapGuide.ObjectModels.Common;
+using System.ComponentModel;
+using OSGeo.MapGuide.MaestroAPI.Services;
+using OSGeo.MapGuide.MaestroAPI.ObjectModels;
+using OSGeo.MapGuide.ObjectModels.FeatureSource;
+using System.Globalization;
+
+#if LDF_110
+namespace OSGeo.MapGuide.ObjectModels.LayerDefinition_1_1_0
+#elif LDF_120
+namespace OSGeo.MapGuide.ObjectModels.LayerDefinition_1_2_0
+#elif LDF_130
+namespace OSGeo.MapGuide.ObjectModels.LayerDefinition_1_3_0
+#else
+namespace OSGeo.MapGuide.ObjectModels.LayerDefinition_1_0_0
+#endif
+{
+    using OSGeo.MapGuide.ObjectModels.LayerDefinition;
+
+    abstract partial class BaseLayerDefinitionType : ISubLayerDefinition
+    {
+        [XmlIgnore]
+        public abstract LayerType LayerType { get; }
+    }
+
+    partial class NameStringPairType : INameStringPair
+    {
+        [XmlIgnore]
+        string INameStringPair.Name
+        {
+            get
+            {
+                return this.Name;
+            }
+            set
+            {
+                this.Name = value;
+            }
+        }
+
+        [XmlIgnore]
+        string INameStringPair.Value
+        {
+            get
+            {
+                return this.Value;
+            }
+            set
+            {
+                this.Value = value;
+            }
+        }
+    }
+
+
+    partial class VectorScaleRangeType : IVectorScaleRange
+    {
+        #region Missing generated stuff
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        private bool minScaleFieldSpecified;
+
+        [System.Xml.Serialization.XmlIgnoreAttribute()]
+        public bool MinScaleSpecified
+        {
+            get
+            {
+                return this.minScaleFieldSpecified;
+            }
+            set
+            {
+                if ((minScaleFieldSpecified.Equals(value) != true))
+                {
+                    this.minScaleFieldSpecified = value;
+                    this.OnPropertyChanged("MinScaleSpecified");
+                }
+            }
+        }
+        #endregion
+
+        [XmlIgnore]
+        public IAreaVectorStyle AreaStyle
+        {
+            get
+            {
+                foreach (var item in this.itemsField)
+                {
+                    if (typeof(IAreaVectorStyle).IsAssignableFrom(item.GetType()))
+                        return (IAreaVectorStyle)item;
+                }
+
+                return null;
+            }
+            set
+            {
+                //Remove old one if it exists
+                var item = this.AreaStyle;
+                if (item != null)
+                {
+                    this.itemsField.Remove(item);
+                }
+                //Put the new one in if it is not null
+                if (value != null)
+                {
+                    this.itemsField.Add(value);   
+                }
+            }
+        }
+
+        [XmlIgnore]
+        public ILineVectorStyle LineStyle
+        {
+            get
+            {
+                foreach (var item in this.itemsField)
+                {
+                    if (typeof(ILineVectorStyle).IsAssignableFrom(item.GetType()))
+                        return (ILineVectorStyle)item;
+                }
+
+                return null;
+            }
+            set
+            {
+                //Remove old one if it exists
+                var item = this.LineStyle;
+                if (item != null)
+                {
+                    this.itemsField.Remove(item);
+                }
+                //Put the new one in if it is not null
+                if (value != null)
+                {
+                    this.itemsField.Add(value);
+                }
+            }
+        }
+        
+        [XmlIgnore]
+        public IPointVectorStyle PointStyle
+        {
+            get
+            {
+                foreach (var item in this.itemsField)
+                {
+                    if (typeof(IPointVectorStyle).IsAssignableFrom(item.GetType()))
+                        return (IPointVectorStyle)item;
+                }
+
+                return null;
+            }
+            set
+            {
+                //Remove old one if it exists
+                var item = this.PointStyle;
+                if (item != null)
+                {
+                    this.itemsField.Remove(item);
+                }
+                //Put the new one in if it is not null
+                if (value != null)
+                {
+                    this.itemsField.Add(value);
+                }
+            }
+        }
+
+        double? IVectorScaleRange.MinScale
+        {
+            get
+            {
+                return this.MinScaleSpecified ? new Nullable<double>(this.MinScale) : null;
+            }
+            set
+            {
+                if (value.HasValue)
+                {
+                    this.MinScaleSpecified = true;
+                    this.MinScale = value.Value;
+                }
+                else
+                {
+                    this.MinScaleSpecified = false;
+                }
+            }
+        }
+
+        double? IVectorScaleRange.MaxScale
+        {
+            get
+            {
+                return this.MaxScaleSpecified ? new Nullable<double>(this.MaxScale) : null;
+            }
+            set
+            {
+                if (value.HasValue)
+                {
+                    this.MaxScaleSpecified = true;
+                    this.MaxScale = value.Value;
+                }
+                else
+                {
+                    this.MaxScaleSpecified = false;
+                }
+            }
+        }
+
+        public IList<IVectorStyle> AllStyles
+        {
+            get { return (IList<IVectorStyle>)this.Items; }
+        }
+
+        IVectorScaleRange IVectorScaleRange.Clone()
+        {
+            return this.Clone();
+        }
+    }
+
+    partial class StrokeType : IStroke
+    {
+        internal StrokeType() { }
+    }
+
+    partial class FillType : IFill
+    {
+        internal FillType() { } 
+    }
+
+    partial class AreaTypeStyleType : IAreaVectorStyle
+    {
+        IEnumerable<IAreaRule> IAreaVectorStyle.Rules
+        {
+            get 
+            {
+                foreach (var ar in this.AreaRule)
+                {
+                    yield return ar;
+                }
+            }
+        }
+
+        void IAreaVectorStyle.RemoveAllRules()
+        {
+            this.AreaRule.Clear();
+        }
+
+        void IAreaVectorStyle.AddRule(IAreaRule rule)
+        {
+            var ar = rule as AreaRuleType;
+            if (ar != null)
+                this.AreaRule.Add(ar);
+        }
+
+        void IAreaVectorStyle.RemoveRule(IAreaRule rule)
+        {
+            var ar = rule as AreaRuleType;
+            if (ar != null)
+                this.AreaRule.Remove(ar);
+        } 
+
+        StyleType IVectorStyle.StyleType
+        {
+            get { return StyleType.Area; }
+        }
+    }
+
+    partial class AreaRuleType : IAreaRule
+    {
+        [XmlIgnore]
+        IAreaSymbolizationFill IAreaRule.AreaSymbolization2D
+        {
+            get
+            {
+                return this.Item;
+            }
+            set
+            {
+                this.Item = (AreaSymbolizationFillType)value;
+            }
+        }
+
+        [XmlIgnore]
+        ITextSymbol IVectorRule.Label
+        {
+            get
+            {
+                return this.Label;
+            }
+            set
+            {
+                this.Label = (TextSymbolType)value;
+            }
+        }
+    }
+
+    partial class PointTypeStyleType : IPointVectorStyle
+    {
+        public IEnumerable<IPointRule> Rules
+        {
+            get 
+            { 
+                foreach(var pr in this.PointRule)
+                {
+                    yield return pr;
+                }
+            }
+        }
+
+        public void RemoveAllRules()
+        {
+            this.PointRule.Clear();
+        }
+
+        public void AddRule(IPointRule rule)
+        {
+            var pr = rule as PointRuleType;
+            if (pr != null)
+                this.PointRule.Add(pr);
+        }
+
+        public void RemoveRule(IPointRule rule)
+        {
+            var pr = rule as PointRuleType;
+            if (pr != null)
+                this.PointRule.Remove(pr);
+        }
+
+        public StyleType StyleType
+        {
+            get { return StyleType.Point; }
+        }
+    }
+
+
+    partial class PointRuleType : IPointRule
+    {
+        [XmlIgnore]
+        ITextSymbol IVectorRule.Label
+        {
+            get
+            {
+                return this.Label;
+            }
+            set
+            {
+                this.Label = (TextSymbolType)value;
+            }
+        }
+
+        IPointSymbolization2D IPointRule.PointSymbolization2D
+        {
+            get { return this.Item; }
+            set { this.Item = (PointSymbolization2DType)value; }
+        }
+    }
+
+    partial class PointSymbolization2DType : IPointSymbolization2D
+    {
+        ISymbol IPointSymbolization2D.Symbol
+        {
+            get { return (ISymbol)this.Item; }
+            set { this.Item = (SymbolType)value; }
+        }
+    }
+
+    partial class LineTypeStyleType : ILineVectorStyle
+    {
+        public IEnumerable<ILineRule> Rules
+        {
+            get
+            {
+                foreach (var lr in this.LineRule)
+                {
+                    yield return lr;
+                }
+            }
+        }
+
+        public void RemoveAllRules()
+        {
+            this.LineRule.Clear();
+        }
+
+        public void AddRule(ILineRule rule)
+        {
+            var lr = rule as LineRuleType;
+            if (lr != null)
+                this.LineRule.Add(lr);
+        }
+
+        public void RemoveRule(ILineRule rule)
+        {
+            var lr = rule as LineRuleType;
+            if (lr != null)
+                this.LineRule.Remove(lr);
+        }
+
+        public StyleType StyleType
+        {
+            get { return StyleType.Line; }
+        }
+    }
+
+    partial class LineRuleType : ILineRule
+    {
+        [XmlIgnore]
+        IEnumerable<IStroke> ILineRule.Strokes
+        {
+            get
+            {
+                foreach (var str in this.Items)
+                {
+                    yield return str;
+                }
+            }
+        }
+
+        void ILineRule.SetStrokes(IEnumerable<IStroke> strokes)
+        {
+            Check.NotNull(strokes, "strokes");
+            this.Items.Clear();
+            foreach (var stroke in strokes)
+            {
+                var st = stroke as StrokeType;
+                if (st != null)
+                    this.Items.Add(st);
+            }
+        }
+
+        void ILineRule.AddStroke(IStroke stroke)
+        {
+            var st = stroke as StrokeType;
+            if (st != null)
+                this.Items.Add(st);
+        }
+
+        void ILineRule.RemoveStroke(IStroke stroke)
+        {
+            var st = stroke as StrokeType;
+            if (st != null)
+                this.Items.Remove(st);
+        }
+
+        [XmlIgnore]
+        ITextSymbol IVectorRule.Label
+        {
+            get
+            {
+                return this.Label;
+            }
+            set
+            {
+                this.Label = (TextSymbolType)value;
+            }
+        }
+    }
+
+    partial class TextSymbolType : ITextSymbol
+    {
+        [XmlIgnore]
+        IAdvancedPlacement ITextSymbol.AdvancedPlacement
+        {
+            get
+            {
+                return this.AdvancedPlacement;
+            }
+            set
+            {
+                this.AdvancedPlacement = (TextSymbolTypeAdvancedPlacement)value;
+            }
+        }
+
+        [XmlIgnore]
+        string ITextSymbol.Text
+        {
+            get
+            {
+                return this.Text;
+            }
+            set
+            {
+                this.Text = value;
+            }
+        }
+
+        [XmlIgnore]
+        string ITextSymbol.FontName
+        {
+            get
+            {
+                return this.FontName;
+            }
+            set
+            {
+                this.FontName = value;
+            }
+        }
+
+        [XmlIgnore]
+        string ITextSymbol.ForegroundColor
+        {
+            get
+            {
+                return this.ForegroundColor;
+            }
+            set
+            {
+                this.ForegroundColor = value;
+            }
+        }
+
+        [XmlIgnore]
+        string ITextSymbol.BackgroundColor
+        {
+            get
+            {
+                return this.BackgroundColor;
+            }
+            set
+            {
+                this.BackgroundColor = value;
+            }
+        }
+
+        [XmlIgnore]
+        BackgroundStyleType ITextSymbol.BackgroundStyle
+        {
+            get
+            {
+                return this.BackgroundStyle;
+            }
+            set
+            {
+                this.BackgroundStyle = value;
+            }
+        }
+
+        [XmlIgnore]
+        string ITextSymbol.HorizontalAlignment
+        {
+            get
+            {
+                return this.HorizontalAlignment;
+            }
+            set
+            {
+                this.HorizontalAlignment = value;
+            }
+        }
+
+        [XmlIgnore]
+        string ITextSymbol.VerticalAlignment
+        {
+            get
+            {
+                return this.VerticalAlignment;
+            }
+            set
+            {
+                this.VerticalAlignment = value;
+            }
+        }
+
+        [XmlIgnore]
+        string ITextSymbol.Bold
+        {
+            get
+            {
+                return this.Bold;
+            }
+            set
+            {
+                this.Bold = value;
+            }
+        }
+
+        [XmlIgnore]
+        string ITextSymbol.Italic
+        {
+            get
+            {
+                return this.Italic;
+            }
+            set
+            {
+                this.Italic = value;
+            }
+        }
+
+        [XmlIgnore]
+        string ITextSymbol.Underlined
+        {
+            get
+            {
+                return this.Underlined;
+            }
+            set
+            {
+                this.Underlined = value;
+            }
+        }
+
+        PointSymbolType ISymbol.Type
+        {
+            get { return PointSymbolType.Font; }
+        }
+    }
+
+    partial class MarkSymbolType : IMarkSymbol
+    {
+        [XmlIgnore]
+        ShapeType IMarkSymbol.Shape
+        {
+            get
+            {
+                return this.Shape;
+            }
+            set
+            {
+                this.Shape = value;
+            }
+        }
+
+        [XmlIgnore]
+        IFill IMarkSymbol.Fill
+        {
+            get
+            {
+                return (IFill)this.Fill;
+            }
+            set
+            {
+                this.Fill = (FillType)value;
+            }
+        }
+
+        [XmlIgnore]
+        IStroke IMarkSymbol.Edge
+        {
+            get
+            {
+                return (IStroke)this.Edge;
+            }
+            set
+            {
+                this.Edge = (StrokeType)value;
+            }
+        }
+
+        PointSymbolType ISymbol.Type
+        {
+            get { return PointSymbolType.Mark; }
+        }
+    }
+
+    internal class ImageBinaryContainer : IInlineImageSymbol
+    {
+        public byte[] Content
+        {
+            get;
+            set;
+        }
+
+        public ImageSymbolReferenceType Type
+        {
+            get { return ImageSymbolReferenceType.Inline; }
+        }
+    }
+
+
+    partial class ImageSymbolType : IImageSymbol
+    {
+        [XmlIgnore]
+        IBaseImageSymbol IImageSymbol.Image
+        {
+            get
+            {
+                IBaseImageSymbol img = null;
+                if (this.Item == null)
+                    return null;
+
+                if (typeof(byte[]).IsAssignableFrom(this.Item.GetType()))
+                    img = new ImageBinaryContainer() { Content = (byte[])this.Item };
+                else
+                    img = (ISymbolReference)this.Item;
+                return img;
+            }
+            set
+            {
+                if (typeof(IInlineImageSymbol).IsAssignableFrom(value.GetType()))
+                    this.Item = ((IInlineImageSymbol)value).Content;
+                else
+                    this.Item = (ImageSymbolTypeImage)value;
+            }
+        }
+
+        PointSymbolType ISymbol.Type
+        {
+            get { return PointSymbolType.Image; }
+        }
+    }
+
+    partial class SymbolType : ISymbol
+    {
+        [XmlIgnore]
+        LengthUnitType ISymbol.Unit
+        {
+            get
+            {
+                return this.Unit;
+            }
+            set
+            {
+                this.Unit = value;
+            }
+        }
+
+        [XmlIgnore]
+        SizeContextType ISymbol.SizeContext
+        {
+            get
+            {
+                return this.SizeContext;
+            }
+            set
+            {
+                this.SizeContext = value;
+            }
+        }
+
+        [XmlIgnore]
+        double? ISymbol.SizeX
+        {
+            get
+            {
+                if (string.IsNullOrEmpty(this.SizeX))
+                    return null;
+
+                double d;
+                if (double.TryParse(this.SizeX, out d))
+                    return d;
+
+                return null;
+            }
+            set
+            {
+                if (!value.HasValue)
+                    this.SizeX = null;
+                else
+                    this.SizeX = value.Value.ToString(CultureInfo.InvariantCulture);
+            }
+        }
+
+        [XmlIgnore]
+        double? ISymbol.SizeY
+        {
+            get
+            {
+                if (string.IsNullOrEmpty(this.SizeY))
+                    return null;
+
+                double d;
+                if (double.TryParse(this.SizeY, out d))
+                    return d;
+
+                return null;
+            }
+            set
+            {
+                if (!value.HasValue)
+                    this.SizeY = null;
+                else
+                    this.SizeY = value.Value.ToString(CultureInfo.InvariantCulture);
+            }
+        }
+
+        [XmlIgnore]
+        double? ISymbol.Rotation
+        {
+            get
+            {
+                if (string.IsNullOrEmpty(this.Rotation))
+                    return null;
+
+                double d;
+                if (double.TryParse(this.Rotation, out d))
+                    return d;
+
+                return null;
+            }
+            set
+            {
+                if (!value.HasValue)
+                    this.Rotation = null;
+                else
+                    this.Rotation = value.Value.ToString(CultureInfo.InvariantCulture);
+            }
+        }
+
+        [XmlIgnore]
+        bool ISymbol.MaintainAspect
+        {
+            get
+            {
+                return this.MaintainAspect;
+            }
+            set
+            {
+                this.MaintainAspect = true;
+            }
+        }
+
+        [XmlIgnore]
+        double? ISymbol.InsertionPointX
+        {
+            get
+            {
+                if (string.IsNullOrEmpty(this.InsertionPointX))
+                    return null;
+
+                double d;
+                if (double.TryParse(this.InsertionPointX, out d))
+                    return d;
+                else
+                    return null;
+            }
+            set
+            {
+                if (value.HasValue)
+                    this.InsertionPointX = value.Value.ToString(CultureInfo.InvariantCulture);
+                else
+                    this.InsertionPointX = null;
+            }
+        }
+
+        [XmlIgnore]
+        double? ISymbol.InsertionPointY
+        {
+            get
+            {
+                if (string.IsNullOrEmpty(this.InsertionPointX))
+                    return null;
+
+                double d;
+                if (double.TryParse(this.InsertionPointX, out d))
+                    return d;
+                else
+                    return null;
+            }
+            set
+            {
+                if (value.HasValue)
+                    this.InsertionPointY = value.Value;
+
+                //TODO: throw exception?
+            }
+        }
+
+        PointSymbolType ISymbol.Type
+        {
+            get { throw new NotImplementedException(); }
+        }
+    }
+
+    partial class FontSymbolType : IFontSymbol
+    {
+        [XmlIgnore]
+        string IFontSymbol.FontName
+        {
+            get
+            {
+                return this.FontName;
+            }
+            set
+            {
+                this.FontName = value;
+            }
+        }
+
+        [XmlIgnore]
+        string IFontSymbol.Character
+        {
+            get
+            {
+                return this.Character;
+            }
+            set
+            {
+                this.Character = value;
+            }
+        }
+
+        [XmlIgnore]
+        bool? IFontSymbol.Bold
+        {
+            get
+            {
+                return this.BoldSpecified ? new Nullable<bool>(this.Bold) : null;
+            }
+            set
+            {
+                if (value.HasValue)
+                {
+                    this.Bold = value.Value;
+                    this.BoldSpecified = true;
+                }
+                else
+                {
+                    this.BoldSpecified = false;
+                }
+            }
+        }
+
+        [XmlIgnore]
+        bool? IFontSymbol.Italic
+        {
+            get
+            {
+                return this.ItalicSpecified ? new Nullable<bool>(this.Italic) : null;
+            }
+            set
+            {
+                if (value.HasValue)
+                {
+                    this.Italic = value.Value;
+                    this.ItalicSpecified = true;
+                }
+                else
+                {
+                    this.ItalicSpecified = false;
+                }
+            }
+        }
+
+        [XmlIgnore]
+        bool? IFontSymbol.Underlined
+        {
+            get
+            {
+                return this.UnderlinedSpecified ? new Nullable<bool>(this.Underlined) : null;
+            }
+            set
+            {
+                if (value.HasValue)
+                {
+                    this.Underlined = value.Value;
+                    this.UnderlinedSpecified = true;
+                }
+                else
+                {
+                    this.UnderlinedSpecified = false;
+                }
+            }
+        }
+
+        [XmlIgnore]
+        string IFontSymbol.ForegroundColor
+        {
+            get
+            {
+                return this.ForegroundColor;
+            }
+            set
+            {
+                this.ForegroundColor = value;
+            }
+        }
+
+        PointSymbolType ISymbol.Type
+        {
+            get { return PointSymbolType.Font; }
+        }
+    }
+
+    partial class BlockSymbolType : IBlockSymbol
+    {
+        [XmlIgnore]
+        string IBlockSymbol.DrawingName
+        {
+            get
+            {
+                return this.DrawingName;
+            }
+            set
+            {
+                this.DrawingName = value;
+            }
+        }
+
+        [XmlIgnore]
+        string IBlockSymbol.BlockName
+        {
+            get
+            {
+                return this.BlockName;
+            }
+            set
+            {
+                this.BlockName = value;
+            }
+        }
+
+        [XmlIgnore]
+        string IBlockSymbol.BlockColor
+        {
+            get
+            {
+                return this.BlockColor;
+            }
+            set
+            {
+                this.BlockColor = value;
+            }
+        }
+
+        [XmlIgnore]
+        string IBlockSymbol.LayerColor
+        {
+            get
+            {
+                return this.LayerColor;
+            }
+            set
+            {
+                this.LayerColor = value;
+            }
+        }
+
+        PointSymbolType ISymbol.Type
+        {
+            get { return PointSymbolType.Block; }
+        }
+    }
+
+    partial class W2DSymbolType : IW2DSymbol
+    {
+        [XmlIgnore]
+        ISymbolReference IW2DSymbol.W2DSymbol
+        {
+            get
+            {
+                return (ISymbolReference)this.W2DSymbol;
+            }
+            set
+            {
+                this.W2DSymbol = (W2DSymbolTypeW2DSymbol)value;
+            }
+        }
+
+        [XmlIgnore]
+        string IW2DSymbol.FillColor
+        {
+            get
+            {
+                return this.FillColor;
+            }
+            set
+            {
+                this.FillColor = value;
+            }
+        }
+
+        [XmlIgnore]
+        string IW2DSymbol.LineColor
+        {
+            get
+            {
+                return this.LineColor;
+            }
+            set
+            {
+                this.LineColor = value;
+            }
+        }
+
+        [XmlIgnore]
+        string IW2DSymbol.TextColor
+        {
+            get
+            {
+                return this.TextColor;
+            }
+            set
+            {
+                this.TextColor = value;
+            }
+        }
+
+        PointSymbolType ISymbol.Type
+        {
+            get { return PointSymbolType.W2D; }
+        }
+    }
+
+    partial class W2DSymbolTypeW2DSymbol : ISymbolReference
+    {
+        string ISymbolReference.ResourceId
+        {
+            get
+            {
+                return this.ResourceId == null ? string.Empty : this.ResourceId.ToString();
+            }
+            set
+            {
+                this.ResourceId = value;
+            }
+        }
+
+        string ISymbolReference.LibraryItemName
+        {
+            get
+            {
+                return this.LibraryItemName == null ? string.Empty : this.LibraryItemName.ToString();
+            }
+            set
+            {
+                this.LibraryItemName = value;
+            }
+        }
+
+        ImageSymbolReferenceType IBaseImageSymbol.Type
+        {
+            get { return ImageSymbolReferenceType.SymbolReference; }
+        }
+    }
+
+    partial class ImageSymbolTypeImage : ISymbolReference
+    {
+        [XmlIgnore]
+        string ISymbolReference.ResourceId
+        {
+            get
+            {
+                return this.ResourceId == null ? string.Empty : this.ResourceId.ToString();
+            }
+            set
+            {
+                this.ResourceId = value;
+            }
+        }
+
+        [XmlIgnore]
+        string ISymbolReference.LibraryItemName
+        {
+            get
+            {
+                return this.LibraryItemName == null ? string.Empty : this.LibraryItemName.ToString();
+            }
+            set
+            {
+                this.LibraryItemName = value;
+            }
+        }
+
+        ImageSymbolReferenceType IBaseImageSymbol.Type
+        {
+            get { return ImageSymbolReferenceType.SymbolReference; }
+        }
+    }
+
+    partial class TextSymbolTypeAdvancedPlacement : IAdvancedPlacement
+    {
+        
+    }
+
+    partial class AreaSymbolizationFillType : IAreaSymbolizationFill
+    {
+        [XmlIgnore]
+        IFill IAreaSymbolizationFill.Fill
+        {
+            get
+            {
+                return this.Fill;
+            }
+            set
+            {
+                this.Fill = (FillType)value;
+            }
+        }
+
+        [XmlIgnore]
+        IStroke IAreaSymbolizationFill.Stroke
+        {
+            get
+            {
+                return this.Stroke;
+            }
+            set
+            {
+                this.Stroke = (StrokeType)value;
+            }
+        }
+    }
+
+    partial class LayerDefinition : ILayerDefinition
+    {
+        //internal LayerDefinition() { } 
+
+        #if LDF_110
+        private static readonly Version RES_VERSION = new Version(1, 1, 0);
+        #elif LDF_120
+        private static readonly Version RES_VERSION = new Version(1, 2, 0);
+        #elif LDF_130
+        private static readonly Version RES_VERSION = new Version(1, 3, 0);
+        #else
+        private static readonly Version RES_VERSION = new Version(1, 0, 0);
+        #endif
+
+        [XmlIgnore]
+        public OSGeo.MapGuide.MaestroAPI.IServerConnection CurrentConnection
+        {
+            get;
+            set;
+        }
+
+        private string _resId;
+
+        [XmlIgnore]
+        public string ResourceID
+        {
+            get
+            {
+                return _resId;
+            }
+            set
+            {
+                if (!ResourceIdentifier.Validate(value))
+                    throw new InvalidOperationException("Not a valid resource identifier"); //LOCALIZE
+
+                var res = new ResourceIdentifier(value);
+                if (res.Extension != ResourceTypes.LayerDefinition.ToString())
+                    throw new InvalidOperationException("Invalid resource identifier for this type of object: " + res.Extension); //LOCALIZE
+
+                _resId = value;
+                this.OnPropertyChanged("ResourceID");
+            }
+        }
+
+        [XmlIgnore]
+        public ResourceTypes ResourceType
+        {
+            get
+            {
+                return ResourceTypes.LayerDefinition;
+            }
+        }
+
+        [XmlIgnore]
+        public Version ResourceVersion
+        {
+            get
+            {
+                return RES_VERSION;
+            }
+        }
+
+        object ICloneable.Clone()
+        {
+            return this.Clone();
+        }
+
+        [XmlAttribute("noNamespaceSchemaLocation", Namespace = "http://www.w3.org/2001/XMLSchema-instance")]
+        public string ValidatingSchema
+        {
+            get { return "LayerDefinition-1.0.0.xsd"; }
+            set { }
+        }
+
+        [XmlIgnore]
+        public bool IsStronglyTyped
+        {
+            get { return true; }
+        }
+
+        public ISubLayerDefinition SubLayer
+        {
+            get { return this.Item; }
+        }
+
+        public INameStringPair CreatePair(string name, string value)
+        {
+            return new NameStringPairType() { Name = name, Value = value };
+        }
+    }
+
+    partial class DrawingLayerDefinitionType : IDrawingLayerDefinition
+    {
+        public override LayerType LayerType
+        {
+            get { return LayerType.Drawing; }
+        }
+
+        [XmlIgnore]
+        string ISubLayerDefinition.ResourceId
+        {
+            get { return this.ResourceId; }
+            set { this.ResourceId = value; }
+        }
+    }
+
+    partial class VectorLayerDefinitionType : IVectorLayerDefinition
+    {
+        public override LayerType LayerType
+        {
+            get { return LayerType.Vector; }
+        }
+
+        [XmlIgnore]
+        string ISubLayerDefinition.ResourceId
+        {
+            get { return this.ResourceId; }
+            set { this.ResourceId = value; }
+        }
+
+        [XmlIgnore]
+        string IVectorLayerDefinition.FeatureName
+        {
+            get { return this.FeatureName; }
+            set { this.FeatureName = value; }
+        }
+
+        [XmlIgnore]
+        string IVectorLayerDefinition.Geometry
+        {
+            get { return this.Geometry; }
+            set { this.Geometry = value; }
+        }
+
+        [XmlIgnore]
+        string IVectorLayerDefinition.Url
+        {
+            get { return this.Url; }
+            set { this.Url = value; }
+        }
+
+        [XmlIgnore]
+        string IVectorLayerDefinition.ToolTip
+        {
+            get { return this.ToolTip; }
+            set { this.ToolTip = value; }
+        }
+
+        [XmlIgnore]
+        string IVectorLayerDefinition.Filter
+        {
+            get { return this.Filter; }
+            set { this.Filter = value; }
+        }
+
+        [XmlIgnore]
+        IList<IVectorScaleRange> IVectorLayerDefinition.VectorScaleRange
+        {
+            get { return (IList<IVectorScaleRange>)this.VectorScaleRange; }
+        }
+
+        [XmlIgnore]
+        IList<INameStringPair> IVectorLayerDefinition.PropertyMapping
+        {
+            get { return (IList<INameStringPair>)this.PropertyMapping; }
+        }
+    }
+}

Modified: sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/Properties/Resources.Designer.cs
===================================================================
--- sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/Properties/Resources.Designer.cs	2010-10-07 10:05:07 UTC (rev 5253)
+++ sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/Properties/Resources.Designer.cs	2010-10-07 12:42:50 UTC (rev 5254)
@@ -1,7 +1,7 @@
 //------------------------------------------------------------------------------
 // <auto-generated>
 //     This code was generated by a tool.
-//     Runtime Version:2.0.50727.4927
+//     Runtime Version:2.0.50727.4952
 //
 //     Changes to this file may cause incorrect behavior and will be lost if
 //     the code is regenerated.
@@ -167,5 +167,131 @@
                 return ResourceManager.GetString("ERR_SERIALIZER_ALREADY_REGISTERED", resourceCulture);
             }
         }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to Only vector layers and raster layers are currently validated.
+        /// </summary>
+        internal static string LDF_DrawingLayerDefinitionNotSupportedWarning {
+            get {
+                return ResourceManager.GetString("LDF_DrawingLayerDefinitionNotSupportedWarning", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to Maestro does not support DrawingLayers.
+        /// </summary>
+        internal static string LDF_DrawingLayerNotSupportedWarning {
+            get {
+                return ResourceManager.GetString("LDF_DrawingLayerNotSupportedWarning", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to Failed to load featuresource.
+        /// </summary>
+        internal static string LDF_FeatureSourceLoadError {
+            get {
+                return ResourceManager.GetString("LDF_FeatureSourceLoadError", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to Failed to find geometry column {0} in schema {1} on featuresource {2}.
+        /// </summary>
+        internal static string LDF_GeometryMissingError {
+            get {
+                return ResourceManager.GetString("LDF_GeometryMissingError", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to Layer is missing core information.
+        /// </summary>
+        internal static string LDF_LayerNullError {
+            get {
+                return ResourceManager.GetString("LDF_LayerNullError", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to The minimum scale ({0}) is larger than the maximum scale ({1}).
+        /// </summary>
+        internal static string LDF_MinAndMaxScaleSwappedError {
+            get {
+                return ResourceManager.GetString("LDF_MinAndMaxScaleSwappedError", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to No FeatureSource is assigned to the layer.
+        /// </summary>
+        internal static string LDF_MissingFeatureSourceError {
+            get {
+                return ResourceManager.GetString("LDF_MissingFeatureSourceError", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to No Geometry is assigned to the layer.
+        /// </summary>
+        internal static string LDF_MissingGeometryError {
+            get {
+                return ResourceManager.GetString("LDF_MissingGeometryError", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to No scale ranges are defined, no data can be displayed.
+        /// </summary>
+        internal static string LDF_MissingScaleRangesError {
+            get {
+                return ResourceManager.GetString("LDF_MissingScaleRangesError", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to More than one scale ranges is defined, this is valid, but unsupported by Maestro.
+        /// </summary>
+        internal static string LDF_MultipleScaleRangesWarning {
+            get {
+                return ResourceManager.GetString("LDF_MultipleScaleRangesWarning", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to The scale range {0}-{1} overlaps the range {2}-{3}.
+        /// </summary>
+        internal static string LDF_ScaleRangesOverlapInformation {
+            get {
+                return ResourceManager.GetString("LDF_ScaleRangesOverlapInformation", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to Failed to validate column and schema.
+        /// </summary>
+        internal static string LDF_SchemaAndColumnReadFailedError {
+            get {
+                return ResourceManager.GetString("LDF_SchemaAndColumnReadFailedError", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to Failed to find schema {0} in featuresource {1}.
+        /// </summary>
+        internal static string LDF_SchemaMissingError {
+            get {
+                return ResourceManager.GetString("LDF_SchemaMissingError", resourceCulture);
+            }
+        }
+        
+        /// <summary>
+        ///   Looks up a localized string similar to The layer has no type, or the type is unsupported by Maestro.
+        /// </summary>
+        internal static string LDF_UnsupportedLayerTypeWarning {
+            get {
+                return ResourceManager.GetString("LDF_UnsupportedLayerTypeWarning", resourceCulture);
+            }
+        }
     }
 }

Modified: sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/Properties/Resources.resx
===================================================================
--- sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/Properties/Resources.resx	2010-10-07 10:05:07 UTC (rev 5253)
+++ sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/Properties/Resources.resx	2010-10-07 12:42:50 UTC (rev 5254)
@@ -154,4 +154,60 @@
   <data name="ERR_SERIALIZER_ALREADY_REGISTERED" xml:space="preserve">
     <value>A resource serializer has already been registered for {0} v{1}</value>
   </data>
+  <data name="LDF_DrawingLayerDefinitionNotSupportedWarning" xml:space="preserve">
+    <value>Only vector layers and raster layers are currently validated</value>
+    <comment>A warning message that is displayed if the layer is not Grid or Vector</comment>
+  </data>
+  <data name="LDF_DrawingLayerNotSupportedWarning" xml:space="preserve">
+    <value>Maestro does not support DrawingLayers</value>
+    <comment>A warning message that is displayed if the layer is a DrawingLayer type</comment>
+  </data>
+  <data name="LDF_FeatureSourceLoadError" xml:space="preserve">
+    <value>Failed to load featuresource</value>
+    <comment>An error message that is displayed if the featuresource fails to load</comment>
+  </data>
+  <data name="LDF_GeometryMissingError" xml:space="preserve">
+    <value>Failed to find geometry column {0} in schema {1} on featuresource {2}</value>
+    <comment>An error message that is displayed if the geometry is not present in the selected schema</comment>
+  </data>
+  <data name="LDF_LayerNullError" xml:space="preserve">
+    <value>Layer is missing core information</value>
+    <comment>An error message that is displayed if the layer has a null reference</comment>
+  </data>
+  <data name="LDF_MinAndMaxScaleSwappedError" xml:space="preserve">
+    <value>The minimum scale ({0}) is larger than the maximum scale ({1})</value>
+    <comment>An error message that is displayed if the scale ranges are reversed</comment>
+  </data>
+  <data name="LDF_MissingFeatureSourceError" xml:space="preserve">
+    <value>No FeatureSource is assigned to the layer</value>
+    <comment>An error message that is displayed if the layer has no FeatureSource</comment>
+  </data>
+  <data name="LDF_MissingGeometryError" xml:space="preserve">
+    <value>No Geometry is assigned to the layer</value>
+    <comment>An error message that is displayed if the layer has no geometry column selected</comment>
+  </data>
+  <data name="LDF_MissingScaleRangesError" xml:space="preserve">
+    <value>No scale ranges are defined, no data can be displayed</value>
+    <comment>An error message that is displayed if there are no scale ranges defined</comment>
+  </data>
+  <data name="LDF_MultipleScaleRangesWarning" xml:space="preserve">
+    <value>More than one scale ranges is defined, this is valid, but unsupported by Maestro</value>
+    <comment>A warning message that is displayed if a raster layer has multiple scale ranges defined</comment>
+  </data>
+  <data name="LDF_ScaleRangesOverlapInformation" xml:space="preserve">
+    <value>The scale range {0}-{1} overlaps the range {2}-{3}</value>
+    <comment>A warning message that is displayed if two scaleranges overlap</comment>
+  </data>
+  <data name="LDF_SchemaAndColumnReadFailedError" xml:space="preserve">
+    <value>Failed to validate column and schema</value>
+    <comment>An error message that is displayed if the schema and column read fails</comment>
+  </data>
+  <data name="LDF_SchemaMissingError" xml:space="preserve">
+    <value>Failed to find schema {0} in featuresource {1}</value>
+    <comment>An error message that is displayed if the selected schema is not present in the FeatureSource</comment>
+  </data>
+  <data name="LDF_UnsupportedLayerTypeWarning" xml:space="preserve">
+    <value>The layer has no type, or the type is unsupported by Maestro</value>
+    <comment>A  warning message that is displayed if the layer type is unknown</comment>
+  </data>
 </root>
\ No newline at end of file

Added: sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/Resource/BaseLayerDefinitionValidator.cs
===================================================================
--- sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/Resource/BaseLayerDefinitionValidator.cs	                        (rev 0)
+++ sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/Resource/BaseLayerDefinitionValidator.cs	2010-10-07 12:42:50 UTC (rev 5254)
@@ -0,0 +1,178 @@
+#region Disclaimer / License
+// Copyright (C) 2010, Jackie Ng
+// http://trac.osgeo.org/mapguide/wiki/maestro, jumpinjackie at gmail.com
+// 
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// 
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+// 
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+// 
+#endregion
+using System;
+using System.Collections.Generic;
+using System.Text;
+using OSGeo.MapGuide.ObjectModels.LayerDefinition;
+using OSGeo.MapGuide.ObjectModels.FeatureSource;
+
+namespace OSGeo.MapGuide.MaestroAPI.Resource
+{
+    public abstract class BaseLayerDefinitionValidator : IResourceValidator
+    {
+        public virtual ValidationIssue[] Validate(IResource resource, bool recurse)
+        {
+            if (resource.GetResourceTypeDescriptor() != this.SupportedResourceAndVersion)
+                return null;
+
+            return ValidateBase(resource, recurse);
+        }
+
+        protected static ValidationIssue[] ValidateBase(IResource resource, bool recurse)
+        {
+            var ldef = resource as ILayerDefinition;
+            var vldef = ldef.SubLayer as IVectorLayerDefinition;
+            var gldef = ldef.SubLayer as IRasterLayerDefinition;
+            var dldef = ldef.SubLayer as IDrawingLayerDefinition;
+
+            List<ValidationIssue> issues = new List<ValidationIssue>();
+
+            if (ldef.SubLayer == null)
+                issues.Add(new ValidationIssue(resource, ValidationStatus.Error, Properties.Resources.LDF_LayerNullError));
+            else if (vldef == null && gldef == null)
+                issues.Add(new ValidationIssue(resource, ValidationStatus.Warning, Properties.Resources.LDF_DrawingLayerDefinitionNotSupportedWarning));
+
+            if (vldef != null)
+            {
+                if (string.IsNullOrEmpty(vldef.FeatureName))
+                    issues.Add(new ValidationIssue(resource, ValidationStatus.Error, Properties.Resources.LDF_MissingFeatureSourceError));
+                if (string.IsNullOrEmpty(vldef.Geometry))
+                    issues.Add(new ValidationIssue(resource, ValidationStatus.Error, Properties.Resources.LDF_MissingGeometryError));
+
+                if (vldef.VectorScaleRange == null || vldef.VectorScaleRange.Count == 0)
+                    issues.Add(new ValidationIssue(resource, ValidationStatus.Error, Properties.Resources.LDF_MissingScaleRangesError));
+                else
+                {
+                    //Test for overlapping scale ranges
+                    List<KeyValuePair<double, double>> ranges = new List<KeyValuePair<double, double>>();
+                    foreach (IVectorScaleRange vsr in vldef.VectorScaleRange)
+                    {
+                        ranges.Add(new KeyValuePair<double, double>(
+                            vsr.MaxScale.HasValue ? vsr.MaxScale.Value : double.PositiveInfinity,
+                            vsr.MinScale.HasValue ? vsr.MinScale.Value : double.NegativeInfinity));
+                    }
+
+                    double min = double.PositiveInfinity;
+                    double max = double.NegativeInfinity;
+                    foreach (KeyValuePair<double, double> sr in ranges)
+                    {
+                        min = Math.Min(min, sr.Value);
+                        max = Math.Max(max, sr.Key);
+                        if (sr.Key < sr.Value)
+                            issues.Add(new ValidationIssue(resource, ValidationStatus.Error, string.Format(Properties.Resources.LDF_MinAndMaxScaleSwappedError, sr.Value, sr.Key)));
+                    }
+
+                    //TODO: Detect gaps in scale ranges
+                    for (int i = 0; i < ranges.Count; i++)
+                        for (int j = i + 1; j < ranges.Count; j++)
+                            if (ranges[i].Key > ranges[j].Value || ranges[i].Value > ranges[j].Value)
+                                issues.Add(new ValidationIssue(resource, ValidationStatus.Information, string.Format(Properties.Resources.LDF_ScaleRangesOverlapInformation, ranges[i].Value, ranges[i].Key, ranges[j].Value, ranges[j].Key)));
+
+                }
+            }
+            else if (gldef != null)
+            {
+                if (gldef.GridScaleRange == null || gldef.GridScaleRange.Count == 0)
+                    issues.Add(new ValidationIssue(resource, ValidationStatus.Error, Properties.Resources.LDF_MissingScaleRangesError));
+                else if (gldef.GridScaleRange.Count != 1)
+                    issues.Add(new ValidationIssue(resource, ValidationStatus.Warning, Properties.Resources.LDF_MultipleScaleRangesWarning));
+            }
+            else if (dldef != null)
+                issues.Add(new ValidationIssue(resource, ValidationStatus.Warning, Properties.Resources.LDF_DrawingLayerNotSupportedWarning));
+            else
+                issues.Add(new ValidationIssue(resource, ValidationStatus.Warning, Properties.Resources.LDF_UnsupportedLayerTypeWarning));
+
+            if (recurse)
+            {
+                try
+                {
+                    FeatureSourceType fs = (FeatureSourceType)ldef.CurrentConnection.ResourceService.GetResource(ldef.SubLayer.ResourceId);
+                    issues.AddRange(ResourceValidatorSet.Validate(fs, recurse));
+
+                    try
+                    {
+                        if (vldef != null || gldef != null)
+                        {
+                            string schema = vldef == null ? gldef.FeatureName : vldef.FeatureName;
+                            string geometry = vldef == null ? gldef.Geometry : vldef.Geometry;
+
+                            bool foundSchema = false;
+                            bool foundGeometry = false;
+
+                            FeatureSourceDescription desc = fs.Describe();
+                            foreach (FeatureSourceDescription.FeatureSourceSchema scm in desc.Schemas)
+                                if (scm.FullnameDecoded == schema)
+                                {
+                                    foundSchema = true;
+
+                                    foreach (FeatureSetColumn col in scm.Columns)
+                                        if (col.Name == geometry)
+                                        {
+                                            foundGeometry = true;
+                                            break;
+                                        }
+
+
+                                    if (vldef != null && vldef.PropertyMapping != null)
+                                        foreach (INameStringPair s in vldef.PropertyMapping)
+                                        {
+                                            bool found = false;
+                                            foreach (FeatureSetColumn col in scm.Columns)
+                                            {
+                                                if (col.Name == s.Name)
+                                                {
+                                                    found = true;
+                                                    break;
+                                                }
+                                            }
+                                            if (!found)
+                                                issues.Add(new ValidationIssue(resource, ValidationStatus.Error, string.Format(Properties.Resources.LDF_SchemaMissingError, schema, fs.ResourceID)));
+
+                                        }
+
+                                    break;
+                                }
+
+                            if (!foundSchema)
+                                issues.Add(new ValidationIssue(resource, ValidationStatus.Error, string.Format(Properties.Resources.LDF_SchemaMissingError, schema, fs.ResourceID)));
+                            else if (!foundGeometry)
+                                issues.Add(new ValidationIssue(resource, ValidationStatus.Error, string.Format(Properties.Resources.LDF_GeometryMissingError, geometry, schema, fs.ResourceID)));
+                        }
+                    }
+                    catch (Exception)
+                    {
+                        issues.Add(new ValidationIssue(fs, ValidationStatus.Error, string.Format(Properties.Resources.LDF_SchemaAndColumnReadFailedError)));
+                    }
+                }
+                catch (Exception)
+                {
+                    issues.Add(new ValidationIssue(resource, ValidationStatus.Error, string.Format(Properties.Resources.LDF_FeatureSourceLoadError)));
+                }
+            }
+
+            return issues.ToArray();
+        }
+
+        public abstract ResourceTypeDescriptor SupportedResourceAndVersion
+        {
+            get;
+        }
+    }
+}

Modified: sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/ResourceTypeRegistry.cs
===================================================================
--- sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/ResourceTypeRegistry.cs	2010-10-07 10:05:07 UTC (rev 5253)
+++ sandbox/maestro-3.0/OSGeo.MapGuide.MaestroAPI/ResourceTypeRegistry.cs	2010-10-07 12:42:50 UTC (rev 5254)
@@ -90,7 +90,7 @@
                 new ResourceSerializer()
                 {
                     Serialize = (res) => { return res.SerializeToStream(); },
-                    Deserialize = (xml) => { return LayerDefinition.Deserialize(xml); }
+                    Deserialize = (xml) => { return OSGeo.MapGuide.ObjectModels.LayerDefinition_1_0_0.LayerDefinition.Deserialize(xml); }
                 });
 
             //LoadProcedure 1.0.0



More information about the mapguide-commits mailing list