Beispiel #1
0
        private EdmxReader(XmlReader reader)
        {
            this.reader = reader;
            this.errors = new List<EdmError>();
            this.csdlParser = new CsdlParser();

            // Setup the edmx parser.
            this.edmxParserLookup = new Dictionary<string, Action>
            {
                { CsdlConstants.Element_DataServices, this.ParseDataServicesElement },
                { CsdlConstants.Element_Runtime, this.ParseRuntimeElement }
            };
            this.dataServicesParserLookup = new Dictionary<string, Action>
            {
                { CsdlConstants.Element_Schema, this.ParseCsdlSchemaElement }
            };
            this.runtimeParserLookup = new Dictionary<string, Action>
            {
                { CsdlConstants.Element_ConceptualModels, this.ParseConceptualModelsElement }
            };
            this.conceptualModelsParserLookup = new Dictionary<string, Action>
            {
                { CsdlConstants.Element_Schema, this.ParseCsdlSchemaElement }
            };
        }
Beispiel #2
0
        public static bool TryParse(IEnumerable <XmlReader> csdlReaders, out CsdlModel entityModel, out IEnumerable <EdmError> errors)
        {
            EdmUtil.CheckArgumentNull(csdlReaders, "csdlReaders");
            CsdlParser parser      = new CsdlParser();
            int        readerCount = 0;

            foreach (var inputReader in csdlReaders)
            {
                if (inputReader != null)
                {
                    try
                    {
                        parser.AddReader(inputReader);
                    }
                    catch (XmlException e)
                    {
                        entityModel = null;
                        errors      = new EdmError[] { new EdmError(new CsdlLocation(e.LineNumber, e.LinePosition), EdmErrorCode.XmlError, e.Message) };

                        return(false);
                    }
                }
                else
                {
                    entityModel = null;
                    errors      = new EdmError[] { new EdmError(null, EdmErrorCode.NullXmlReader, Edm.Strings.CsdlParser_NullXmlReader) };

                    return(false);
                }

                readerCount++;
            }

            if (readerCount == 0)
            {
                entityModel = null;
                errors      = new EdmError[] { new EdmError(null, EdmErrorCode.NoReadersProvided, Edm.Strings.CsdlParser_NoReadersProvided) };

                return(false);
            }

            bool success = parser.GetResult(out entityModel, out errors);

            if (!success)
            {
                entityModel = null;
            }

            return(success);
        }
Beispiel #3
0
        public static bool TryParse(IEnumerable<XmlReader> csdlReaders, out CsdlModel entityModel, out IEnumerable<EdmError> errors)
        {
            EdmUtil.CheckArgumentNull(csdlReaders, "csdlReaders");
            CsdlParser parser = new CsdlParser();
            int readerCount = 0;
            foreach (var inputReader in csdlReaders)
            {
                if (inputReader != null)
                {
                    try
                    {
                        parser.AddReader(inputReader);
                    }
                    catch (XmlException e)
                    {
                        entityModel = null;
                        errors = new EdmError[] { new EdmError(new CsdlLocation(e.LineNumber, e.LinePosition), EdmErrorCode.XmlError, e.Message) };

                        return false;
                    }
                }
                else
                {
                    entityModel = null;
                    errors = new EdmError[] { new EdmError(null, EdmErrorCode.NullXmlReader, Edm.Strings.CsdlParser_NullXmlReader) };

                    return false;
                }

                readerCount++;
            }

            if (readerCount == 0)
            {
                entityModel = null;
                errors = new EdmError[] { new EdmError(null, EdmErrorCode.NoReadersProvided, Edm.Strings.CsdlParser_NoReadersProvided) };

                return false;
            }

            bool success = parser.GetResult(out entityModel, out errors);
            if (!success)
            {
                entityModel = null;
            }

            return success;
        }
Beispiel #4
0
		private EdmxReader(XmlReader reader)
		{
			this.reader = reader;
			this.errors = new List<EdmError>();
			this.csdlParser = new CsdlParser();
			Dictionary<string, Action> strs = new Dictionary<string, Action>();
			strs.Add("DataServices", new Action(this.ParseDataServicesElement));
			strs.Add("Runtime", new Action(this.ParseRuntimeElement));
			this.edmxParserLookup = strs;
			Dictionary<string, Action> strs1 = new Dictionary<string, Action>();
			strs1.Add("Schema", new Action(this.ParseCsdlSchemaElement));
			this.dataServicesParserLookup = strs1;
			Dictionary<string, Action> strs2 = new Dictionary<string, Action>();
			strs2.Add("ConceptualModels", new Action(this.ParseConceptualModelsElement));
			this.runtimeParserLookup = strs2;
			Dictionary<string, Action> strs3 = new Dictionary<string, Action>();
			strs3.Add("Schema", new Action(this.ParseCsdlSchemaElement));
			this.conceptualModelsParserLookup = strs3;
		}
