Ejemplo n.º 1
0
		private bool TryParse(IEnumerable<IEdmModel> references, out IEdmModel model, out IEnumerable<EdmError> parsingErrors)
		{
			Version version = null;
			CsdlModel csdlModel = null;
			IEnumerable<EdmError> edmErrors = null;
			bool flag;
			try
			{
				this.ParseEdmxFile(out version);
				if (this.errors.Count != 0)
				{
					model = null;
				}
				else
				{
					if (!this.csdlParser.GetResult(out csdlModel, out edmErrors))
					{
						this.errors.AddRange(edmErrors);
						model = null;
					}
					else
					{
						model = new CsdlSemanticsModel(csdlModel, new CsdlSemanticsDirectValueAnnotationsManager(), references);
						model.SetEdmxVersion(version);
						if (this.dataServiceVersion != null)
						{
							model.SetDataServiceVersion(this.dataServiceVersion);
						}
						if (this.maxDataServiceVersion != null)
						{
							model.SetMaxDataServiceVersion(this.maxDataServiceVersion);
						}
					}
				}
				parsingErrors = this.errors;
				return this.errors.Count == 0;
			}
			catch (XmlException xmlException1)
			{
				XmlException xmlException = xmlException1;
				model = null;
				EdmError[] edmError = new EdmError[1];
				edmError[0] = new EdmError(new CsdlLocation(xmlException.LineNumber, xmlException.LinePosition), EdmErrorCode.XmlError, xmlException.Message);
				parsingErrors = edmError;
				flag = false;
			}
			return flag;
		}
Ejemplo n.º 2
0
        private bool TryParse(IEnumerable<IEdmModel> references, out IEdmModel model, out IEnumerable<EdmError> parsingErrors)
        {
            Version edmxVersion;
            try
            {
                this.ParseEdmxFile(out edmxVersion);
            }
            catch (XmlException e)
            {
                model = null;
                parsingErrors = new EdmError[] { new EdmError(new CsdlLocation(e.LineNumber, e.LinePosition), EdmErrorCode.XmlError, e.Message) };
                return false;
            }

            if (this.errors.Count == 0)
            {
                CsdlModel astModel;
                IEnumerable<EdmError> csdlErrors;
                if (this.csdlParser.GetResult(out astModel, out csdlErrors))
                {
                    model = new CsdlSemanticsModel(astModel, new CsdlSemanticsDirectValueAnnotationsManager(), references);
                    
                    Debug.Assert(edmxVersion != null, "edmxVersion != null");
                    model.SetEdmxVersion(edmxVersion);
                    
                    if (this.dataServiceVersion != null)
                    {
                        model.SetDataServiceVersion(this.dataServiceVersion);
                    }

                    if (this.maxDataServiceVersion != null)
                    {
                        model.SetMaxDataServiceVersion(this.maxDataServiceVersion);
                    }
                }
                else
                {
                    Debug.Assert(csdlErrors != null && csdlErrors.Count() > 0, "csdlErrors != null && csdlErrors.Count() > 0");
                    this.errors.AddRange(csdlErrors);
                    model = null;
                }
            }
            else
            {
                model = null;
            }

            parsingErrors = this.errors;
            return this.errors.Count == 0;
        }