本文整理汇总了C#中Processor.Process方法的典型用法代码示例。如果您正苦于以下问题:C# Processor.Process方法的具体用法?C# Processor.Process怎么用?C# Processor.Process使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Processor
的用法示例。
在下文中一共展示了Processor.Process方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DoThing
public void DoThing()
{
var args1 = new byte[] {1, 2, 3};
var args2 = new byte[] {1, 2, 3};
var t = new Processor();
// Both lambdas share a backing class, so the scope of args1 or args2
// may be wider than you think. Only way to suppress is with an
// annotation attribute to tell ReSharper that the closure's scope
// is constrained to the called method only
DoesSomethingWithAction(() => t.Process(args1));
DoesSomethingWithAction(() => t.Process(args2));
}
示例2: Process
public async Task Process()
{
var bytes = File.ReadAllBytes(Environment.CurrentDirectory + @"\icon.png");
var versions = this.Versions();
var version = versions.Values.First();
var queued = new ImageQueued
{
Identifier = Guid.NewGuid(),
OriginalExtension = Naming.DefaultExtension,
};
queued.FileNameFormat = queued.Identifier.ToString() + "_{0}.{1}";
await this.container.Save(string.Format("{0}_original.jpeg", queued.Identifier), bytes);
var store = new DataStore(connectionString);
var processor = new Processor(new DataStore(connectionString), versions);
await processor.Process(queued);
var data = await this.container.Get(string.Format("{0}_test.gif", queued.Identifier));
Assert.IsNotNull(data);
var entities = await this.table.QueryByRow<ImageEntity>("test");
var entity = entities.FirstOrDefault();
Assert.IsNotNull(entity);
Assert.AreEqual(version.Format.MimeType, entity.MimeType);
Assert.AreEqual(string.Format(Naming.PathFormat, this.container.Name, entity.FileName), entity.RelativePath);
}
示例3: ImageProcessing
/// <summary>
/// Image Processing
/// </summary>
/// <param name="image">image</param>
public static void ImageProcessing([QueueTrigger("imaging")] string img)
{
var connectionString = CloudConfigurationManager.GetSetting("StorageAccount");
var image = JsonConvert.DeserializeObject<ImageQueued>(img);
var processor = new Processor(new DataStore(connectionString), versions.Images);
processor.Process(image).Wait();
}
示例4: CrashesOnUnassignedRequiredValues
public void CrashesOnUnassignedRequiredValues()
{
var proc = new Processor(defaultArgument: "--test");
proc.Handle("--test").Required();
Assert.Throws<ValueRequiredException>(
() => proc.Process(new string[0])
);
}
示例5: DoSomething
public override string DoSomething(string val1)
{
Processor processor = new Processor();
var str = processor.Process(val1, new BaseType());
return str;
}
示例6: CanImplyFlagWhenPassingMultipleKeys
public void CanImplyFlagWhenPassingMultipleKeys()
{
var proc = new Processor(defaultArgument: "--test");
var test = proc.Handle("--test");
var set = new[] { "--bar", "--test", "foo" };
proc.Process(set);
Assert.That(test.Value, Is.EqualTo("foo"));
}
示例7: CanAddOptionsToDefaultArgument
public void CanAddOptionsToDefaultArgument()
{
var proc = new Processor(defaultArgument: "--test");
var test = proc.Handle("--test").TakesManyValues();
var set = new[] { "foo", "bar" };
proc.Process(set);
Assert.That(test.Value, Is.EquivalentTo(set));
}
示例8: Main
static void Main(string[] args)
{
Logger.Setup("Error.log");
try
{
ExtractorConfig config;
bool showUI;
if (File.Exists(ExtractorConfig.DefualtConfigPath))
{
config = new ExtractorConfig(ExtractorConfig.DefualtConfigPath);
showUI = !args.Contains("-q");
}
else
{
config = new ExtractorConfig();
showUI = true;
}
if (showUI)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
MainWindow window = new MainWindow(config);
DialogResult result = window.ShowDialog();
if (result != DialogResult.OK)
{
return;
}
config.Save(ExtractorConfig.DefualtConfigPath);
}
Processor processor = new Processor(config);
processor.Process();
Thread.Sleep(3000);
}
catch (Exception ex)
{
Logger.Log(ex.ToString());
}
finally
{
Logger.Teardown();
}
}
示例9: Show
private static void Show(params string[] args)
{
var processor = new Processor(defaultArgument: "--method");
processor.Handle("--configuration", "-c").Required();
var method = processor.Handle("--method", "-m");
var full = processor.Handle("--full").Flag(false);
processor.Process(args);
var showFull = full.Enabled;
switch(method.Value.ToString())
{
case "name":
Console.WriteLine("Name: {0}", showFull ? "Adoption Option Parser" : "adoption");
break;
case "description":
Console.WriteLine("Description: {0}", showFull ? "Parses command line options!" : "option parser");
break;
}
}
示例10: Process_ProperOverloadOfMethodIsChoosen
public void Process_ProperOverloadOfMethodIsChoosen()
{
var processor = new Processor();
var listOfTuples = new List<Tuple<IColorable, IColorable, string>>();
IColorable redColor = new RedColor();
IColorable greenColor = new GreenColor();
listOfTuples.Add(Tuple.Create(greenColor, redColor, "GreenRed"));
listOfTuples.Add(Tuple.Create(redColor, greenColor, "RedGreen"));
listOfTuples.Add(Tuple.Create(greenColor, greenColor, "GreenGreen"));
listOfTuples.Add(Tuple.Create(redColor, redColor, "RedRed"));
foreach (var tuple in listOfTuples)
{
var firstColor = tuple.Item1;
var secondColor = tuple.Item2;
var expectedColotCombination = tuple.Item3;
var actualColorCombination = processor.Process(firstColor, secondColor);
Assert.AreEqual(expectedColotCombination, actualColorCombination);
}
}
示例11: CanSpecifyDefaultArgument
public void CanSpecifyDefaultArgument()
{
var proc = new Processor(defaultArgument: "--test");
proc.Process(new[] { "foo" });
Assert.That(proc["--test"], Is.EqualTo("foo"));
}
示例12: CanGetUnresolvedParts
public void CanGetUnresolvedParts()
{
var proc = new Processor();
proc.Process(new[] { "--test1", "foo" });
Assert.AreEqual(new[] {"--test1", "foo" }, proc.UnresolvedParts);
}
示例13: Main
static void Main(string[] args)
{
Processor p = new Processor();
p.Process(args);
}
示例14: SetLanguage
/// <summary>
///
/// </summary>
/// <param name="infos"></param>
/// <returns></returns>
public Return<object> SetLanguage(List<InfoGrp_Class> infos)
{
Return<object> _answer = new Return<object>();
if (infos == null)
{
_answer.theresError = true;
_answer.error = Utility.GetError(new ArgumentNullException("infos"), this.GetType());
}
else
{
try
{
List<InfoGrp_Class> _infosNoLanguage = infos.Where(i => !i.language.HasValue).ToList();
if (_infosNoLanguage.Any())
{
int _numberSubprocess = _infosNoLanguage.Count < this.numberSubprocessLanguageIdentification ? _infosNoLanguage.Count : this.numberSubprocessLanguageIdentification;
List<object> _objects = new List<object>();
for (int _i = 0; _i < _numberSubprocess; _i++)
{
LanguageIdentificationUtility _object = new LanguageIdentificationUtility();
Return<object> _answerLoadDefaultModels = _object.LoadDefaultModels();
if (_answerLoadDefaultModels.theresError)
{
_answer.theresError = true;
_answer.error = _answerLoadDefaultModels.error;
}
else
_objects.Add(_object);
if (_answer.theresError)
break;
}
if (!_answer.theresError)
{
Stopwatch _stopwatch = new Stopwatch();
string _tiempo = string.Empty;
_stopwatch.Start();
using (Processor<InfoGrp_Class> _processor = new Processor<InfoGrp_Class>(_numberSubprocess, MILLISECONDS_PAUSE_LANGUAGE_IDENTIFICATION, _objects))
{
_processor.ErrorProcessEntity += processorSetLanguage_ErrorProcessEntity;
_processor.Progress += processorSetLanguage_Progress;
_answer = _numberSubprocess == 1 ? _processor.ProcessSynchronously(_infosNoLanguage, SetLanguage)
: _processor.Process(_infosNoLanguage, SetLanguage);
_processor.ErrorProcessEntity -= processorSetLanguage_ErrorProcessEntity;
_processor.Progress -= processorSetLanguage_Progress;
}
_stopwatch.Stop();
_tiempo = string.Format("{0} Ticks", _stopwatch.Elapsed.Ticks);
}
}
}
catch (Exception _ex)
{
_answer.theresError = true;
_answer.error = Utility.GetError(_ex, this.GetType());
}
}
return _answer;
}
示例15: CountBeginningOfSentence
/// <summary>
/// Performs a count of occurrences of a string into a beginning of a sentence
/// </summary>
/// <param name="countSubprocesses"></param>
/// <param name="text">The sentences where to search into</param>
/// <param name="strings">The strings to search</param>
/// <returns>searched text, count of occurrences</returns>
private Return<List<WritableTuple<string, int>>> CountBeginningOfSentence(int countSubprocesses, List<string> sentences, List<string> strings)
{
Return<List<WritableTuple<string, int>>> _answer = new Return<List<WritableTuple<string, int>>>() { data = new List<WritableTuple<string, int>>() };
{
try
{
List<List<string>> _partitions = strings.PartitionAccordingSizeOfPartitions(SIZE_PARTITION_STRINGS);
List<CountWrapper> _wrappers = _partitions.Select(p => new CountWrapper()
{
sentences = sentences
,
textToFind = p.Select(s => new WritableTuple<string, int>(s, 0)).ToList()
}
).ToList();
int _countSubprocesses = _wrappers.Count < countSubprocesses ? _wrappers.Count : countSubprocesses;
errorsMultithreadedProcess.Clear();
Return<object> _answerProcess = new Return<object>();
using (Processor<CountWrapper> _processor
= new Processor<CountWrapper>(_countSubprocesses, PAUSE_MILISECONDS_PROCESSOR))
{
_processor.ErrorProcessEntity += processorCountExistingStrings_ErrorProcessEntity;
_processor.Progress += processorCountExistingStrings_Progress;
_answerProcess = _countSubprocesses == 1 ? _processor.ProcessSynchronously(_wrappers, CountBeginningOfSentenceDirtyHands)
: _processor.Process(_wrappers, CountBeginningOfSentenceDirtyHands);
_processor.Progress -= processorCountExistingStrings_Progress;
_processor.ErrorProcessEntity -= processorCountExistingStrings_ErrorProcessEntity;
}
if (_answerProcess.theresError)
{
_answer.theresError = true;
_answer.error = _answerProcess.error;
}
else
if (errorsMultithreadedProcess.Any())
{
_answer.theresError = true;
_answer.error = errorsMultithreadedProcess.First().Item2;
}
else
{
_answer.data = _wrappers.SelectMany(c => c.textToFind).ToList();
}
}
catch (Exception _ex)
{
_answer.theresError = true;
_answer.error = Utility.GetError(_ex, this.GetType());
}
}
return _answer;
}