protected override void OnChildDeleted(EFContainer efContainer)
 {
     if (efContainer == _designerInfoRoot)
     {
         _designerInfoRoot = null;
     }
 }
        internal override void Parse(ICollection<XName> unprocessedElements)
        {
            State = EFElementState.ParseAttempted;

            if (_designerInfoRoot != null)
            {
                _designerInfoRoot.Dispose();
                _designerInfoRoot = null;
            }

            // convert the xlinq tree to our model
            var elem = XObject.Document.Elements().FirstOrDefault();

            if (elem != null)
            {
                Debug.Assert(elem.Name.LocalName == "Edmx", "Incorrect element name Expected: Edmx; Actual:" + elem.Name.LocalName);
                if (elem.Name.LocalName == "Edmx")
                {
                    foreach (var elem2 in elem.Elements())
                    {
                        ParseSingleElement(unprocessedElements, elem2);
                    }
                }
            }
            State = EFElementState.Parsed;
        }
        internal override void Parse(ICollection <XName> unprocessedElements)
        {
            State = EFElementState.ParseAttempted;

            if (_designerInfoRoot != null)
            {
                _designerInfoRoot.Dispose();
                _designerInfoRoot = null;
            }

            // convert the xlinq tree to our model
            var elem = XObject.Document.Elements().FirstOrDefault();

            if (elem != null)
            {
                Debug.Assert(elem.Name.LocalName == "Edmx", "Incorrect element name Expected: Edmx; Actual:" + elem.Name.LocalName);
                if (elem.Name.LocalName == "Edmx")
                {
                    foreach (var elem2 in elem.Elements())
                    {
                        ParseSingleElement(unprocessedElements, elem2);
                    }
                }
            }
            State = EFElementState.Parsed;
        }
        public void ShouldValidateArtifactDuringBuild_returns_true_if_designer_info_option_does_not_contain_ValidateOnBuild_value()
        {
            var modelManager = new Mock<ModelManager>(null, null).Object;
            var modelProvider = new Mock<XmlModelProvider>().Object;
            var entityDesignArtifactMock =
                new Mock<EntityDesignArtifact>(modelManager, new Uri("urn:dummy"), modelProvider);

            using (var designerInfoRoot = new EFDesignerInfoRoot(entityDesignArtifactMock.Object, new XElement("_")))
            {
                using (var designerProperty = new DesignerProperty(null, new XElement("_")))
                {
                    var optionsDesignerInfoMock = new Mock<OptionsDesignerInfo>(designerInfoRoot, new XElement("_"));
                    optionsDesignerInfoMock
                        .Setup(o => o.ValidateOnBuild)
                        .Returns(designerProperty);

                    designerInfoRoot
                        .AddDesignerInfo(
                            "Options",
                            optionsDesignerInfoMock.Object);

                    entityDesignArtifactMock
                        .Setup(a => a.DesignerInfo)
                        .Returns(designerInfoRoot);

                    Assert.True(
                        EdmUpdateSolutionEvents.ShouldValidateArtifactDuringBuild(entityDesignArtifactMock.Object));
                }
            }
        }
Example #5
0
        /// <summary>
        ///     Retrieve the root "Schema" node for current node.  If there is no root mapping node, this will return null.
        /// </summary>
        internal override XNamespace GetRootNamespace(EFObject node)
        {
            var currNode = node;
            EFRuntimeModelRoot runtimeModel = null;
            EFDesignerInfoRoot designerInfo = null;
            XNamespace         ns           = null;

            while (currNode != null)
            {
                runtimeModel = currNode as EFRuntimeModelRoot;
                designerInfo = currNode as EFDesignerInfoRoot;

                if (runtimeModel != null)
                {
                    ns = runtimeModel.XNamespace;
                    break;
                }
                else if (designerInfo != null)
                {
                    ns = designerInfo.XNamespace;
                    break;
                }
                else
                {
                    currNode = currNode.Parent;
                }
            }

            return(ns);
        }
