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


C# HybridDictionary.Add方法代码示例

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


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

示例1: Arguments

		// Constructor
		public Arguments(string[] Args){
			//Parameters=new StringDictionary();
			Parameters=new HybridDictionary();
			Regex Spliter=new Regex(@"^-{1,2}|^/|=|:", RegexOptions.IgnoreCase|RegexOptions.Compiled);
			Regex Remover= new Regex(@"^['""]?(.*?)['""]?$", RegexOptions.IgnoreCase|RegexOptions.Compiled);
			string Parameter=null;
			string[] Parts;

			// Valid parameters forms:
			// {-,/,--}param{ ,=,:}((",')value(",'))
			// Examples: -param1 value1 --param2 /param3:"Test-:-work" /param4=happy -param5 '--=nice=--'
			foreach(string Txt in Args){
				// Look for new parameters (-,/ or --) and a possible enclosed value (=,:)
				Parts=Spliter.Split(Txt,3);
				switch(Parts.Length){
					// Found a value (for the last parameter found (space separator))
					case 1:
						if(Parameter!=null){
							if(!Parameters.Contains(Parameter)){
								Parts[0]=Remover.Replace(Parts[0],"$1");
								Parameters.Add(Parameter,Parts[0]);
								}
							Parameter=null;
							}
						// else Error: no parameter waiting for a value (skipped)
						break;
					// Found just a parameter
					case 2:
						// The last parameter is still waiting. With no value, set it to true.
						if(Parameter!=null){
							if(!Parameters.Contains(Parameter)) Parameters.Add(Parameter,"true");
							}
						Parameter=Parts[1];
						break;
					// Parameter with enclosed value
					case 3:
						// The last parameter is still waiting. With no value, set it to true.
						if(Parameter!=null){
							if(!Parameters.Contains(Parameter)) Parameters.Add(Parameter,"true");
							}
						Parameter=Parts[1];
						// Remove possible enclosing characters (",')
						if(!Parameters.Contains(Parameter)){
							Parts[2]=Remover.Replace(Parts[2],"$1");
							Parameters.Add(Parameter,Parts[2]);
							}
						Parameter=null;
						break;
					}
				}
			// In case a parameter is still waiting
			if(Parameter!=null){
				if(!Parameters.Contains(Parameter)) Parameters.Add(Parameter,"true");
				}
			}
开发者ID:kodenine,项目名称:SubWriter,代码行数:56,代码来源:Arguments.cs

示例2: Main

        static void Main(string[] args)
        {
            HybridDictionary hb = new HybridDictionary();

            hb.Add("M", "Male");
            hb.Add("S", "Scot");
            hb.Add("F", "Female");

            Console.WriteLine("M:{0}", hb["S"]);

            Console.ReadKey();
        }
开发者ID:Kristijan10048,项目名称:diplomska,代码行数:12,代码来源:Program.cs

