本文整理汇总了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");
}
}
示例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();
}
示例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");
}
}
}
示例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);
}
}
}
示例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);
}
示例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");
}
}
}
示例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;
}
示例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 );
}
}
}
示例9: NotEmpty
public void NotEmpty ()
{
HybridDictionary hd = new HybridDictionary (true);
hd.Add ("CCC", "ccc");
AssertEquals ("Count", 1, hd.Count);
Assert ("null", !hd.Contains (null));
}
示例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);
}
示例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));
}
示例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;
}
示例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;
}
示例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");
}
示例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;
}