void HandleExporter(MapDataInfo aMapDataInfo, BaseExporter aBaseExporter) { if (aBaseExporter is GroundExporter) { GroundExporter typedExporter = (GroundExporter)aBaseExporter; aMapDataInfo.m_GroundDataInfo.Add(typedExporter.ToGroundDataInfo()); } else if (aBaseExporter is CameraLimitExporter) { CameraLimitExporter typedExporter = (CameraLimitExporter)aBaseExporter; aMapDataInfo.m_CameraLimitDataInfo.Add(typedExporter.ToCameraLimitDataInfo()); } else if (aBaseExporter is ColliderExporter) { ColliderExporter typedExporter = (ColliderExporter)aBaseExporter; aMapDataInfo.m_ColliderDataInfo.Add(typedExporter.ToColliderDataInfo()); } else if (aBaseExporter is SpawnPointExporter) { SpawnPointExporter typedExporter = (SpawnPointExporter)aBaseExporter; aMapDataInfo.m_SpawnPointDataInfo.Add(typedExporter.ToSpawnPointDataInfo()); } else if (aBaseExporter is TeleportExporter) { TeleportExporter typedExporter = (TeleportExporter)aBaseExporter; aMapDataInfo.m_TeleportDataInfo.Add(typedExporter.ToTeleportDataInfo()); } else { Debug.LogError("UnHandled Type of Exporter :: Name =" + aBaseExporter.name + " :: TypeOf =" + aBaseExporter.GetType()); } }
private void Export() { try { if (string.IsNullOrEmpty(SavePath)) { throw new Exception("Save path not defined."); } else if (string.IsNullOrEmpty(SelectedExporter)) { throw new Exception("No exporter selected."); } else if (SelectedBook == null) { throw new Exception("No book selected."); } if (File.Exists(SavePath) && !MessageBoxFactory.ShowConfirmAsBool("Overwrite existing file?", "File Exists")) { return; } BaseExporter exporter = GetExporter(); exporter.Export(SelectedBook, SavePath); MessageBoxFactory.ShowInfo("Book has been exported to: " + SavePath, "Book Exported"); } catch (Exception e) { MessageBoxFactory.ShowError(e); } }
public LogRecordTest() { this.exporter = new InMemoryExporter <LogRecord>(this.exportedItems); this.processor = new TestLogRecordProcessor(this.exporter); #if NETCOREAPP2_1 var serviceCollection = new ServiceCollection().AddLogging(builder => #else this.loggerFactory = LoggerFactory.Create(builder => #endif { builder.AddOpenTelemetry(options => { this.options = options; options .AddProcessor(this.processor); }); builder.AddFilter(typeof(LogRecordTest).FullName, LogLevel.Trace); }); #if NETCOREAPP2_1 this.serviceProvider = serviceCollection.BuildServiceProvider(); this.logger = this.serviceProvider.GetRequiredService <ILogger <LogRecordTest> >(); #else this.logger = this.loggerFactory.CreateLogger <LogRecordTest>(); #endif }
public PeriodicExportingMetricReader( BaseExporter <Metric> exporter, int exportIntervalMilliseconds = DefaultExportIntervalMilliseconds, int exportTimeoutMilliseconds = DefaultExportTimeoutMilliseconds) : base(exporter) { if (exportIntervalMilliseconds <= 0) { throw new ArgumentOutOfRangeException(nameof(exportIntervalMilliseconds), exportIntervalMilliseconds, "exportIntervalMilliseconds should be greater than zero."); } if (exportTimeoutMilliseconds < 0) { throw new ArgumentOutOfRangeException(nameof(exportTimeoutMilliseconds), exportTimeoutMilliseconds, "exportTimeoutMilliseconds should be non-negative."); } if ((this.SupportedExportModes & ExportModes.Push) != ExportModes.Push) { throw new InvalidOperationException($"The '{nameof(exporter)}' does not support '{nameof(ExportModes)}.{nameof(ExportModes.Push)}'"); } this.exportIntervalMilliseconds = exportIntervalMilliseconds; this.exportTimeoutMilliseconds = exportTimeoutMilliseconds; this.exporterThread = new Thread(new ThreadStart(this.ExporterProc)) { IsBackground = true, Name = $"OpenTelemetry-{nameof(PeriodicExportingMetricReader)}-{exporter.GetType().Name}", }; this.exporterThread.Start(); }
public DelegatingTestExporter( BaseExporter <T> exporter, Action onExportAction = null) { this.exporter = exporter; this.onExportAction = onExportAction; }
/// <summary> /// 导出页签 /// </summary> /// <param name="type">导出器类型</param> /// <param name="path">导出路径</param> /// <param name="createLogo">导出标记</param> public void Export(Type type, string path, string createLogo) { BaseExporter exporter = GetExporter(type); if (exporter.IsContainsLogo(createLogo)) { exporter.ExportFile(path, createLogo); } }
/// <summary> /// 获取导出器 /// </summary> public BaseExporter GetExporter(Type type) { for (int i = 0; i < _exporters.Count; i++) { BaseExporter exporter = _exporters[i]; if (exporter.GetType() == type) { return(exporter); } } throw new Exception($"Should never get here. {type}"); }
public PushMetricProcessor(BaseExporter <MetricItem> exporter, int exportIntervalMs, bool isDelta) : base(exporter) { this.exportIntervalMs = exportIntervalMs; this.token = new CancellationTokenSource(); this.exportTask = new Task(() => { while (!this.token.IsCancellationRequested) { Task.Delay(this.exportIntervalMs).Wait(); this.Export(isDelta); } }); this.exportTask.Start(); }
public LogRecordTest() { this.exporter = new InMemoryExporter <LogRecord>(this.exportedItems); this.processor = new TestLogRecordProcessor(this.exporter); this.loggerFactory = LoggerFactory.Create(builder => { builder.AddOpenTelemetry(options => { this.options = options; options .AddProcessor(this.processor); }); builder.AddFilter(typeof(LogRecordTest).FullName, LogLevel.Trace); }); this.logger = this.loggerFactory.CreateLogger <LogRecordTest>(); }
public void FlushMetricExporterTest(ExportModes mode) { BaseExporter <Metric> exporter = null; switch (mode) { case ExportModes.Push: exporter = new PushOnlyMetricExporter(); break; case ExportModes.Pull: exporter = new PullOnlyMetricExporter(); break; case ExportModes.Pull | ExportModes.Push: exporter = new PushPullMetricExporter(); break; } var reader = new BaseExportingMetricReader(exporter); using var meterProvider = Sdk.CreateMeterProviderBuilder() .AddReader(reader) .Build(); switch (mode) { case ExportModes.Push: Assert.True(reader.Collect()); Assert.True(meterProvider.ForceFlush()); break; case ExportModes.Pull: Assert.False(reader.Collect()); Assert.False(meterProvider.ForceFlush()); Assert.True((exporter as IPullMetricExporter).Collect(-1)); break; case ExportModes.Pull | ExportModes.Push: Assert.True(reader.Collect()); Assert.True(meterProvider.ForceFlush()); break; } }
public BaseExportingMetricReader(BaseExporter <Metric> exporter) { Guard.Null(exporter, nameof(exporter)); this.exporter = exporter; var exportorType = exporter.GetType(); var attributes = exportorType.GetCustomAttributes(typeof(AggregationTemporalityAttribute), true); if (attributes.Length > 0) { var attr = (AggregationTemporalityAttribute)attributes[attributes.Length - 1]; this.PreferredAggregationTemporality = attr.Preferred; this.SupportedAggregationTemporality = attr.Supported; } attributes = exportorType.GetCustomAttributes(typeof(ExportModesAttribute), true); if (attributes.Length > 0) { var attr = (ExportModesAttribute)attributes[attributes.Length - 1]; this.supportedExportModes = attr.Supported; } if (exporter is IPullMetricExporter pullExporter) { if (this.supportedExportModes.HasFlag(ExportModes.Push)) { pullExporter.Collect = this.Collect; } else { pullExporter.Collect = (timeoutMilliseconds) => { using (PullMetricScope.Begin()) { return(this.Collect(timeoutMilliseconds)); } }; } } }
internal static PeriodicExportingMetricReader CreatePeriodicExportingMetricReader( BaseExporter <Metric> exporter, MetricReaderOptions options, int defaultExportIntervalMilliseconds, int defaultExportTimeoutMilliseconds) { var exportInterval = options.PeriodicExportingMetricReaderOptions?.ExportIntervalMilliseconds ?? defaultExportIntervalMilliseconds; var exportTimeout = options.PeriodicExportingMetricReaderOptions?.ExportTimeoutMilliseconds ?? defaultExportTimeoutMilliseconds; var metricReader = new PeriodicExportingMetricReader(exporter, exportInterval, exportTimeout) { TemporalityPreference = options.TemporalityPreference, }; return(metricReader); }
/// <summary> /// Initializes a new instance of the <see cref="BaseExportingMetricReader"/> class. /// </summary> /// <param name="exporter">Exporter instance to export Metrics to.</param> public BaseExportingMetricReader(BaseExporter <Metric> exporter) { Guard.ThrowIfNull(exporter); this.exporter = exporter; var exportorType = exporter.GetType(); var attributes = exportorType.GetCustomAttributes(typeof(ExportModesAttribute), true); if (attributes.Length > 0) { var attr = (ExportModesAttribute)attributes[attributes.Length - 1]; this.supportedExportModes = attr.Supported; } if (exporter is IPullMetricExporter pullExporter) { if (this.supportedExportModes.HasFlag(ExportModes.Push)) { pullExporter.Collect = this.Collect; } else { pullExporter.Collect = (timeoutMilliseconds) => { using (PullMetricScope.Begin()) { return(this.Collect(timeoutMilliseconds)); } }; } } this.exportCalledMessage = $"{nameof(BaseExportingMetricReader)} calling {this.Exporter}.{nameof(this.Exporter.Export)} method."; this.exportSucceededMessage = $"{this.Exporter}.{nameof(this.Exporter.Export)} succeeded."; this.exportFailedMessage = $"{this.Exporter}.{nameof(this.Exporter.Export)} failed."; }
public PeriodicExportingMetricReader( BaseExporter <Metric> exporter, int exportIntervalMilliseconds = DefaultExportIntervalMilliseconds, int exportTimeoutMilliseconds = DefaultExportTimeoutMilliseconds) : base(exporter) { Guard.ThrowIfOutOfRange(exportIntervalMilliseconds, nameof(exportIntervalMilliseconds), min: 1); Guard.ThrowIfOutOfRange(exportTimeoutMilliseconds, nameof(exportTimeoutMilliseconds), min: 0); if ((this.SupportedExportModes & ExportModes.Push) != ExportModes.Push) { throw new InvalidOperationException($"The '{nameof(exporter)}' does not support '{nameof(ExportModes)}.{nameof(ExportModes.Push)}'"); } this.exportIntervalMilliseconds = exportIntervalMilliseconds; this.exportTimeoutMilliseconds = exportTimeoutMilliseconds; this.exporterThread = new Thread(new ThreadStart(this.ExporterProc)) { IsBackground = true, Name = $"OpenTelemetry-{nameof(PeriodicExportingMetricReader)}-{exporter.GetType().Name}", }; this.exporterThread.Start(); }
protected MetricProcessor(BaseExporter <MetricItem> exporter) { this.exporter = exporter ?? throw new ArgumentNullException(nameof(exporter)); }
public DelegatingTestExporter(BaseExporter <T> exporter) { this.exporter = exporter; }
public TestExportProcessor(BaseExporter <T> exporter) : base(exporter) { }
public WebCrawlerSettings AddExporter(BaseExporter exporter) { exporters.Add(exporter); return(this); }
public PicVisitorDiecutOutput(string fileExt) { _exporter = ExporterSet.GetExporterFromExtension(fileExt); }
public TestActivityExportProcessor(BaseExporter <Activity> exporter) : base(exporter) { }
/// <summary> /// 加载页签 /// </summary> public void Load(IWorkbook workbook, ISheet sheet) { _workbook = workbook; _sheet = sheet; // 公式计算器 _evaluator = new XSSFFormulaEvaluator(_workbook); int firstRowNum = sheet.FirstRowNum; // 数据头一共三行 IRow row1 = sheet.GetRow(firstRowNum); //类型 IRow row2 = sheet.GetRow(++firstRowNum); //名称 IRow row3 = sheet.GetRow(++firstRowNum); //CBS // 检测策划备注行 while (true) { int checkRow = firstRowNum + 1; if (checkRow > sheet.LastRowNum) { break; } IRow row = sheet.GetRow(checkRow); if (IsNotesRow(row)) { ++firstRowNum; } else { break; } } // 组织头部数据 for (int cellNum = row1.FirstCellNum; cellNum < row1.LastCellNum; cellNum++) { ICell row1cell = row1.GetCell(cellNum); ICell row2cell = row2.GetCell(cellNum); ICell row3cell = row3.GetCell(cellNum); // 检测重复的列 string headName = GetCellValue(row1cell); bool isNotesRow = headName.Contains(ConstDefine.StrNotesRow); if (isNotesRow == false) { if (IsContainsHead(headName)) { throw new Exception($"检测到重复列 : {headName}"); } } // 创建Wrapper string type = GetCellValue(row1cell); string name = GetCellValue(row2cell); string logo = GetCellValue(row3cell); HeadWrapper wrapper = new HeadWrapper(cellNum, name, type, logo); Heads.Add(wrapper); } // 如果没有ID列 if (IsContainsHead(ConstDefine.StrHeadId) == false) { throw new Exception("表格必须设立一个 'id' 列."); } // 所有数据行 int tableBeginRowNum = ++firstRowNum; //Table初始行 for (int rowNum = tableBeginRowNum; rowNum <= sheet.LastRowNum; rowNum++) { IRow row = sheet.GetRow(rowNum); // 如果是结尾行 if (IsEndRow(row)) { break; } TableWrapper wrapper = new TableWrapper(rowNum, row); wrapper.CacheAllCellValue(this); Tables.Add(wrapper); } // 创建所有注册的导出器 for (int i = 0; i < ExportHandler.ExportTypes.Count; i++) { Type type = ExportHandler.ExportTypes[i]; BaseExporter exporter = (BaseExporter)Activator.CreateInstance(type, this); _exporters.Add(exporter); } }
static void Main(string[] args) { string inputFileName = string.Empty; string outputFileName = string.Empty; bool verbose = false; bool show_help = true; #region Do command line parsing var p = new OptionSet() { { "i|input=", "the {INPUT} file name to convert.", v => inputFileName = v }, { "o|output=", "the {OUTPUT} file name", v => outputFileName = v }, { "v|verbose", "increase debug message verbosity", v => verbose = v != null }, { "h|help", "syntax : DXF2Diecut --i input.dxf --o output.(cf2,ai)", v => show_help = v != null }, }; List <string> extra; try { extra = p.Parse(args); } catch (OptionException e) { Console.Write("DXF2Diecut: "); Console.WriteLine(e.Message); Console.WriteLine("Try `DXF2Diecut --help' for more information."); return; } #endregion // shows input commands if (verbose) { Console.WriteLine("Input : {0}", inputFileName); Console.WriteLine("Output : {0}", outputFileName); } // exit if no valid input file if (!File.Exists(inputFileName)) { Console.WriteLine("Input file {0} does not exists! Exiting...", inputFileName); return; } // check if output file already exist if (File.Exists(outputFileName)) { if (verbose) { Console.WriteLine("Output file {1} already exists! Deleting..."); } try { File.Delete(outputFileName); } catch (Exception /*ex*/) { Console.WriteLine("Failed to delete file {0}", outputFileName); return; } } try { // open dxf document DxfDocument dxf = DxfDocument.Load(inputFileName); if (null == dxf) { Console.WriteLine("Failed to load dxf document!"); return; } if (verbose) { Console.WriteLine("FILE VERSION: {0}", dxf.DrawingVariables.AcadVer); } // ### // ### find exporter BaseExporter exporter = ExporterSet.GetExporterFromExtension(Path.GetExtension(outputFileName)); if (null == exporter) { Console.WriteLine("Failed to find valid exporter for file {0}", outputFileName); return; } if (verbose) { Console.WriteLine("Now using exporter {0}", exporter.ToString()); } // ### // initialization exporter.Initialize(); // set authoring tool exporter.AuthoringTool = "DXF2Diecut"; // bounding box exporter.SetBoundingBox(0.0, 0.0, 100.0, 100.0); // create layers, pens (actually using layers) foreach (var o in dxf.Layers) { if (dxf.Layers.GetReferences(o).Count > 0) { exporter.CreateLayer(o.Name); ExpPen pen = exporter.CreatePen( string.Equals(o.Name, "20") ? ExpPen.ToolAttribute.LT_CREASING : ExpPen.ToolAttribute.LT_CUT , o.Name); } } // create blocks foreach (var o in dxf.Blocks) { netDxf.Blocks.Block b = o as netDxf.Blocks.Block; if (verbose) { Console.WriteLine(string.Format("Block: {0}, entities = {1}", b.Name, b.Entities.Count)); } } // lines foreach (netDxf.Entities.Line line in dxf.Lines) { ExpLayer layer = exporter.GetLayerByName(line.Layer.Name); ExpPen pen = exporter.GetPenByName(line.Layer.Name); exporter.AddSegment(exporter.GetBlockOrCreate("default"), layer, pen , line.StartPoint.X, line.StartPoint.Y , line.EndPoint.X, line.EndPoint.Y); } // arcs foreach (netDxf.Entities.Arc arc in dxf.Arcs) { ExpLayer layer = exporter.GetLayerByName(arc.Layer.Name); ExpPen pen = exporter.GetPenByName(arc.Layer.Name); exporter.AddArc(exporter.GetBlockOrCreate("default"), layer, pen , arc.Center.X, arc.Center.Y, arc.Radius , arc.StartAngle, arc.EndAngle); } // create at list one blockref if (null != exporter.GetBlock("default")) { exporter.CreateBlockRef(exporter.GetBlock("default")); } // saving if (verbose) { Console.WriteLine("Saving as {0}", outputFileName); } exporter.Save(outputFileName); // done! Console.WriteLine("Done!"); } catch (Exception ex) { Console.WriteLine(ex.ToString()); return; } }
public PullMetricProcessor(BaseExporter <MetricItem> exporter, bool isDelta) : base(exporter) { this.isDelta = isDelta; }