コード例 #1
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);
        }
コード例 #2
0
ファイル: CsdlParser.cs プロジェクト: smasonuk/odata-sparql
        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;
        }
コード例 #3
0
ファイル: CsdlParser.cs プロジェクト: modulexcite/pash-1
        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);
            }
        }
コード例 #4
0
ファイル: CsdlParser.cs プロジェクト: nickchal/pash
		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;
			}
		}