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


C# IEdmModel.TryWriteCsdl方法代码示例

本文整理汇总了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();
 }
开发者ID:nickgoodrow,项目名称:ODataSamples,代码行数:13,代码来源:Program.cs

示例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;
        }
开发者ID:larsenjo,项目名称:odata.net,代码行数:27,代码来源:VocabularyDefinitionCsdlGenerator.cs

示例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();
        }
开发者ID:AlineGuan,项目名称:odata.net,代码行数:15,代码来源:ExtensionMethodsTests.cs

示例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;
        }
开发者ID:AlineGuan,项目名称:odata.net,代码行数:24,代码来源:TermAttributeTests.cs


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