本文整理匯總了C#中System.Collections.Generic.System.Collections.Generic.Dictionary.Remove方法的典型用法代碼示例。如果您正苦於以下問題:C# System.Collections.Generic.Dictionary.Remove方法的具體用法?C# System.Collections.Generic.Dictionary.Remove怎麽用?C# System.Collections.Generic.Dictionary.Remove使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Collections.Generic.System.Collections.Generic.Dictionary
的用法示例。
在下文中一共展示了System.Collections.Generic.Dictionary.Remove方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: UploadData
public override void UploadData(Common.Solution solution, Stream messageBody, bool checkExisting)
{
UpdateCurrentCulterInfo();
SqlConnection conn = GetConnection(solution);
using (conn)
{
SqlTransaction tran = conn.BeginTransaction();
Dictionary<String, SqlCommand[]> sqlCommands = new Dictionary<String, SqlCommand[]>();
Dictionary<XmlNode, Exception> fkErrors = new System.Collections.Generic.Dictionary<XmlNode, Exception>();
XmlDocument doc = new XmlDocument();
try
{
doc.Load(messageBody);
XmlNodeList rows = doc.DocumentElement.SelectNodes("//Root/Rows/Row");
foreach (XmlNode row in rows)
{
UploadRow(row, tran, sqlCommands, fkErrors, checkExisting);
}
int pass = 0;
int cnt = 0;
System.Collections.IEnumerable errorRows = null;
while (fkErrors.Count > 0)
{
if (pass > 0 && cnt == 0 && fkErrors.Count > 0)
{
System.Collections.IEnumerator err = fkErrors.Values.GetEnumerator();
if (err.MoveNext())
throw (Exception)err.Current;
}
cnt = 0;
errorRows = new List<XmlNode>(fkErrors.Keys);
foreach (XmlNode row in errorRows)
{
if (UploadRow(row, tran, sqlCommands, fkErrors, checkExisting))
{
fkErrors.Remove(row);
cnt++;
}
}
pass++;
}
tran.Commit();
}
catch (Exception)
{
tran.Rollback();
throw;
}
}
}
示例2: FurtherFillTimeLineWithSubCalEvents
//.........這裏部分代碼省略.........
}
foreach (List<Dictionary<TimeSpan, mTuple<int, TimeSpanWithStringID>>> allFreeSpotSnugPossibiilities in FreeSpotSnugPossibiilities.Values)
{
AllMoveOvrSet.AddRange(allFreeSpotSnugPossibiilities);
}
TimeSpanWithStringID UnAssignedTimeSpanWithString = new TimeSpanWithStringID(ReferenceTimeLine.TimelineSpan, ReferenceTimeLine.TimelineSpan.ToString());
/*if (LeftOvers.Count > 0)
{
UnAssignedTimeSpanWithString = LeftOvers[0];
}*/
TimeSpan TotalMovedSofar = new TimeSpan(0);
Dictionary<TimeLine, List<mTuple<bool, SubCalendarEvent>>> FreeSpots_MatchedEvents = new System.Collections.Generic.Dictionary<TimeLine, System.Collections.Generic.List<mTuple<bool, SubCalendarEvent>>>();
Dictionary<TimeSpan, mTuple<int, TimeSpanWithStringID>> CompatibleListForReferenceTimeLine = AllCompatibleWithList[ReferenceTimeLine];
foreach (TimeLine eachTimeLine in AllFreeSpots)
{
FreeSpots_MatchedEvents.Add(eachTimeLine, new System.Collections.Generic.List<mTuple<bool, SubCalendarEvent>>());
Tuple<Dictionary<TimeSpan, mTuple<int, TimeSpanWithStringID>>, Dictionary<TimeSpan, mTuple<int, TimeSpanWithStringID>>> UpdatedCompatibleList_BestSnugPossibility = UpdateCompatibleListOfTimeLine(CompatibleListForReferenceTimeLine, FreeSpotSnugPossibiilities[eachTimeLine], ReferenceTimeLine, UnAssignedTimeSpanWithString, TotalPossibleTimeSpanWithStrings);
Dictionary<TimeSpan, mTuple<int, TimeSpanWithStringID>> UpdatedCompatibleList = UpdatedCompatibleList_BestSnugPossibility.Item1;
Dictionary<TimeSpan, mTuple<int, TimeSpanWithStringID>> BestSnugAvailability = UpdatedCompatibleList_BestSnugPossibility.Item2;
TotalMovedSofar += SnugArray.TotalTimeSpanOfSnugPossibility(BestSnugAvailability);
Dictionary<TimeSpan, List<mTuple<bool, SubCalendarEvent>>> TimeLineMatchingSubEvents = TimeLine_WithMathChingSubCalevents[eachTimeLine];
foreach (KeyValuePair<TimeSpan, mTuple<int, TimeSpanWithStringID>> eachKeyValuePair in BestSnugAvailability)
{
if (TimeLineMatchingSubEvents[eachKeyValuePair.Key].Count > 0)
{
FreeSpots_MatchedEvents[eachTimeLine].Add(TimeLineMatchingSubEvents[eachKeyValuePair.Key][0]);
TimeLineMatchingSubEvents[eachKeyValuePair.Key].RemoveAt(0);
--TotalPossibleTimeSpanWithStrings[eachKeyValuePair.Key].Item1;
if (TotalPossibleTimeSpanWithStrings[eachKeyValuePair.Key].Item1 == 0)
{
TotalPossibleTimeSpanWithStrings.Remove(eachKeyValuePair.Key);
}
}
else
{
;
}
}
//KeyValuePair<string, mTuple<int, TimeSpanWithStringID>> eachKeyValuePair
List<TimeSpan> AllKeys = CompatibleListForReferenceTimeLine.Keys.ToList();
foreach (TimeSpan eachTimeSpan in AllKeys)//Updates the Compatible List of the Reference timelin, in order to reflect movement in data
{
if (UpdatedCompatibleList.ContainsKey(eachTimeSpan))//checks if reference timeLine has updated keys
{
CompatibleListForReferenceTimeLine[eachTimeSpan] = UpdatedCompatibleList[eachTimeSpan];
}
else
{
CompatibleListForReferenceTimeLine.Remove(eachTimeSpan);
}
}
}
示例3: UploadData
public override void UploadData(Common.Solution solution, Stream messageBody, bool checkExisting)
{
UpdateCurrentCulterInfo();
int progressCnt = 0;
SqlConnection conn = GetConnection(solution);
using (conn)
{
using (SqlTransaction tran = conn.BeginTransaction())
{
Dictionary<String, SqlCommand[]> sqlCommands = new Dictionary<String, SqlCommand[]>();
Dictionary<Entity, Exception> fkErrors = new System.Collections.Generic.Dictionary<Entity, Exception>();
try
{
System.Xml.XmlTextReader doc = new XmlTextReader(messageBody);
try
{
using (doc)
{
Dictionary<String, String> regionalSetting = FastXmlReader.ReadRegionalSettings(doc);
if (regionalSetting != null)
base.SetRegionalSettings(regionalSetting);
if (progressCallback != null)
progressCallback(0);
foreach (Entity row in FastXmlReader.ReadRow(doc))
{
if (UploadRow(row, tran, sqlCommands, fkErrors, checkExisting) && progressCallback != null)
{
progressCnt++;
if ((progressCnt % progressStep) == 0)
progressCallback(progressCnt);
}
}
}
int pass = 0;
int cnt = 0;
System.Collections.IEnumerable errorRows = null;
while (fkErrors.Count > 0)
{
if (pass > 0 && cnt == 0 && fkErrors.Count > 0)
{
System.Collections.IEnumerator err = fkErrors.Values.GetEnumerator();
if (err.MoveNext())
throw (Exception)err.Current;
}
cnt = 0;
errorRows = new List<Entity>(fkErrors.Keys);
foreach (Entity row in errorRows)
{
if (UploadRow(row, tran, sqlCommands, fkErrors, checkExisting))
{
fkErrors.Remove(row);
cnt++;
if (progressCallback != null)
{
progressCnt++;
if ((progressCnt % progressStep) == 0)
progressCallback(progressCnt);
}
}
}
pass++;
}
tran.Commit();
}
catch (Exception e)
{
try
{
tran.Rollback();
}
catch
{
}
throw e;
}
}
finally
{
try
{
if (sqlCommands != null)
{
foreach (KeyValuePair<String, SqlCommand[]> kvp in sqlCommands)
{
SqlCommand[] arr = kvp.Value;
for (int i = 0; i < arr.Length; i++)
{
if (arr[i] != null)
{
arr[i].Dispose();
}
//.........這裏部分代碼省略.........