本文整理汇总了C#中Lookup类的典型用法代码示例。如果您正苦于以下问题:C# Lookup类的具体用法?C# Lookup怎么用?C# Lookup使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Lookup类属于命名空间,在下文中一共展示了Lookup类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Import
public override void Import(Lookup settings)
{
Dictionary<string, OptionItem> optionLookup = new Dictionary<string, OptionItem>();
StoryProgression.Main.GetOptionLookup(optionLookup);
foreach(KeyValuePair<string,OptionItem> option in optionLookup)
{
string value = settings.GetString(option.Key);
if (value == null) continue;
try
{
option.Value.PersistValue = value;
}
catch (Exception e)
{
Common.Exception(option.Key, e);
}
}
StoryProgression.Main.Options.ImportCastes(settings);
foreach (OptionItem option in optionLookup.Values)
{
IAfterImportOptionItem afterOption = option as IAfterImportOptionItem;
if (afterOption == null) continue;
afterOption.PerformAfterImport();
}
}
示例2: Export
public override void Export(Lookup settings)
{
List<OptionItem> allOptions = new List<OptionItem>();
StoryProgression.Main.GetOptions(allOptions, false, IsExportable);
StoryProgression.Main.Options.ExportCastes(settings);
foreach (OptionItem option in StoryProgression.Main.Options.GetOptions(StoryProgression.Main, "Town", false))
{
allOptions.Add(option);
}
foreach (OptionItem option in StoryProgression.Main.Options.GetImmigrantOptions(StoryProgression.Main))
{
allOptions.Add(option);
}
foreach (OptionItem option in allOptions)
{
try
{
List<string> names = GetExportKey(option);
if ((names == null) || (names.Count == 0)) continue;
settings.Add(names[0], option.GetExportValue());
}
catch (Exception e)
{
Common.Exception(option.Name, e);
}
}
}
示例3: foreach
/// <summary>
/// Creates an instance of this class using the given bucket data.
/// </summary>
/// <param name="itemNames">Item types being batched on: null indicates no batching is occurring</param>
/// <param name="itemMetadata">Hashtable of item metadata values: null indicates no batching is occurring</param>
internal ItemBucket
(
ICollection<string> itemNames,
Dictionary<string, string> metadata,
Lookup lookup,
int bucketSequenceNumber
)
{
ErrorUtilities.VerifyThrow(lookup != null, "Need lookup.");
// Create our own lookup just for this bucket
_lookup = lookup.Clone();
// Push down the items, so that item changes in this batch are not visible to parallel batches
_lookupEntry = _lookup.EnterScope("ItemBucket()");
// Add empty item groups for each of the item names, so that (unless items are added to this bucket) there are
// no item types visible in this bucket among the item types being batched on
if (itemNames != null)
{
foreach (string name in itemNames)
{
_lookup.PopulateWithItems(name, new List<ProjectItemInstance>());
}
}
_metadata = metadata;
_expander = new Expander<ProjectPropertyInstance, ProjectItemInstance>(_lookup.ReadOnlyLookup, _lookup.ReadOnlyLookup, new StringMetadataTable(metadata));
_bucketSequenceNumber = bucketSequenceNumber;
}
示例4: AddShouldThrowIfKeyIsNullOrWhiteSpace
public void AddShouldThrowIfKeyIsNullOrWhiteSpace()
{
var lookup = new Lookup<object>();
Should.Throw<ArgumentException>(() => lookup.Add(null, new object()));
Should.Throw<ArgumentException>(() => lookup.Add(string.Empty, new object()));
Should.Throw<ArgumentException>(() => lookup.Add(" ", new object()));
}
示例5: 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);
}
}
示例6: TestConstructorNullTarget
public void TestConstructorNullTarget()
{
ProjectInstance project = CreateTestProject(true /* Returns enabled */);
BuildRequestConfiguration config = new BuildRequestConfiguration(1, new BuildRequestData("foo", new Dictionary<string, string>(), "foo", new string[0], null), "2.0");
BuildRequestEntry requestEntry = new BuildRequestEntry(CreateNewBuildRequest(1, new string[] { "foo" }), config);
Lookup lookup = new Lookup(new ItemDictionary<ProjectItemInstance>(project.Items), new PropertyDictionary<ProjectPropertyInstance>(project.Properties), null);
TargetEntry entry = new TargetEntry(requestEntry, this, null, lookup, null, _host, false);
}
示例7: PrepareBatchingBuckets
/// <summary>
/// Determines how many times the batchable object needs to be executed (each execution is termed a "batch"), and prepares
/// buckets of items to pass to the object in each batch.
/// </summary>
/// <returns>ArrayList containing ItemBucket objects, each one representing an execution batch.</returns>
internal static List<ItemBucket> PrepareBatchingBuckets
(
List<string> batchableObjectParameters,
Lookup lookup,
ElementLocation elementLocation
)
{
return PrepareBatchingBuckets(batchableObjectParameters, lookup, null, elementLocation);
}
示例8: TestGenericGetEnumerator
public void TestGenericGetEnumerator()
{
IEnumerable<IGrouping<string, int>> lookup = new Lookup<string, int>
{
{"one", 1},
{"two", 2},
{"one", -1}
};
AssertContents(lookup.GetEnumerator());
}
示例9: BuildTargets
/// <summary>
/// Builds the specified targets of an entry. The cancel event should only be set to true if we are planning
/// on simulating execution time when a target is built
/// </summary>
public Task<BuildResult> BuildTargets(ProjectLoggingContext loggingContext, BuildRequestEntry entry, IRequestBuilderCallback callback, string[] targetNames, Lookup baseLookup, CancellationToken cancellationToken)
{
_requestEntry = entry;
_projectLoggingContext = loggingContext;
_requestCallBack = callback;
_testDefinition = _testDataProvider[entry.Request.ConfigurationId];
_cancellationToken = cancellationToken;
BuildResult result = GenerateResults(targetNames);
return Task<BuildResult>.FromResult(result);
}
示例10: RecieveItemInteraction
protected override void RecieveItemInteraction(Entity actor, Entity item,
Lookup<ItemCapabilityType, ItemCapabilityVerb> verbs)
{
base.RecieveItemInteraction(actor, item, verbs);
if (verbs[ItemCapabilityType.Tool].Contains(ItemCapabilityVerb.Wrench))
{
}
else
PlaceItem(actor, item);
}
示例11: TestContains
public void TestContains()
{
Lookup<string, int> lookup = new Lookup<string, int>
{
{"one", 1},
{"two", 2},
{"one", -1}
};
Assert.IsTrue(lookup.Contains("one"));
Assert.IsTrue(lookup.Contains("two"));
Assert.IsFalse(lookup.Contains("three"));
}
示例12: Evaluate
/// <summary>
/// This is the Evaluate Method
/// </summary>
/// <param name="s"></param>
/// <param name="varEvaluator"></param>
/// <returns></returns>
public static int Evaluate(String s, Lookup varEvaluator)
{
Stack<string> operatorStack = new Stack<string>();
Stack<double> numberStack = new Stack<double>();
try{
//This helps to split strings to the proper operator.
string[] substrings = Regex.Split(s, "(\\()|(\\))|(-)|(\\+)|(\\*)|(/)", RegexOptions.IgnorePatternWhitespace);
//run through each string and do things to it.
//Lets populate the stacks here.
foreach(String t in substrings)
{
if (isNum(t))
{
double newNum = Double.Parse(t);
string newOp = operatorStack.Peek();
if (newOp.Equals("*") || newOp.Equals("/"))
{
numberStack.Pop();
operatorStack.Pop();
}
}
else if (isVar(t))
{
varEvaluator(t);
}
else if (isOp(t))
{
if (operatorStack.Peek().Equals("+") || operatorStack.Peek().Equals("-"))
{
double x = numberStack.Pop();
double y = numberStack.Pop();
string poppedOp = operatorStack.Pop();
if(poppedOp.Equals("+"))
{
x = x + y;
} else
{
x = x - y;
}
}
}
}
}catch(ArgumentException){
}
return 0;
}
示例13: Export
public override void Export(Lookup settings)
{
settings.Add("Enabled", DebugEnabler.Settings.mEnabled);
settings.Add("HotKeyCount", DebugEnabler.Settings.mInteractions.Count);
int i = 0;
foreach (Type type in DebugEnabler.Settings.mInteractions.Keys)
{
settings.Add("HotKey" + i, type);
i++;
}
}
示例14: ReportLookupError
public override void ReportLookupError(Lookup lookup, Type fail_type)
{
Dirty = true;
if (fail_type == null) {
Console.Error.WriteLine("Undefined name “{0}”. Lookup was as follows:", lookup.Name);
} else {
Console.Error.WriteLine("Non-frame type {1} while resolving name “{0}”. Lookup was as follows:",
lookup.Name, fail_type);
}
var col_width = Math.Max((int) Math.Log(lookup.FrameCount, 10) + 1, 3);
for (var name_it = 0; name_it < lookup.NameCount; name_it++) {
col_width = Math.Max(col_width, lookup.GetName(name_it).Length);
}
for (var name_it = 0; name_it < lookup.NameCount; name_it++) {
Console.Error.Write("│ {0}", lookup.GetName(name_it).PadRight(col_width, ' '));
}
Console.Error.WriteLine("│");
for (var name_it = 0; name_it < lookup.NameCount; name_it++) {
Console.Error.Write(name_it == 0 ? "├" : "┼");
for (var s = 0; s <= col_width; s++) {
Console.Error.Write("─");
}
}
Console.Error.WriteLine("┤");
var seen = new Dictionary<SourceReference, bool>();
var known_frames = new Dictionary<Frame, string>();
var frame_list = new List<Frame>();
var null_text = "│ ".PadRight(col_width + 2, ' ');
for (var frame_it = 0; frame_it < lookup.FrameCount; frame_it++) {
for (var name_it = 0; name_it < lookup.NameCount; name_it++) {
var frame = lookup[name_it, frame_it];
if (frame == null) {
Console.Error.Write(null_text);
continue;
}
if (!known_frames.ContainsKey(frame)) {
frame_list.Add(frame);
known_frames[frame] = frame_list.Count.ToString().PadRight(col_width, ' ');
}
Console.Error.Write("│ {0}", known_frames[frame]);
}
Console.Error.WriteLine("│");
}
for (var it = 0; it < frame_list.Count; it++) {
Console.Error.WriteLine("Frame {0} defined:", it + 1);
frame_list[it].SourceReference.Write(Console.Error, " ", seen);
}
Console.Error.WriteLine("Lookup happened here:");
lookup.SourceReference.Write(Console.Error, " ", seen);
}
示例15: BaseViewModel
public BaseViewModel()
{
List<KeyValuePair<string, string>> _properties = new List<KeyValuePair<string, string>>();
foreach (var property in GetType().GetProperties())
{
foreach (var d in (DependsUponAttribute[])property.GetCustomAttributes(typeof(DependsUponAttribute), true))
{
_properties.Add(new KeyValuePair<string, string>(d.DependancyName, property.Name));
}
}
DependentProperties = (Lookup<string, string>)_properties.ToLookup(p => p.Key, p => p.Value);
}