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


C# Collections.DictionaryEntry类代码示例

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


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

示例1: BuildSerializer

        public override ValueSerializer BuildSerializer(Serializer serializer, Type type,
            ConcurrentDictionary<Type, ValueSerializer> typeMapping)
        {
            var ser = new ObjectSerializer(type);
            typeMapping.TryAdd(type, ser);
            var elementSerializer = serializer.GetSerializerByType(typeof (DictionaryEntry));

            ValueReader reader = (stream, session) =>
            {
                var count = stream.ReadInt32(session);
                var entries = new DictionaryEntry[count];
                for (var i = 0; i < count; i++)
                {
                    var entry = (DictionaryEntry) stream.ReadObject(session);
                    entries[i] = entry;
                }
                return null;
            };

            ValueWriter writer = (stream, obj, session) =>
            {
                var dict = obj as IDictionary;
                // ReSharper disable once PossibleNullReferenceException
                stream.WriteInt32(dict.Count);
                foreach (var item in dict)
                {
                    stream.WriteObject(item, typeof (DictionaryEntry), elementSerializer,
                        serializer.Options.PreserveObjectReferences, session);
                    // elementSerializer.WriteValue(stream,item,session);
                }
            };
            ser.Initialize(reader, writer);
            
            return ser;
        }
开发者ID:philiplaureano,项目名称:Wire,代码行数:35,代码来源:DictionarySerializerFactory.cs

示例2: SetSessionStateItem

        internal override void SetSessionStateItem(string path, object value, bool writeItem)
        {
            Path name = PathIntrinsics.RemoveDriveName(path);
            path = name.TrimStartSlash();

            if (value == null)
            {
                Environment.SetEnvironmentVariable(path, null);
            }
            else
            {
                if (value is DictionaryEntry)
                {
                    value = ((DictionaryEntry)value).Value;
                }
                string str = value as string;
                if (str == null)
                {
                    str = PSObject.AsPSObject(value).ToString();
                }
                Environment.SetEnvironmentVariable(path, str);
                DictionaryEntry item = new DictionaryEntry(path, str);
                if (writeItem)
                {
                    WriteItemObject(item, path, false);
                }
            }
        }
开发者ID:mauve,项目名称:Pash,代码行数:28,代码来源:EnvironmentProvider.cs

示例3: BasicTests

		private void BasicTests (ListDictionary ld)
		{
			Assert.AreEqual (0, ld.Count, "Count");
			Assert.IsFalse (ld.IsFixedSize, "IsFixedSize");
			Assert.IsFalse (ld.IsReadOnly, "IsReadOnly");
			Assert.IsFalse (ld.IsSynchronized, "IsSynchronized");
			Assert.AreEqual (0, ld.Keys.Count, "Keys");
			Assert.AreEqual (0, ld.Values.Count, "Values");
			Assert.IsNotNull (ld.SyncRoot, "SyncRoot");
			Assert.IsNotNull (ld.GetEnumerator (), "GetEnumerator");
			Assert.IsNotNull ((ld as IEnumerable).GetEnumerator (), "IEnumerable.GetEnumerator");

			ld.Add ("a", "1");
			Assert.AreEqual (1, ld.Count, "Count-1");
			Assert.IsTrue (ld.Contains ("a"), "Contains(a)");
			Assert.IsFalse (ld.Contains ("1"), "Contains(1)");

			ld.Add ("b", null);
			Assert.AreEqual (2, ld.Count, "Count-2");
			Assert.IsNull (ld["b"], "this[b]");

			DictionaryEntry[] entries = new DictionaryEntry[2];
			ld.CopyTo (entries, 0);

			ld["b"] = "2";
			Assert.AreEqual ("2", ld["b"], "this[b]2");

			ld.Remove ("b");
			Assert.AreEqual (1, ld.Count, "Count-3");
			ld.Clear ();
			Assert.AreEqual (0, ld.Count, "Count-4");
		}
开发者ID:nlhepler,项目名称:mono,代码行数:32,代码来源:ListDictionaryTest.cs

示例4: ChangeProviderFactory

        private void ChangeProviderFactory(DictionaryEntry i)
        {
            var valueField = i.Value.GetType().GetField("_value", BindingFlags.NonPublic | BindingFlags.Instance);
            if (valueField != null)
            {
                var value = valueField.GetValue(i.Value);
                var workspaceField = value.GetType().GetField("_workspace", BindingFlags.NonPublic | BindingFlags.Instance);
                if (workspaceField != null)
                {
                    var workspace = workspaceField.GetValue(value);
                    var metadataWorkspaceField = workspace.GetType().GetField("_metadataWorkspace", BindingFlags.NonPublic | BindingFlags.Instance);
                    if (metadataWorkspaceField != null)
                    {
                        var metadataWorkspace = metadataWorkspaceField.GetValue(workspace);
                        var itemsSSpaceField = metadataWorkspace.GetType().GetField("_itemsSSpace", BindingFlags.NonPublic | BindingFlags.Instance);

                        if (itemsSSpaceField != null)
                        {
                            var itemsSSpace = itemsSSpaceField.GetValue(metadataWorkspace);
                            var providerFactoryField = itemsSSpace.GetType().GetField("_providerFactory", BindingFlags.NonPublic | BindingFlags.Instance);

                            if (providerFactoryField != null)
                            {
                                var providerFactory = providerFactoryField.GetValue(itemsSSpace);

                                providerFactoryField.SetValue(itemsSSpace, Activator.CreateInstance(GetProxyTypeForProvider(providerFactory.GetType())));
                            }
                        }
                    }
                }
            }
        }