Example #6
0
        public void CreateSetDesignerPropertyValueCommandFromArtifact_returns_non_null_for_existing_property_with_non_matching_value()
        {
            // this test just tests that CreateSetDesignerPropertyValueCommandFromArtifact() calls
            // CreateSetDesignerPropertyCommandInsideDesignerInfo(). The tests that the latter works
            // correctly are below.
            var modelManager             = new Mock <ModelManager>(null, null).Object;
            var modelProvider            = new Mock <XmlModelProvider>().Object;
            var entityDesignArtifactMock =
                new Mock <EntityDesignArtifact>(modelManager, new Uri("urn:dummy"), modelProvider);

            using (var designerInfoRoot = new EFDesignerInfoRoot(entityDesignArtifactMock.Object, new XElement("_")))
            {
                const string designerPropertyName = "TestPropertyName";
                designerInfoRoot
                .AddDesignerInfo(
                    "Options",
                    SetupOptionsDesignerInfo(designerPropertyName, "TestValue"));

                entityDesignArtifactMock
                .Setup(a => a.DesignerInfo)
                .Returns(designerInfoRoot);

                Assert.NotNull(
                    ModelHelper.CreateSetDesignerPropertyValueCommandFromArtifact(
                        entityDesignArtifactMock.Object, "Options", designerPropertyName, "NewValue"));
            }
        }
 private void ParseDesignerInfoRoot(XElement designerInfoElement)
 {
     if (_designerInfoRoot != null)
     {
         _designerInfoRoot.Dispose();
     }
     _designerInfoRoot = new EFDesignerInfoRoot(this, designerInfoElement);
 }
 internal void ParseDesignerInfoRoot(XElement designerInfoElement)
 {
     if (_designerInfoRoot != null)
     {
         _designerInfoRoot.Dispose();
     }
     _designerInfoRoot = new EFDesignerInfoRoot(this, designerInfoElement);
     _designerInfoRoot.Parse(new HashSet <XName>());
 }
        public void ShouldValidateArtifactDuringBuild_returns_true_if_designer_info_does_not_contain_options()
        {
            var modelManager = new Mock<ModelManager>(null, null).Object;
            var modelProvider = new Mock<XmlModelProvider>().Object;
            var entityDesignArtifactMock =
                new Mock<EntityDesignArtifact>(modelManager, new Uri("urn:dummy"), modelProvider);

            using (var designerInfoRoot = new EFDesignerInfoRoot(entityDesignArtifactMock.Object, new XElement("root")))
            {
                entityDesignArtifactMock
                    .Setup(a => a.DesignerInfo)
                    .Returns(designerInfoRoot);

                Assert.True(EdmUpdateSolutionEvents.ShouldValidateArtifactDuringBuild(entityDesignArtifactMock.Object));
            }
        }
 protected override void Dispose(bool disposing)
 {
     try
     {
         if (disposing)
         {
             if (_designerInfoRoot != null)
             {
                 _designerInfoRoot.Dispose();
                 _designerInfoRoot = null;
             }
         }
     }
     finally
     {
         base.Dispose(disposing);
     }
 }
 protected override void Dispose(bool disposing)
 {
     try
     {
         if (disposing)
         {
             if (_designerInfoRoot != null)
             {
                 _designerInfoRoot.Dispose();
                 _designerInfoRoot = null;
             }
         }
     }
     finally
     {
         base.Dispose(disposing);
     }
 }
        protected override void Dispose(bool disposing)
        {
            try
            {
                if (disposing)
                {
                    if (_designerInfoRoot != null)
                    {
                        _designerInfoRoot.Dispose();
                        _designerInfoRoot = null;
                    }

                    if (_mappingModel != null)
                    {
                        _mappingModel.Dispose();
                        _mappingModel = null;
                    }

                    if (_conceptualEntityModel != null)
                    {
                        _conceptualEntityModel.Dispose();
                        _conceptualEntityModel = null;
                    }

                    if (_storageEntityModel != null)
                    {
                        _storageEntityModel.Dispose();
                        _storageEntityModel = null;
                    }

                    if (DiagramArtifact != null)
                    {
                        ModelManager.ClearArtifact(DiagramArtifact.Uri);
                        DiagramArtifact = null;
                    }
                }
            }
            finally
            {
                base.Dispose(disposing);
            }
        }
        protected override void OnChildDeleted(EFContainer efContainer)
        {
            if (efContainer == _designerInfoRoot)
            {
                _designerInfoRoot = null;
            }
            else if (efContainer == _mappingModel)
            {
                _mappingModel = null;
            }
            else if (efContainer == _conceptualEntityModel)
            {
                _conceptualEntityModel = null;
            }
            else if (efContainer == _storageEntityModel)
            {
                _storageEntityModel = null;
            }

            base.OnChildDeleted(efContainer);
        }
        internal static XNamespace GetRootNamespace(EFObject node)
        {
            var currNode             = node;
            EFDesignerInfoRoot model = null;
            XNamespace         ns    = null;

            while (currNode != null)
            {
                model = currNode as EFDesignerInfoRoot;
                if (model != null)
                {
                    ns = model.XNamespace;
                    break;
                }
                else
                {
                    currNode = currNode.Parent;
                }
            }

            return(ns);
        }
        internal override void Parse(ICollection<XName> unprocessedElements)
        {
            State = EFElementState.ParseAttempted;

            var path = Uri.LocalPath;
            var lastdot = path.LastIndexOf('.');
            var extension = Uri.LocalPath.Substring(lastdot, path.Length - lastdot);

            if (extension.EndsWith(ExtensionMsl, StringComparison.OrdinalIgnoreCase))
            {
                _mappingModel = new MappingModel(this, XDocument.Root);
            }
            else if (extension.EndsWith(ExtensionCsdl, StringComparison.OrdinalIgnoreCase))
            {
                _conceptualEntityModel = new ConceptualEntityModel(this, XDocument.Root);
            }
            else if (extension.EndsWith(ExtensionSsdl, StringComparison.OrdinalIgnoreCase))
            {
                _storageEntityModel = new StorageEntityModel(this, XDocument.Root);
            }
            else if (GetFileExtensions().Contains(extension))
            {
                if (_designerInfoRoot != null)
                {
                    _designerInfoRoot.Dispose();
                    _designerInfoRoot = null;
                }

                if (_storageEntityModel != null)
                {
                    _storageEntityModel.Dispose();
                    _storageEntityModel = null;
                }

                if (_mappingModel != null)
                {
                    _mappingModel.Dispose();
                    _mappingModel = null;
                }

                if (_conceptualEntityModel != null)
                {
                    _conceptualEntityModel.Dispose();
                    _conceptualEntityModel = null;
                }

                // convert the xlinq tree to our model
                foreach (var elem in XObject.Document.Elements())
                {
                    ParseSingleElement(unprocessedElements, elem);
                }
            }

            if (_designerInfoRoot != null)
            {
                _designerInfoRoot.Parse(unprocessedElements);
            }

            if (_conceptualEntityModel != null)
            {
                _conceptualEntityModel.Parse(unprocessedElements);
            }

            if (_storageEntityModel != null)
            {
                _storageEntityModel.Parse(unprocessedElements);
            }

            if (_mappingModel != null)
            {
                _mappingModel.Parse(unprocessedElements);
            }

            State = EFElementState.Parsed;
        }
        protected override void Dispose(bool disposing)
        {
            try
            {
                if (disposing)
                {
                    if (_designerInfoRoot != null)
                    {
                        _designerInfoRoot.Dispose();
                        _designerInfoRoot = null;
                    }

                    if (_mappingModel != null)
                    {
                        _mappingModel.Dispose();
                        _mappingModel = null;
                    }

                    if (_conceptualEntityModel != null)
                    {
                        _conceptualEntityModel.Dispose();
                        _conceptualEntityModel = null;
                    }

                    if (_storageEntityModel != null)
                    {
                        _storageEntityModel.Dispose();
                        _storageEntityModel = null;
                    }

                    if (DiagramArtifact != null)
                    {
                        ModelManager.ClearArtifact(DiagramArtifact.Uri);
                        DiagramArtifact = null;
                    }
                }
            }
            finally
            {
                base.Dispose(disposing);
            }
        }
 protected override void OnChildDeleted(EFContainer efContainer)
 {
     if (efContainer == _designerInfoRoot)
     {
         _designerInfoRoot = null;
     }
 }
 internal void ParseDesignerInfoRoot(XElement designerInfoElement)
 {
     if (_designerInfoRoot != null)
     {
         _designerInfoRoot.Dispose();
     }
     _designerInfoRoot = new EFDesignerInfoRoot(this, designerInfoElement);
     _designerInfoRoot.Parse(new HashSet<XName>());
 }
