当前位置: 首页>>代码示例>>C#>>正文


C# IEdmModel.GetSerializationErrors方法代码示例

本文整理汇总了C#中IEdmModel.GetSerializationErrors方法的典型用法代码示例。如果您正苦于以下问题:C# IEdmModel.GetSerializationErrors方法的具体用法?C# IEdmModel.GetSerializationErrors怎么用?C# IEdmModel.GetSerializationErrors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IEdmModel的用法示例。


在下文中一共展示了IEdmModel.GetSerializationErrors方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TryWriteCsdl

        internal static bool TryWriteCsdl(IEdmModel model, Func<string, XmlWriter> writerProvider, bool singleFileExpected, out IEnumerable<EdmError> errors)
        {
            EdmUtil.CheckArgumentNull(model, "model");
            EdmUtil.CheckArgumentNull(writerProvider, "writerProvider");

            errors = model.GetSerializationErrors();
            if (errors.FirstOrDefault() != null)
            {
                return false;
            }

            IEnumerable<EdmSchema> schemas = new EdmModelSchemaSeparationSerializationVisitor(model).GetSchemas();
            if (schemas.Count() > 1 && singleFileExpected)
            {
                errors = new EdmError[] { new EdmError(new CsdlLocation(0, 0), EdmErrorCode.SingleFileExpected, Edm.Strings.Serializer_SingleFileExpected) };
                return false;
            }

            if (schemas.Count() == 0)
            {
                errors = new EdmError[] { new EdmError(new CsdlLocation(0, 0), EdmErrorCode.NoSchemasProduced, Edm.Strings.Serializer_NoSchemasProduced) };
                return false;
            }

            WriteSchemas(model, schemas, writerProvider);

            errors = Enumerable.Empty<EdmError>();
            return true;
        }
开发者ID:larsenjo,项目名称:odata.net,代码行数:29,代码来源:CsdlWriter.cs

示例2: TryWriteEdmx

        /// <summary>
        /// Outputs an EDMX artifact to the provided XmlWriter.
        /// </summary>
        /// <param name="model">Model to be written.</param>
        /// <param name="writer">XmlWriter the generated EDMX will be written to.</param>
        /// <param name="target">Target implementation of the EDMX being generated.</param>
        /// <param name="errors">Errors that prevented successful serialization, or no errors if serialization was successfull. </param>
        /// <returns>A value indicating whether serialization was successful.</returns>
        public static bool TryWriteEdmx(IEdmModel model, XmlWriter writer, EdmxTarget target, out IEnumerable<EdmError> errors)
        {
            EdmUtil.CheckArgumentNull(model, "model");
            EdmUtil.CheckArgumentNull(writer, "writer");

            errors = model.GetSerializationErrors();
            if (errors.FirstOrDefault() != null)
            {
                return false;
            }

            Version edmxVersion = model.GetEdmxVersion();

            if (edmxVersion != null)
            {
                if (!CsdlConstants.SupportedEdmxVersions.ContainsKey(edmxVersion))
                {
                    errors = new EdmError[] { new EdmError(new CsdlLocation(0, 0), EdmErrorCode.UnknownEdmxVersion, Edm.Strings.Serializer_UnknownEdmxVersion) };
                    return false;
                }
            }
            else if (!CsdlConstants.EdmToEdmxVersions.TryGetValue(model.GetEdmVersion() ?? EdmConstants.EdmVersionLatest, out edmxVersion))
            {
                errors = new EdmError[] { new EdmError(new CsdlLocation(0, 0), EdmErrorCode.UnknownEdmVersion, Edm.Strings.Serializer_UnknownEdmVersion) };
                return false;
            }

            IEnumerable<EdmSchema> schemas = new EdmModelSchemaSeparationSerializationVisitor(model).GetSchemas();

            EdmxWriter edmxWriter = new EdmxWriter(model, schemas, writer, edmxVersion, target);
            edmxWriter.WriteEdmx();

            errors = Enumerable.Empty<EdmError>();
            return true;
        }