开发者ID:sperling,项目名称:Glimpse,代码行数:32,代码来源:WrapCachedMetadata.cs

示例5: ReadDictionaryEventArgs

 /// <summary>
 /// 实例化
 /// </summary>
 /// <param name="value">对象</param>
 /// <param name="keyType">键类型</param>
 /// <param name="valueType">值类型</param>
 /// <param name="index"></param>
 /// <param name="callback"></param>
 public ReadDictionaryEventArgs(DictionaryEntry value, Type keyType,Type valueType, Int32 index, ReadObjectCallback callback)
     : base(index, callback)
 {
     Value = value;
     KeyType = keyType;
     ValueType = valueType;
 }
开发者ID:windygu,项目名称:asxinyunet,代码行数:15,代码来源:ReadDictionaryEventArgs.cs

示例6: AddressChangedCallback

 private static void AddressChangedCallback(object stateObject, bool signaled)
 {
     lock (s_callerArray)
     {
         s_isPending = false;
         if (s_isListening)
         {
             s_isListening = false;
             DictionaryEntry[] array = new DictionaryEntry[s_callerArray.Count];
             s_callerArray.CopyTo(array, 0);
             StartHelper(null, false, (StartIPOptions) stateObject);
             for (int i = 0; i < array.Length; i++)
             {
                 NetworkAddressChangedEventHandler key = (NetworkAddressChangedEventHandler) array[i].Key;
                 ExecutionContext context = (ExecutionContext) array[i].Value;
                 if (context == null)
                 {
                     key(null, EventArgs.Empty);
                 }
                 else
                 {
                     ExecutionContext.Run(context.CreateCopy(), s_runHandlerCallback, key);
                 }
             }
         }
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:27,代码来源:NetworkChange.cs

示例7: nextEntry

		internal DictionaryEntry nextEntry() {
			DictionaryEntry cEntry = entry;
			hasMore = enum_Renamed.MoveNext();
			if (hasMore)
				entry = enum_Renamed.Entry;
			return cEntry;
		}
开发者ID:Belxjander,项目名称:Asuna,代码行数:7,代码来源:SearchId.cs

示例8: Ctor

		public void Ctor () {

			DictionaryEntry d = new DictionaryEntry (1, "something");
			AssertNotNull (d);
			AssertEquals ("#01", d.Key, 1);
			AssertEquals ("#02", d.Value, "something");
		}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:7,代码来源:DictionaryEntryTest.cs

示例9: foreach

		public object this[object key]
		{
			get {
				if (_extraData == null) return null;

				foreach (DictionaryEntry entry in _extraData)
					if (entry.Key.Equals (key)) return entry.Value;

				return null;
			}

			set {
				if (_extraData == null)
				{
					_extraData = new DictionaryEntry [] { new DictionaryEntry (key, value) };
				}
				else
				{
					DictionaryEntry[] tmpData = new DictionaryEntry [_extraData.Length + 1];
					_extraData.CopyTo (tmpData, 0);
					tmpData [_extraData.Length] = new DictionaryEntry (key, value);
					_extraData = tmpData;
				}
			}
		}
开发者ID:KonajuGames,项目名称:SharpLang,代码行数:25,代码来源:ChannelDataStore.cs

示例10: GetPages

        public CascadingDropDownNameValue[] GetPages(string knownCategoryValues, string category)
        {
            AnswerApp.Models.AnswerAppDataContext db = new AnswerApp.Models.AnswerAppDataContext();

            StringDictionary knownCatagories = CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues);
            DictionaryEntry[] CatagoryArray = new DictionaryEntry[knownCatagories.Count];
            knownCatagories.CopyTo(CatagoryArray, 0);
            String SelectedSection = "Error 1";
            foreach (DictionaryEntry theEntry in CatagoryArray)
            {
                if (theEntry.Key.ToString().Equals("section"))
                {
                    SelectedSection = theEntry.Value.ToString();
                }
            }

            IQueryable<AnswerApp.Models.Page> retrieved = from theAnswers in db.Pages
                                                              where theAnswers.Section_Title.Equals(SelectedSection)//Textbook_Title)
                                                              select theAnswers;
            AnswerApp.Models.Page[] results = retrieved.ToArray<AnswerApp.Models.Page>();
            List<CascadingDropDownNameValue> theList = new List<CascadingDropDownNameValue>();
            foreach (AnswerApp.Models.Page thePage in results)
            {
                theList.Add(new CascadingDropDownNameValue(thePage.Page_Number, thePage.Page_Number));
            }
            return theList.ToArray();
        }
开发者ID:HoldFast,项目名称:AnswerApp,代码行数:27,代码来源:SelectionWebService.asmx.cs

示例11: All

		public void All ()
		{
			HybridDictionary dict = new HybridDictionary (true);
			dict.Add ("CCC", "ccc");
			dict.Add ("BBB", "bbb");
			dict.Add ("fff", "fff");
			dict ["EEE"] = "eee";
			dict ["ddd"] = "ddd";
			
			Assert.AreEqual (5, dict.Count, "#1");
			Assert.AreEqual ("eee", dict["eee"], "#2");
			
			dict.Add ("CCC2", "ccc");
			dict.Add ("BBB2", "bbb");
			dict.Add ("fff2", "fff");
			dict ["EEE2"] = "eee";
			dict ["ddd2"] = "ddd";
			dict ["xxx"] = "xxx";
			dict ["yyy"] = "yyy";

			Assert.AreEqual (12, dict.Count, "#3");
			Assert.AreEqual ("eee", dict["eee"], "#4");

			dict.Remove ("eee");
			Assert.AreEqual (11, dict.Count, "Removed/Count");
			Assert.IsFalse (dict.Contains ("eee"), "Removed/Contains(xxx)");
			DictionaryEntry[] entries = new DictionaryEntry [11];
			dict.CopyTo (entries, 0);

			Assert.IsTrue (dict.Contains ("xxx"), "Contains(xxx)");
			dict.Clear ();
			Assert.AreEqual (0, dict.Count, "Cleared/Count");
			Assert.IsFalse (dict.Contains ("xxx"), "Cleared/Contains(xxx)");
		}
开发者ID:Profit0004,项目名称:mono,代码行数:34,代码来源:HybridDictionaryTest.cs

示例12: button1_Click

        private void button1_Click(object sender, EventArgs e)
        {
            List<DictionaryEntry> list = new List<DictionaryEntry>();
            DataSet dsData = new DataSet();

            dsData.ReadXml(@"..\..\..\..\..\..\Data\Orders.xml");

            //Create word document
            Document document = new Document();
            document.LoadFromFile(@"..\..\..\..\..\..\Data\Invoice.doc");

            DictionaryEntry dictionaryEntry = new DictionaryEntry("Customer", string.Empty);
            list.Add(dictionaryEntry);

            dictionaryEntry = new DictionaryEntry("Order", "Customer_Id = %Customer.Customer_Id%");
            list.Add(dictionaryEntry);

            document.MailMerge.ExecuteWidthNestedRegion(dsData, list);

            //Save doc file.
            document.SaveToFile("Sample.doc", FileFormat.Doc);

            //Launching the MS Word file.
            WordDocViewer("Sample.doc");
        }
开发者ID:spirecomponent,项目名称:Word-Library,代码行数:25,代码来源:Form1.cs

示例13: Add

 public void Add(object key, object value)
 {
     // Add the new key/value pair even if this key already exists in the dictionary. 
     if (ItemsInUse == items.Length)
         throw new InvalidOperationException("The dictionary cannot hold any more items.");
     items[ItemsInUse++] = new DictionaryEntry(key, value);
 }
开发者ID:wanggan768q,项目名称:litjson-portable,代码行数:7,代码来源:SimpleDictionary.cs

示例14: SetSessionStateItem

 internal override void SetSessionStateItem(string name, object value, bool writeItem)
 {
     if (value == null)
     {
         Environment.SetEnvironmentVariable(name, null);
     }
     else
     {
         if (value is DictionaryEntry)
         {
             value = ((DictionaryEntry)value).Value;
         }
         string str = value as string;
         if (str == null)
         {
             str = PSObject.AsPSObject(value).ToString();
         }
         Environment.SetEnvironmentVariable(name, str);
         DictionaryEntry item = new DictionaryEntry(name, str);
         if (writeItem)
         {
             WriteItemObject(item, name, false);
         }
     }
 }
开发者ID:JamesTryand,项目名称:Pash2,代码行数:25,代码来源:EnvironmentProvider.cs

示例15: Ctor

		public void Ctor () {

			DictionaryEntry d = new DictionaryEntry (1, "something");
			Assert.IsNotNull (d);
			Assert.AreEqual (1, d.Key, "#01");
			Assert.AreEqual ("something", d.Value, "#02");
		}
开发者ID:nlhepler,项目名称:mono,代码行数:7,代码来源:DictionaryEntryTest.cs


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