当前位置: 首页>>代码示例>>C#>>正文


C# Dictionary.GetValue方法代码示例

本文整理汇总了C#中Dictionary.GetValue方法的典型用法代码示例。如果您正苦于以下问题:C# Dictionary.GetValue方法的具体用法?C# Dictionary.GetValue怎么用?C# Dictionary.GetValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Dictionary的用法示例。


在下文中一共展示了Dictionary.GetValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetValueTest

		public void GetValueTest()
		{
			IDictionary<String, String> d = new Dictionary<String, String>();
			d["Test1"] = "Test";
			Assert.AreEqual("Test", d.GetValue("Test1"));
			Assert.AreEqual(null, d.GetValue("Test2"));
		}
开发者ID:holtsoftware,项目名称:House,代码行数:7,代码来源:ExtensionsTests.cs

示例2: SVGGradientElement

    protected SVGGradientElement(SVGParser xmlImp, Dictionary<string, string> attrList)
    {
        _attrList = attrList;
        _xmlImp = xmlImp;
        _stopList = new List<SVGStopElement>();
        _id = _attrList.GetValue("id");
        _gradientUnits = SVGGradientUnit.ObjectBoundingBox;
        if (_attrList.GetValue("gradiantUnits") == "userSpaceOnUse")
        {
            _gradientUnits = SVGGradientUnit.UserSpaceOnUse;
        }

        //------
        // TODO: It's probably a bug that the value is not innoculated for CaSe
        // VaRiAtIoN in GetValue, below:
        _spreadMethod = SVGSpreadMethod.Pad;
        if (_attrList.GetValue("spreadMethod") == "reflect")
        {
            _spreadMethod = SVGSpreadMethod.Reflect;
        }
        else if (_attrList.GetValue("spreadMethod") == "repeat")
        {
            _spreadMethod = SVGSpreadMethod.Repeat;
        }

        GetElementList();
    }
开发者ID:grrava,项目名称:UnitySVG,代码行数:27,代码来源:SVGGradientElement.cs

示例3: GetValueTest

		public void GetValueTest()
		{
			var d = new Dictionary<int?, string> { { 1, "a" } };

			AssertSome(d.GetValue(1), "a");
			AssertNothing(d.GetValue(2));
			AssertNothing(d.GetValue(null));
		}
开发者ID:pavel-drobushevich,项目名称:Tp.Core.Functional,代码行数:8,代码来源:DictionaryExtensionsTests.cs

示例4: ReturnsNullableValue

        public void ReturnsNullableValue()
        {
            var dict = new Dictionary<Type, string>() {{typeof(int), "1"}, {typeof(double), "2.0"}};

            Assert.Equal("1", dict.GetValue(typeof(int)));
            Assert.Equal(null, dict.GetValue(typeof(string)));

        }
开发者ID:etkirsch,项目名称:NetDiff,代码行数:8,代码来源:DictionaryGetValue.cs

示例5: SVGCircleElement

    public SVGCircleElement(Dictionary<string, string> attrList,
		SVGTransformList inheritTransformList,
		SVGPaintable inheritPaintable,
		SVGGraphics render)
        : base(attrList, inheritTransformList, inheritPaintable, render)
    {
        _cx = new SVGLength(attrList.GetValue("cx"));
        _cy = new SVGLength(attrList.GetValue("cy"));
        _r = new SVGLength(attrList.GetValue("r"));
    }
开发者ID:grrava,项目名称:UnitySVG,代码行数:10,代码来源:SVGCircleElement.cs

示例6: SetValue

 public void SetValue()
 {
     IDictionary<string, int> Test = new Dictionary<string, int>();
     Test.Add("Q", 4);
     Test.Add("Z", 2);
     Test.Add("C", 3);
     Test.Add("A", 1);
     Assert.Equal(4, Test.GetValue("Q"));
     Test.SetValue("Q", 40);
     Assert.Equal(40, Test.GetValue("Q"));
 }
