本文整理汇总了C#中System.Collections.Specialized.OrderedDictionary类的典型用法代码示例。如果您正苦于以下问题:C# OrderedDictionary类的具体用法?C# OrderedDictionary怎么用?C# OrderedDictionary使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
OrderedDictionary类属于System.Collections.Specialized命名空间,在下文中一共展示了OrderedDictionary类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PrintDictionary
private void PrintDictionary(OrderedDictionary dic)
{
foreach (DictionaryEntry entry in dic)
{
Output.WriteLine("{0}-{1}", entry.Key, entry.Value);
}
}
示例2: languageSearchSettings
public virtual IEnumerable languageSearchSettings()
{
var cache = LanguageSearchSettings.Cache;
var oldDirtyValue = cache.IsDirty;
foreach (PXResult<SMLanguageSearchSettings, WikiPageLanguage> record in
PXSelectJoinGroupBy<SMLanguageSearchSettings,
RightJoin<WikiPageLanguage, On<WikiPageLanguage.language, Equal<SMLanguageSearchSettings.name>>>,
Where<SMLanguageSearchSettings.userID, IsNull,
Or<SMLanguageSearchSettings.userID, Equal<Current<AccessInfo.userID>>>>,
Aggregate<GroupBy<WikiPageLanguage.language,
GroupBy<SMLanguageSearchSettings.userID,
GroupBy<SMLanguageSearchSettings.active>>>>>.
Select(this))
{
var langSettings = (SMLanguageSearchSettings)record;
var pageLanguage = (WikiPageLanguage)record;
if (langSettings.UserID == null)
{
var fieldValues = new OrderedDictionary
{
{cache.GetField(typeof(SMLanguageSearchSettings.name)), pageLanguage.Language},
{cache.GetField(typeof(SMLanguageSearchSettings.userID)), PXAccess.GetUserID()},
{cache.GetField(typeof(SMLanguageSearchSettings.active)), false}
};
cache.Insert(fieldValues);
langSettings = (SMLanguageSearchSettings)cache.Current;
}
yield return langSettings;
}
cache.IsDirty = oldDirtyValue;
}
示例3: ParseParams
/// <summary>
/// Parses the parameters passed to the constructor.
/// </summary>
/// <param name="fields">The object[] passed to the constructor.</param>
/// <exception cref="ArgumentException">Either the length of the params argument is odd, each pair of objects within the params argument do not each comprise a valid <see cref="KeyValuePair{SortBy,SortOrder}"/>, or there is a duplicate <see cref="SortBy"/> key within the params argument.</exception>
private void ParseParams(ref object[] fields)
{
var orderedDictionary = new OrderedDictionary();
// Must have an even number of items in the array.
if (fields.Length % 2 != 0)
{
throw new ArgumentException("There must be an even number of items in the array.");
}
else
{
for (int i = 0; i < fields.Length/2; i++)
{
if (fields[i*2] is SortBy && fields[i*2 + 1] is SortOrder)
{
orderedDictionary.Add((SortBy)fields[i * 2], (SortOrder)fields[i * 2 + 1]);
}
else
{
throw new ArgumentException(
"Each pair of items added to the object array must be a pairing of SortBy then SortOrder.");
}
}
}
OrderedDictionary = orderedDictionary;
}
示例4: CreateFinders
private static OrderedDictionary CreateFinders()
{
OrderedDictionary createFinders = new OrderedDictionary();
createFinders[typeof(MenuStrip)] = (Find<MenuStrip>)delegate(MenuStrip menu, string name)
{
foreach (ToolStripItem item in menu.Items)
{
if (item.Name == name)
return item;
object recursed = FindFirst(item, name);
if (recursed != null)
return recursed;
}
return null;
};
createFinders[typeof(ToolStripItem)] = (Find<ToolStripMenuItem>)delegate(ToolStripMenuItem rootItem, string name)
{
foreach (ToolStripItem item in rootItem.DropDownItems)
{
if (item.Name == name)
return item;
object recursed = FindFirst(item, name);
if (recursed != null)
return recursed;
}
return null;
};
return createFinders;
}
示例5: UpdateCartItems
public List<CartItem> UpdateCartItems()
{
using (ShoppingCartActions usersShoppingCart = new ShoppingCartActions())
{
String cartId = usersShoppingCart.GetCartId();
ShoppingCartActions.ShoppingCartUpdates[] cartUpdates = new ShoppingCartActions.ShoppingCartUpdates[CartList.Rows.Count];
for (int i = 0; i < CartList.Rows.Count; i++)
{
IOrderedDictionary rowValues = new OrderedDictionary();
rowValues = GetValues(CartList.Rows[i]);
cartUpdates[i].ProductId = Convert.ToInt32(rowValues["ProductID"]);
CheckBox cbRemove = new CheckBox();
cbRemove = (CheckBox)CartList.Rows[i].FindControl("Remove");
cartUpdates[i].RemoveItem = cbRemove.Checked;
TextBox quantityTextBox = new TextBox();
quantityTextBox = (TextBox)CartList.Rows[i].FindControl("PurchaseQuantity");
cartUpdates[i].PurchaseQuantity = Convert.ToInt16(quantityTextBox.Text.ToString());
if (!usersShoppingCart.CheckAvailability(cartUpdates[i].PurchaseQuantity, cartUpdates[i].ProductId, cartId))
{
// Reload the page.
string pageUrl = Request.Url.AbsoluteUri.Substring(0, Request.Url.AbsoluteUri.Count() - Request.Url.Query.Count());
Response.Redirect(pageUrl + "?Action=stock&id=" + cartUpdates[i].ProductId);
}
}
usersShoppingCart.UpdateShoppingCartDatabase(cartId, cartUpdates);
CartList.DataBind();
lblTotal.Text = String.Format("{0:c}", usersShoppingCart.GetTotal());
return usersShoppingCart.GetCartItems();
}
}
示例6: GetEmoticonHashTable
public static OrderedDictionary GetEmoticonHashTable()
{
var emoticons = new OrderedDictionary
{
{":D", "big-smile-emoticon-for-facebook.png"},
{":O", "surprised-emoticon.png"},
{":/", "unsure-emoticon.png"},
{":P", "facebook-tongue-out-emoticon.png"},
{":)", "facebook-smiley-face-for-comments.png"},
{":(", "facebook-frown-emoticon.png"},
{":'(", "facebook-cry-emoticon-crying-symbol.png"},
{"O:)", "angel-emoticon.png"},
{"3:)", "devil-emoticon.png"},
{"-_-", "squinting-emoticon.png"},
{":*", "kiss-emoticon.png"},
{"^_^", "kiki-emoticon.png"},
{":v", "pacman-emoticon.png"},
{":3", "curly-lips-emoticon.png"},
{"o.O", "confused-emoticon-wtf-symbol-for-facebook.png"},
{";)", "wink-emoticon.png"},
{"8-)", "glasses-emoticon.png"},
{"8| B|", "sunglasses-emoticon.png"}
//{">:O", "angry-emoticon.png"},
//{">:(", "grumpy-emoticon.png"}
};
return emoticons;
}
示例7: LoadAll
/// <summary>
/// Load widgets from the assembly provided.
/// </summary>
/// <param name="filePath">File path containing the model definitions</param>
/// <param name="assemblyNamesDelimited">Comma delimited list of assembly names to load modeldefs from.</param>
/// <param name="author">Override author</param>
/// <param name="email">Override email</param>
/// <param name="version">Override version</param>
/// <param name="url">Ovverride url</param>
/// <returns></returns>
public static IList<ModelSettings> LoadAll(string filePath, string assemblyNamesDelimited, string author = "kishore reddy", string email = "[email protected]", string version = "0.9.4.1", string url = "http://commonlibrarynetcms.codeplex.com")
{
bool fileProvided = !string.IsNullOrEmpty(filePath);
bool hasAssemblys = !string.IsNullOrEmpty(assemblyNamesDelimited);
if (!fileProvided && !hasAssemblys)
throw new ArgumentException("File path for model defs or list of assembly names must be provided.");
var models = new OrderedDictionary();
if (hasAssemblys)
{
// Any loaded from assembly? Load into dictionary.
var modelDefsFromAssembly = LoadFromAssemblies(assemblyNamesDelimited);
if (modelDefsFromAssembly != null && modelDefsFromAssembly.Count > 0)
foreach (var modelDef in modelDefsFromAssembly)
models[modelDef.Value.Name] = modelDef.Value;
}
// Model definition config file supplied?
if (fileProvided)
{
// Override the model defs from assembly with ones supplied in configuration file.
var modelDefsFromFile = LoadFromFile(filePath);
if (modelDefsFromFile != null && modelDefsFromFile.Count > 0)
foreach (var modelDef in modelDefsFromFile)
models[modelDef.Name] = modelDef;
}
// Now get all models from map as a list.
var all = new List<ModelSettings>();
foreach (DictionaryEntry pair in models) all.Add(pair.Value as ModelSettings);
return all;
}
示例8: CreateCategoryNamePropertyListMap
private void CreateCategoryNamePropertyListMap()
{
this.evaluatedCategories = new List<Category>();
if (this.Categories != null)
{
this.evaluatedCategories.AddRange(this.Categories);
}
this.categoryNamePropertyListMap = new OrderedDictionary();
foreach (Category category in this.Categories)
{
this.categoryNamePropertyListMap.Add(category.Name, new List<BaseProperty>());
}
foreach (BaseProperty property in this.Properties)
{
if (!this.categoryNamePropertyListMap.Contains(property.Category))
{
Category item = new Category {
Name = property.Category
};
this.evaluatedCategories.Add(item);
this.categoryNamePropertyListMap.Add(item.Name, new List<BaseProperty>());
}
(this.categoryNamePropertyListMap[property.Category] as List<BaseProperty>).Add(property);
}
}
示例9: GetSelectedRowData
public IOrderedDictionary GetSelectedRowData()
{
IOrderedDictionary result;
if (null == this.SelectedRow)
{
result = null;
}
else
{
OrderedDictionary fieldValues = new OrderedDictionary();
foreach (object field in this.CreateColumns(null, false))
{
if (field is BoundField && !fieldValues.Contains(((BoundField)field).DataField))
{
fieldValues.Add(((BoundField)field).DataField, null);
}
}
string[] dataKeyNames = this.DataKeyNames;
for (int i = 0; i < dataKeyNames.Length; i++)
{
string key = dataKeyNames[i];
if (!fieldValues.Contains(key))
{
fieldValues.Add(key, null);
}
}
this.ExtractRowValues(fieldValues, this.SelectedRow, true, true);
result = fieldValues;
}
return result;
}
示例10: RemoveDepartmentButton_Click
/// <summary>
/// Remove the user being chosen
/// by the user drop down list
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void RemoveDepartmentButton_Click(object sender, EventArgs e)
{
HalonModels.Department[] removeList = new HalonModels.Department[DeptList.Rows.Count];
for (int i = 0; i < DeptList.Rows.Count; i++)
{
IOrderedDictionary rowValues = new OrderedDictionary();
rowValues = GetValues(DeptList.Rows[i]);
int tempID = Convert.ToInt32(rowValues["Dept_ID"]);
CheckBox cbRemove = new CheckBox();
cbRemove = (CheckBox)DeptList.Rows[i].FindControl("RemoveDept");
if (cbRemove.Checked)
{
var myItem = (from c in db.Departments where c.Dept_ID == tempID select c).FirstOrDefault();
if (myItem != null)
{
//Remove all related items to this department first
//then remove the department
db.Departments.Remove(myItem);
db.SaveChanges();
// Reload the page.
string pageUrl = Request.Url.AbsoluteUri.Substring(0, Request.Url.AbsoluteUri.Count() - Request.Url.Query.Count());
Response.Redirect(pageUrl + "?DepartmentAction=remove");
}
else
{
LabelRemoveStatus.Text = "Unable to locate Department.";
}
}
}
}
示例11: CountTests
public void CountTests()
{
var d = new OrderedDictionary();
Assert.Equal(0, d.Count);
for (int i = 0; i < 1000; i++)
{
d.Add(i, i);
Assert.Equal(i + 1, d.Count);
}
for (int i = 0; i < 1000; i++)
{
d.Remove(i);
Assert.Equal(1000 - i - 1, d.Count);
}
for (int i = 0; i < 1000; i++)
{
d[(object)i] = i;
Assert.Equal(i + 1, d.Count);
}
for (int i = 0; i < 1000; i++)
{
d.RemoveAt(0);
Assert.Equal(1000 - i - 1, d.Count);
}
}
示例12: PassingEqualityComparers
public void PassingEqualityComparers()
{
var eqComp = new CaseInsensitiveEqualityComparer();
var d1 = new OrderedDictionary(eqComp);
d1.Add("foo", "bar");
Assert.Throws<ArgumentException>(() => d1.Add("FOO", "bar"));
}
示例13: XmlDocumentViewSchema
public XmlDocumentViewSchema(string name, Pair data, bool includeSpecialSchema)
{
this._includeSpecialSchema = includeSpecialSchema;
this._children = (OrderedDictionary) data.First;
this._attrs = (ArrayList) data.Second;
this._name = name;
}
示例14: Index
public ActionResult Index()
{
Member _member = new Member("users");
Hashtable user = _member.getBySession();
Permission _permission = new Permission(Convert.ToInt32(user["type_id"]));
string[] permission = _permission.get();
OrderedDictionary application = new OrderedDictionary();
if(permission.Length > 0)
{
ArrayList apps = this.getApplication();
if(apps.Count > 0)
{
foreach (Hashtable item in apps)
{
if (permission.Contains(item["id"]))
{
application["app" + item["id"]] = new Hashtable() {
{"name", item["title"]},
{"setting", "/desktop/application/" + item["id"]},
{"path", "/"},
{"showOnDesktop", true}
};
}
}
}
}
ViewBag.application = application;
return View();
}
示例15: SwcHeaderStore
public SwcHeaderStore()
{
tables = new OrderedDictionary();
tables["ORIGINAL_SOURCE"] = "SIGEN";
tables["CREATURE"] = "";
tables["REGION"] = "";
tables["FIELD/LAYER"] = "";
tables["TYPE"] = "";
tables["CONTRIBUTOR"] = "";
tables["REFERENCE"] = "";
tables["RAW"] = "";
tables["EXTRAS"] = "";
tables["SOMA_AREA"] = "";
tables["SHINKAGE_CORRECTION"] = "";
tables["VERSION_NUMBER"] = "";
tables["VERSION_DATE"] = "";
tables["SCALE"] = "";
tables["INTERPOLATION"] = "";
tables["DISTANCE_THRESHOLD"] = "";
tables["VOLUME_THRESHOLD"] = "";
tables["SMOOTHING"] = "";
tables["CLIPPING"] = "";
tables["ROOT_SETTING"] = "NO";
}