示例3: WebPartDescriptionCollection

        public WebPartDescriptionCollection(ICollection webPartDescriptions) {
            if (webPartDescriptions == null) {
                throw new ArgumentNullException("webPartDescriptions");
            }

            _ids = new HybridDictionary(webPartDescriptions.Count, true /* caseInsensitive */);
            foreach (object obj in webPartDescriptions) {
                if (obj == null) {
                    throw new ArgumentException(SR.GetString(SR.Collection_CantAddNull), "webPartDescriptions");
                }
                WebPartDescription description = obj as WebPartDescription;
                if (description == null) {
                    throw new ArgumentException(SR.GetString(SR.Collection_InvalidType, "WebPartDescription"),
                                                "webPartDescriptions");
                }
                string id = description.ID;
                if (!_ids.Contains(id)) {
                    InnerList.Add(description);
                    _ids.Add(id, description);
                }
                else {
                    throw new ArgumentException(SR.GetString(SR.WebPart_Collection_DuplicateID, "WebPartDescription", id), "webPartDescriptions");
                }
            }
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:25,代码来源:WebPartDescriptionCollection.cs

示例4: BasicPropertiesWrapper

        public BasicPropertiesWrapper(IBasicProperties basicProperties)
        {
            ContentType = basicProperties.ContentType;
            ContentEncoding = basicProperties.ContentEncoding;
            DeliveryMode = basicProperties.DeliveryMode;
            Priority = basicProperties.Priority;
            CorrelationId = basicProperties.CorrelationId;
            ReplyTo = basicProperties.ReplyTo;
            Expiration = basicProperties.Expiration;
            MessageId = basicProperties.MessageId;
            Timestamp = basicProperties.Timestamp.UnixTime;
            Type = basicProperties.Type;
            UserId = basicProperties.UserId;
            AppId = basicProperties.AppId;
            ClusterId = basicProperties.ClusterId;

            if (basicProperties.IsHeadersPresent())
            {
                Headers = new HybridDictionary();
                foreach (DictionaryEntry header in basicProperties.Headers)
                {
                    Headers.Add(header.Key, header.Value);
                }
            }
        }
开发者ID:sovanesyan,项目名称:Burrow.NET,代码行数:25,代码来源:BurrowError.cs

示例5: Resolve

			public override object Resolve(IKernel kernel)
			{
				string key = null;
				var argument = arguments[0];

				if (arguments.Length == 2)
				{
					key = (string)argument;
					argument = arguments[1];
				}
				else if (argument is string)
				{
					return kernel.Resolve((string)argument, ComponentType);
				}

				if (argument is Uri)
				{
					argument = WcfEndpoint.At((Uri)argument);
				}

				var args = new HybridDictionary();
				args.Add(Guid.NewGuid().ToString(), argument);

				if (key == null)
				{
					return kernel.Resolve(ComponentType, args);
				}

				return kernel.Resolve(key, ComponentType, args);
			}
开发者ID:bwegman,项目名称:Castle.Facilities.Wcf,代码行数:30,代码来源:WcfClientFactorySelector.cs

示例6: ConsumerConnectionPointCollection

        public ConsumerConnectionPointCollection(ICollection connectionPoints) {
            if (connectionPoints == null) {
                throw new ArgumentNullException("connectionPoints");
            }

            _ids = new HybridDictionary(connectionPoints.Count, true /* caseInsensitive */);
            foreach (object obj in connectionPoints) {
                if (obj == null) {
                    throw new ArgumentException(SR.GetString(SR.Collection_CantAddNull), "connectionPoints");
                }
                ConsumerConnectionPoint point = obj as ConsumerConnectionPoint;
                if (point == null) {
                    throw new ArgumentException(SR.GetString(SR.Collection_InvalidType, "ConsumerConnectionPoint"),
                                                "connectionPoints");
                }
                string id = point.ID;
                if (!_ids.Contains(id)) {
                    InnerList.Add(point);
                    _ids.Add(id, point);
                }
                else {
                    throw new ArgumentException(SR.GetString(SR.WebPart_Collection_DuplicateID, "ConsumerConnectionPoint", id), "connectionPoints");
                }
            }
        }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:25,代码来源:ConsumerConnectionPointCollection.cs

示例7: BadgeComponent

 /// <summary>
 /// Initializes a new instance of the <see cref="BadgeComponent"/> class.
 /// </summary>
 /// <param name="userId">The user identifier.</param>
 /// <param name="data">The data.</param>
 internal BadgeComponent(uint userId, UserData data)
 {
     BadgeList = new HybridDictionary();
     foreach (var current in data.Badges.Where(current => !BadgeList.Contains(current.Code)))
         BadgeList.Add(current.Code, current);
     _userId = userId;
 }
开发者ID:BjkGkh,项目名称:Azure2,代码行数:12,代码来源:BadgeComponent.cs

示例8: AnalyzeEnum

		private void AnalyzeEnum( Type enumType )
		{
			_enumName = enumType.Name;

			R.FieldInfo[] fieldInfos = enumType.GetFields( BindingFlags.Static | BindingFlags.Public );

			_namedValues = new HybridDictionary( fieldInfos.Length, false );
			_valuedNames = new HybridDictionary( fieldInfos.Length, false );

			foreach( R.FieldInfo fi in fieldInfos )
			{
				if( ( fi.Attributes & EnumField ) == EnumField )
				{
					string name = fi.Name;
					object value = fi.GetValue( null );

					Attribute[] attrs =
						Attribute.GetCustomAttributes( fi, typeof( XmlEnumAttribute ) );
					if( attrs.Length > 0 )
					{
						XmlEnumAttribute attr = (XmlEnumAttribute)attrs[0];
						name = attr.Name;
					}

					_namedValues.Add( name, value );
					if( !_valuedNames.Contains( value ))
						_valuedNames.Add( value, name );
				}
			}
		}
开发者ID:zanyants,项目名称:mvp.xml,代码行数:30,代码来源:EnumConverter.cs

示例9: NotEmpty

		public void NotEmpty () 
		{
			HybridDictionary hd = new HybridDictionary (true);
			hd.Add ("CCC", "ccc");
			AssertEquals ("Count", 1, hd.Count);
			Assert ("null", !hd.Contains (null));
		}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:7,代码来源:HybridDictionaryTest.cs

示例10: UI

        public UI(UIComponentGroup headGroup)
        {
            m_menuDictionary = new HybridDictionary(4, true);
            m_menuStack = new UIMenuStack();

            UIMenu menu = new UIMenu(headGroup);

            m_menuDictionary.Add(1, menu);
        }
开发者ID:JELGT2011,项目名称:A_Spire_to_Defend,代码行数:9,代码来源:UI.cs

示例11: MappingInternal

 protected virtual object MappingInternal(IStatementSetting statement, IDictionary dictionary, Type instanceType, object instance)
 {
     var parameters = new HybridDictionary { { typeof(IObjectMapper), dictionary } };
     if(instance != null) {
         parameters.Add(typeof(ObjectMapperExtender), instance);
     }
     var resultType = statement.ResultTypeName;
     return this.GetOrCreateObject(resultType, instanceType, parameters, x => ObjectMapper.RefectionMapping(x, dictionary));
 }
开发者ID:mer2,项目名称:devfx,代码行数:9,代码来源:ObjectMapperBase.cs

示例12: UserBadgeManager

        /// <summary>
        ///     Initializes a new instance of the <see cref="UserBadgeManager" /> class.
        /// </summary>
        /// <param name="userId">The user identifier.</param>
        /// <param name="data">The data.</param>
        internal UserBadgeManager(uint userId, UserData data)
        {
            BadgeList = new HybridDictionary();

            foreach (Badge current in data.Badges.Where(current => !BadgeList.Contains(current.Code)))
                BadgeList.Add(current.Code, current);

            _userId = userId;
        }
开发者ID:AngelRmz,项目名称:Yupi,代码行数:14,代码来源:UserBadgeManager.cs

示例13: DictionaryFromList

        // populate a dictionary from the given list
        private static HybridDictionary DictionaryFromList(Type[] types)
        {
            HybridDictionary dictionary = new HybridDictionary(types.Length);
            for (int i=0; i<types.Length; ++i)
            {
                dictionary.Add(types[i], null);
            }

            return dictionary;
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:11,代码来源:BaseHashHelper.cs

示例14: HybridDictionaryTest

        public void HybridDictionaryTest()
        {
            string methodName = "HybridDictionaryTest";
            string filePath = className + "." + methodName + ".xml";
            HybridDictionary hybridDictionary = new HybridDictionary();
            hybridDictionary.Add(1, "Aaron");
            hybridDictionary.Add(2, "Monica");
            hybridDictionary.Add(3, "Michelle");
            hybridDictionary.Add(4, "Michael");
            hybridDictionary.Add(5, "Nathan");

            FileStream fs = new FileStream(filePath, FileMode.Create);
            DictionarySerializer ds = new DictionarySerializer(hybridDictionary);
            XmlSerializer s = new XmlSerializer(typeof (DictionarySerializer));
            s.Serialize(fs, ds);
            fs.Close();

            FileStream fsopen = new FileStream(filePath, FileMode.Open);
            ds = (DictionarySerializer) s.Deserialize(fsopen);
            Console.WriteLine("Deserialized " + ds.dictionary.Count + " items");
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:21,代码来源:DictionarySerializerTest.cs

示例15: RemoveMailbox

		private IEnumerable<Mailbox> RemoveMailbox(IEnumerable<Mailbox> source, string email)
		{
			email = email.With(_ => _.Trim());
			var addresses = new HybridDictionary();
			if (!string.IsNullOrEmpty(email))
				foreach (Mailbox mailbox in MailboxList.Parse(email))
					if (!string.IsNullOrEmpty(mailbox.Address))
						addresses.Add(mailbox.Address.ToLower(), mailbox);
			foreach (Mailbox item in source)
				if (addresses.Count == 0 || !addresses.Contains(item.Address.ToLower()))
					yield return item;
		}
开发者ID:PavelMPD,项目名称:SimpleProjects,代码行数:12,代码来源:NotificationEmailProcessor.cs


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