Example #19
0
            CreateUpdateCodeGenStrategyCommand_returns_UpdateDefaultableValueCommand_when_updating_CodeGenStrategy_value_from_non_empty_string
            ()
        {
            var modelManager = new Mock<ModelManager>(null, null).Object;
            var modelProvider = new Mock<XmlModelProvider>().Object;
            var entityDesignArtifactMock =
                new Mock<EntityDesignArtifact>(modelManager, new Uri("urn:dummy"), modelProvider);

            using (var designerInfoRoot = new EFDesignerInfoRoot(entityDesignArtifactMock.Object, new XElement("_")))
            {
                const string designerPropertyName = "CodeGenerationStrategy";
                designerInfoRoot
                    .AddDesignerInfo(
                        "Options",
                        SetupOptionsDesignerInfo(designerPropertyName, "Default"));

                entityDesignArtifactMock
                    .Setup(a => a.DesignerInfo)
                    .Returns(designerInfoRoot);

                Assert.IsType<UpdateDefaultableValueCommand<string>>(
                    EdmUtils.SetCodeGenStrategyToNoneCommand(entityDesignArtifactMock.Object));
            }
        }
Example #20
0
        public void CreateUpdateCodeGenStrategyCommand_returns_null_when_attempting_to_update_CodeGenStrategy_to_same_value()
        {
            var modelManager = new Mock<ModelManager>(null, null).Object;
            var modelProvider = new Mock<XmlModelProvider>().Object;
            var entityDesignArtifactMock =
                new Mock<EntityDesignArtifact>(modelManager, new Uri("urn:dummy"), modelProvider);

            using (var designerInfoRoot = new EFDesignerInfoRoot(entityDesignArtifactMock.Object, new XElement("_")))
            {
                const string designerPropertyName = "CodeGenerationStrategy";
                designerInfoRoot
                    .AddDesignerInfo(
                        "Options",
                        SetupOptionsDesignerInfo(designerPropertyName, "None"));

                entityDesignArtifactMock
                    .Setup(a => a.DesignerInfo)
                    .Returns(designerInfoRoot);

                Assert.Null(EdmUtils.SetCodeGenStrategyToNoneCommand(entityDesignArtifactMock.Object));
            }
        }
 private void ParseDesignerInfoRoot(XElement designerInfoElement)
 {
     if (_designerInfoRoot != null)
     {
         _designerInfoRoot.Dispose();
     }
     _designerInfoRoot = new EFDesignerInfoRoot(this, designerInfoElement);
 }
        public void CreateSetDesignerPropertyValueCommandFromArtifact_returns_non_null_for_existing_property_with_non_matching_value()
        {
            // this test just tests that CreateSetDesignerPropertyValueCommandFromArtifact() calls
            // CreateSetDesignerPropertyCommandInsideDesignerInfo(). The tests that the latter works
            // correctly are below.
            var modelManager = new Mock<ModelManager>(null, null).Object;
            var modelProvider = new Mock<XmlModelProvider>().Object;
            var entityDesignArtifactMock =
                new Mock<EntityDesignArtifact>(modelManager, new Uri("urn:dummy"), modelProvider);

            using (var designerInfoRoot = new EFDesignerInfoRoot(entityDesignArtifactMock.Object, new XElement("_")))
            {
                const string designerPropertyName = "TestPropertyName";
                designerInfoRoot
                    .AddDesignerInfo(
                        "Options",
                        SetupOptionsDesignerInfo(designerPropertyName, "TestValue"));

                entityDesignArtifactMock
                    .Setup(a => a.DesignerInfo)
                    .Returns(designerInfoRoot);

                Assert.NotNull(
                    ModelHelper.CreateSetDesignerPropertyValueCommandFromArtifact(
                        entityDesignArtifactMock.Object, "Options", designerPropertyName, "NewValue"));
            }
        }
        protected override void OnChildDeleted(EFContainer efContainer)
        {
            if (efContainer == _designerInfoRoot)
            {
                _designerInfoRoot = null;
            }
            else if (efContainer == _mappingModel)
            {
                _mappingModel = null;
            }
            else if (efContainer == _conceptualEntityModel)
            {
                _conceptualEntityModel = null;
            }
            else if (efContainer == _storageEntityModel)
            {
                _storageEntityModel = null;
            }

            base.OnChildDeleted(efContainer);
        }
        internal override void Parse(ICollection <XName> unprocessedElements)
        {
            State = EFElementState.ParseAttempted;

            var path      = Uri.LocalPath;
            var lastdot   = path.LastIndexOf('.');
            var extension = Uri.LocalPath.Substring(lastdot, path.Length - lastdot);

            if (extension.EndsWith(ExtensionMsl, StringComparison.OrdinalIgnoreCase))
            {
                _mappingModel = new MappingModel(this, XDocument.Root);
            }
            else if (extension.EndsWith(ExtensionCsdl, StringComparison.OrdinalIgnoreCase))
            {
                _conceptualEntityModel = new ConceptualEntityModel(this, XDocument.Root);
            }
            else if (extension.EndsWith(ExtensionSsdl, StringComparison.OrdinalIgnoreCase))
            {
                _storageEntityModel = new StorageEntityModel(this, XDocument.Root);
            }
            else if (GetFileExtensions().Contains(extension))
            {
                if (_designerInfoRoot != null)
                {
                    _designerInfoRoot.Dispose();
                    _designerInfoRoot = null;
                }

                if (_storageEntityModel != null)
                {
                    _storageEntityModel.Dispose();
                    _storageEntityModel = null;
                }

                if (_mappingModel != null)
                {
                    _mappingModel.Dispose();
                    _mappingModel = null;
                }

                if (_conceptualEntityModel != null)
                {
                    _conceptualEntityModel.Dispose();
                    _conceptualEntityModel = null;
                }

                // convert the xlinq tree to our model
                foreach (var elem in XObject.Document.Elements())
                {
                    ParseSingleElement(unprocessedElements, elem);
                }
            }

            if (_designerInfoRoot != null)
            {
                _designerInfoRoot.Parse(unprocessedElements);
            }

            if (_conceptualEntityModel != null)
            {
                _conceptualEntityModel.Parse(unprocessedElements);
            }

            if (_storageEntityModel != null)
            {
                _storageEntityModel.Parse(unprocessedElements);
            }

            if (_mappingModel != null)
            {
                _mappingModel.Parse(unprocessedElements);
            }

            State = EFElementState.Parsed;
        }