Beispiel #5
0
        public bool AddReader(XmlReader csdlReader)
        {
            string baseURI = csdlReader.BaseURI;
            string empty   = baseURI;

            if (baseURI == null)
            {
                empty = string.Empty;
            }
            string             str = empty;
            CsdlDocumentParser csdlDocumentParser = new CsdlDocumentParser(str, csdlReader);

            csdlDocumentParser.ParseDocumentElement();
            CsdlParser hasErrors = this;

            hasErrors.success = hasErrors.success & !csdlDocumentParser.HasErrors;
            this.errorsList.AddRange(csdlDocumentParser.Errors);
            if (csdlDocumentParser.Result != null)
            {
                this.result.AddSchema(csdlDocumentParser.Result.Value);
            }
            return(this.success);
        }
Beispiel #6
0
        public static bool TryParse(IEnumerable <XmlReader> csdlReaders, out CsdlModel entityModel, out IEnumerable <EdmError> errors)
        {
            bool flag;

            EdmUtil.CheckArgumentNull <IEnumerable <XmlReader> >(csdlReaders, "csdlReaders");
            CsdlParser csdlParser = new CsdlParser();
            int        num        = 0;
            IEnumerator <XmlReader> enumerator = csdlReaders.GetEnumerator();

            using (enumerator)
            {
                while (enumerator.MoveNext())
                {
                    XmlReader current = enumerator.Current;
                    if (current == null)
                    {
                        entityModel = null;
                        EdmError[] edmError = new EdmError[1];
                        edmError[0] = new EdmError(null, EdmErrorCode.NullXmlReader, Strings.CsdlParser_NullXmlReader);
                        errors      = edmError;
                        flag        = false;
                        return(flag);
                    }
                    else
                    {
                        try
                        {
                            csdlParser.AddReader(current);
                        }
                        catch (XmlException xmlException1)
                        {
                            XmlException xmlException = xmlException1;
                            entityModel = null;
                            EdmError[] edmErrorArray = new EdmError[1];
                            edmErrorArray[0] = new EdmError(new CsdlLocation(xmlException.LineNumber, xmlException.LinePosition), EdmErrorCode.XmlError, xmlException.Message);
                            errors           = edmErrorArray;
                            flag             = false;
                            return(flag);
                        }
                        num++;
                    }
                }
                goto Label0;
            }
            return(flag);

Label0:
            if (num != 0)
            {
                bool result = csdlParser.GetResult(out entityModel, out errors);
                if (!result)
                {
                    entityModel = null;
                }
                return(result);
            }
            else
            {
                entityModel = null;
                EdmError[] edmError1 = new EdmError[1];
                edmError1[0] = new EdmError(null, EdmErrorCode.NoReadersProvided, Strings.CsdlParser_NoReadersProvided);
                errors       = edmError1;
                return(false);
            }
        }
Beispiel #7
0
		public static bool TryParse(IEnumerable<XmlReader> csdlReaders, out CsdlModel entityModel, out IEnumerable<EdmError> errors)
		{
			bool flag;
			EdmUtil.CheckArgumentNull<IEnumerable<XmlReader>>(csdlReaders, "csdlReaders");
			CsdlParser csdlParser = new CsdlParser();
			int num = 0;
			IEnumerator<XmlReader> enumerator = csdlReaders.GetEnumerator();
			using (enumerator)
			{
				while (enumerator.MoveNext())
				{
					XmlReader current = enumerator.Current;
					if (current == null)
					{
						entityModel = null;
						EdmError[] edmError = new EdmError[1];
						edmError[0] = new EdmError(null, EdmErrorCode.NullXmlReader, Strings.CsdlParser_NullXmlReader);
						errors = edmError;
						flag = false;
						return flag;
					}
					else
					{
						try
						{
							csdlParser.AddReader(current);
						}
						catch (XmlException xmlException1)
						{
							XmlException xmlException = xmlException1;
							entityModel = null;
							EdmError[] edmErrorArray = new EdmError[1];
							edmErrorArray[0] = new EdmError(new CsdlLocation(xmlException.LineNumber, xmlException.LinePosition), EdmErrorCode.XmlError, xmlException.Message);
							errors = edmErrorArray;
							flag = false;
							return flag;
						}
						num++;
					}
				}
				goto Label0;
			}
			return flag;
		Label0:
			if (num != 0)
			{
				bool result = csdlParser.GetResult(out entityModel, out errors);
				if (!result)
				{
					entityModel = null;
				}
				return result;
			}
			else
			{
				entityModel = null;
				EdmError[] edmError1 = new EdmError[1];
				edmError1[0] = new EdmError(null, EdmErrorCode.NoReadersProvided, Strings.CsdlParser_NoReadersProvided);
				errors = edmError1;
				return false;
			}
		}