• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Lookup类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Lookup的典型用法代码示例。如果您正苦于以下问题:C# Lookup类的具体用法?C# Lookup怎么用?C# Lookup使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Lookup类属于命名空间,在下文中一共展示了Lookup类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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();
            }
        }
开发者ID:Robobeurre,项目名称:NRaas,代码行数:30,代码来源:PersistenceEx.cs


示例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);
                }
            }
        }
开发者ID:Robobeurre,项目名称:NRaas,代码行数:32,代码来源:PersistenceEx.cs


示例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;
        }
开发者ID:cameron314,项目名称:msbuild,代码行数:36,代码来源:ItemBucket.cs


示例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()));
 }
开发者ID:JonasSamuelsson,项目名称:cmdBuddy,代码行数:7,代码来源:LookupTests.cs


示例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);
     }
 }
开发者ID:davidhankins,项目名称:flabbergast,代码行数:8,代码来源:test-harness.cs


示例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);
 }
开发者ID:JamesLinus,项目名称:msbuild,代码行数:8,代码来源:TargetEntry_Tests.cs


示例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);
 }
开发者ID:cameron314,项目名称:msbuild,代码行数:14,代码来源:BatchingEngine.cs


示例8: TestGenericGetEnumerator

 public void TestGenericGetEnumerator()
 {
     IEnumerable<IGrouping<string, int>> lookup = new Lookup<string, int>
     {
         {"one", 1},
         {"two", 2},
         {"one", -1}
     };
     AssertContents(lookup.GetEnumerator());
 }
开发者ID:webappsuk,项目名称:CoreLibraries,代码行数:10,代码来源:TestLookup.cs


示例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);
        }
开发者ID:cameron314,项目名称:msbuild,代码行数:15,代码来源:MockTargetBuilder.cs


示例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);
        }
开发者ID:MSylvia,项目名称:space-station-14,代码行数:11,代码来源:WorktopComponent.cs


示例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"));
 }
开发者ID:webappsuk,项目名称:CoreLibraries,代码行数:12,代码来源:TestLookup.cs


示例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;
        }
开发者ID:LeGrange,项目名称:CS3500_F15,代码行数:58,代码来源:Evaluator.cs


示例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++;
                }
            }
开发者ID:Robobeurre,项目名称:NRaas,代码行数:13,代码来源:PersistedSettings.cs


示例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);
        }
开发者ID:brian-brazil,项目名称:flabbergast,代码行数:51,代码来源:library-runtime.cs


示例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);

        }
开发者ID:nexus1976,项目名称:WPF.HOAPro,代码行数:14,代码来源:BaseViewModel.cs


示例16: TestGetByIndex

 public void TestGetByIndex()
 {
     Lookup<string, int> lookup = new Lookup<string, int>
     {
         {"one", 1},
         {"two", 2},
         {"one", -1}
     };
     Assert.AreEqual(2, lookup.Count);
     int[] one = lookup["one"].ToArray();
     Assert.IsTrue(one.Contains(1));
     Assert.IsTrue(one.Contains(-1));
     Assert.AreEqual(2, one.Length);
 }
开发者ID:webappsuk,项目名称:CoreLibraries,代码行数:14,代码来源:TestLookup.cs


示例17: Import

            public override void Import(Lookup settings)
            {
                DebugEnabler.Settings.mEnabled = settings.GetBool("Enabled", true);

                DebugEnabler.Settings.mInteractions.Clear();

                int count = settings.GetInt("HotKeyCount", 0);

                for (int i = 0; i < count; i++)
                {
                    Type type = settings.GetType("HotKey" + i);
                    if (type == null) continue;

                    DebugEnabler.Settings.mInteractions[type] = true;
                }
            }
开发者ID:Robobeurre,项目名称:NRaas,代码行数:16,代码来源:PersistedSettings.cs


示例18: RecieveItemInteraction

        protected override void RecieveItemInteraction(Entity actor, Entity item,
                                                       Lookup<ItemCapabilityType, ItemCapabilityVerb> verbs)
        {
            base.RecieveItemInteraction(actor, item, verbs);

            if (verbs[ItemCapabilityType.Tool].Contains(ItemCapabilityVerb.Pry))
            {
                ToggleDoor(true);
            }
            else if (verbs[ItemCapabilityType.Tool].Contains(ItemCapabilityVerb.Hit))
            {
                var cm = IoCManager.Resolve<IChatManager>();
                cm.SendChatMessage(ChatChannel.Default,
                                   actor.Name + " hit the " + Owner.Name + " with a " + item.Name + ".", null, item.Uid);
            }
            else if (verbs[ItemCapabilityType.Tool].Contains(ItemCapabilityVerb.Emag))
            {
                OpenDoor();
                disabled = true;
            }
        }
开发者ID:millpond,项目名称:space-station-14,代码行数:21,代码来源:BasicDoorComponent.cs


示例19: Page_Load

        protected void Page_Load(object sender, EventArgs e)
        {
            LookupCollection validNumbers = new LookupCollection(new Guid("11B4ADEC-CB8C-4D01-B99E-7A0FFE2007B5"));
            StringBuilder sb = new StringBuilder();

            foreach (String s in AllowedPhoneNumbersSetting.Split(','))
            {
                Lookup lk = new Lookup(Convert.ToInt32(s));
                sb.AppendLine(String.Format("ddl.append('<option value=\"{0}\">{1}</option>');",
                    Arena.Custom.HDC.Twilio.TwilioSMS.CleanPhone(lk.Qualifier), Server.HtmlEncode(lk.Value)));
            }

            ltSelect.Text = sb.ToString();

            if (!String.IsNullOrEmpty(Request.Params["MEDIUM"]) && Request.Params["MEDIUM"] == "email")
            {
                IsMediumEmail = 1;
                FromEmail = CurrentPerson.Emails.FirstActive;
                ReplyToEmail = CurrentPerson.Emails.FirstActive;
            }
        }
开发者ID:mattbaylor,项目名称:arena-hdc-twilio,代码行数:21,代码来源:SmsCommunicationInjection.ascx.cs


示例20: ReadBinaryFile

        public static Dictionary<ulong,Lookup> ReadBinaryFile(string filename)
        {
            Dictionary<ulong, Lookup> lookup = new Dictionary<ulong, Lookup>();

            if (File.Exists(filename))
            {
                FileStream inFile = new FileStream(filename, FileMode.Open, FileAccess.Read);
                using (BinaryReader file = new BinaryReader(inFile, Encoding.Unicode))
                {
                    byte[] buffer = new byte[7];
                    file.Read(buffer, 0, 7);

                    uint count = file.ReadUInt32();

                    file.Read(buffer, 0, 6);

                    for (uint i = 0; i < count; i++)
                    {
                        ulong id = file.ReadUInt64();

                        uint len = file.ReadUInt32();

                        char[] text = file.ReadChars((int)len);

                        Lookup value;
                        if (!lookup.TryGetValue(id, out value))
                        {
                            value = new Lookup("0x" + id.ToString("X16"), new string(text), false);
                            lookup.Add(id, value);
                        }
                        else
                        {
                            value.mText = new string (text);
                        }
                    }
                }
            }

            return lookup;
        }
开发者ID:Robobeurre,项目名称:NRaas,代码行数:40,代码来源:STBLImporter.cs



注:本文中的Lookup类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# LookupMode类代码示例发布时间:2022-05-24
下一篇:
C# LoginViewModel类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap