本文整理汇总了C#中System.Collections.Dictionary.Add方法的典型用法代码示例。如果您正苦于以下问题:C# Dictionary.Add方法的具体用法?C# Dictionary.Add怎么用?C# Dictionary.Add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.Dictionary
的用法示例。
在下文中一共展示了Dictionary.Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ModuleControl
public ModuleControl(Guid moduleID, String fileName)
{
Dictionary<string, object> parameters = new Dictionary<string,object>();
parameters.Add("moduleID", moduleID);
parameters.Add("fileName", fileName);
this.DataManager.Load(parameters);
}
示例2: LogSession
/// <summary>
/// Logs a session and returns session information on success.
/// </summary>
public static void LogSession(MonoBehaviour mb, ClientArgs args, Guid userId, string detail, string revisionId, Action<Guid, string> onSuccess, Action<string> onFailure)
{
var data = new Dictionary<string, object>();
data.Add("user_id", userId);
data.Add("release_id", args.ReleaseId);
// XXX (kasiu): Need to check if this is the right DateTime string to send. I THINK THIS IS WRONG BUT I DON'T GIVE A FOOBAR RIGHT NOW. FIXME WHEN THE SERVER SCREAMS.
data.Add("client_time", DateTime.Now.ToString());
data.Add("detail", detail);
data.Add("library_revid", revisionId);
// Processing to get session_id
Action<string> callback = s => {
var s2 = s.Replace("{", "").Replace("}", "").Replace("\"", "").Trim();
var split = s2.Split(',');
if (split.Length != 2) {
onFailure(string.Format("LogSession received ill-formatted JSON: {0}", s));
}
var sessionId = split[0].Split(':')[1].Trim();
var sessionKey = split[1].Split(':')[1].Trim();
onSuccess(new Guid(sessionId), sessionKey);
};
var newArgs = new ClientArgs(new Uri(args.BaseUri, "/api/session"), args);
SendNonSessionRequest(mb, newArgs, data, callback, onFailure);
}
示例3: TestOtherIdMappings
public void TestOtherIdMappings()
{
String otherIdMapping = "<agent id=\"Repro\" sifVersion=\"2.0\">"
+ " <mappings id=\"Default\">"
+ " <object object='StudentPersonal'>"
+
" <field direction='inbound' name='FIELD1'><otherid type='ZZ' prefix='FIELD1:'/></field>"
+
" <field direction='outbound' name='FIELD1'>OtherIdList/OtherId[@Type='ZZ'+]=FIELD1:$(FIELD1)</field>"
+
" <field direction='inbound' name='FIELD2'><otherid type='ZZ' prefix='FIELD2:'/></field>"
+
" <field direction='outbound' name='FIELD2'>OtherIdList/OtherId[@Type='ZZ'+]=FIELD2:$(FIELD2)</field>"
+ " </object>" + " </mappings>" + "</agent>";
Dictionary<String, String> sourceMap = new Dictionary<String, String>();
sourceMap.Add( "FIELD1", "1234" );
sourceMap.Add( "FIELD2", "5678" );
StringMapAdaptor sma = new StringMapAdaptor( sourceMap );
StudentPersonal sp = mapToStudentPersonal( sma, otherIdMapping, null );
Assertion.AssertNotNull( "Student should not be null", sp );
IDictionary destinationMap = doInboundMapping( otherIdMapping, sp );
assertMapsAreEqual( sourceMap, destinationMap );
}
示例4: GetMerchantHashKey
public ActionResult GetMerchantHashKey()
{
try
{
long mid = 1000179;
//### 透過WebService取得Key與IV
ApiWS.ApiWSSoapClient WS = new ApiWS.ApiWSSoapClient();
ApiWS.AllPayMerchantFunction merchantFunction = WS.GetAllPayMerchantFunctionByMerchant(mid);
Dictionary<string, string> postCollection = new Dictionary<string, string>();
postCollection.Add("MerchantID", mid.ToString());
postCollection.Add("XMLData", "tXrjXcgaYAHCE4QIKuDAcuuDKprFV0kXfIrsUWk45RvnYGwXPOkoG8/PHVkUnZvhmzcnceccITG43H1PwnWctlVL43s7Aow8HU8HJmYiuI/Q/MaWX+5yd1zGhuhKMzR/wpJzjEzYyn9ZBErGru+4W69aEHQg/LheV2Yl5Ln0DiP8SKpSiZZPCge2vULAMJYvMlf9qfa5Dhd7x3uuf8BirnCSg6MxIMBnaftx7B2HjCQi+gQeo9n4cJ9JUucWHf3BWgRyTGgPeLF/kxfWEjXmkcpsSEfDqxeFUEQzt7PjHmmqqCUd8Kg5VDJmdBo3Rrz9iMtd3MpV4vAj5I4aIttfGdW4PYCJSmzC4jpopQOD7mRyCwX5iFFfN6hGgSYKvBzxhAvoPQ6/8SYaInS/nvvjzawEYjEC7OWjJFZx0InLAKPA6Wr1q8nG0SZXocvt+HtTi8prBepMiZTYwyaJYCXKZQ==");
Hashtable RequestTable = new Hashtable();
foreach (var item in postCollection)
{
RequestTable.Add(item.Key, item.Value);
}
//### 發送到Mp, 取得Response
string ServerResponse = DoRequest("http://payment-stage.allpay.com.tw/cashier/OrderChangeConfirm", RequestTable);
ViewBag.SendResult = ServerResponse;
return null;
}
catch (Exception e)
{
throw e;
}
}
示例5: GetIndexMasterList
public IList<MstIndexModels> GetIndexMasterList(string indexCode, string indexName, string indexTypeCode, string securityType, string term)
{
Dictionary<string, object> param = new Dictionary<string, object>();
if (!StringUtils.IsEmpty(indexCode))
{
param.Add("indexCode", indexCode);
}
if (!StringUtils.IsEmpty(term))
{
param.Add("term", term);
}
if (!StringUtils.IsEmpty(indexName))
{
param.Add("indexName", indexName);
}
if (!StringUtils.IsEmpty(indexTypeCode))
{
param.Add("indexTypeCode", indexTypeCode);
}
if (!StringUtils.IsEmpty(securityType))
{
param.Add("securityType", securityType);
}
param.Add("indexStatus", Constants.Status.Active);
IList<MstIndexModels> result = mapper.QueryForList<MstIndexModels>("Master.selectIndexMaster", param);
return result;
}
示例6: CreateTransitionTable
private void CreateTransitionTable()
{
_transitions = new Dictionary<MenuItemID, ScreenID>();
//Opening screen transitions
_transitions.Add(MenuItemID.OPENING_SCREEN_NEW_GAME, ScreenID.NEW_GAME_SCREEN);
_transitions.Add(MenuItemID.OPENING_SCREEN_LOAD_GAME, ScreenID.LOAD_GAME_SCREEN);
_transitions.Add(MenuItemID.OPENING_SCREEN_SETTINGS, ScreenID.SETTINGS_SCREEN);
_transitions.Add(MenuItemID.OPENING_SCREEN_SCORES, ScreenID.SCORES_SCREEN);
_transitions.Add(MenuItemID.OPENING_SCREEN_CREDITS, ScreenID.CREDITS_SCREEN);
_transitions.Add(MenuItemID.OPENING_SCREEN_QUIT, ScreenID.QUIT_SCREEN);
//New game screen's transitions
_transitions.Add(MenuItemID.NEW_GAME_SCREEN_BACK, ScreenID.OPENING_SCREEN);
//Load game screen's transitions
_transitions.Add(MenuItemID.LOAD_GAME_SCREEN_BACK, ScreenID.OPENING_SCREEN);
//Settings screen's transitions
_transitions.Add(MenuItemID.SETTINGS_SCREEN_BACK, ScreenID.OPENING_SCREEN);
//Scores screen's transitions
_transitions.Add(MenuItemID.SCORES_SCREEN_BACK, ScreenID.OPENING_SCREEN);
//Credits screen's transitions
_transitions.Add(MenuItemID.CREDITS_SCREEN_BACK, ScreenID.OPENING_SCREEN);
//Quit screen transitions
_transitions.Add(MenuItemID.QUIT_SCREEN_CANCEL, ScreenID.OPENING_SCREEN);
}
示例7: WebHeaderCollection
// Static Initializer
static WebHeaderCollection ()
{
// the list of restricted header names as defined
// by the ms.net spec
restricted = new Hashtable (CaseInsensitiveHashCodeProvider.DefaultInvariant,
CaseInsensitiveComparer.DefaultInvariant);
restricted.Add ("accept", true);
restricted.Add ("connection", true);
restricted.Add ("content-length", true);
restricted.Add ("content-type", true);
restricted.Add ("date", true);
restricted.Add ("expect", true);
restricted.Add ("host", true);
restricted.Add ("if-modified-since", true);
restricted.Add ("range", true);
restricted.Add ("referer", true);
restricted.Add ("transfer-encoding", true);
restricted.Add ("user-agent", true);
restricted.Add ("proxy-connection", true);
//
restricted_response = new Dictionary<string, bool> (StringComparer.InvariantCultureIgnoreCase);
restricted_response.Add ("Content-Length", true);
restricted_response.Add ("Transfer-Encoding", true);
restricted_response.Add ("WWW-Authenticate", true);
// see par 14 of RFC 2068 to see which header names
// accept multiple values each separated by a comma
multiValue = new Hashtable (CaseInsensitiveHashCodeProvider.DefaultInvariant,
CaseInsensitiveComparer.DefaultInvariant);
multiValue.Add ("accept", true);
multiValue.Add ("accept-charset", true);
multiValue.Add ("accept-encoding", true);
multiValue.Add ("accept-language", true);
multiValue.Add ("accept-ranges", true);
multiValue.Add ("allow", true);
multiValue.Add ("authorization", true);
multiValue.Add ("cache-control", true);
multiValue.Add ("connection", true);
multiValue.Add ("content-encoding", true);
multiValue.Add ("content-language", true);
multiValue.Add ("expect", true);
multiValue.Add ("if-match", true);
multiValue.Add ("if-none-match", true);
multiValue.Add ("proxy-authenticate", true);
multiValue.Add ("public", true);
multiValue.Add ("range", true);
multiValue.Add ("transfer-encoding", true);
multiValue.Add ("upgrade", true);
multiValue.Add ("vary", true);
multiValue.Add ("via", true);
multiValue.Add ("warning", true);
multiValue.Add ("www-authenticate", true);
// Extra
multiValue.Add ("set-cookie", true);
multiValue.Add ("set-cookie2", true);
}
示例8: FindFirstChar
/* Find first character which is not repetitve in string
* if string has length n, it may need n*n time O(n).
* Let's find a better algorithm
* First, make Hash table that saves the number of character appears in string
* for each char
* if, not saved value for the char, save 1
* else, value++;
* Second, lookup character
* for each char
* if, the number of appears = 1, return char
* else, 1 not exists, return null
*/
public static char FindFirstChar(string str)
{
Dictionary<char,int> table = new Dictionary<char, int>();
int length = str.Length;
char c;
int i;
for (i = 0; i< length; i++)
{
c = str[i];
if (table.ContainsKey (c)) {
int temp = table [c];
table.Remove (c);
table.Add (c, temp+1);
} else {
table.Add (c, 1);
}
}
for ( i = 0; i<length; i++)
{
c = str[i];
if (table [c] == 1) {
return c;
}
}
char Null = '\0';
return Null;
}
示例9: KeywordCollection
internal KeywordCollection(Scintilla scintilla)
: base(scintilla)
{
// Auugh, this plagued me for a while. Each of the lexers cna define their own "Name"
// and also asign themsleves to a Scintilla Lexer Constant. Most of the time these
// match the defined constant, but sometimes they don't. We'll always use the constant
// name since it's easier to use, consistent and will always have valid characters.
// However its still valid to access the lexers by this name (as SetLexerLanguage
// uses this value) so we'll create a lookup.
_lexerAliasMap = new Dictionary<string, Lexer>(StringComparer.OrdinalIgnoreCase);
// I have no idea how Progress fits into this. It's defined with the PS lexer const
// and a name of "progress"
_lexerAliasMap.Add("PL/M", Lexer.Plm);
_lexerAliasMap.Add("props", Lexer.Properties);
_lexerAliasMap.Add("inno", Lexer.InnoSetup);
_lexerAliasMap.Add("clarion", Lexer.Clw);
_lexerAliasMap.Add("clarionnocase", Lexer.ClwNoCase );
//_lexerKeywordListMap = new Dictionary<string,string[]>(StringComparer.OrdinalIgnoreCase);
//_lexerKeywordListMap.Add("xml", new string[] { "HTML elements and attributes", "JavaScript keywords", "VBScript keywords", "Python keywords", "PHP keywords", "SGML and DTD keywords" });
//_lexerKeywordListMap.Add("yaml", new string[] { "Keywords" });
// baan, kix, ave, scriptol, diff, props, makefile, errorlist, latex, null, lot, haskell
// lexers don't have keyword list names
}
示例10: insertFee
public int insertFee(String feeDesc, Double feeAmount, ArrayList memberTypeNo, int Status)
{
int resultInner = 0;
DAL dal = new DAL(ConfigurationManager.ConnectionStrings["CMS"].ConnectionString);
String sql = "EXEC insertFee @feeDesc, @Amount, @Status;";
Dictionary<String, Object> parameters = new Dictionary<string, object>();
parameters.Add("@feeDesc", feeDesc);
parameters.Add("@Amount", feeAmount);
parameters.Add("@Status", Status);
int result = Convert.ToInt32(dal.executeNonQuery(sql, parameters));
Object rs = dal.executeScalar("SELECT @@IDENTITY"); //problem area
int id = int.Parse(rs.ToString());
if (id != 0)
{
foreach (int i in memberTypeNo)
{
String sqlInner = "INSERT INTO MEMBER_TYPE_FEE (MemberTypeNo, FeeId) VALUES (@memberTypeNo, @feeId)";
Dictionary<String, Object> parametersInner = new Dictionary<string, object>();
parametersInner.Add("@memberTypeNo", i);
parametersInner.Add("@feeId", id);
resultInner = Convert.ToInt32(dal.executeNonQuery(sqlInner, parametersInner));
}
}
return resultInner;
}
示例11: GenerateUsageReport
private object GenerateUsageReport(IUnitOfWork uow, DateRange dateRange, int start,
int length, out int count)
{
_dataUrlMappings = new Dictionary<string, string>();
_dataUrlMappings.Add("BookingRequest", "/Dashboard/Index/");
_dataUrlMappings.Add("Email", "/Dashboard/Index/");
_dataUrlMappings.Add("User", "/User/Details?userID=");
var factDO = uow.FactRepository.GetQuery().WhereInDateRange(e => e.CreateDate, dateRange);
count = factDO.Count();
return factDO
.OrderByDescending(e => e.CreateDate)
.Skip(start)
.Take(length)
.AsEnumerable()
.Select(
f => new
{
PrimaryCategory = f.PrimaryCategory,
SecondaryCategory = f.SecondaryCategory,
Activity = f.Activity,
Status = f.Status,
Data = AddClickability(f.Data),
CreateDate = f.CreateDate.ToString(DateStandardFormat),
})
.ToList();
}
示例12: Format
/// <summary>
/// Overrides the Format method for log4net's layout
/// </summary>
/// <param name="writer">The text writer</param>
/// <param name="loggingEvent">The logging event</param>
public override void Format(TextWriter writer, LoggingEvent loggingEvent)
{
var dictionary = new Dictionary<string, object>();
// Add the main properties
dictionary.Add("timestamp", loggingEvent.TimeStamp);
dictionary.Add("level", loggingEvent.Level != null ? loggingEvent.Level.DisplayName : "null");
dictionary.Add("message", loggingEvent.RenderedMessage);
dictionary.Add("logger", loggingEvent.LoggerName);
// Loop through all other properties
foreach (DictionaryEntry dictionaryEntry in loggingEvent.GetProperties())
{
var key = dictionaryEntry.Key.ToString();
// Check if the key exists
if (!dictionary.ContainsKey(key))
{
dictionary.Add(key, dictionaryEntry.Value);
}
}
// Convert the log string into a JSON string
var logString = JsonConvert.SerializeObject(dictionary);
writer.WriteLine(logString);
}
示例13: AuthOauthCheckToken
public OAuthAccessToken AuthOauthCheckToken(string oauthToken)
{
var dictionary = new Dictionary<string, string>();
dictionary.Add("method", "flickr.auth.oauth.checkToken");
dictionary.Add("oauth_token", oauthToken);
return GetResponse<OAuthAccessToken>(dictionary);
}
示例14: Initialize
public void Initialize()
{
// Create some items and place them in a dictionary
// Add some include information so that when we check the final
// item spec we can verify that the item was recreated properly
BuildItem[] buildItems = new BuildItem[1];
buildItems[0] = new BuildItem("BuildItem1", "Item1");
Dictionary<object, object> dictionary1 = new Dictionary<object, object>();
dictionary1.Add("Target1", buildItems);
Hashtable resultsByTarget1 = new Hashtable(StringComparer.OrdinalIgnoreCase);
resultsByTarget1.Add("Target1", Target.BuildState.CompletedSuccessfully);
Dictionary<object, object> dictionary2 = new Dictionary<object, object>();
dictionary2.Add("Target2", buildItems);
dictionary2.Add("Target3", null);
Hashtable resultsByTarget2 = new Hashtable(StringComparer.OrdinalIgnoreCase);
resultsByTarget2.Add("Target2", Target.BuildState.CompletedSuccessfully);
resultsByTarget2.Add("Target3", Target.BuildState.CompletedSuccessfully);
Dictionary<object, object> dictionary3 = new Dictionary<object, object>();
dictionary3.Add("Target4", buildItems);
Hashtable resultsByTarget3 = new Hashtable(StringComparer.OrdinalIgnoreCase);
resultsByTarget3.Add("Target4", Target.BuildState.Skipped);
resultWith0Outputs = new BuildResult(new Hashtable(), new Hashtable(StringComparer.OrdinalIgnoreCase), true, 1, 1, 2, true, string.Empty, string.Empty, 0, 0, 0);
resultWith1Outputs = new BuildResult(dictionary1, resultsByTarget1, true, 1, 1, 2, true, string.Empty, string.Empty, 0, 0, 0);
resultWith2Outputs = new BuildResult(dictionary2, resultsByTarget2, true, 1, 1, 2, true, string.Empty, string.Empty, 0, 0, 0);
uncacheableResult = new BuildResult(dictionary3, resultsByTarget3, true, 1, 1, 2, true, string.Empty, string.Empty, 0, 0, 0);
}
示例15: GetFeaturedItem
public Dictionary<string, string> GetFeaturedItem(string SectionId)
{
SqlDataReader myDA = null;
connection = new SqlConnection(is_dsn);
connection.Open();
selectCommand = new SqlCommand();
string strStatement;
strStatement = "select * from tblPortfolio p join tblFeaturedItems f on p.ItemId = f.ItemId left join tblExpandText e on p.ItemExpandId = e.ExpandId where f.sectionId = @strSectionId";
selectCommand = new SqlCommand(strStatement, connection);
//selectCommand.CommandType = CommandType.StoredProcedure;
selectCommand.Parameters.AddWithValue("@strSectionId", SectionId);
myDA = selectCommand.ExecuteReader(CommandBehavior.CloseConnection);
Dictionary<string, string> list = new Dictionary<string, string>();
while (myDA.Read())
{
list.Add("ItemId", myDA["ItemId"].ToString());
list.Add("ItemTitle", myDA["ItemTitle"].ToString());
list.Add("ItemDate", myDA["ItemDate"].ToString());
list.Add("ItemLanguages", myDA["ItemLanguages"].ToString());
list.Add("ItemDescription", myDA["ItemDescription"].ToString());
list.Add("ItemImageName", myDA["ItemImageName"].ToString());
list.Add("ItemFolderName", myDA["ItemFolderName"].ToString());
list.Add("ItemWebUrl", myDA["ItemWebUrl"].ToString());
list.Add("ItemCodeUrl", myDA["ItemCodeUrl"].ToString());
list.Add("ExpandText", myDA["ExpandText"].ToString());
}
connection.Close();
return list;
}