开发者ID:AngelMarquez,项目名称:Craig-s-Utility-Library,代码行数:11,代码来源:IDictionaryExtensions.cs

示例7: SVGStopElement

 public SVGStopElement(Dictionary<string, string> attrList)
 {
     _stopColor = new SVGColor(attrList.GetValue("stop-color"));
     string temp = attrList.GetValue("offset").Trim();
     if(temp != "") {
       if(temp.EndsWith("%"))
     _offset = float.Parse(temp.TrimEnd(new[] { '%' }), System.Globalization.CultureInfo.InvariantCulture);
       else
     _offset = float.Parse(temp, System.Globalization.CultureInfo.InvariantCulture) * 100;
     }
 }
开发者ID:MrJoy,项目名称:UnitySVG,代码行数:11,代码来源:SVGStopElement.cs

示例8: GetValue

 public void GetValue()
 {
     IDictionary<string, int> Test = new Dictionary<string, int>();
     Test.Add("Q", 4);
     Test.Add("Z", 2);
     Test.Add("C", 3);
     Test.Add("A", 1);
     Assert.Equal(4, Test.GetValue("Q"));
     Assert.Equal(0, Test.GetValue("V"));
     Assert.Equal(123, Test.GetValue("B", 123));
 }
开发者ID:AngelMarquez,项目名称:Craig-s-Utility-Library,代码行数:11,代码来源:IDictionaryExtensions.cs

示例9: SVGEllipseElement

 public SVGEllipseElement(Dictionary<string, string> attrList,
                        SVGTransformList inheritTransformList,
                        SVGPaintable inheritPaintable,
                        SVGGraphics render)
     : base(attrList, inheritTransformList, inheritPaintable, render)
 {
     _cx = new SVGLength(attrList.GetValue("cx"));
     _cy = new SVGLength(attrList.GetValue("cy"));
     _rx = new SVGLength(attrList.GetValue("rx"));
     _ry = new SVGLength(attrList.GetValue("ry"));
     currentTransformList = new SVGTransformList(attrList.GetValue("transform"));
 }
开发者ID:MrJoy,项目名称:UnitySVG,代码行数:12,代码来源:SVGEllipseElement.cs

示例10: GetValue

        public void GetValue()
        {
            var d = new Dictionary<int, int>
                {
                    {1, 2}
                };
            Assert.AreEqual(2, d.GetValue(1, 0));
            Assert.AreEqual(0, d.GetValue(2, 0));

            Assert.AreEqual(Maybe<int>.Empty, d.GetValue(10));
            Assert.AreEqual(2, d.GetValue(1).Value);
        }
开发者ID:pocheptsov,项目名称:lokad-shared-libraries,代码行数:12,代码来源:ExtendIDictionaryTests.cs

示例11: SVGLineElement

 public SVGLineElement(Dictionary<string, string> attrList,
                     SVGTransformList inheritTransformList,
                     SVGPaintable inheritPaintable,
                     SVGGraphics render)
     : base(inheritTransformList)
 {
     _paintable = new SVGPaintable(inheritPaintable, attrList);
     _render = render;
     _x1 = new SVGLength(attrList.GetValue("x1"));
     _y1 = new SVGLength(attrList.GetValue("y1"));
     _x2 = new SVGLength(attrList.GetValue("x2"));
     _y2 = new SVGLength(attrList.GetValue("y2"));
 }
开发者ID:MrJoy,项目名称:UnitySVG,代码行数:13,代码来源:SVGLineElement.cs

示例12: Cookie

 internal Cookie(RemoteSession session, Dictionary dict) {
     _session = session;
     try {
         _name = dict.GetValue("name", string.Empty);
         _value = dict.GetValue("value", string.Empty);
         _path = dict.GetValue("path", string.Empty);
         _domain = dict.GetValue("domain", string.Empty);
         _secure = Convert.ToBoolean(dict.Get("secure", false));
         _expiry = Convert.ToDouble(dict.Get("expiry", 0));
     } catch (Errors.KeyNotFoundError ex) {
         throw new DeserializeException(typeof(Cookie), ex);
     } catch (Exception ex) {
         throw new SeleniumException(ex);
     }
 }
