本文整理汇总了C#中IEdmModel.TryWriteCsdl方法的典型用法代码示例。如果您正苦于以下问题:C# IEdmModel.TryWriteCsdl方法的具体用法?C# IEdmModel.TryWriteCsdl怎么用?C# IEdmModel.TryWriteCsdl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IEdmModel
的用法示例。
在下文中一共展示了IEdmModel.TryWriteCsdl方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteModelToCsdl
private static string WriteModelToCsdl(IEdmModel model)
{
var stringBuilder = new StringBuilder();
using (var writer = XmlWriter.Create(stringBuilder))
{
IEnumerable<EdmError> errors;
if (!model.TryWriteCsdl(writer, out errors))
{
return null;
}
}
return stringBuilder.ToString();
}
示例2: GetSerializerResult
protected IEnumerable<string> GetSerializerResult(IEdmModel edmModel, EdmVersion edmVersion, out IEnumerable<EdmError> errors)
{
// TODO: figure out the best way for multiple schemas
List<StringBuilder> stringBuilders = new List<StringBuilder>();
List<XmlWriter> xmlWriters = new List<XmlWriter>();
edmModel.SetEdmVersion(this.toProductVersionlookup[edmVersion]);
edmModel.TryWriteCsdl(
s =>
{
stringBuilders.Add(new StringBuilder());
xmlWriters.Add(XmlWriter.Create(stringBuilders.Last()));
return xmlWriters.Last();
}, out errors);
for (int i = 0; i < stringBuilders.Count; i++)
{
xmlWriters[i].Close();
}
List<string> strings = new List<string>();
foreach (var sb in stringBuilders)
{
strings.Add(sb.ToString());
}
return strings;
}
示例3: SerializeModel
private string SerializeModel(IEdmModel model)
{
IEnumerable<EdmError> errors;
StringWriter sw = new StringWriter();
XmlWriterSettings settings = new XmlWriterSettings();
settings.Indent = true;
settings.Encoding = System.Text.Encoding.UTF8;
XmlWriter xw = XmlWriter.Create(sw, settings);
model.TryWriteCsdl(xw, out errors);
xw.Flush();
xw.Close();
return sw.ToString();
}
示例4: SerializeModelToCsdls
private IEnumerable<XElement> SerializeModelToCsdls(IEdmModel model)
{
List<StringBuilder> stringBuilders = new List<StringBuilder>();
List<XmlWriter> xmlWriters = new List<XmlWriter>();
IEnumerable<EdmError> errors;
model.TryWriteCsdl(
s =>
{
stringBuilders.Add(new StringBuilder());
xmlWriters.Add(XmlWriter.Create(stringBuilders.Last()));
return xmlWriters.Last();
}, out errors);
Assert.IsFalse(errors.Any(), "Error occurs while serializing model to csdl");
for (int i = 0; i < stringBuilders.Count; i++)
{
xmlWriters[i].Close();
}
var csdls = stringBuilders.Select(stringBuilder => stringBuilder.ToString()).Select(XElement.Parse);
return csdls;
}