public static ITaskInteraction Create( MSBuildFramework.IBuildEngine buildEngine, ITaskOutputHandler outputHandler, ITask task, IArgumentProvider arguments, ITypedServiceProvider services) { return new BuildTaskInteraction(task, arguments, outputHandler, buildEngine, services); }
private BuildTaskInteraction( ITask task, IArgumentProvider arguments, ITaskOutputHandler outputHandler, MSBuildFramework.IBuildEngine buildEngine, ITypedServiceProvider services) : base (arguments, services) { this.outputHandler = outputHandler; this.loggers = new Lazy<BuildTaskLoggers>(() => new BuildTaskLoggers(buildEngine, task, arguments)); }
public ConsoleTaskLoggers(ITask task, IArgumentProvider arguments) { if (arguments.GetOption<bool?>(StandardOptions.Clipboard) ?? task.GetOptionDefault<bool>(StandardOptions.Clipboard[0])) { this.richTextLogger = new RichTextLogger(); this.csvLogger = new CsvLogger(); this.textLogger = new TextLogger(); this.spreadsheetLogger = new XmlSpreadsheetLogger(); this.aggregatedLogger = new AggregatedLogger( ConsoleLogger.Instance, this.richTextLogger, this.spreadsheetLogger, this.csvLogger, this.textLogger); this.RegisterLogger(LoggerType.Result, this.aggregatedLogger); } else { this.RegisterLogger(LoggerType.Result, ConsoleLogger.Instance); } this.RegisterLogger(LoggerType.Status, ConsoleLogger.Instance); }
public static Expression[] VisitArguments(ExpressionVisitor visitor, IArgumentProvider nodes) { Expression[] newNodes = null; for (int i = 0, n = nodes.ArgumentCount; i < n; i++) { Expression curNode = nodes.GetArgument(i); Expression node = visitor.Visit(curNode); if (newNodes != null) { newNodes[i] = node; } else if (!object.ReferenceEquals(node, curNode)) { newNodes = new Expression[n]; for (int j = 0; j < i; j++) { newNodes[j] = nodes.GetArgument(j); } newNodes[i] = node; } } return newNodes; }
protected void Initialize(IArgumentProvider arguments) { string assembliesToResolve = arguments.GetOption<string>(StandardOptions.AssembliesToResolve); if (!String.IsNullOrEmpty(assembliesToResolve)) { foreach (string assemblyToResolve in assembliesToResolve.Split(';')) { this.AddAssemblyToResolve(assemblyToResolve); } } string resolutionPaths = arguments.GetOption<string>(StandardOptions.AssemblyResolutionPaths); if (!String.IsNullOrEmpty(resolutionPaths)) { foreach (string resolutionPath in resolutionPaths.Split(';')) { if (!String.IsNullOrWhiteSpace(resolutionPath)) { string expandedResolutionPath = Environment.ExpandEnvironmentVariables(resolutionPath); this.AddResolutionPath(expandedResolutionPath); } } } }
internal ArgumentPrepender(Expression first, IArgumentProvider provider) { _first = first; _expression = provider; }
public void DoWorkAsync(Action<Object> workAction, IArgumentProvider provider) { exitState = ExitState.NORMAL; CancellationToken token = tokenSource.Token; Task mainTask = Task.Factory.StartNew(() => { while (true) { if (token.IsCancellationRequested) break; try { Object[] args = provider.GetArguments(); if (args.Length == 0) break; List<Task> tasks = new List<Task>(); foreach (Object arg in args) { if (token.IsCancellationRequested) break; try { Task subtask = Task.Factory.StartNew(workAction, arg, token); subtask.ContinueWith(TaskFailed, TaskContinuationOptions.OnlyOnFaulted); tasks.Add(subtask); } catch { exitState = ExitState.ERROR; tokenSource.Cancel(); break; } } try { Task.WaitAll(tasks.ToArray(), tokenSource.Token); } catch (OperationCanceledException) { } } catch { exitState = ExitState.ERROR; break; } } }, TaskCreationOptions.LongRunning); mainTask.ContinueWith(Done, scheduler); }
public static AssemblyResolver Create(IArgumentProvider arguments) { AssemblyResolver resolver = new AssemblyResolver(); resolver.Initialize(arguments); return resolver; }
// assumes 'object' of non-static call is already on stack private void EmitMethodCall(MethodInfo mi, IArgumentProvider args, Type objectType) { EmitMethodCall(mi, args, objectType, CompilationFlags.EmitAsNoTail); }
/// <summary> /// Emits arguments to a call, and returns an array of write-backs that /// should happen after the call. /// </summary> private List<WriteBack> EmitArguments(MethodBase method, IArgumentProvider args) { return EmitArguments(method, args, 0); }
private void EmitMethodCall(Expression obj, MethodInfo method, IArgumentProvider methodCallExpr) { EmitMethodCall(obj, method, methodCallExpr, CompilationFlags.EmitAsNoTail); }
public BuildTaskLoggers(MSBuildFramework.IBuildEngine buildEngine, ITask task, IArgumentProvider arguments) { BuildLogger logger = new BuildLogger(buildEngine, task.GetType().ToString()); this.RegisterLogger(LoggerType.Result, logger); this.RegisterLogger(LoggerType.Status, logger); }
public int[] Filter(IArgumentProvider argProvider, Rectangle aoiRect, int[] aoi) { List <int> retAOI = new List <int>(aoi.Length); using (IRasterPixelsVisitor <UInt16> visitor = new RasterPixelsVisitor <UInt16>(argProvider)) { _width = argProvider.DataProvider.Width; //邻域内符合条件的像元个数 int preHitedPixelCount = 0; int preWndSize = 0; int[] bandNos = new int[] { _visBandNo, _nearIfrBandNo, _midIfrBandNo, _farIfrBandNo }; _visBandIdx = 0; _nearIfrBandIdx = 1; _midIfrBandIdx = 2; _farIfrBandIndex = 3; // bool isDoubtFir = false; // int[] hitedIndexes = new int[100 * 100]; //最大窗口100 visitor.VisitPixelWnd(bandNos, bandNos, _minWndSize, _maxWndSize, (pixelIdx, crtWndSize, bandValues, wndValues) => { if (pixelIdx == 219998) { pixelIdx = 219998; } isDoubtFir = false; //直接判定疑似火点 if (bandValues[_midIfrBandIdx] / _bandZoom > (_midInfraredValue_DoubtFir - _dltMidInfraredValue_DoubtFir) && ((bandValues[_midIfrBandIdx] - bandValues[_farIfrBandIndex]) / _bandZoom) > _midInfrared_farInfrared_DoubtFir) { isDoubtFir = true; retAOI.Add(pixelIdx); return(false); } // if (preWndSize != crtWndSize) { preHitedPixelCount = 0; preWndSize = crtWndSize; } preHitedPixelCount = GetHitedPixelCount(argProvider, pixelIdx, bandValues, wndValues, hitedIndexes); return(preHitedPixelCount < _maxHitedPixelCount); }, (pixelIdx, crtWndSize, bandValues, wndValues) => { if (isDoubtFir) { return; } if (preHitedPixelCount < _maxHTmpPixelCount_DoubtFir) { return; } else { float avgMidIfr = Avg(_midIfrBandIdx, wndValues, preHitedPixelCount, hitedIndexes); float avgMidFarIfr = DiffAvg(_midIfrBandIdx, _farIfrBandIndex, wndValues, preHitedPixelCount, hitedIndexes); bool isOK = preHitedPixelCount >= _maxHTmpPixelCount_DoubtFir && (bandValues[_midIfrBandIdx] / _bandZoom) > (avgMidIfr + _midInfraredAvg_DoubtFir) && ((bandValues[_midIfrBandIdx] - bandValues[_farIfrBandIndex]) / _bandZoom) > (avgMidFarIfr + _midInfraredAvg_DoubtFir) ; if (isOK) { retAOI.Add(pixelIdx); } } }); } return(retAOI.Count > 0 ? retAOI.ToArray() : null); }
/// <summary> /// 临时测试用获取文件填充 SelectedPrimaryFiles 属性 /// </summary> /// <param name="obj"></param> /// <param name="iArgumentProvider"></param> /// <returns></returns> public static bool SetSelectedPrimaryFiles(ISmartSession session, ref object obj, IArgumentProvider iArgumentProvider, string algorithmName) { IWorkspace wks = (session.MonitoringSession as IMonitoringSession).Workspace; if (wks == null) { return(false); } ICatalog catalog = wks.ActiveCatalog; if (catalog == null) { return(false); } string[] fnames = catalog.GetSelectedFiles(); if (fnames == null || fnames.Length == 0) { return(false); } obj = fnames; iArgumentProvider.SetArg("SelectedPrimaryFiles", fnames); iArgumentProvider.SetArg("AlgorithmName", algorithmName); return(true); }
public override ITaskService GetTaskService(ref IArgumentProvider argumentProvider) { throw new NotImplementedException(); }
public SnwDisplayInfo(IArgumentProvider argumentProvider) { _argumentProvider = argumentProvider; }
private string ComputeBackgroudImage(Action <int, string> processTracker) { List <string> computeFiles = new List <string>(); foreach (FileItem item in listBox1.Items) { computeFiles.Add(item.FileName); } if (computeFiles == null || computeFiles.Count < 1) { return(null); } foreach (string item in computeFiles) { if (!File.Exists(item)) { MessageBox.Show("所选择的数据:\"" + item + "\"不存在。"); return(null); } } IArgumentProvider argPrd = Tag as IArgumentProvider; if (argPrd == null) { return(null); } int visiNo = (int)argPrd.GetArg("Visible"); int midNo2 = (int)argPrd.GetArg("MiddleInfrared2"); int farNo1 = (int)argPrd.GetArg("FarInfrared11"); int farNo2 = (int)argPrd.GetArg("FarInfrared12"); int[] bandNos = new int[] { farNo1, farNo2, midNo2, visiNo }; List <RasterMaper> rms = new List <RasterMaper>(); try { for (int i = 0; i < computeFiles.Count; i++) { IRasterDataProvider inRaster = RasterDataDriver.Open(computeFiles[i]) as IRasterDataProvider; if (inRaster.BandCount < bandNos.Length) { MessageBox.Show("请选择正确的数据进行背景亮温计算。"); return(null); } RasterMaper rm = new RasterMaper(inRaster, bandNos); rms.Add(rm); } //输出文件准备(作为输入栅格并集处理) RasterIdentify ri = new RasterIdentify(_dataProvider.fileName); string outFileName = MifEnvironment.GetFullFileName(Path.GetFileName(ri.ToWksFullFileName(".ldf"))); using (IRasterDataProvider outRaster = CreateOutRaster(outFileName, bandNos.Length)) { //栅格数据映射 RasterMaper[] fileIns = rms.ToArray(); List <int> bandNoList = new List <int>(); for (int i = 1; i <= bandNos.Length; i++) { bandNoList.Add(i); } RasterMaper[] fileOuts = new RasterMaper[] { new RasterMaper(outRaster, bandNoList.ToArray()) }; //创建处理模型 RasterProcessModel <short, short> rfr = null; rfr = new RasterProcessModel <short, short>(null); rfr.SetRaster(fileIns, fileOuts); rfr.RegisterCalcModel(new RasterCalcHandler <short, short>((rvInVistor, rvOutVistor, aoi) => { for (int j = 0; j < rvInVistor.Length; j++) { for (int i = 0; i < bandNos.Length; i++) { short[] dt = rvInVistor[j].RasterBandsData[i]; if (dt != null) { for (int index = 0; index < dt.Length; index++) { if (dt[index] > rvOutVistor[0].RasterBandsData[i][index]) { rvOutVistor[0].RasterBandsData[i][index] = dt[index]; } } } } } })); //执行 rfr.Excute(); return(outFileName); } } finally { foreach (RasterMaper rm in rms) { rm.Raster.Dispose(); } } }
/// <summary> /// 夜间火背景计算 /// </summary> /// <param name="argProvider"></param> /// <param name="aoiRect"></param> /// <param name="aoi"></param> /// <returns></returns> public Dictionary <int, PixelFeature> ComputeNight(IArgumentProvider argProvider, Rectangle aoiRect, int[] aoi) { _width = argProvider.DataProvider.Width; _maxLat = argProvider.DataProvider.CoordEnvelope.MaxY; _res = argProvider.DataProvider.ResolutionY; _isNight = bool.Parse(argProvider.GetArg("IsNight").ToString()); CreateAndInitFeatures(aoi); int tempIndex = 0; using (IRasterPixelsVisitor <UInt16> visitor = new RasterPixelsVisitor <UInt16>(argProvider)) { //邻域内符合条件的像元个数 int preHitedPixelCount = 0; int preWndSize = 0; int[] bandNos = new int[] { _midIfrBandNo, _farIfrBandNo }; _midIfrBandIdx = 0; _farIfrBandIdx = 1; // int[] hitedIndexes = new int[100 * 100]; //最大窗口100 // //by chennan 20140423 处理当当前窗口被恢复成最小窗口时,将晴空像元个数、索引更改回最小窗口状态 int preHitedPixelCountSave = 0; List <int> hitedIndexesSave = new List <int>(); // visitor.VisitPixelWnd(aoiRect, aoi, bandNos, bandNos, _minWndSize, _maxWndSize, (pixelIdx, crtWndSize, bandValues, wndValues) => { if (preWndSize != crtWndSize) { preHitedPixelCount = 0; preWndSize = crtWndSize; } _cloudCount = 0; preHitedPixelCount = GetNightHitedPixelCount(pixelIdx, bandValues, wndValues, hitedIndexes); //by chennan 20140423 处理当当前窗口被恢复成最小窗口时,将晴空像元个数、索引更改回最小窗口状态 // if (crtWndSize == _minWndSize) { preHitedPixelCountSave = preHitedPixelCount; hitedIndexesSave.AddRange(hitedIndexes); } // return(preHitedPixelCount < _maxHitedPixelCount && crtWndSize < _maxWndSize); }, (pixelIdx, crtWndSize, bandValues, wndValues) => { if (preHitedPixelCount >= _maxHitedPixelCount) { //by chennan 20140423 处理当当前窗口被恢复成最小窗口时,将晴空像元个数、索引更改回最小窗口状态 // if (crtWndSize == _minWndSize) { preHitedPixelCount = preHitedPixelCountSave; hitedIndexes = hitedIndexesSave.ToArray(); } // Compute(preHitedPixelCount, pixelIdx, bandValues, wndValues, hitedIndexes); } else { int row = pixelIdx / _width; int col = pixelIdx % _width; int length = crtWndSize / 2; for (int i = row - length; i <= row + length; i++) { if (i < 0) { continue; } for (int j = col - length; j <= col + length; j++) { tempIndex = i * _width + j; if (_featrueIndex.Contains(tempIndex)) { _features[pixelIdx] = _features[tempIndex]; } } } } preHitedPixelCountSave = 0; hitedIndexesSave.Clear(); }); } return(_features); }
public static ITaskInteraction Create(ITask task, IArgumentProvider arguments, ITypedServiceProvider services) { return new ConsoleTaskInteraction(task, arguments, services); }
/// <summary> /// Returns files from the specified argument or empty array if none specified /// </summary> public static string[] GetExtensionsFromArgument(this IArgumentProvider arguments, params string[] optionAliases) { return(ArgumentProviderExtensions.SplitExtensions(arguments.GetOption <string>(optionAliases))); }
public static IExtractResult GetExtractResult(IArgumentProvider argProvider, Dictionary <int, PixelFeature> features, IPixelIndexMapper candidateFirPixels, IContextMessage contextMessage, Action <int, string> progressTracker) { if (features == null || features.Count == 0) { PrintInfo(contextMessage, "当前影像无火点信息!"); return(null); } IExtractResultArray array = new ExtractResultArray("火点判识"); if (progressTracker != null) { progressTracker.Invoke(75, "正在生成强度文件,请稍候..."); } //强度栅格文件 IFileExtractResult intensityFile = (new IntensityRasterGenerator()).Generate(argProvider, features); if (intensityFile != null) { array.Add(intensityFile); intensityFile.SetDispaly(false); intensityFile.SetOutIdentify("0FPG"); } //内存判识二值图 //array.Add(candidateFirPixels); if (progressTracker != null) { progressTracker.Invoke(80, "正在生成火区列表,请稍候..."); } //计算火区 using (FireAreaInfoListGenerator fireArea = new FireAreaInfoListGenerator()) { Dictionary <int, FireAreaFeature> fireAFeatures = fireArea.GetFireArea(argProvider, candidateFirPixels, features); IFileExtractResult fALTFile = fireArea.Generator(argProvider, fireAFeatures); //fireArea.ExportILSTToExcel(fALTFile.FileName); if (fALTFile != null) { array.Add(fALTFile); } //环保部信息列表 IFileExtractResult fALHFile = fireArea.GeneratorHB(argProvider, fireAFeatures); if (fALHFile != null) { array.Add(fALHFile); } //火情信息快报 IFileExtractResult fALKFile = fireArea.GeneratorKB(argProvider, fireAFeatures); if (fALKFile != null) { array.Add(fALKFile); } if (progressTracker != null) { progressTracker.Invoke(95, "正在生成火点列表,请稍候..."); } //火点信息列表 using (FirePixelInfoListGenerator p = new FirePixelInfoListGenerator()) { IFileExtractResult pLSTFile = p.Generator(argProvider, features); if (pLSTFile != null) { array.Add(pLSTFile); } //return array; } //环保部火点信息列表 using (FirePixelInfoListGenerator p = new FirePixelInfoListGenerator()) { IFileExtractResult pLSTFile = p.GeneratorHB(argProvider, features); if (pLSTFile != null) { array.Add(pLSTFile); } return(array); } } }
//CONFORMING private void EmitMethodCall(Expression obj, MethodInfo method, IArgumentProvider methodCallExpr) { // Emit instance, if calling an instance method Type objectType = null; if (!method.IsStatic) { EmitInstance(obj, objectType = obj.Type); } EmitMethodCall(method, methodCallExpr, objectType); }
protected TaskExecution(IArgumentProvider argumentProvider, ITaskRegistry taskRegistry, ITypedServiceProvider services) { this.ArgumentProvider = argumentProvider; this.taskRegistry = taskRegistry; this.Services = services; }
// assumes 'object' of non-static call is already on stack private void EmitMethodCall(MethodInfo mi, IArgumentProvider args, Type objectType) { EmitMethodCall(mi, args, objectType, CompilationFlags.EmitAsNoTail); }
public TestArgumentSettingsProvider(string settingsSection, IArgumentProvider argumentProvider, IClientSettings clientSettings) : base (settingsSection, argumentProvider, clientSettings) { }
public static string GetFileBySattileSensor(IArgumentProvider argumentProvider, string dirArgName, string defDirArgName, string baseFile) { string dir; string filter; RasterIdentify rid = null; if (!string.IsNullOrEmpty(baseFile) && File.Exists(baseFile)) { rid = new RasterIdentify(baseFile); } GetDirFilter(argumentProvider, dirArgName, out dir, out filter, rid); string serverdir = GetServerDir(dir, rid); if (serverdir == null) { GetDirFilter(argumentProvider, defDirArgName, out dir, out filter, rid); } else { dir = serverdir; } if (!Directory.Exists(dir)) { return(null); } string csrfile = null; string[] files = null; if (string.IsNullOrEmpty(filter)) { files = Directory.GetFiles(dir, "*.*", SearchOption.AllDirectories); } else { files = Directory.GetFiles(dir, filter, SearchOption.AllDirectories); } int length = files.Length; if (files != null || length != 0) { if (rid == null) { csrfile = files[length - 1]; } else { if (string.IsNullOrEmpty(rid.Satellite) && string.IsNullOrEmpty(rid.Sensor)) { csrfile = files[length - 1]; } else if (!string.IsNullOrEmpty(rid.Satellite) && !string.IsNullOrEmpty(rid.Sensor)) { csrfile = GetFileByKey(rid.Satellite, rid.Sensor, files); } else if (!string.IsNullOrEmpty(rid.Satellite)) { csrfile = GetFileByKey(rid.Satellite, files); } else if (!string.IsNullOrEmpty(rid.Sensor)) { csrfile = GetFileByKey(rid.Sensor, files); } } } csrfile = FileUsedProcessor(csrfile, files, length); return(csrfile); }
internal IFileExtractResult Generator(IArgumentProvider argProvider, Dictionary <int, PixelFeature> features) { if (argProvider.DataProvider == null || features == null || features.Count == 0) { return(null); } DateTime orbitDateTime = DateTime.MinValue; string saveFilename = GetPLSTFilename(argProvider, out orbitDateTime); CoordEnvelope envelope = argProvider.DataProvider.CoordEnvelope; float resolutionX = argProvider.DataProvider.ResolutionX; float resolutionY = argProvider.DataProvider.ResolutionY; int sample = argProvider.DataProvider.Width; int line = argProvider.DataProvider.Height; int row, col, index = 0; double longitude, latitude; using (StreamWriter sw = new StreamWriter(saveFilename, false, Encoding.Default)) { foreach (int fet in features.Keys) { if (features[fet].IsVertified) { row = features[fet].PixelIndex / sample; col = features[fet].PixelIndex - row * sample; longitude = envelope.MinX + col * resolutionX; latitude = envelope.MaxY - row * resolutionY; //0 sw.Write((index++).ToString().PadLeft(7, ' ')); sw.Write("\t"); //1 sw.Write(latitude.ToString("0.00").PadLeft(6, ' ')); sw.Write("\t"); //2 sw.Write(longitude.ToString("0.00").PadLeft(7, ' ')); sw.Write("\t"); //3 sw.Write(features[fet].FireAreaNum.ToString().PadLeft(7, ' ')); sw.Write("\t"); //4 int xianJie = _xianJieDictionary.GetCode(longitude, latitude); if (xianJie != default(int)) { sw.Write(xianJie.ToString().PadLeft(6, ' ')); } else { //sw.Write("-9999".PadLeft(6, ' ')); sw.Write("0".PadLeft(6, ' ')); } sw.Write("\t"); //5 byte landUse = _landTypeDictionary.GetCode(longitude, latitude); if (landUse != default(byte)) { sw.Write(landUse.ToString().PadLeft(12, ' ')); } else { //sw.Write("-9999".PadLeft(12, ' ')); sw.Write("0".PadLeft(12, ' ')); } sw.Write("\t"); //6 sw.Write(features[fet].PixelArea.ToString("#0.000000").PadLeft(10, ' ')); sw.Write("\t"); //7 if (features[fet].PixelArea == 0) { sw.Write("0.0000".PadLeft(6, ' ')); } else { sw.Write((features[fet].SecondPixelArea / (features[fet].PixelArea * 100) * 100).ToString("#0.0000").PadLeft(6, ' ')); } sw.Write("\t"); //8 sw.Write("750.00".PadLeft(8, ' ')); sw.Write("\t"); //9 sw.Write(orbitDateTime.ToString("yyyy-MM-dd HH:mm").PadLeft(16, ' ')); sw.Write("\t"); //10 sw.Write(features[fet].FireIntensityGrade.ToString().PadLeft(8, ' ')); sw.Write("\t"); //11 //sw.Write(features[fet].FirIntensity.ToString("#.########").PadLeft(16, ' ')); sw.Write(features[fet].FirIntensity.ToString("0.0000000").PadLeft(16, ' ')); sw.WriteLine(); } } } if (File.Exists(saveFilename)) { IFileExtractResult result = new FileExtractResult("PLST", saveFilename); result.SetDispaly(false); return(result); } return(null); }
public override ITaskService GetTaskService(ref IArgumentProvider argumentProvider) { throw new NotImplementedException(); }
protected TaskExecution(IArgumentProvider argumentProvider, ITaskRegistry taskRegistry, ITypedServiceProvider services) { this.ArgumentProvider = argumentProvider; this.taskRegistry = taskRegistry; this.Services = services; }
public abstract ITaskService GetTaskService(ref IArgumentProvider argumentProvider);
/// <summary> /// Helper used for ensuring we only return 1 instance of a ReadOnlyCollection of T. /// /// This is similar to the ReturnReadOnly of T. This version supports nodes which hold /// onto multiple Expressions where one is typed to object. That object field holds either /// an expression or a ReadOnlyCollection of Expressions. When it holds a ReadOnlyCollection /// the IList which backs it is a ListArgumentProvider which uses the Expression which /// implements IArgumentProvider to get 2nd and additional values. The ListArgumentProvider /// continues to hold onto the 1st expression. /// /// This enables users to get the ReadOnlyCollection w/o it consuming more memory than if /// it was just an array. Meanwhile The DLR internally avoids accessing which would force /// the readonly collection to be created resulting in a typical memory savings. /// </summary> internal static ReadOnlyCollection <Expression> ReturnReadOnly(IArgumentProvider provider, ref object collection) { return(ExpressionUtils.ReturnReadOnly(provider, ref collection)); }
/// <summary> /// Execution handler for tasks running under MSBuild. /// </summary> /// <param name="services">Override services, can be null. Used to get services before falling back on defaults.</param> public BuildTaskExecution(MSBuildFramework.IBuildEngine buildEngine, ITaskOutputHandler outputHandler, IArgumentProvider argumentProvider, ITaskRegistry taskRegistry, ITypedServiceProvider services = null) : base(argumentProvider, taskRegistry, services) { this.outputHandler = outputHandler; this.buildEngine = buildEngine; }
public void TestInitialize(IArgumentProvider arguments) { this.Initialize(arguments); this.AssemblyResolveFallback += this.TestFallBack_AssemblyResolve; }
private ConsoleTaskInteraction(ITask task, IArgumentProvider arguments, ITypedServiceProvider services) : base(arguments, services) { this.loggers = new Lazy<ConsoleTaskLoggers>(() => new ConsoleTaskLoggers(task, arguments)); }
/// <summary> /// Gets target directory arguments or null if none specified /// </summary> public static string[] GetDirectories(this IArgumentProvider arguments, IFileService fileService) { return(ArgumentProviderExtensions.SplitAndValidateDirectories(fileService, arguments.Targets)); }
public BuildTaskLoggers(MSBuildFramework.IBuildEngine buildEngine, ITask task, IArgumentProvider arguments) { BuildLogger logger = new BuildLogger(buildEngine, task.GetType().ToString()); RegisterLogger(LoggerType.Result, logger); RegisterLogger(LoggerType.Status, logger); }
/// <summary> /// Returns files from the specified argument or empty array if none specified /// </summary> public static string[] GetFilesFromArgument(this IArgumentProvider arguments, IFileService fileService, params string[] optionAliases) { return(ArgumentProviderExtensions.SplitFiles(fileService, arguments.GetOption <string>(optionAliases))); }
public static TestAssemblyResolver TestCreate(IArgumentProvider arguments) { TestAssemblyResolver resolver = new TestAssemblyResolver(); resolver.Initialize(arguments); return resolver; }
public void InitControl(IExtractPanel panel, ArgumentBase arg) { if (panel == null) { return; } UCExtractPanel ucPanel = panel as UCExtractPanel; if (ucPanel == null) { return; } IMonitoringSubProduct subProduct = ucPanel.MonitoringSubProduct; if (subProduct == null) { return; } IArgumentProvider arp = subProduct.ArgumentProvider; if (arp != null) { if (arp.DataProvider != null) { IRasterDataProvider dataPrd = arp.DataProvider; txtFileName.Text = arp.DataProvider.fileName; //set cmbBand and cmbRange if (dataPrd.BandCount >= 1) { for (int i = 1; i <= dataPrd.BandCount; i++) { string datasetStr = dataPrd.GetRasterBand(i).Description; if (!string.IsNullOrEmpty(datasetStr)) { string[] stringArray = datasetStr.Split(new char[] { '_' }, StringSplitOptions.RemoveEmptyEntries); if (stringArray != null && stringArray.Length == 3) { if (stringArray[1] == "NorthernDaily") { cmbRange.SelectedIndex = 0; } else { cmbRange.SelectedIndex = 1; } if (stringArray[0] == "SD") { if (stringArray[2] == "A") { cmbBands.SelectedIndex = 0; } else { cmbBands.SelectedIndex = 1; } } else { if (stringArray[2] == "A") { cmbBands.SelectedIndex = 2; } else { cmbBands.SelectedIndex = 3; } } break; } } } } } } }
/// <summary> /// Execution handler for tasks running under the console. /// </summary> /// <param name="services">Override services, can be null. Used to get services before falling back on defaults.</param> public ConsoleTaskExecution(IArgumentProvider argumentProvider, ITaskRegistry taskRegistry, ITypedServiceProvider services = null) : base(argumentProvider, taskRegistry, services) { }
public void TestInitialize(IArgumentProvider arguments) { this.Initialize(arguments); this.AssemblyResolveFallback += this.TestFallBack_AssemblyResolve; }
public static AssemblyResolver Create(IArgumentProvider arguments, IFileService fileService) { AssemblyResolver resolver = new AssemblyResolver(fileService); resolver.Initialize(arguments); return resolver; }
public int[] Filter(IArgumentProvider argProvider, Dictionary <int, PixelFeature> features) { using (IRasterPixelsVisitor <UInt16> vistor = new RasterPixelsVisitor <UInt16>(argProvider)) { int[] bandNos = new int[] { _visibleBandNo, _midInfraredBandNo, _farInfraredBandNo }; _visibleBandIndex = 0; _midInfraredBandIndex = 1; _farInfraredBandIndex = 2; // int[] aoi = GetAOI(features, (fet) => { return(fet.IsDoubtFirPixel); }); if (aoi == null) { return(null); } Rectangle aoiRect = AOIHelper.ComputeAOIRect(aoi, new System.Drawing.Size(argProvider.DataProvider.Width, argProvider.DataProvider.Height)); vistor.VisitPixel(aoiRect, aoi, bandNos, (idx, values) => { float pvFarIfr = values[_farInfraredBandIndex] / _bandZoom; float pvMidIfr = values[_midInfraredBandIndex] / _bandZoom; float pvVis = values[_visibleBandIndex] / _bandZoom; float pvMidIfr_FarIfr = values[_midInfraredBandIndex] - values[_farInfraredBandIndex]; //by chennan 20120821 一期火点确认错误代码 if (pvFarIfr < _maxFarIfrValue_fir || pvVis > _minVisValue_fir) { return; } PixelFeature fet = features[idx]; if (pvMidIfr > _secondMidIfrValue_fir) { //if (pvMidIfr > fet.MidIfrAvgValue + fet.MidIfr_StdDev) if (pvMidIfr > fet.MidIfrAvgValue + _backTmpFactor_fir * fet.MidIfr_StdDev) { fet.IsVertified = true; } } else { if ( (pvMidIfr > fet.MidIfrAvgValue + _backTmpFactor_fir * fet.MidIfr_StdDev) && (pvMidIfr_FarIfr > fet.MidIfr_FarIfr_Diff_AvgValue + _backTmpFactor_fir * fet.MidIfr_FarIfr_Diff_StdDev) ) { fet.IsVertified = true; } } //by chennan 20120821 增加中红外偏移量与远红外偏移量比值火点确认条件 if (fet.IsVertified == true && _isUsedMidFar) { float bzCH4 = (pvFarIfr - fet.FarIfrAvgValue); if (bzCH4 <= 0) { bzCH4 = _defaultPercent; } //bzCH4 = 0.2f; if ((pvMidIfr - fet.MidIfrAvgValue) / bzCH4 < _midFarRatio) { fet.IsVertified = false; return; } } }); } return(GetAOI(features, (fet) => { return fet.IsVertified; })); }
/// <summary> /// Adds child <paramref name="expressions"/> provided through an argument /// provider to the rewriter, causing them to be rewritten using the parent /// stack spiller, and the evaluation stack state and rewrite action to be /// updated accordingly. /// </summary> /// <param name="expressions"> /// The argument provider containing the child expression to add. /// </param> internal void AddArguments(IArgumentProvider expressions) { for (int i = 0, count = expressions.ArgumentCount; i < count; i++) { Add(expressions.GetArgument(i)); } }
private Expression[] VisitArguments(IArgumentProvider nodes) { return(ExpressionVisitorUtils.VisitArguments(this, nodes)); }
//CONFORMING // assumes 'object' of non-static call is already on stack private void EmitMethodCall(MethodInfo mi, IArgumentProvider args, Type objectType) { // Emit arguments List<WriteBack> wb = EmitArguments(mi, args); // Emit the actual call OpCode callOp = UseVirtual(mi) ? OpCodes.Callvirt : OpCodes.Call; if (callOp == OpCodes.Callvirt && objectType.IsValueType) { // This automatically boxes value types if necessary. _ilg.Emit(OpCodes.Constrained, objectType); } if (mi.CallingConvention == CallingConventions.VarArgs) { _ilg.EmitCall(callOp, mi, args.Map(a => a.Type)); } else { _ilg.Emit(callOp, mi); } // Emit writebacks for properties passed as "ref" arguments EmitWriteBack(wb); }
internal ListArgumentProvider(IArgumentProvider provider, Expression arg0) { _provider = provider; _arg0 = arg0; }
private void EmitMethodCall(Expression obj, MethodInfo method, IArgumentProvider methodCallExpr, CompilationFlags flags) { // Emit instance, if calling an instance method Type objectType = null; if (!method.IsStatic) { EmitInstance(obj, objectType = obj.Type); } // if the obj has a value type, its address is passed to the method call so we cannot destroy the // stack by emitting a tail call if (obj != null && obj.Type.GetTypeInfo().IsValueType) { EmitMethodCall(method, methodCallExpr, objectType); } else { EmitMethodCall(method, methodCallExpr, objectType, flags); } }
/// <summary> /// Emits arguments to a call, and returns an array of write-backs that /// should happen after the call. /// </summary> private List <WriteBack>?EmitArguments(MethodBase method, IArgumentProvider args) { return(EmitArguments(method, args, 0)); }
// assumes 'object' of non-static call is already on stack private void EmitMethodCall(MethodInfo mi, IArgumentProvider args, Type objectType, CompilationFlags flags) { // Emit arguments List<WriteBack> wb = EmitArguments(mi, args); // Emit the actual call OpCode callOp = UseVirtual(mi) ? OpCodes.Callvirt : OpCodes.Call; if (callOp == OpCodes.Callvirt && objectType.GetTypeInfo().IsValueType) { // This automatically boxes value types if necessary. _ilg.Emit(OpCodes.Constrained, objectType); } // The method call can be a tail call if // 1) the method call is the last instruction before Ret // 2) the method does not have any ByRef parameters, refer to ECMA-335 Partition III Section 2.4. // "Verification requires that no managed pointers are passed to the method being called, since // it does not track pointers into the current frame." if ((flags & CompilationFlags.EmitAsTailCallMask) == CompilationFlags.EmitAsTail && !MethodHasByRefParameter(mi)) { _ilg.Emit(OpCodes.Tailcall); } if (mi.CallingConvention == CallingConventions.VarArgs) { int count = args.ArgumentCount; Type[] types = new Type[count]; for (int i = 0; i < count; i++) { types[i] = args.GetArgument(i).Type; } _ilg.EmitCall(callOp, mi, types); } else { _ilg.Emit(callOp, mi); } // Emit write-backs for properties passed as "ref" arguments EmitWriteBack(wb); }
private void EmitMethodCall(Expression obj, MethodInfo method, IArgumentProvider methodCallExpr) { EmitMethodCall(obj, method, methodCallExpr, CompilationFlags.EmitAsNoTail); }
/// <summary> /// Emits arguments to a call, and returns an array of write-backs that /// should happen after the call. For emitting dynamic expressions, we /// need to skip the first parameter of the method (the call site). /// </summary> private List<WriteBack> EmitArguments(MethodBase method, IArgumentProvider args, int skipParameters) { ParameterInfo[] pis = method.GetParametersCached(); Debug.Assert(args.ArgumentCount + skipParameters == pis.Length); var writeBacks = new List<WriteBack>(); for (int i = skipParameters, n = pis.Length; i < n; i++) { ParameterInfo parameter = pis[i]; Expression argument = args.GetArgument(i - skipParameters); Type type = parameter.ParameterType; if (type.IsByRef) { type = type.GetElementType(); WriteBack wb = EmitAddressWriteBack(argument, type); if (wb != null) { writeBacks.Add(wb); } } else { EmitExpression(argument); } } return writeBacks; }
/// <summary> /// 生成Excel环保部信息列表 /// </summary> /// <param name="argProvider"></param> /// <param name="features"></param> /// <returns></returns> internal IFileExtractResult GeneratorHB(IArgumentProvider argProvider, Dictionary <int, FireAreaFeature> features) { DateTime orbitDateTime = DateTime.MinValue; string saveFilename = GetFALTFilenameHB(argProvider, out orbitDateTime); List <string[]> excelInfos = new List <string[]>(); string[] columns = new string[] { "省", "地区", "县", "中心纬度", "中心经度", "火点像素数", "禁烧区", "明火面积(公顷)" }; List <string> listTemp = new List <string>(); SortedDictionary <string, StatAreaItem> statResult; RasterStatByVector <Int16> stat = new RasterStatByVector <Int16>(null); List <int> inRegionIndex = new List <int>(); statResult = stat.CountByVector(argProvider.DataProvider, "禁烧区.shp", "JS", (cur, idx, cursum) => { if (cur != 0) { inRegionIndex.Add(idx); } return(cursum += cur); }); for (int i = 0; i < features.Count; i++) { if (features[i].FarmlandPercent == 0) { continue; } listTemp.Add(string.IsNullOrEmpty(features[i].SJName) ? @"\" : features[i].SJName); listTemp.Add(string.IsNullOrEmpty(features[i].ShiName) ? @"\" : features[i].ShiName); if (string.IsNullOrEmpty(features[i].XJName)) { listTemp.Add(@"\"); } else if (!string.IsNullOrEmpty(features[i].SJName + features[i].ShiName)) { listTemp.Add(features[i].XJName.Replace(features[i].SJName + features[i].ShiName, "")); } else { listTemp.Add(features[i].XJName); } listTemp.Add(features[i].Latitude.ToString()); listTemp.Add(features[i].Longitude.ToString()); listTemp.Add(features[i].FireCount.ToString("#")); listTemp.Add(GetHBInfos(features[i].FireIndeies, inRegionIndex)); listTemp.Add(features[i].SecondryFireArea.ToString("#0.000")); excelInfos.Add(listTemp.ToArray()); listTemp.Clear(); } IStatResult result = new StatResult("环保部信息统计结果", columns, excelInfos.ToArray()); using (StatResultToExcelFile excelControl = new StatResultToExcelFile()) { excelControl.Init(); excelControl.Add(true, "环保部信息数据统计", result, false, 0); excelControl.SaveFile(saveFilename); } IFileExtractResult resultFile = new FileExtractResult("FRIH", saveFilename); resultFile.SetDispaly(false); return(resultFile); }