开发者ID:thomb1,项目名称:SeleniumBasic,代码行数:15,代码来源:Cookie.cs

示例13: PropertiesFromMap

        public static ArchiveProperties PropertiesFromMap(Dictionary<string, string> properties)
        {
            Contract.Requires(properties != null);

            var result = new ArchiveProperties { Name = properties.GetValue("Path") };
            if (string.IsNullOrEmpty(result.Name)) {
                throw new ArgumentException("Archive properties do not contain path.", nameof(properties));
            }

            result.Type = Archive.StringToType(properties.GetValue("Type"));
            result.Size = SevenZipTools.LongFromString(properties.GetValue("Size"));
            result.PhysicalSize = SevenZipTools.LongFromString(properties.GetValue("Physical Size"));
            result.TotalPhysicalSize = SevenZipTools.LongFromString(properties.GetValue("Total Physical Size"));
            return result;
        }
开发者ID:EnoughTea,项目名称:arcomp,代码行数:15,代码来源:SevenZipArchiveListing.cs

示例14: VarietyPairSurrogate

 public VarietyPairSurrogate(VarietyPair vp)
 {
     Variety1 = vp.Variety1.Name;
     Variety2 = vp.Variety2.Name;
     var wordPairSurrogates = new Dictionary<WordPair, WordPairSurrogate>();
     _wordPairs = vp.WordPairs.Select(wp => wordPairSurrogates.GetValue(wp, () => new WordPairSurrogate(wp))).ToList();
     PhoneticSimilarityScore = vp.PhoneticSimilarityScore;
     LexicalSimilarityScore = vp.LexicalSimilarityScore;
     DefaultSoundCorrespondenceProbability = vp.DefaultSoundCorrespondenceProbability;
     _cognateSoundCorrespondenceFrequencyDistribution = new Dictionary<SoundContextSurrogate, Tuple<string[], int>[]>();
     foreach (SoundContext lhs in vp.CognateSoundCorrespondenceFrequencyDistribution.Conditions)
     {
         FrequencyDistribution<Ngram<Segment>> freqDist = vp.CognateSoundCorrespondenceFrequencyDistribution[lhs];
         _cognateSoundCorrespondenceFrequencyDistribution[new SoundContextSurrogate(lhs)] = freqDist.ObservedSamples.Select(ngram => Tuple.Create(ngram.Select(seg => seg.StrRep).ToArray(), freqDist[ngram])).ToArray();
     }
     _cognateSoundCorrespondenceByPosition = new Dictionary<string, List<SoundCorrespondenceSurrogate>>();
     foreach (KeyValuePair<FeatureSymbol, SoundCorrespondenceCollection> kvp in vp.CognateSoundCorrespondencesByPosition)
     {
         string pos;
         if (kvp.Key == CogFeatureSystem.Onset)
             pos = "onset";
         else if (kvp.Key == CogFeatureSystem.Nucleus)
             pos = "nucleus";
         else
             pos = "coda";
         _cognateSoundCorrespondenceByPosition[pos] = kvp.Value.Select(corr => new SoundCorrespondenceSurrogate(wordPairSurrogates, corr)).ToList();
     }
 }
开发者ID:sillsdev,项目名称:cog,代码行数:28,代码来源:VarietyPairSurrogate.cs

示例15: GetValue_Absent_Empty

        public void GetValue_Absent_Empty()
        {
            var dictiionary = new Dictionary<string, int> { { "A", 1 } };
            Option<int> item = dictiionary.GetValue("B");

            Assert.False(item.HasValue);
        }
开发者ID:blake2002,项目名称:Nelibur,代码行数:7,代码来源:DictionaryExtensionsTests.cs


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