本文整理汇总了C#中StringDictionary类的典型用法代码示例。如果您正苦于以下问题:C# StringDictionary类的具体用法?C# StringDictionary怎么用?C# StringDictionary使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
StringDictionary类属于命名空间,在下文中一共展示了StringDictionary类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BindCountries
/// <summary>
/// Binds the country dropdown list with countries retrieved
/// from the .NET Framework.
/// </summary>
public void BindCountries()
{
StringDictionary dic = new StringDictionary();
List<string> col = new List<string>();
foreach (CultureInfo ci in CultureInfo.GetCultures(CultureTypes.SpecificCultures))
{
RegionInfo ri = new RegionInfo(ci.Name);
if (!dic.ContainsKey(ri.EnglishName))
dic.Add(ri.EnglishName, ri.TwoLetterISORegionName.ToLowerInvariant());
if (!col.Contains(ri.EnglishName))
col.Add(ri.EnglishName);
}
// Add custom cultures
if (!dic.ContainsValue("bd"))
{
dic.Add("Bangladesh", "bd");
col.Add("Bangladesh");
}
col.Sort();
ddlCountry.Items.Add(new ListItem("[Not specified]", ""));
foreach (string key in col)
{
ddlCountry.Items.Add(new ListItem(key, dic[key]));
}
SetDefaultCountry();
}
示例2: SharedDataObjectBase
//public StringHashTable WildVars;
//the following fields stores only default settings used for the simulation, so there is no need to change them after parsing.
//public FairnessType FairnessType;
//public bool CalculateParticipatingProcess;
//public bool TimedRefinementAssertion;
//public int TimedRefinementClockCeiling;
//public int TimedRefinementClockFloor;
//public CSPDataStore DataManager;
public SharedDataObjectBase()
{
//DataManager = new CSPDataStore();
//AlphaDatabase = new Dictionary<string, EventCollection>(8);
VariableLowerBound = new StringDictionary<int>(8);
VariableUpperLowerBound = new StringDictionary<int>(8);
ValutionHashTable = new StringDictionary<string>(Ultility.Ultility.MC_INITIAL_SIZE);
SyncrhonousChannelNames = new List<string>();
HasSyncrhonousChannel = false;
HasAtomicEvent = false;
//TimedRefinementAssertion = false;
CSharpMethods = new Dictionary<string, System.Reflection.MethodInfo>();
CSharpDataType = new Dictionary<string, Type>();
//MacroDefinition = new Dictionary<string, KeyValuePair<List<string>, Expression>>();
//FairnessType = FairnessType.NO_FAIRNESS;
//CalculateParticipatingProcess = false;
//CalculateCreatedProcess = false;
//TimedRefinementClockCeiling = Common.Classes.Ultility.Ultility.TIME_REFINEMENT_CLOCK_CEILING;
//TimedRefinementClockFloor = Common.Classes.Ultility.Ultility.TIME_REFINEMENT_CLOCK_FLOOR;
LocalVars = null;
//WildVars = null;
}
示例3: Add
public void Add()
{
int count = 10;
StringDictionary stringDictionary = new StringDictionary();
for (int i = 0; i < count; i++)
{
string key = "Key_" + i;
string value = "Value_" + i;
stringDictionary.Add(key, value);
Assert.Equal(i + 1, stringDictionary.Count);
Assert.True(stringDictionary.ContainsKey(key));
Assert.True(stringDictionary.ContainsValue(value));
Assert.Equal(value, stringDictionary[key]);
}
Assert.False(stringDictionary.ContainsValue(null));
stringDictionary.Add("nullkey", null);
Assert.Equal(count + 1, stringDictionary.Count);
Assert.True(stringDictionary.ContainsKey("nullkey"));
Assert.True(stringDictionary.ContainsValue(null));
Assert.Null(stringDictionary["nullkey"]);
}
示例4: GetResponseText
public override async Task<string> GetResponseText(Uri uri, StringDictionary headers)
{
using (HttpClient client = new HttpClient(new HttpClientHandler() { AutomaticDecompression = System.Net.DecompressionMethods.Deflate | System.Net.DecompressionMethods.GZip }))
{
if (Timeout > 0)
client.Timeout = TimeSpan.FromMilliseconds(Timeout);
else
client.Timeout = TimeSpan.FromMilliseconds(DefaultTimeout);
if (headers != null)
{
foreach (var header in headers)
client.DefaultRequestHeaders.Add(header.Key, header.Value);
}
try
{
return await client.GetStringAsync(uri);
}
catch (HttpRequestException ex)
{
throw new WebRequestException(ex.Message, ex);
}
catch (TaskCanceledException ex)
{
throw new WebRequestException("The request timed out.", ex);
}
}
}
示例5: ContainsValue_DuplicateValues
public void ContainsValue_DuplicateValues(string value)
{
StringDictionary stringDictionary = new StringDictionary();
stringDictionary.Add("key1", value);
stringDictionary.Add("key2", value);
Assert.True(stringDictionary.ContainsValue(value));
}
示例6: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
SettingsPropertyCollection profileProperties = ProfileCommon.Properties;
string[] settings;
ArrayList keys = new ArrayList();
ArrayList alias = new ArrayList();
ArrayList name = new ArrayList();
foreach (SettingsProperty prop in profileProperties)
{
if (prop.Attributes["CustomProviderData"].ToString() != "None")
{
settings = prop.Attributes["CustomProviderData"].ToString().Split(';');
name.Add(settings[1] + prop.Name);
alias.Add(settings[1] + settings[0]);
}
}
name.Sort();
alias.Sort();
ArrayList name1 = ArrayList.Repeat("", name.Count);
foreach (String item in name) name1[name.IndexOf(item)] = item.Substring(1);
ArrayList alias1 = ArrayList.Repeat("", alias.Count);
foreach (String item in alias) alias1[alias.IndexOf(item)] = item.Substring(1);
int n = 0;
StringDictionary properties = new StringDictionary();
foreach (string item in name1) { properties[item] = alias1[n].ToString(); n++; }
rptProfile.DataSource = properties;
rptProfile.DataBind();
}
示例7: UserCommandMessage
public UserCommandMessage(StringDictionary StringResources, MessageDirection Direction, byte[] Buffer, int StartIndex = 0)
: base ()
{
this.TransferDirection = Direction;
this.StringResources = StringResources;
ReadFrom(Buffer, StartIndex);
}
示例8: ContainsValue_IsCaseSensitive
public void ContainsValue_IsCaseSensitive()
{
StringDictionary stringDictionary = new StringDictionary();
stringDictionary.Add("key", "value");
Assert.False(stringDictionary.ContainsValue("VALUE"));
Assert.False(stringDictionary.ContainsValue("vaLue"));
Assert.True(stringDictionary.ContainsValue("value"));
}
示例9: Item_Get_IsCaseInsensitive
public void Item_Get_IsCaseInsensitive()
{
StringDictionary stringDictionary = new StringDictionary();
stringDictionary.Add("key", "value");
Assert.Equal("value", stringDictionary["KEY"]);
Assert.Equal("value", stringDictionary["kEy"]);
Assert.Equal("value", stringDictionary["key"]);
}
示例10: ContainsKey_IsCaseInsensitive
public void ContainsKey_IsCaseInsensitive()
{
StringDictionary stringDictionary = new StringDictionary();
stringDictionary.Add("key", "value");
Assert.True(stringDictionary.ContainsKey("KEY"));
Assert.True(stringDictionary.ContainsKey("kEy"));
Assert.True(stringDictionary.ContainsKey("key"));
}
示例11: PIDecoder
/// <summary>
/// Constructor
/// </summary>
/// <param name="StringResources">A threadsafe dictionary used to resolve Meridian Strings from.</param>
public PIDecoder(StringDictionary StringResources)
{
this.stringResources = StringResources;
if (StringResources == null)
stringBytes = Encoding.Default.GetBytes(FALLBACKSTRING);
Reset();
}
示例12: PIEncoder
/// <summary>
/// Constructor
/// </summary>
/// <param name="StringResources">A threadsafe dictionary used to resolve Meridian Strings from.</param>
public PIEncoder(StringDictionary StringResources)
{
this.stringResources = StringResources;
if (StringResources == null)
hashString = Encoding.Default.GetBytes(StaticFallbackHashString);
Reset();
}
示例13: Item_Set_IsCaseInsensitive
public void Item_Set_IsCaseInsensitive()
{
StringDictionary stringDictionary = new StringDictionary();
stringDictionary["KEY"] = "value1";
stringDictionary["kEy"] = "value2";
stringDictionary["key"] = "value3";
Assert.Equal(1, stringDictionary.Count);
Assert.Equal("value3", stringDictionary["key"]);
}
示例14: RenderPosts
private string RenderPosts(List<Post> posts, StringDictionary settings)
{
if (posts.Count == 0)
{
//HttpRuntime.Cache.Insert("widget_recentposts", "<p>" + Resources.labels.none + "</p>");
return "<p>" + Resources.labels.none + "</p>";
}
StringBuilder sb = new StringBuilder();
sb.Append("<ul class=\"recentPosts\" id=\"recentPosts\">");
bool showComments = DEFAULT_SHOW_COMMENTS;
bool showRating = DEFAULT_SHOW_RATING;
if (settings.ContainsKey("showcomments"))
{
bool.TryParse(settings["showcomments"], out showComments);
}
if (settings.ContainsKey("showrating"))
{
bool.TryParse(settings["showrating"], out showRating);
}
foreach (Post post in posts)
{
if (!post.IsVisibleToPublic)
continue;
string rating = Math.Round(post.Rating, 1).ToString(System.Globalization.CultureInfo.InvariantCulture);
string link = "<li><a href=\"{0}\">{1}</a>{2}{3}</li>";
string comments = string.Format("<span>{0}: {1}</span>", Resources.labels.comments, post.ApprovedComments.Count);
if(BlogSettings.Instance.ModerationType == BlogSettings.Moderation.Disqus)
comments = string.Format("<span><a href=\"{0}#disqus_thread\">{1}</a></span>", post.PermaLink, Resources.labels.comments);
string rate = string.Format("<span>{0}: {1} / {2}</span>", Resources.labels.rating, rating, post.Raters);
if (!showComments || !BlogSettings.Instance.IsCommentsEnabled)
comments = null;
if (!showRating || !BlogSettings.Instance.EnableRating)
rate = null;
if (post.Raters == 0)
rating = Resources.labels.notRatedYet;
sb.AppendFormat(link, post.RelativeLink, HttpUtility.HtmlEncode(post.Title), comments, rate);
}
sb.Append("</ul>");
//HttpRuntime.Cache.Insert("widget_recentposts", sb.ToString());
return sb.ToString();
}
示例15: CreateStringDictionary
public static StringDictionary CreateStringDictionary(int count)
{
StringDictionary stringDictionary = new StringDictionary();
for (int i = 0; i < count; i++)
{
stringDictionary.Add("Key_" + i, "Value_" + i);
}
return stringDictionary;
}