コード例 #1
0
ファイル: EDMXIO.cs プロジェクト: ootsby/SharpDevelop
        public static XElement ReadSection(XElement edmxElement, EDMXSection section)
        {
            if (section == EDMXSection.EDMX)
                return edmxElement;
            
            if (edmxElement == null)
                throw new ArgumentException("Input file is not a valid EDMX file.");

            if (section == EDMXSection.Designer || section == EDMXSection.DesignerViews)
            {
                XElement designerElement = edmxElement.Element(XName.Get("Designer", edmxNamespace.NamespaceName));

                if (designerElement == null)
                    return null;

                if (section == EDMXSection.Designer)
                    return designerElement;
                else
                {
                    XElement diagramsElement = designerElement.Element(XName.Get("Diagrams", edmxNamespace.NamespaceName));

                    if (diagramsElement == null)
                        throw new ArgumentException("Input file is not a valid EDMX file.");

                    return diagramsElement.Element(XName.Get("DesignerViews"));
                }
            }

            XElement runtimeElement = edmxElement.Element(XName.Get("Runtime", edmxNamespace.NamespaceName));

            if (runtimeElement == null)
                throw new ArgumentException("Input file is not a valid EDMX file.");

            if (section == EDMXSection.Runtime)
                return runtimeElement;

            switch (section)
            { 
                case EDMXSection.SSDL:
                    XElement storageModelsElement = runtimeElement.Element(XName.Get("StorageModels", edmxNamespace.NamespaceName));

                    if (storageModelsElement == null)
                        throw new ArgumentException("Input file is not a valid EDMX file.");

                    return storageModelsElement;
                case EDMXSection.CSDL:
                    XElement conceptualModelsElement = runtimeElement.Element(XName.Get("ConceptualModels", edmxNamespace.NamespaceName));

                    if (conceptualModelsElement == null)
                        throw new ArgumentException("Input file is not a valid EDMX file.");

                    return conceptualModelsElement;
                case EDMXSection.MSL:
                    XElement mappingsElement = runtimeElement.Element(XName.Get("Mappings", edmxNamespace.NamespaceName));

                    if (mappingsElement == null)
                        throw new ArgumentException("Input file is not a valid EDMX file.");

                    return mappingsElement;
            }

            return null;
        }
コード例 #2
0
        public static XElement ReadSection(XElement edmxElement, EDMXSection section)
        {
            if (section == EDMXSection.EDMX)
            {
                return(edmxElement);
            }

            if (edmxElement == null)
            {
                throw new ArgumentException("Input file is not a valid EDMX file.");
            }

            if (section == EDMXSection.Designer || section == EDMXSection.DesignerViews)
            {
                XElement designerElement = edmxElement.Element(XName.Get("Designer", edmxNamespace.NamespaceName));

                if (designerElement == null)
                {
                    return(null);
                }

                if (section == EDMXSection.Designer)
                {
                    return(designerElement);
                }
                else
                {
                    XElement diagramsElement = designerElement.Element(XName.Get("Diagrams", edmxNamespace.NamespaceName));

                    if (diagramsElement == null)
                    {
                        throw new ArgumentException("Input file is not a valid EDMX file.");
                    }

                    return(diagramsElement.Element(XName.Get("DesignerViews")));
                }
            }

            XElement runtimeElement = edmxElement.Element(XName.Get("Runtime", edmxNamespace.NamespaceName));

            if (runtimeElement == null)
            {
                throw new ArgumentException("Input file is not a valid EDMX file.");
            }

            if (section == EDMXSection.Runtime)
            {
                return(runtimeElement);
            }

            switch (section)
            {
            case EDMXSection.SSDL:
                XElement storageModelsElement = runtimeElement.Element(XName.Get("StorageModels", edmxNamespace.NamespaceName));

                if (storageModelsElement == null)
                {
                    throw new ArgumentException("Input file is not a valid EDMX file.");
                }

                return(storageModelsElement);

            case EDMXSection.CSDL:
                XElement conceptualModelsElement = runtimeElement.Element(XName.Get("ConceptualModels", edmxNamespace.NamespaceName));

                if (conceptualModelsElement == null)
                {
                    throw new ArgumentException("Input file is not a valid EDMX file.");
                }

                return(conceptualModelsElement);

            case EDMXSection.MSL:
                XElement mappingsElement = runtimeElement.Element(XName.Get("Mappings", edmxNamespace.NamespaceName));

                if (mappingsElement == null)
                {
                    throw new ArgumentException("Input file is not a valid EDMX file.");
                }

                return(mappingsElement);
            }

            return(null);
        }
コード例 #3
0
ファイル: EDMXIO.cs プロジェクト: ootsby/SharpDevelop
 public static XElement ReadSection(XDocument edmxDocument, EDMXSection section)
 {
     return ReadSection(edmxDocument.Root, section);
 }
コード例 #4
0
 public static XElement ReadSection(XDocument edmxDocument, EDMXSection section)
 {
     return(ReadSection(edmxDocument.Root, section));
 }