开发者ID:rossjempson,项目名称:odata.net,代码行数:43,代码来源:EdmxWriter.cs

示例3: TryWriteEdmx

		public static bool TryWriteEdmx(IEdmModel model, XmlWriter writer, EdmxTarget target, out IEnumerable<EdmError> errors)
		{
			EdmUtil.CheckArgumentNull<IEdmModel>(model, "model");
			EdmUtil.CheckArgumentNull<XmlWriter>(writer, "writer");
			errors = model.GetSerializationErrors();
			if (errors.FirstOrDefault<EdmError>() == null)
			{
				Version edmxVersion = model.GetEdmxVersion();
				if (edmxVersion == null)
				{
					Dictionary<Version, Version> edmToEdmxVersions = CsdlConstants.EdmToEdmxVersions;
					Version edmVersion = model.GetEdmVersion();
					Version edmVersionLatest = edmVersion;
					if (edmVersion == null)
					{
						edmVersionLatest = EdmConstants.EdmVersionLatest;
					}
					if (!edmToEdmxVersions.TryGetValue(edmVersionLatest, out edmxVersion))
					{
						EdmError[] edmError = new EdmError[1];
						edmError[0] = new EdmError(new CsdlLocation(0, 0), EdmErrorCode.UnknownEdmVersion, Strings.Serializer_UnknownEdmVersion);
						errors = edmError;
						return false;
					}
				}
				else
				{
					if (!CsdlConstants.SupportedEdmxVersions.ContainsKey(edmxVersion))
					{
						EdmError[] edmErrorArray = new EdmError[1];
						edmErrorArray[0] = new EdmError(new CsdlLocation(0, 0), EdmErrorCode.UnknownEdmxVersion, Strings.Serializer_UnknownEdmxVersion);
						errors = edmErrorArray;
						return false;
					}
				}
				IEnumerable<EdmSchema> schemas = (new EdmModelSchemaSeparationSerializationVisitor(model)).GetSchemas();
				EdmxWriter edmxWriter = new EdmxWriter(model, schemas, writer, edmxVersion, target);
				edmxWriter.WriteEdmx();
				errors = Enumerable.Empty<EdmError>();
				return true;
			}
			else
			{
				return false;
			}
		}
开发者ID:nickchal,项目名称:pash,代码行数:46,代码来源:EdmxWriter.cs

示例4: TryWriteCsdl

		internal static bool TryWriteCsdl(IEdmModel model, Func<string, XmlWriter> writerProvider, bool singleFileExpected, out IEnumerable<EdmError> errors)
		{
			EdmUtil.CheckArgumentNull<IEdmModel>(model, "model");
			EdmUtil.CheckArgumentNull<Func<string, XmlWriter>>(writerProvider, "writerProvider");
			errors = model.GetSerializationErrors();
			if (errors.FirstOrDefault<EdmError>() == null)
			{
				IEnumerable<EdmSchema> schemas = (new EdmModelSchemaSeparationSerializationVisitor(model)).GetSchemas();
				if (schemas.Count<EdmSchema>() <= 1 || !singleFileExpected)
				{
					if (schemas.Count<EdmSchema>() != 0)
					{
						CsdlWriter.WriteSchemas(model, schemas, writerProvider);
						errors = Enumerable.Empty<EdmError>();
						return true;
					}
					else
					{
						EdmError[] edmError = new EdmError[1];
						edmError[0] = new EdmError(new CsdlLocation(0, 0), EdmErrorCode.NoSchemasProduced, Strings.Serializer_NoSchemasProduced);
						errors = edmError;
						return false;
					}
				}
				else
				{
					EdmError[] edmErrorArray = new EdmError[1];
					edmErrorArray[0] = new EdmError(new CsdlLocation(0, 0), EdmErrorCode.SingleFileExpected, Strings.Serializer_SingleFileExpected);
					errors = edmErrorArray;
					return false;
				}
			}
			else
			{
				return false;
			}
		}
开发者ID:nickchal,项目名称:pash,代码行数:37,代码来源:CsdlWriter.cs


注:本文中的IEdmModel.GetSerializationErrors方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。