本文整理汇总了C#中Lookup.Notify方法的典型用法代码示例。如果您正苦于以下问题:C# Lookup.Notify方法的具体用法?C# Lookup.Notify怎么用?C# Lookup.Notify使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Lookup
的用法示例。
在下文中一共展示了Lookup.Notify方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HandleFrameResult
private void HandleFrameResult(object result)
{
if (result is Frame)
{
var lookup = new Lookup(task_master, null, new[] {"value"}, ((Frame) result).Context);
lookup.Notify(HandleFinalResult);
}
}
示例2: Run
protected override bool Run()
{
if (mappings.Count == 0) {
interlock = categories.Count + 2;
Computation input_lookup = new Lookup(master, source_reference, new []{"arg"}, context);
input_lookup.Notify(input_result => {
if (input_result is Stringish) {
input = input_result.ToString();
if (Interlocked.Decrement(ref interlock) == 0) {
master.Slot(this);
}
} else {
master.ReportOtherError(source_reference, "Input argument must be a string.");
}
});
master.Slot(input_lookup);
foreach (var entry in categories) {
var lookup = new Lookup(master, source_reference, new []{ entry.Value }, context);
lookup.Notify(cat_result => {
mappings[entry.Key] = cat_result;
if (Interlocked.Decrement(ref interlock) == 0) {
master.Slot(this);
}
});
master.Slot(lookup);
}
if (Interlocked.Decrement(ref interlock) > 0) {
return false;
}
}
var frame = new Frame(master, master.NextId(), source_reference, context, container);
for(int it = 0; it < input.Length; it++) {
frame[TaskMaster.OrdinalNameStr(it + 1)] = mappings[Char.GetUnicodeCategory(input[it])];
}
result = frame;
return true;
}
示例3: HandleFrameResult
private void HandleFrameResult(object result)
{
var frame = result as Frame;
if (frame != null) {
var lookup = new Lookup(task_master, new SourceReference("printer", "<native>", 0, 0, 0, 0, null), new[] {"value"}, frame.Context);
lookup.Notify(HandleFinalResult);
task_master.Slot(lookup);
} else {
Console.Error.WriteLine("File did not contain a frame. That should be impossible.");
}
}
示例4: Run
protected override bool Run()
{
if (input == null) {
Computation input_lookup = new Lookup(task_master, source_reference, new []{"arg"}, context);
input_lookup.Notify(input_result => {
if (input_result is Stringish) {
input = input_result.ToString();
if (Interlocked.Decrement(ref interlock) == 0) {
task_master.Slot(this);
}
} else {
task_master.ReportOtherError(source_reference, "Input argument must be a string.");
}
});
if (Interlocked.Decrement(ref interlock) > 0) {
return false;
}
}
var frame = new MutableFrame(task_master, source_reference, context, container);
for(int it = 0; it < input.Length; it++) {
frame.Set(it + 1, (long) Char.ConvertToUtf32(input, it));
}
result = frame;
return true;
}
示例5: LookupString
void LookupString(Frame frame, string name, ConsumeString consume)
{
var lookup = new Lookup(task_master, source_ref, new []{name}, Context.Prepend(frame, null));
lookup.Notify(result => {
if (result is Stringish) {
var str = result.ToString();
consume(str);
} else {
task_master.ReportOtherError(source_ref, String.Format("Expected “{0}” to be a string. Got {1} instead.", name, Stringish.NameForType(result.GetType())));
}
});
}
示例6: HandleTransformation
private void HandleTransformation(object result)
{
if (result is Frame) {
var frame = (Frame) result;
var lookup = new Lookup(task_master, source_ref, new []{"type"}, Context.Prepend(frame, null));
lookup.Notify(type_result => {
if (type_result is long) {
switch ((long) type_result) {
case 0:
HandleSubstition(frame);
return;
case 1:
HandleRange(frame);
return;
}
}
task_master.ReportOtherError(source_ref, "Illegal transformation specified.");
});
} else {
task_master.ReportOtherError(source_ref, "Non-frame in transformation list.");
}
}