src/Misc/EFTools/EntityDesignModel/MetadataConverter/UseStrongSpatialTypesHandler.cs
/// <summary>
///     If we are retargeting to a schema version which supports it, ensure
///     UseStrongSpatialTypes="false" is set on the CSDL Schema Element.
///     If we are retargeting to a schema version which does not support it, ensure
///     UseStrongSpatialTypes is absent from the CSDL Schema Element.
/// </summary>
/// <param name="doc"></param>
/// <returns></returns>
If we are retargeting to a schema version which supports it, ensure
UseStrongSpatialTypes="false" is set on the CSDL Schema Element.
If we are retargeting to a schema version which does not support it, ensure
UseStrongSpatialTypes is absent from the CSDL Schema Element.
If we are retargeting to a schema version which supports it ensure UseStrongSpatialTypes = " false " is set on the CSDL Schema Element . If we are retargeting to a schema version which does not support it ensure UseStrongSpatialTypes is absent from the CSDL Schema Element .
protected override XmlDocument DoHandleConversion(XmlDocument doc)
        {
            var nsmgr = SchemaManager.GetEdmxNamespaceManager(doc.NameTable, _targetSchemaVersion);
            var annotationNamespace = SchemaManager.GetAnnotationNamespaceName();
            var csdlSchemaElement = (XmlElement)doc.SelectSingleNode("/edmx:Edmx/edmx:Runtime/edmx:ConceptualModels/csdl:Schema", nsmgr);
            if (csdlSchemaElement != null)
            {
                var useStrongSpatialTypesAttr =
                    csdlSchemaElement.Attributes[UseStrongSpatialTypesDefaultableValue.AttributeUseStrongSpatialTypes, annotationNamespace];
                if (EdmFeatureManager.GetUseStrongSpatialTypesFeatureState(_targetSchemaVersion).IsEnabled())
                {
                    if (useStrongSpatialTypesAttr == null)
                    {
                        useStrongSpatialTypesAttr = doc.CreateAttribute(
                            "annotation", UseStrongSpatialTypesDefaultableValue.AttributeUseStrongSpatialTypes, annotationNamespace);
                        useStrongSpatialTypesAttr.Value = "false";
                        csdlSchemaElement.Attributes.Append(useStrongSpatialTypesAttr);
                        var annotationXmlnsAttr = doc.CreateAttribute("xmlns", "annotation", "http://www.w3.org/2000/xmlns/");
                        annotationXmlnsAttr.Value = annotationNamespace;
                        csdlSchemaElement.SetAttributeNode(annotationXmlnsAttr);
                    }
                }
                else
                {
                    if (useStrongSpatialTypesAttr != null)
                    {
                        csdlSchemaElement.Attributes.Remove(useStrongSpatialTypesAttr);
                    }
                }
            }
            return doc;
        }
protected override XmlDocument DoHandleConversion ( XmlDocument doc ) { var nsmgr = SchemaManager . GetEdmxNamespaceManager ( doc . NameTable , _targetSchemaVersion ) ; var annotationNamespace = SchemaManager . GetAnnotationNamespaceName ( ) ; var csdlSchemaElement = ( XmlElement ) doc . SelectSingleNode ( " " , nsmgr ) ; if ( csdlSchemaElement != null ) { var useStrongSpatialTypesAttr = csdlSchemaElement . Attributes [ UseStrongSpatialTypesDefaultableValue . AttributeUseStrongSpatialTypes , annotationNamespace ] ; if ( EdmFeatureManager . GetUseStrongSpatialTypesFeatureState ( _targetSchemaVersion ) . IsEnabled ( ) ) { if ( useStrongSpatialTypesAttr == null ) { useStrongSpatialTypesAttr = doc . CreateAttribute ( " " , UseStrongSpatialTypesDefaultableValue . AttributeUseStrongSpatialTypes , annotationNamespace ) ; useStrongSpatialTypesAttr . Value = " " ; csdlSchemaElement . Attributes . Append ( useStrongSpatialTypesAttr ) ; var annotationXmlnsAttr = doc . CreateAttribute ( " " , " " , " " ) ; annotationXmlnsAttr . Value = annotationNamespace ; csdlSchemaElement . SetAttributeNode ( annotationXmlnsAttr ) ; } } else { if ( useStrongSpatialTypesAttr != null ) { csdlSchemaElement . Attributes . Remove ( useStrongSpatialTypesAttr ) ; } } } return doc ; }
If we are retargeting to a schema version which supports it, ensure
UseStrongSpatialTypes="false" is set on the CSDL Schema Element.
If we are retargeting to a schema version which supports it ensure UseStrongSpatialTypes = " false " is set on the CSDL Schema Element .
// we are retargeting to a Schema Version that supports UseStrongSpatialTypes - add UseStrongSpatialTypes="false" if it is not present // setting the xmlns:annotation attribute explicitly will ensure that the XmlReader does not come up // with an auto-generated namespace prefix which may cause an NRE in the XmlEditor leading to a VS crash // we are retargeting to a Schema Version that does not support UseStrongSpatialTypes - remove UseStrongSpatialTypes if it is present
None
doc
XmlDocument
None