public static void Main(string[] args) { IReader reader = new ConsoleReader(); ILayoutFactory layoutFactory = new LayoutFactory(); IAppenderFactory appenderFactory = new AppenderFactory(); ICommandInterpreter commandInterpreter = new CommandInterpreter(); ILoggerReport loggerReport = new LoggerReport(); var engine = new Engine(reader, layoutFactory, appenderFactory, commandInterpreter, loggerReport); engine.Run(); }
static void Main(string[] args) { List <IAppender> appenders = new List <IAppender>(); List <string> messages = new List <string>(); int appendersCount = int.Parse(Console.ReadLine()); for (int i = 0; i < appendersCount; i++) { var input = Console.ReadLine().Split(); var appenderType = input[0]; var layoutType = input[1]; var reportLevel = ReportLevel.INFO; try { Enum.TryParse(input[2], out reportLevel); } catch (Exception) {} var layout = LayoutFactory.InitializeLayout(layoutType); var appender = AppenderFactory.InitializeAppender(appenderType, layout, reportLevel); appenders.Add(appender); } while (true) { var message = Console.ReadLine(); if (message == "END") { foreach (var m in messages) { foreach (var appender in appenders) { var messageInfo = m.Split("|"); Enum.TryParse(messageInfo[0], out ReportLevel messageReportLevel); var messageDateTime = messageInfo[1]; var messageString = messageInfo[2]; appender.Append(messageDateTime, messageString, messageReportLevel); } } Console.WriteLine("Logger info"); foreach (var appender in appenders) { Console.WriteLine(appender.ToString()); } return; } messages.Add(message); } }
static void Main(string[] args) { IAppenderFactory appenderFactory = new AppenderFactory(); ILayoutFactory layoutFactory = new LayoutFactory(); //IReader reader = new ConsoleReader(); IReader reader = new FileReader(); IWriter writer = new ConsoleWriter(); //IWriter writer = new FileWriter(); IEngine engine = new Engine(appenderFactory, layoutFactory, reader, writer); engine.Run(); }
public IAppender Build() { var fileAppender = new RollingFileAppender(); fileAppender.RollingStyle = RollingFileAppender.RollingMode.Date; fileAppender.DatePattern = "'.'yyyyMMdd'.txt'"; fileAppender.File = File(); fileAppender.StaticLogFileName = false; fileAppender.Layout = LayoutFactory.Create(); fileAppender.ActivateOptions(); return(fileAppender); }
public EngineDependencies() { try { this.ErrorFactory = new ErrorFactory(); this.layoutFactory = new LayoutFactory(); this.appenderFactory = new AppenderFactory(this.layoutFactory); } catch (ArgumentException ae) { Console.WriteLine(ae.Message); } }
public static void Main() { IReader reader = new Reader(); IWriter writer = new Writer(); LayoutFactory layoutFactory = new LayoutFactory(); AppenderFactory appenderFactory = new AppenderFactory(); Controller controller = new Controller(layoutFactory, appenderFactory); Engine engine = new Engine(reader, writer, controller); engine.Run(); }
public static void Main() { var reader = new Reader(); var writer = new Writer(); var layoutFactory = new LayoutFactory(); var appenderFactory = new AppenderFactory(); var controller = new Controller(layoutFactory, appenderFactory); var engine = new Engine(reader, writer, controller); engine.Run(); }
public ShellViewModel(IShellView view) : base(view) { ObservableLayout = new Layout(); settingsHandler.GetLayoutOptions(); ProductParts = settingsHandler.GetProductPartList(); LayoutFactory layoutFactory = new LayoutFactory(); ProductPartName = ObservableLayout.ProductPartName; exitCommand = new DelegateCommand(Close); getLayoutCommand = new DelegateCommand(GetLayout); getOptionalsCommand = new DelegateCommand(GetOptionals); }
public static void Main(string[] args) { IList <IAppender> appenders = new List <IAppender>(); LayoutFactory layoutFactory = new LayoutFactory(); AppenderFactory appenderFactory = new AppenderFactory(layoutFactory); ErrorFactory errorFactory = new ErrorFactory(); Controller controller = new Controller(appenders, appenderFactory, errorFactory); controller.ReadAppendersFromConsole(); ILogger logger = new Logger(new List <IAppender>(controller.Appenders).ToArray()); controller.ExecuteCommands(logger); }
static void Main(string[] args) { LayoutFactory layoutFactory = new LayoutFactory(); AppenderFactory appenderFactory = new AppenderFactory(); int n = int.Parse(Console.ReadLine()); IReader reader = new ConsoleReader(); IWriter writer = new ConsoleWriter(); IPathManager pathManager = new PathManager("logs", "logs.txt"); IFile file = new LogFile(pathManager); ILogger logger = SetUpLogger(n, reader, writer, file, layoutFactory, appenderFactory); IEngine engine = new Engine(logger, reader, writer); engine.Run(); }
private void _002PageControlTest() { var viewModel = _userControlViewModel as PageControlViewModel; viewModel.Layout = LayoutFactory.CreateLayout(3, 3); var cells = CreateCells(); viewModel.ImageCells = cells; viewModel.TitleBarVisibility = Visibility.Visible; viewModel.TitleBarPosition = Dock.Bottom; viewModel.PageNO = 1; }
public virtual void AppendPage() { MakeLastPageBreak(); // TODO-Later: Layout of New Page is the same with LastPage // TODO-Later£º PageRepository use LayoutFactory.CreateDefaultLayout(), Depends on File system, not good to UT // TODO-Later: Make Project Model not Dependent on Project Adapters Add(PageModelFactory.CreatePageModel(LayoutFactory.CreateDefaultLayout())); var lastPageNO = Count - 1; FocusIndex = lastPageNO; PageChange(lastPageNO); }
public void Run() { int numOfAppenders = int.Parse(Console.ReadLine()); string appenderType = string.Empty; string layoutType = string.Empty; ReportLevel reportLevel = 0; var layoutFactory = new LayoutFactory(); var appenderFactory = new AppenderFactory(); var appenders = new List <IAppender>(); for (int i = 0; i < numOfAppenders; i++) { var lines = Console.ReadLine().Split(); appenderType = lines[0]; layoutType = lines[1]; if (lines.Length > 2) { reportLevel = Enum.Parse <ReportLevel>(lines[2]); } var layout = layoutFactory.Create(layoutType); var appender = appenderFactory.Create(appenderType, layout, reportLevel); appenders.Add(appender); reportLevel = 0; } string input = string.Empty; while ((input = Console.ReadLine()) != "END") { var messages = input.Split("|"); reportLevel = Enum.Parse <ReportLevel>(messages[0]); var date = DateTime.ParseExact(messages[1], "M/dd/yyyy h:mm:ss tt", CultureInfo.InvariantCulture); string message = messages[2]; var error = new Error(date, reportLevel, message); var logger = new Logger(appenders); logger.Log(error); } var logFile = new LogFile(); Console.WriteLine("Logger info"); logFile.Write(appenders); }
private void BuildLayout() { if (m_Words == null) { return; } using (CanvasDrawingSession ds = _DrawingCanvas.CreateDrawingSession()) { IGraphicEngine graphicEngine = new GdiGraphicEngine(ds, FontStyle, FontFamily, m_Palette, MinFontSize, MaxFontSize, m_MinWordWeight, m_MaxWordWeight); m_Layout = LayoutFactory.CrateLayout(m_LayoutType, new Size(this.ActualWidth, this.ActualHeight)); m_Layout.Arrange(m_Words, graphicEngine); } }
public void GetVerticalOffset_XAxisInverted_ContainerIsEmpty() { LayoutFactory factory = new LayoutFactory(); DocumentElement documentElement = new DocumentElement(); documentElement.Pages.Add(new PageElement() { Key = "MyFirstPage", Height = UnitConverter.GetPoints(297), Width = UnitConverter.GetPoints(210) }); Layout layout = factory.GetLayout(null, true, documentElement.Pages[0].Height, UnitConverter.GetPoints(10), UnitConverter.GetPoints(10), UnitConverter.GetPoints(200), UnitConverter.GetPoints(100)); Assert.AreEqual(841.89, layout.YPosition, 0.01); }
private void CreateAppender(string[] inputInfo) { string appenderType = inputInfo[1]; string layoutType = inputInfo[2]; ReportLevel reportLevel = ReportLevel.Info; if (inputInfo.Length > 2) { //reportLevel = Enum.Parse<ReportLevel>(inputInfo[3], true); } ILayout layout = LayoutFactory.CreateLayout(layoutType); IAppender appender = AppenderFactory.CreateAppender(appenderType, layout, reportLevel); appenders.Add(appender); }
private void SubGrid(object sender, EventArgs rArgs) { Button button = sender as Button; if (button == null) { return; } string imageDisplaySet = (string)button.Tag; if (imageDisplaySet == null || imageDisplaySet == "") { return; } if (imageDisplaySet == "CUSTOM") { int row = int.Parse(this.RowNumeric.Text); int col = int.Parse(this.ColumnNumeric.Text); if (row == 0 || col == 0) { return; } displayFormat = LayoutFactory.TileFactory(row, col); } else { displayFormat = ImageDisplayFormat.FromDicomString(imageDisplaySet); } if (this.fenge.Checked) { _component.SetTileGrid(displayFormat); if (printComponent != null) { printComponent.DicomPrinterConfigurationEditorComponent.ImageDisplayFormat = new PrinterImageDisplayFormat() { Value = displayFormat.DicomString };; } } else { _component.SubGrid(displayFormat); } }
private void Paint(IEnumerable <IWord> wordsToDraw, string saveImageLocation) { var layout = new LayoutFactory().CreateLayout(Size, LayoutType); var toDraw = wordsToDraw as IList <IWord> ?? wordsToDraw.ToList(); var minMax = CaclulateMinMaxWordWeights(toDraw); var bitmap = new Bitmap(Size.Width, Size.Height); bitmap.SetResolution(Convert.ToInt32(Size.Width / 6), Convert.ToInt32(Size.Height / 6)); var graphics = Graphics.FromImage(bitmap); graphics.Clear(GetRandomBackgroundColor()); var graphicEngine = new GdiGraphicEngine(graphics, FontFamily, FontStyle, ColorPalette, MinFontSize, MaxFontSize, minMax.Min, minMax.Max); layout.Arrange(toDraw, graphicEngine); SaveFile(bitmap, saveImageLocation); }
/// <summary> /// ロガーを初期化します。 /// </summary> static Log() { try { var thisAsm = Assembly.GetExecutingAssembly(); var entryAsm = Assembly.GetEntryAssembly(); // ロガーを作成する前に、必要なオブジェクトを // 読み込んでおきます。 TargetFactory.AddTargetsFromAssembly(thisAsm, ""); LayoutFactory.AddLayoutsFromAssembly(thisAsm, ""); LayoutRendererFactory.AddLayoutRenderersFromAssembly(thisAsm, ""); // 実行ファイルと同じパスからappname.exe.nlogやNLog.configを検索します。 var configFileNames = new string[] { Path.GetFileName(entryAsm.CodeBase) + ".nlog", "NLog.config", }; var basePath = Path.GetDirectoryName(entryAsm.Location); foreach (var configFile in configFileNames) { var filename = Path.Combine(basePath, configFile); if (!File.Exists(filename)) { continue; } LogManager.Configuration = new XmlLoggingConfiguration(filename); break; } logger = LogManager.GetCurrentClassLogger(); // 最後に未処理の例外ハンドラを追加します。 AppDomain.CurrentDomain.UnhandledException += UnhandledException; } catch { // どうしよう。。。 } }
public static void Main(string[] args) { //// //ILayout simpleLayout = new SimpleLayout(); //// //IAppender consoleAppender = //// //new FileAppender(simpleLayout); //// //ILogger logger = new Logger(consoleAppender); //// //logger.Error("3/26/2015 2:08:11 PM", "Error parsing JSON."); //// //logger.Info("3/26/2015 2:08:11 PM", "User Pesho successfully registered."); //// var layout = new XmlLayout(); ////// var simpleLayout = new SimpleLayout(); //// var consoleAppender = new ConsoleAppender(layout); //// var file = new LogFile(); //// var fileAppender = new FileAppender(layout, file); //// var logger = new Logger(consoleAppender, fileAppender); //// //logger.Error("3/26/2015 2:08:11 PM", "Error parsing JSON."); //// //logger.Info("3/26/2015 2:08:11 PM", "User Pesho successfully registered."); //// logger.Fatal("3/31/2015 5:23:54 PM", "mscorlib.dll does not respond"); ////logger.Critical("3/31/2015 5:23:54 PM", "No connection string found in App.config"); //var simpleLayout = new JsonLayout(); //var consoleAppender = new ConsoleAppender(simpleLayout); //consoleAppender.ReportLevel = ReportLevel.Error; //var logger = new Logger(consoleAppender); //logger.Info("3/31/2015 5:33:07 PM", "Everything seems fine"); //logger.Warning("3/31/2015 5:33:07 PM", "Warning: ping is too high - disconnect imminent"); //logger.Error("3/31/2015 5:33:07 PM", "Error parsing request"); //logger.Critical("3/31/2015 5:33:07 PM", "No connection string found in App.config"); //logger.Fatal("3/31/2015 5:33:07 PM", "mscorlib.dll does not respond"); IAppenderFactory appenderFactory = new AppenderFactory(); ILayoutFactory layoutFactory = new LayoutFactory(); IReader reader = new FileReader(); IEngine engine = new Engine(appenderFactory, layoutFactory, reader); engine.Run(); }
public IAppender ReadAppender() { var appenderParts = Console.ReadLine().Split(" "); var type = appenderParts[0]; var layoutFactory = new LayoutFactory(); var layout = layoutFactory.CreateLayout(appenderParts[1]); var treshold = ReportLevel.INFO; if (appenderParts.Length == 3) { treshold = (ReportLevel)Enum.Parse(typeof(ReportLevel), appenderParts[2]); } var appenderFactory = new AppenderFactory(); return(appenderFactory.CreateAppender(type, layout, treshold)); }
static void Main(string[] args) { int n = int.Parse(Console.ReadLine()); LayoutFactory layoutFactory = new LayoutFactory(); AppenderFactory appenderFactory = new AppenderFactory(); IReader reader = new ConsoleReader(); IWriter writer = new ConsoleWriter(); IPathManager pathManager = new PathManager("logs", "logs.txt"); IFile file = new LogFile(pathManager); ILogger logger = SetUpLogger(n, writer, reader, file, layoutFactory, appenderFactory); IEngine engine = new Engine(logger, reader, writer); engine.Run(); //logger.Error("3/26/2015 2:08:11 PM", "Error parsing JSON."); //logger.Info("3/26/2015 2:08:11 PM", "User Pesho successfully registered."); }
public TablePlugin(WordprocessingDocument wpDoc) { var styles = wpDoc.MainDocumentPart?.StyleDefinitionsPart?.Styles ?? new Styles(); var stylesCollector = new StyleCollector { Styles = styles }; var layoutFactory = new LayoutFactory { StyleCollector = stylesCollector }; var gridOptimizer = new GridOptimizer(); GridStateFactory = new GridStateFactory { StyleCollector = stylesCollector, LayoutFactory = layoutFactory, GridOptimizer = gridOptimizer }; }
private static ILogger SetUpLogger(int appendersCnt, IReader reader, IWriter writer, IFile file, LayoutFactory layoutFactory, AppenderFactory appenderFactory) { ICollection <IAppender> appenders = new HashSet <IAppender>(); for (int i = 0; i < appendersCnt; i++) { string[] appendersArgs = reader.ReadLine() .Split(' ', StringSplitOptions.RemoveEmptyEntries) .ToArray(); string appenderType = appendersArgs[0]; string layoutType = appendersArgs[1]; bool hasError = false; Level level = ParseLevel(appendersArgs, writer, ref hasError); if (hasError) { continue; } try { ILayout layout = layoutFactory.CreateLayout(layoutType); IAppender appender = appenderFactory.CreateAppender( appenderType, layout, level, file); appenders.Add(appender); } catch (InvalidOperationException ioe) { Console.WriteLine(ioe.Message); } } ILogger logger = new Logger(appenders); return(logger); }
static ILogger InitializeLogger() { ICollection <IAppender> appenders = new List <IAppender>(); LayoutFactory layoutFactory = new LayoutFactory(); AppenderFactory appenderFactory = new AppenderFactory(layoutFactory); int n = int.Parse(Console.ReadLine()); for (int count = 0; count < n; count++) { List <string> args = Console.ReadLine() .Split(' ', StringSplitOptions.RemoveEmptyEntries) .ToList(); IAppender appender = appenderFactory.CreateAppender(args); appenders.Add(appender); } ILogger logger = new Logger(appenders.ToArray()); return(logger); }
public static bool SetLayoutFromElement(object o, XmlElement el, NameValueCollection variables) { string name = el.LocalName; if (!IsLayoutProperty(o.GetType(), name)) { return(false); } PropertyInfo targetPropertyInfo = o.GetType().GetProperty(name, BindingFlags.Public | BindingFlags.Instance | BindingFlags.FlattenHierarchy | BindingFlags.IgnoreCase); if (targetPropertyInfo != null && typeof(ILayout).IsAssignableFrom(targetPropertyInfo.PropertyType)) { ILayout layout = LayoutFactory.CreateLayout(GetCaseInsensitiveAttribute(el, "type", variables)); ConfigureObjectFromAttributes(layout, el.Attributes, variables, true); ConfigureObjectFromElement(layout, el, variables); targetPropertyInfo.SetValue(o, layout, null); return(true); } if (name == "layout" && (o is TargetWithLayout)) { if (HasCaseInsensitiveAttribute(el, "type")) { ILayout layout = LayoutFactory.CreateLayout(GetCaseInsensitiveAttribute(el, "type", variables)); ConfigureObjectFromAttributes(layout, el.Attributes, variables, true); ConfigureObjectFromElement(layout, el, variables); ((TargetWithLayout)o).CompiledLayout = layout; } else { ((TargetWithLayout)o).Layout = el.InnerText; } return(true); } return(false); }
private void ProviderDataBind(HtmlTable tblProviders, object item, Dictionary <ItemCollectionAttribute, PropertyInfo> properties, bool showCheckers) { List <HtmlTableCell> rowCells = new List <HtmlTableCell>(); foreach (var attr in properties.Keys) { object obj = properties[attr].GetValue(item, null); if (obj == null) { continue; } object value = obj; if (obj is string) { value = HttpContext.Current.Server.HtmlEncode(obj.ToString()); } if (attr.IsId) { if (showCheckers) { // Checkbox for every item, presented in the table rowCells.Add(CheckItemCell(value.ToString())); } } else { LayoutFactory.DrawContent(value, attr, rowCells); } } HtmlTableRow tblRow = new HtmlTableRow(); rowCells.ForEach(cell => tblRow.Cells.Add(cell)); tblProviders.Rows.Add(tblRow); }
private void ReadAppendersInfo() { int appendersCount = int.Parse(ConsoleReader.ReadLine()); this.appenders = new IAppender[appendersCount]; for (int i = 0; i < appendersCount; i++) { string[] appenderInfo = ConsoleReader.ReadLine().Split(); string appenderType = appenderInfo[0]; string layoutType = appenderInfo[1]; ILayout layout = LayoutFactory.CreateLayout(layoutType); IAppender appender = AppenderFactory.CreateAppender(appenderType, layout); if (appenderInfo.Length > 2) { string reportLevel = this.ConvertStringToTitleCase(appenderInfo[2]); appender.ReportLevel = (ReportLevel)Enum.Parse(typeof(ReportLevel), reportLevel); } this.appenders[i] = appender; } }
static ILogger InitializeLogger() { ICollection <IAppender> appenders = new List <IAppender>(); LayoutFactory layoutFactory = new LayoutFactory(); AppenderFactory appenderFactory = new AppenderFactory(layoutFactory); var appenderCount = int.Parse(Console.ReadLine()); for (int i = 0; i < appenderCount; i++) { string[] args = Console.ReadLine().Split(); var appenderType = args[0]; var layoutType = args[1]; var errorLevel = args.Length > 2 ? args[2] : "INFO"; IAppender appender = appenderFactory.CreateAppender(appenderType, errorLevel, layoutType); appenders.Add(appender); } ILogger logger = new Logger(appenders); return(logger); }
public void CreateAppender(string input) { string[] appenderInfo = input.Split(" ", StringSplitOptions.RemoveEmptyEntries); string appenderType = appenderInfo[0]; string layoutType = appenderInfo[1]; ReportLevel reportLevel = ReportLevel.INFO; try { if (appenderInfo.Length == 3) { reportLevel = Enum.Parse <ReportLevel>(appenderInfo[2]); } ILayout layout = LayoutFactory.Create(layoutType); IAppender appender = AppenderFactory.Create(appenderType, layout); appender.ReportLevel = reportLevel; appenders.Add(appender); } catch (Exception argEx) { Console.WriteLine(argEx.Message); } }