Esempio n. 1
0
        private static void PerformTest()
        {
            var viewTree = new NodeView
            {
                Name     = "Root",
                Children = new List <NodeView>
                {
                    new NodeView
                    {
                        Children = new List <NodeView>
                        {
                            new NodeView()
                        }
                    }
                },
                IsLeaf = true
            };

            var checkResult = viewTree.CheckAsView();
            var logBuilder  = new StringBuilder();

            logBuilder.AppendLine();
            logBuilder.AppendLine($"IsCorrect: {checkResult.IsCorrect}");
            logBuilder.AppendLine(Separator);
            logBuilder.AppendLine("Message:");
            logBuilder.AppendLine(checkResult.ErrorDescription);

            var level = checkResult.IsCorrect ? LogLevel.Info : LogLevel.Warning;

            LogMessage(level, logBuilder.ToString());

            var apiErrorView = ApiErrorViewFactory.ForeignKeyError(typeof(List <string>), "jljfslkdf");

            using (var stringWriter = new StringWriter())
            {
                var settings = new XmlWriterSettings
                {
                    Indent = true,
                    NewLineOnAttributes = true
                };
                using (var xmlWriter = XmlWriter.Create(stringWriter, settings))
                {
                    var xmlSerializer = new XmlSerializer(apiErrorView.GetType());
                    xmlSerializer.Serialize(xmlWriter, apiErrorView);
                }
                LogMessage(LogLevel.Info, stringWriter.ToString());

                LogMessage(LogLevel.Info, EnumInfoProvider.GetEnumElementByName("1", typeof(SimpleEnum)).ToString());
                var str = EnumInfoProvider.GetElementName(FlagsEnum.Second | FlagsEnum.Third);
                LogMessage(LogLevel.Info, EnumInfoProvider.GetEnumElementByName <FlagsEnum>(str).ToString());
            }
        }