本文整理汇总了C#中System.Collections.Generic.System.Collections.Generic.Dictionary.ContainsKey方法的典型用法代码示例。如果您正苦于以下问题:C# System.Collections.Generic.Dictionary.ContainsKey方法的具体用法?C# System.Collections.Generic.Dictionary.ContainsKey怎么用?C# System.Collections.Generic.Dictionary.ContainsKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.Generic.System.Collections.Generic.Dictionary
的用法示例。
在下文中一共展示了System.Collections.Generic.Dictionary.ContainsKey方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateAvatar
public static void CreateAvatar()
{
GameObject go = Selection.activeGameObject;
if (go != null && go.GetComponent("Animator") != null)
{
HumanDescription hd = new HumanDescription();
Dictionary<string,string> boneName = new System.Collections.Generic.Dictionary<string, string>();
boneName["Chest"] = "spine";
boneName["Head"] = "head";
boneName["Hips"] = "hip";
boneName["LeftFoot"] = "footL";
boneName["LeftHand"] = "handL";
boneName["LeftLowerArm"] = "elbowL";
boneName["LeftLowerLeg"] = "kneeL";
boneName["LeftShoulder"] = "clavL";
boneName["LeftUpperArm"] = "armL";
boneName["LeftUpperLeg"] = "legL";
boneName["RightFoot"] = "footR";
boneName["RightHand"] = "handR";
boneName["RightLowerArm"] = "elbowR";
boneName["RightLowerLeg"] = "kneeR";
boneName["RightShoulder"] = "clavR";
boneName["RightUpperArm"] = "armR";
boneName["RightUpperLeg"] = "legR";
boneName["Spine"] = "spine2";
string[] humanName = HumanTrait.BoneName;
HumanBone[] humanBones = new HumanBone[boneName.Count];
int j = 0;
int i = 0;
while (i < humanName.Length) {
if (boneName.ContainsKey(humanName[i])) {
HumanBone humanBone = new HumanBone();
humanBone.humanName = humanName[i];
humanBone.boneName = boneName[humanName[i]];
humanBone.limit.useDefaultValues = true;
humanBones[j++] = humanBone;
}
i++;
}
hd.human = humanBones;
//hd.skeleton = new SkeletonBone[18];
//hd.skeleton[0].name = ("Hips") ;
Avatar avatar = AvatarBuilder.BuildHumanAvatar(go, hd);
avatar.name = (go.name + "_Avatar");
Debug.Log(avatar.isHuman ? "is human" : "is generic");
Animator animator = go.GetComponent("Animator") as Animator;
animator.avatar = avatar;
string path = AssetDatabase.GenerateUniqueAssetPath(Puppet2D_Editor._puppet2DPath+"/Animation/"+avatar.name+".asset");
AssetDatabase.CreateAsset(avatar, path);
}
}
示例2: Index
// GET: Zakup
public ActionResult Index()
{
DbModule module = DbModule.GetInstance();
string[] koszyk = Request.Cookies["Cart"].Value.ToString().Split(',');
var dict = new System.Collections.Generic.Dictionary<int, int>();
if(!String.IsNullOrEmpty(Request.Cookies["Cart"].Value))
foreach(string Ids in koszyk)
{
int Id = int.Parse(Ids);
if (!dict.ContainsKey(Id))
{
dict.Add(Id, 1);
}
else
{
dict[Id] += 1;
}
}
var dict2 = new System.Collections.Generic.Dictionary<Album, int>();
decimal wartosc = 0;
string waluta = "";
foreach(var obiekt in dict)
{
var album = module.Albumy.Where(x => x.Id == obiekt.Key).First();
dict2.Add(album, obiekt.Value);
wartosc += album.BruttoValue * obiekt.Value;
if(waluta == "")
{
waluta = album.BruttoSymbol;
}
else if(waluta != album.BruttoSymbol)
{
waluta = "(Wiele walut)";
wartosc = 0;
}
}
ViewBag.wartosc = wartosc;
ViewBag.waluta = waluta;
return View(dict2);
}
示例3: LoadSubtitle
public override void LoadSubtitle(Subtitle subtitle, List<string> lines, string fileName)
{
_errorCount = 0;
var sb = new StringBuilder();
lines.ForEach(line => sb.AppendLine(line));
var xml = new XmlDocument();
xml.LoadXml(sb.ToString().Trim());
var nsmgr = new XmlNamespaceManager(xml.NameTable);
nsmgr.AddNamespace("ttaf1", xml.DocumentElement.NamespaceURI);
XmlNode div = xml.DocumentElement.SelectSingleNode("//ttaf1:body", nsmgr).SelectSingleNode("ttaf1:div", nsmgr);
if (div == null)
div = xml.DocumentElement.SelectSingleNode("//ttaf1:body", nsmgr).FirstChild;
var styleDic = new System.Collections.Generic.Dictionary<string, string>();
foreach (XmlNode node in xml.DocumentElement.SelectNodes("//ttaf1:style", nsmgr))
{
if (node.Attributes["tts:fontStyle"] != null && node.Attributes["xml:id"] != null)
{
styleDic.Add(node.Attributes["xml:id"].Value, node.Attributes["tts:fontStyle"].Value);
}
}
foreach (XmlNode node in div.ChildNodes)
{
try
{
var pText = new StringBuilder();
foreach (XmlNode innerNode in node.ChildNodes)
{
switch (innerNode.Name)
{
case "br":
pText.AppendLine();
break;
case "span":
bool italic = false;
if (innerNode.Attributes["style"] != null && styleDic.ContainsKey(innerNode.Attributes["style"].Value))
{
if (styleDic[innerNode.Attributes["style"].Value].Contains("italic"))
{
italic = true;
pText.Append("<i>");
}
}
if (!italic && innerNode.Attributes != null)
{
var fs = innerNode.Attributes.GetNamedItem("tts:fontStyle");
if (fs != null && fs.Value == "italic")
{
italic = true;
pText.Append("<i>");
}
}
if (innerNode.HasChildNodes)
{
foreach (XmlNode innerInnerNode in innerNode.ChildNodes)
{
if (innerInnerNode.Name == "br")
{
pText.AppendLine();
}
else
{
pText.Append(innerInnerNode.InnerText);
}
}
}
else
{
pText.Append(innerNode.InnerText);
}
if (italic)
pText.Append("</i>");
break;
case "i":
pText.Append("<i>" + innerNode.InnerText + "</i>");
break;
case "b":
pText.Append("<b>" + innerNode.InnerText + "</b>");
break;
default:
pText.Append(innerNode.InnerText);
break;
}
}
string start = null; // = node.Attributes["begin"].InnerText;
string end = null; // = node.Attributes["begin"].InnerText;
string dur = null; // = node.Attributes["begin"].InnerText;
foreach (XmlAttribute attr in node.Attributes)
{
if (attr.Name.EndsWith("begin"))
start = attr.InnerText;
else if (attr.Name.EndsWith("end"))
end = attr.InnerText;
else if (attr.Name.EndsWith("duration"))
dur = attr.InnerText;
//.........这里部分代码省略.........
示例4: ShrinkToAfterShortestMatch
/// <summary>The subSpans are ordered in the same doc, so there is a possible match.
/// Compute the slop while making the match as short as possible by advancing
/// all subSpans except the last one in reverse order.
/// </summary>
private bool ShrinkToAfterShortestMatch()
{
matchStart = subSpans[subSpans.Length - 1].Start();
matchEnd = subSpans[subSpans.Length - 1].End();
System.Collections.Generic.Dictionary<byte[], byte[]> possibleMatchPayloads = new System.Collections.Generic.Dictionary<byte[], byte[]>();
if (subSpans[subSpans.Length - 1].IsPayloadAvailable())
{
System.Collections.Generic.ICollection<byte[]> payload = subSpans[subSpans.Length - 1].GetPayload();
foreach(byte[] pl in payload)
{
if (!possibleMatchPayloads.ContainsKey(pl))
{
possibleMatchPayloads.Add(pl, pl);
}
}
}
System.Collections.Generic.List<byte[]> possiblePayload = null;
int matchSlop = 0;
int lastStart = matchStart;
int lastEnd = matchEnd;
for (int i = subSpans.Length - 2; i >= 0; i--)
{
Spans prevSpans = subSpans[i];
if (collectPayloads && prevSpans.IsPayloadAvailable())
{
System.Collections.Generic.ICollection<byte[]> payload = prevSpans.GetPayload();
possiblePayload = new System.Collections.Generic.List<byte[]>(payload.Count);
possiblePayload.AddRange(payload);
}
int prevStart = prevSpans.Start();
int prevEnd = prevSpans.End();
while (true)
{
// Advance prevSpans until after (lastStart, lastEnd)
if (!prevSpans.Next())
{
inSameDoc = false;
more = false;
break; // Check remaining subSpans for final match.
}
else if (matchDoc != prevSpans.Doc())
{
inSameDoc = false; // The last subSpans is not advanced here.
break; // Check remaining subSpans for last match in this document.
}
else
{
int ppStart = prevSpans.Start();
int ppEnd = prevSpans.End(); // Cannot avoid invoking .end()
if (!DocSpansOrdered(ppStart, ppEnd, lastStart, lastEnd))
{
break; // Check remaining subSpans.
}
else
{
// prevSpans still before (lastStart, lastEnd)
prevStart = ppStart;
prevEnd = ppEnd;
if (collectPayloads && prevSpans.IsPayloadAvailable())
{
System.Collections.Generic.ICollection<byte[]> payload = prevSpans.GetPayload();
possiblePayload = new System.Collections.Generic.List<byte[]>(payload.Count);
possiblePayload.AddRange(payload);
}
}
}
}
if (collectPayloads && possiblePayload != null)
{
foreach (byte[] pl in possiblePayload)
{
if (!possibleMatchPayloads.ContainsKey(pl))
{
possibleMatchPayloads.Add(pl, pl);
}
}
}
System.Diagnostics.Debug.Assert(prevStart <= matchStart);
if (matchStart > prevEnd)
{
// Only non overlapping spans add to slop.
matchSlop += (matchStart - prevEnd);
}
/* Do not break on (matchSlop > allowedSlop) here to make sure
* that subSpans[0] is advanced after the match, if any.
*/
matchStart = prevStart;
lastStart = prevStart;
lastEnd = prevEnd;
}
//.........这里部分代码省略.........
示例5: BuildListMatchingTimelineAndSubCalendarEvent
List<List<SubCalendarEvent>> BuildListMatchingTimelineAndSubCalendarEvent(List<List<TimeSpanWithEventID>> ListOfSnugPossibilities, List<SubCalendarEvent> ListOfSubCalendarEvents, List<SubCalendarEvent> ConsrainedList)
{
List<List<SubCalendarEvent>> retValue = new System.Collections.Generic.List<System.Collections.Generic.List<SubCalendarEvent>>();
Dictionary<string, SubCalendarEventListCounter> Dict_ParentIDListOfSubCalEvents = new System.Collections.Generic.Dictionary<string, SubCalendarEventListCounter>();
foreach (SubCalendarEvent eachSubCalendarEvent in ListOfSubCalendarEvents)
{
string ParentKey = eachSubCalendarEvent.SubEvent_ID.getCalendarEventID();
if (Dict_ParentIDListOfSubCalEvents.ContainsKey(ParentKey))
{
Dict_ParentIDListOfSubCalEvents[ParentKey].UpdateList = eachSubCalendarEvent;
}
else
{
Dict_ParentIDListOfSubCalEvents.Add(ParentKey, new SubCalendarEventListCounter(eachSubCalendarEvent, ParentKey));
}
}
foreach (List<TimeSpanWithEventID> eachListOfTimeSpanWithID in ListOfSnugPossibilities)
{
List<SubCalendarEvent> CurentLine = new System.Collections.Generic.List<SubCalendarEvent>();
CurentLine.AddRange(ConsrainedList);
foreach (TimeSpanWithEventID eachTimeSpanWithID in eachListOfTimeSpanWithID)
{
CurentLine.Add(Dict_ParentIDListOfSubCalEvents[eachTimeSpanWithID.TimeSpanID.ToString()].getNextSubCalendarEvent);
}
retValue.Add(CurentLine);
foreach (SubCalendarEventListCounter eachSubCalendarEventListCounter in Dict_ParentIDListOfSubCalEvents.Values)
{
eachSubCalendarEventListCounter.reset();
}
}
return retValue;
/*List<TimeSpan> AllTimesSpan = new List<TimeSpan>();
Dictionary<TimeSpanWithID, List<SubCalendarEvent>> DictionaryOfTimeSpanWithIDandSubCalendarEvent = new System.Collections.Generic.Dictionary<TimeSpanWithID, System.Collections.Generic.List<SubCalendarEvent>>();
List<List<SubCalendarEvent>> MatchingListOfSnugPossibilitesWithSubcalendarEvents = new System.Collections.Generic.List<System.Collections.Generic.List<SubCalendarEvent>>();
Dictionary<string, List<SubCalendarEvent>> ListOfCaleventIDAndListSubCalendarEvent = new System.Collections.Generic.Dictionary<string, System.Collections.Generic.List<SubCalendarEvent>>();
//foreach (List<TimeSpan> MySnugPossibility in ListOfSnugPossibilities)
//{
//var MyConcatList = AllTimesSpan.Concat(MySnugPossibility);
// AllTimesSpan=MyConcatList.ToList();
//}
Dictionary <string ,int> DictCalendarEventID_Ini = new System.Collections.Generic.Dictionary<string,int>();
foreach (SubCalendarEvent MySubCalendarEvent in ListOfSubCalendarEvents)
{
EventID MyEventID = new EventID( MySubCalendarEvent.ID);
if (ListOfCaleventIDAndListSubCalendarEvent.ContainsKey(MyEventID.getLevelID(0)))
{
ListOfCaleventIDAndListSubCalendarEvent[MyEventID.getLevelID(0)].Add(MySubCalendarEvent);
}
else
{
ListOfCaleventIDAndListSubCalendarEvent.Add(MyEventID.getLevelID(0),new System.Collections.Generic.List<SubCalendarEvent>());
ListOfCaleventIDAndListSubCalendarEvent[MyEventID.getLevelID(0)].Add(MySubCalendarEvent);
DictCalendarEventID_Ini.Add(MyEventID.getLevelID(0),0);
}
}
List<SubCalendarEvent> MyListOfSubCalendarEvent = new System.Collections.Generic.List<SubCalendarEvent>();
int Index = 0;
Dictionary <string ,int> DictCalendarEventID_Index = new System.Collections.Generic.Dictionary<string,int>(DictCalendarEventID_Ini);
foreach (List<TimeSpanWithID> MyListOfTimeSpanWithID in ListOfSnugPossibilities)
{
DictCalendarEventID_Index = new System.Collections.Generic.Dictionary<string,int>(DictCalendarEventID_Ini);
foreach (TimeSpanWithID MyTimeSpanWithID in MyListOfTimeSpanWithID)
{
string ID=MyTimeSpanWithID.TimeSpanID.getLevelID(0);
Index = DictCalendarEventID_Index[ID];
MyListOfSubCalendarEvent.Add(ListOfCaleventIDAndListSubCalendarEvent[ID][Index]);
++Index;
DictCalendarEventID_Index[ID] = Index;
}
MatchingListOfSnugPossibilitesWithSubcalendarEvents.Add(MyListOfSubCalendarEvent);
MyListOfSubCalendarEvent = new System.Collections.Generic.List<SubCalendarEvent>();
}
return MatchingListOfSnugPossibilitesWithSubcalendarEvents;*/
}
示例6: getAveragedOutTIimeLine
List<Dictionary<TimeSpan, mTuple<int, TimeSpanWithStringID>>> getAveragedOutTIimeLine(List<List<Dictionary<TimeSpan, mTuple<int, TimeSpanWithStringID>>>> arg1, int PreecdintTimeSpanWithSringIDCoun)
{
/*
* Function takes a list of valid possible matches. It uses this list of valid matches to calculate an average which will be used to calculate the best snug possibility
* arg1= The List of possible snug time Lines
*/
List<Dictionary<TimeSpan, mTuple<int, TimeSpanWithStringID>>> retValue = new List<Dictionary<TimeSpan, mTuple<int, TimeSpanWithStringID>>>();
List<Dictionary<TimeSpan, mTuple<int, TimeSpanWithStringID>>> Total = new List<Dictionary<TimeSpan, mTuple<int, TimeSpanWithStringID>>>();
/*if (arg1.Count<1)
{
return retValue;
}*/
foreach (Dictionary<TimeSpan, mTuple<int, TimeSpanWithStringID>> eachDictionary in arg1[0])//initializes Total with the first element in the list
{
Total.Add(new System.Collections.Generic.Dictionary<TimeSpan, mTuple<int, TimeSpanWithStringID>>());
}
int i = 0;
int j = 0;
for (; j < arg1.Count; j++)
{
List<Dictionary<TimeSpan, mTuple<int, TimeSpanWithStringID>>> eachList = arg1[j];
if (j == 30)
{
;
}
i = 0;
foreach (Dictionary<TimeSpan, mTuple<int, TimeSpanWithStringID>> eachDictionary in eachList)
{
foreach (KeyValuePair<TimeSpan, mTuple<int, TimeSpanWithStringID>> eachKeyValuePair in eachDictionary)
{
if (Total[i].ContainsKey(eachKeyValuePair.Key))
{
Total[i][eachKeyValuePair.Key].Item1 += eachKeyValuePair.Value.Item1;
}
else
{
Total[i].Add(eachKeyValuePair.Key, new mTuple<int, TimeSpanWithStringID>(eachKeyValuePair.Value.Item1, eachKeyValuePair.Value.Item2));
}
}
++i;
}
}
Dictionary<TimeSpan, int> RoundUpRoundDown = new System.Collections.Generic.Dictionary<TimeSpan, int>();
i = 0;
foreach (Dictionary<TimeSpan, mTuple<int, TimeSpanWithStringID>> eachDictionary in Total)//initializes Total with the first element in the list
{
retValue.Add(new System.Collections.Generic.Dictionary<TimeSpan, mTuple<int, TimeSpanWithStringID>>());
foreach (KeyValuePair<TimeSpan, mTuple<int, TimeSpanWithStringID>> eachKeyValuePair in eachDictionary)
{
double arg0 = eachKeyValuePair.Value.Item1 / j;
int PassedToRet = (int)Math.Round(arg0);
string[] Int_Decimal = arg0.ToString().Split('.');
if (Int_Decimal.Length == 2)
{
if (Int_Decimal[1] == "5")
{
if (RoundUpRoundDown.ContainsKey(eachKeyValuePair.Key))
{
if (RoundUpRoundDown[eachKeyValuePair.Key] == 0)
{
RoundUpRoundDown[eachKeyValuePair.Key] = 1;
}
else
{
PassedToRet = (int)Math.Floor(arg0);
RoundUpRoundDown[eachKeyValuePair.Key] = 0;
}
}
else
{
PassedToRet = (int)Math.Floor(arg0);
RoundUpRoundDown.Add(eachKeyValuePair.Key, 0);
}
}
}
if (PassedToRet > 0)
{
retValue[i].Add(eachKeyValuePair.Key, new mTuple<int, TimeSpanWithStringID>(PassedToRet, eachKeyValuePair.Value.Item2));
}
}
i++;
}
List<List<Dictionary<TimeSpan, mTuple<int, TimeSpanWithStringID>>>> ListOfPossibleretValue = new System.Collections.Generic.List<System.Collections.Generic.List<System.Collections.Generic.Dictionary<TimeSpan, mTuple<int, TimeSpanWithStringID>>>>();
i = 0;
foreach (List<Dictionary<TimeSpan, mTuple<int, TimeSpanWithStringID>>> eachList in arg1)
{
i = 0;
//.........这里部分代码省略.........
示例7: generateCombinationForDifferentEntries
List<List<SubCalendarEvent>> generateCombinationForDifferentEntries(Dictionary<TimeSpan, mTuple<int, TimeSpanWithStringID>> CompatibleWithList, Dictionary<TimeSpan, Dictionary<string, mTuple<bool, SubCalendarEvent>>> PossibleEntries)
{
/*
* Function attempts to generate multiple combinations of compatible sub calendar event for Snug fit entry
* CompatibleWithList is an snug fit result
* PossibleEntries are the possible sub calendar that can be used in the combinatorial result
*/
++CountCall;
if (CountCall == 4)
{
;
}
List<List<List<string>>> MAtrixedSet = new System.Collections.Generic.List<System.Collections.Generic.List<System.Collections.Generic.List<string>>>();
Dictionary<string, mTuple<int, List<SubCalendarEvent>>> var4 = new System.Collections.Generic.Dictionary<string, mTuple<int, System.Collections.Generic.List<SubCalendarEvent>>>();
List<List<SubCalendarEvent>> retValue = new System.Collections.Generic.List<System.Collections.Generic.List<SubCalendarEvent>>();
foreach (KeyValuePair<TimeSpan, mTuple<int, TimeSpanWithStringID>> eachKeyValuePair0 in CompatibleWithList)//loops every timespan in Snug FIt possibility
{
TimeSpan eachTimeSpan = eachKeyValuePair0.Key;
Dictionary<string, mTuple<bool, SubCalendarEvent>> var1 = PossibleEntries[eachTimeSpan];
List<List<string>> receivedValue = new System.Collections.Generic.List<System.Collections.Generic.List<string>>();
Dictionary<string, int> var2 = new System.Collections.Generic.Dictionary<string, int>();
foreach (KeyValuePair<string, mTuple<bool, SubCalendarEvent>> eachKeyValuePair in var1)
{
string ParentID = eachKeyValuePair.Value.Item2.SubEvent_ID.getStringIDAtLevel(0);
if (var2.ContainsKey(ParentID))
{
++var2[ParentID];
var4[ParentID].Item2.Add(eachKeyValuePair.Value.Item2);
}
else
{
var2.Add(ParentID, 1);
List<SubCalendarEvent> var5 = new System.Collections.Generic.List<SubCalendarEvent>();
var5.Add(eachKeyValuePair.Value.Item2);
var4.Add(ParentID, new mTuple<int, System.Collections.Generic.List<SubCalendarEvent>>(0, var5));
}
}
List<mTuple<string, int>> PossibleCalEvents = new System.Collections.Generic.List<mTuple<string, int>>();
foreach (KeyValuePair<string, int> eachKeyValuePair in var2)
{
PossibleCalEvents.Add(new mTuple<string, int>(eachKeyValuePair.Key, eachKeyValuePair.Value));
}
List<List<string>> var3 = generateCombinationForSpecficTimeSpanStringID(eachKeyValuePair0.Value.Item1, PossibleCalEvents);
MAtrixedSet.Add(var3);
}
List<List<string>> serializedList = Utility.SerializeList(MAtrixedSet);
foreach (List<string> eachList in serializedList)//serializedList has a list of fittable ParentIDs, the loop replaces each List of strings with List of subCalendarEvents
{
List<SubCalendarEvent> var6 = new System.Collections.Generic.List<SubCalendarEvent>();
mTuple<int, List<SubCalendarEvent>> var7 = new mTuple<int, System.Collections.Generic.List<SubCalendarEvent>>(0, new System.Collections.Generic.List<SubCalendarEvent>());
foreach (string eachString in eachList)
{
var7 = var4[eachString];
var6.Add(var7.Item2[var7.Item1++]);
}
foreach (KeyValuePair<string, mTuple<int, List<SubCalendarEvent>>> eachKeyValuePair in var4)
{
eachKeyValuePair.Value.Item1 = 0;
}
//var7.Item1 = 0;
retValue.Add(var6);
}
return retValue;
}
示例8: FurtherFillTimeLineWithSubCalEvents
List<mTuple<bool, SubCalendarEvent>> FurtherFillTimeLineWithSubCalEvents(List<mTuple<bool, SubCalendarEvent>> AllReadyAssignedSubCalEvents, TimeLine ReferenceTimeLine, Dictionary<TimeLine, Dictionary<TimeSpan, mTuple<int, TimeSpanWithStringID>>> AllCompatibleWithList, TimeLine PreceedingTimeLine, Dictionary<TimeLine, Dictionary<TimeSpan, Dictionary<string, mTuple<bool, SubCalendarEvent>>>> PossibleEntries)
{
/*
* CompatibleWithList has whats left after stitchUnRestrictedSubCalendarEvent has removed all possible fittable Events
* Hack Alert: The current implementation does not optimize for restricted values
*/
List<SubCalendarEvent> AssignedSubCalendarEvents = new System.Collections.Generic.List<SubCalendarEvent>();
foreach (mTuple<bool, SubCalendarEvent> eachmTuple in AllReadyAssignedSubCalEvents)
{
AssignedSubCalendarEvents.Add(eachmTuple.Item2);
}
List<TimeSpanWithStringID> LeftOvers = new System.Collections.Generic.List<TimeSpanWithStringID>();
foreach (KeyValuePair<TimeSpan, mTuple<int, TimeSpanWithStringID>> eachKeyValuePair in AllCompatibleWithList[PreceedingTimeLine])
{
if (eachKeyValuePair.Value.Item1 > 0)
{
LeftOvers.Add(eachKeyValuePair.Value.Item2);
}
}
PreceedingTimeLine.Empty();
TimeLine UpdatedTImeLine = Utility.AddSubCaleventsToTimeLine(PreceedingTimeLine, AssignedSubCalendarEvents);
PreceedingTimeLine.AddBusySlots(UpdatedTImeLine.OccupiedSlots);
List<TimeLine> AllFreeSpots = PreceedingTimeLine.getAllFreeSlots().ToList();
Dictionary<TimeLine, List<mTuple<bool, SubCalendarEvent>>> matchingValidSubcalendarEvents = new System.Collections.Generic.Dictionary<TimeLine, System.Collections.Generic.List<mTuple<bool, SubCalendarEvent>>>();//Dictionary contains a match up of the free within already assigned variables and possible fillers
Dictionary<TimeLine, Dictionary<string, mTuple<int, TimeSpanWithStringID>>> ForSnugArray = new System.Collections.Generic.Dictionary<TimeLine, System.Collections.Generic.Dictionary<string, mTuple<int, TimeSpanWithStringID>>>();
Dictionary<TimeLine, SnugArray> FreeSpotSnugArrays = new System.Collections.Generic.Dictionary<TimeLine, SnugArray>();
Dictionary<TimeLine, List<Dictionary<TimeSpan, mTuple<int, TimeSpanWithStringID>>>> FreeSpotSnugPossibiilities = new System.Collections.Generic.Dictionary<TimeLine, System.Collections.Generic.List<System.Collections.Generic.Dictionary<TimeSpan, mTuple<int, TimeSpanWithStringID>>>>();
//Dictionary<TimeLine, List<TimeSpanWithStringID>> FreeSpotSnugPossibilities = new System.Collections.Generic.Dictionary<TimeLine, SnugArray>();
Dictionary<string, SubCalendarEvent> AllMovableSubCalEvents = new System.Collections.Generic.Dictionary<string, SubCalendarEvent>();
List<Dictionary<TimeSpan, mTuple<int, TimeSpanWithStringID>>> AllMoveOvrSet = new System.Collections.Generic.List<System.Collections.Generic.Dictionary<TimeSpan, mTuple<int, TimeSpanWithStringID>>>();
// Dictionary<string, Dictionary<SubCalendarEvent, List<TimeLine>>> SubEventToMatchingTimeLinePossible = new System.Collections.Generic.Dictionary<string, System.Collections.Generic.Dictionary<SubCalendarEvent, System.Collections.Generic.List<TimeLine>>>();
Dictionary<TimeLine, Dictionary<TimeSpan, List<mTuple<bool, SubCalendarEvent>>>> TimeLine_WithMathChingSubCalevents = new Dictionary<TimeLine, Dictionary<TimeSpan, List<mTuple<bool, SubCalendarEvent>>>>();// string in second dictionary is the String of the duration of the SubCalendarEvent
Dictionary<TimeSpan, mTuple<int, TimeSpanWithStringID>> TotalPossibleTimeSpanWithStrings = new System.Collections.Generic.Dictionary<TimeSpan, mTuple<int, TimeSpanWithStringID>>();
foreach (TimeLine eachTimeLine in AllFreeSpots)
{
List<mTuple<bool, SubCalendarEvent>> PossibleFillers = removeSubCalEventsThatCantWorkWithTimeLine(eachTimeLine, PossibleEntries[PreceedingTimeLine].ToList(), true);//hack we need to ensure cases of partial fit
ForSnugArray.Add(eachTimeLine, new System.Collections.Generic.Dictionary<string, mTuple<int, TimeSpanWithStringID>>());
TimeLine_WithMathChingSubCalevents.Add(eachTimeLine, new System.Collections.Generic.Dictionary<TimeSpan, System.Collections.Generic.List<mTuple<bool, SubCalendarEvent>>>());
foreach (mTuple<bool, SubCalendarEvent> eachmTuple in PossibleFillers)
{
if (ForSnugArray[eachTimeLine].ContainsKey(eachmTuple.Item2.ActiveDuration.ToString()))
{
++ForSnugArray[eachTimeLine][eachmTuple.Item2.ActiveDuration.ToString()].Item1;
}
else
{
ForSnugArray[eachTimeLine].Add(eachmTuple.Item2.ActiveDuration.ToString(), new mTuple<int, TimeSpanWithStringID>(1, new TimeSpanWithStringID(eachmTuple.Item2.ActiveDuration, eachmTuple.Item2.ActiveDuration.ToString())));
}
if (!AllMovableSubCalEvents.ContainsKey(eachmTuple.Item2.ID))//populates all movable SubCalendarEVents
{
AllMovableSubCalEvents.Add(eachmTuple.Item2.ID, eachmTuple.Item2);
if (TotalPossibleTimeSpanWithStrings.ContainsKey(eachmTuple.Item2.ActiveDuration))
{
++TotalPossibleTimeSpanWithStrings[eachmTuple.Item2.ActiveDuration].Item1;
}
else
{
TotalPossibleTimeSpanWithStrings.Add(eachmTuple.Item2.ActiveDuration, new mTuple<int, TimeSpanWithStringID>(1, new TimeSpanWithStringID(eachmTuple.Item2.ActiveDuration, eachmTuple.Item2.ActiveDuration.ToString())));
}
}
TimeSpan IdTimeSpan = eachmTuple.Item2.ActiveDuration;
if (TimeLine_WithMathChingSubCalevents[eachTimeLine].ContainsKey(IdTimeSpan))
{
TimeLine_WithMathChingSubCalevents[eachTimeLine][IdTimeSpan].Add(eachmTuple);
}
else
{
TimeLine_WithMathChingSubCalevents[eachTimeLine].Add(IdTimeSpan, new System.Collections.Generic.List<mTuple<bool, SubCalendarEvent>>() { eachmTuple });
}
/*if (SubEventToMatchingTimeLinePossible.ContainsKey(eachmTuple.Item2.ActiveDuration.ToString()))// builds a dictionary of the TimeSpan String ID and a Dictionary of SubCalendar EVents with a List of feasible TimeLine
{
if (SubEventToMatchingTimeLinePossible[eachmTuple.Item2.ActiveDuration.ToString()].ContainsKey(eachmTuple.Item2))
{
SubEventToMatchingTimeLinePossible[eachmTuple.Item2.ActiveDuration.ToString()][eachmTuple.Item2].Add(eachTimeLine);
}
else
{
SubEventToMatchingTimeLinePossible[eachmTuple.Item2.ActiveDuration.ToString()].Add(eachmTuple.Item2, new System.Collections.Generic.List<TimeLine>() { eachTimeLine });
}
}
else
{
SubEventToMatchingTimeLinePossible.Add(eachmTuple.Item2.ActiveDuration.ToString(), new System.Collections.Generic.Dictionary<SubCalendarEvent, System.Collections.Generic.List<TimeLine>>());
SubEventToMatchingTimeLinePossible[eachmTuple.Item2.ActiveDuration.ToString()].Add(eachmTuple.Item2, new System.Collections.Generic.List<TimeLine>() { eachTimeLine });
//.........这里部分代码省略.........
示例9: LoadLevel
//.........这里部分代码省略.........
// case 15: // Iron ore to pumpkin
// ourBlockID = 20;
// break;
// case 9: // Water to water
// ourBlockID = 8;
// //Debug.Log ("Creating some water at [" + blockPos.x + ", " + blockPos.y + ", " + blockPos.z + "]");
// break;
//// case 2:
//// iBlockID = 16;
//// break;
//// case 4:
//// iBlockID = 16;
//// break;
//// case 18:
//// iBlockID = 16;
//// break;
// default:
// {
// //Debug.Log ("Unmapped BlockID: " + iBlockID);
//
// if (!unmappedBlockTypes.ContainsKey (iBlockID))
// {
// unmappedBlockTypes.Add (iBlockID, 1);
// }
// else
// {
// unmappedBlockTypes[iBlockID] += 1;
// }
//
// break;
// }
// }
if(mcToOCBlockDictionary.ContainsKey(iBlockID))
{
ourBlockID = mcToOCBlockDictionary[iBlockID];
} else
{
if(!unmappedBlockTypes.ContainsKey(iBlockID))
{
unmappedBlockTypes.Add(iBlockID, 1);
} else
{
unmappedBlockTypes[iBlockID] += 1;
}
}
if(ourBlockID != -1)
{
OCBlock newBlock = blockSet.GetBlock(ourBlockID);
//OCBlockData block = new OpenCog.Map.OCBlockData(newBlock, blockPos);
OCBlockData block = (OCBlockData)OCScriptableObject.CreateInstance<OCBlockData>();
block.Init(newBlock, blockPos);
chunk.SetBlock(block, blockPos);
OpenCog.Map.Lighting.OCLightComputer.RecomputeLightAtPosition(_map, blockPos);
if(block.block.GetName() == "Battery")
{
GameObject batteryPrefab = OCMap.Instance.BatteryPrefab;
if(batteryPrefab == null)
{
UnityEngine.Debug.LogWarning(OCLogSymbol.WARN + "OCBuilder::Update, batteryPrefab == null");
} else
{
示例10: workerExportPdf_DoWork
//.........这里部分代码省略.........
obj2 = str5;
str5 = string.Concat((object[]) new object[] { obj2, "(", ((int) num5), ")" });
}
report.ReportCacheMode = StiReportCacheMode.Off;
report.Compile();
report.Render(false);
new StiPdfExportService().ExportPdf(report, str5 + ".pdf");
}
}
}
}
catch (System.Exception exception)
{
string message = string.Format("[{0}] Ошибка при выгрузке в PDF: Адрес: {4}, ЛС {3}{1}{2}{1}", new object[] { System.DateTime.Now.ToShortTimeString(), System.Environment.get_NewLine(), exception.get_Message(), notice.AccountNumber, notice.AddressName });
this.AddMessageToLogFile(info.get_FullName(), message, "errors");
continue;
}
int num6 = (int) (((num = (int) (num + 1)) * 100) / notices.get_Count());
worker.ReportProgress(num6, (int) num);
}
}
else
{
BoundaryCollection<long> boundarys = null;
System.Collections.Generic.Dictionary<long, int[]> dictionary = null;
foreach (System.Collections.Generic.KeyValuePair<string, System.Collections.Generic.IList<NoticeNotice>> pair in @params.HouseHolderNotices)
{
boundarys = new BoundaryCollection<long>(@params.MaxNoticesPerDocument, @params.MinHouseCount);
dictionary = new System.Collections.Generic.Dictionary<long, int[]>();
foreach (NoticeNotice notice2 in pair.Value)
{
num = (int) (num + 1);
long num7 = (notice2.AddressLevel == 40) ? notice2.ParentAddrId : notice2.AddrId;
if (!dictionary.ContainsKey(num7))
{
dictionary.Add(num7, new int[] { 1, notice2.AddressLevel });
}
else
{
dictionary[num7][0] += 1;
}
}
int num8 = (int) ((num * 100) / notices.get_Count());
worker.ReportProgress(num8, (int) num);
foreach (System.Collections.Generic.KeyValuePair<long, int[]> pair2 in dictionary)
{
boundarys.Add(pair2.Key, pair2.Value[0]);
}
System.Collections.Generic.Dictionary<string, int> dictionary2 = new System.Collections.Generic.Dictionary<string, int>();
foreach (BoundaryCollectionNode<long> node in boundarys.Lists)
{
if (node.Items.get_Count() > 0)
{
if (worker.get_CancellationPending())
{
e.set_Cancel(true);
break;
}
ObjectList<NoticeNotice> list3 = new ObjectList<NoticeNotice>();
string str7 = null;
System.Text.StringBuilder builder = new System.Text.StringBuilder();
foreach (long num9 in node.Items)
{
foreach (NoticeNotice notice3 in notices)
{
if (dictionary[num9][1] == 40)
示例11: RefreshTreeviewNodeFormatting
private void RefreshTreeviewNodeFormatting(TreeNode treeNode)
{
Cursor origCursor = Cursor.Current;
Cursor.Current = Cursors.WaitCursor;
//if (isFolder(treeNode))
if (treeNode.Nodes.Count > 0)
{
// First rename (title) the node items...
//value = "{get_accession.accession_number_part1} + \" \" + {get_accession.accession_number_part2} + \" \" + {get_accession.accession_number_part3}; ";
System.Collections.Generic.Dictionary<string, string> idTypeFormattingFormula = new System.Collections.Generic.Dictionary<string, string>();
System.Collections.Generic.List<string> idTypes = new System.Collections.Generic.List<string>();
System.Collections.Generic.Dictionary<string, string> idNumbers = new System.Collections.Generic.Dictionary<string, string>();
DataSet ds = new DataSet();
// First find all of the distinct ID_TYPES,
// their corresponding formatting formulas,
// and gather all of the ID_NUMBERS for each ID_TYPE in the userItemList collection...
foreach (TreeNode tn in treeNode.Nodes)
{
if (!isFolder(tn))
{
//string pKey = tn.Tag.ToString().Split(';')[1].Trim();
//string nodePKeyType = pKey.Split('=')[0].Replace(":", "").Trim().ToUpper();
//string nodePKeyValue = pKey.Split('=')[1].Trim().ToUpper();
string[] pKey = tn.Name.Split('=');
string nodePKeyType = pKey[0];
string nodePKeyValue = pKey[1];
// Get the ID_TYPE...
if (!idTypes.Contains(nodePKeyType)) idTypes.Add(nodePKeyType);
// Now get the formatting formula for each ID_TYPE in the collection...
if (!idTypeFormattingFormula.ContainsKey(nodePKeyType))
{
//string formula = GetTreeviewNodeProperty(nodePKeyType + "_NAME_FORMULA", tn);
string formula = GetTreeviewNodeProperty(tn.Tag.ToString().Split(';')[0].Trim().ToUpper() + "_NAME_FORMULA", tn, true, "");
if (string.IsNullOrEmpty(formula))
{
// Could not find a formula for this type of treenode object type...
}
idTypeFormattingFormula.Add(nodePKeyType, formula);
}
// Next collect all of the ID_NUMBERS for each of the ID_TYPES for the userItemList collection...
if (!idNumbers.ContainsKey(nodePKeyType))
{
idNumbers.Add(nodePKeyType, nodePKeyValue + ",");
}
else
{
idNumbers[nodePKeyType] = idNumbers[nodePKeyType] + nodePKeyValue + ",";
}
}
else
{
if (ux_checkboxIncludeSubFolders.Checked)
{
RefreshTreeviewNodeFormatting(tn);
}
}
}
Dictionary<string, Dictionary<int, string>> friendlyNames = new Dictionary<string,Dictionary<int,string>>();
// Make all the trips to the server now to get all data needed for new userItemList titles...
foreach (string idType in idTypes)
{
// Create the new dictionary LU for the friendly name and add it to the collection...
friendlyNames.Add(idType, new Dictionary<int, string>());
// Break down the name formula into tokens and process the tokens one by one...
string[] formatTokens = idTypeFormattingFormula[idType].Split(new string[] { " + " }, StringSplitOptions.RemoveEmptyEntries);
string staticTextSeparator = "";
foreach (string formatToken in formatTokens)
{
if (formatToken.Contains("{") &&
formatToken.Contains("}"))
{
// This is a DB field used in the title - so if we don't already have it go get it now...
string[] dataviewAndField = formatToken.Trim().Replace("{", "").Replace("}", "").Trim().Split(new char[] { '.' });
if (!ds.Tables.Contains(dataviewAndField[0]))
{
DataSet newDS = _sharedUtils.GetWebServiceData(dataviewAndField[0], idType.Trim().ToLower() + "=" + idNumbers[idType].Trim().TrimEnd(','), 0, 0);
if (newDS != null &&
newDS.Tables.Contains(dataviewAndField[0]))
{
ds.Tables.Add(newDS.Tables[dataviewAndField[0]].Copy());
}
else if (newDS.Tables.Contains("ExceptionTable") &&
newDS.Tables["ExceptionTable"].Rows.Count > 0)
{
GRINGlobal.Client.Common.GGMessageBox ggMessageBox = new GRINGlobal.Client.Common.GGMessageBox("There was an unexpected error retrieving data from {0} to use in building a node friendly name.\n\nFull error message:\n{1}", "Get Name Data Error", MessageBoxButtons.OK, MessageBoxDefaultButton.Button1);
ggMessageBox.Name = "RefreshTreeviewNodeFormatting1";
_sharedUtils.UpdateControls(ggMessageBox.Controls, ggMessageBox.Name);
//if (ggMessageBox.MessageText.Contains("{0}") &&
// ggMessageBox.MessageText.Contains("{1}"))
//{
// ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, dataviewAndField[0], newDS.Tables["ExceptionTable"].Rows[0]["Message"].ToString());
//}
//else if (ggMessageBox.MessageText.Contains("{0}"))
//{
// ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, dataviewAndField[0]);
//.........这里部分代码省略.........
示例12: LoadDic
//--------------------------------------------------------------------------------------------------------
/// <summary>
/// 载入词典词库 (载入的默认词库文件为同目目录下的DicKey.dic)
/// </summary>
/// <returns></returns>
public bool LoadDic(string subPath)
{
//if (!subPath.Equals("XJU.SpellCheck.Spelling"))
// return false;
try
{
this.fs = new System.IO.FileStream("Dic.dic", System.IO.FileMode.Open);
this.sr = new System.IO.StreamReader(fs, System.Text.Encoding.Default);
this.DicTemp = new List<int>();
this.myDic = new Dictionary<string, string>();
this.resulList = new Dictionary<string, float>();
this.myDicList = new List<string>();
string inStr;
//开始读
while (sr.Peek() >= 0)
{
inStr = sr.ReadLine().Trim();
if (!myDic.ContainsKey(inStr))
{
this.myDic.Add(inStr, String.Empty);
this.myDicList.Add(inStr);
}
}
//清理工作
this.sr.Close();
this.fs.Close();
}
catch(Exception openErr)
{
this.myDic = null;
this.errMessage = openErr.Message;
return false;
}
try
{
this.fs = new System.IO.FileStream("user.dic", System.IO.FileMode.Open);
this.sr = new System.IO.StreamReader(fs, System.Text.Encoding.Default);
string inStr;
//开始读
while (sr.Peek() >= 0)
{
inStr = sr.ReadLine().Trim();
if (!myDic.ContainsKey(inStr))
{
myDic.Add(inStr, String.Empty);
this.myDicList.Add(inStr);
}
}
//清理工作
this.sr.Close();
this.fs.Close();
return true;
}
catch (Exception openErr)
{
this.errMessage = openErr.Message;
return true;
}
}
示例13: LoadRepDic
public bool LoadRepDic(string repdicFullPath, string subPath)
{
//if (!subPath.Equals("XJU.SpellCheck.Spelling"))
// return false;
try
{
this.fs = new System.IO.FileStream(repdicFullPath, System.IO.FileMode.Open);
this.sr = new System.IO.StreamReader(fs, System.Text.Encoding.Default);
this.myRepDic = new Dictionary<string, string>();
ArrayList al = new ArrayList();
string[] inStr;
//开始读
while (sr.Peek() >= 0)
{
inStr = sr.ReadLine().Split(new char[] { '\t' });
if (!myRepDic.ContainsKey(inStr[0]))
{
//al.Clear();
//al.Add(inStr[1]);
try
{
this.myRepDic.Add(inStr[0], inStr[1]);
}
catch (Exception err)
{
//past
}
}
}
//清理工作
this.sr.Close();
this.fs.Close();
return true;
}
catch (Exception openErr)
{
this.errMessage = openErr.Message;
this.myRepDic = null;
return false;
}
}
示例14: Podsumowanie
public ActionResult Podsumowanie(Dokument dok)
{
if (!MusicStore.Models.Module.User.IsAuthenticated) return RedirectToAction("Index", "Home");
if (MusicStore.Models.Module.User.GetCurrentRole() != MusicStore.Models.Module.User.Klient) return RedirectToAction("Index", "Home");
DbModule module = DbModule.GetInstance();
string[] koszyk = Request.Cookies["Cart"].Value.ToString().Split(',');
var dict = new System.Collections.Generic.Dictionary<int, int>();
if (!String.IsNullOrEmpty(Request.Cookies["Cart"].Value))
foreach (string Ids in koszyk)
{
int Id = int.Parse(Ids);
if (!dict.ContainsKey(Id))
{
dict.Add(Id, 1);
}
else
{
dict[Id] += 1;
}
}
var dict2 = new System.Collections.Generic.Dictionary<Album, int>();
decimal wartosc = 0;
string waluta = "";
foreach (var obiekt in dict)
{
var album = module.Albumy.Where(x => x.Id == obiekt.Key).First();
dict2.Add(album, obiekt.Value);
wartosc += album.BruttoValue * obiekt.Value;
if (waluta == "")
{
waluta = album.BruttoSymbol;
}
else if (waluta != album.BruttoSymbol)
{
waluta = "(Wiele walut)";
wartosc = 0;
}
}
ViewBag.wartosc = wartosc;
ViewBag.waluta = waluta;
ViewBag.Pozycje = dict2;
return View(dok);
}
示例15: GetInstalledPlugIns
public static System.Collections.Generic.Dictionary<Guid, string> GetInstalledPlugIns()
{
int count = InstalledPlugInCount;
System.Collections.Generic.Dictionary<Guid, string> plug_in_dictionary = new System.Collections.Generic.Dictionary<Guid, string>(32);
for (int i = 0; i < count; i++)
{
IntPtr name = UnsafeNativeMethods.CRhinoPlugInManager_GetName(i);
if (name != IntPtr.Zero)
{
string sName = Marshal.PtrToStringUni(name);
if (!string.IsNullOrEmpty(sName))
{
Guid id = UnsafeNativeMethods.CRhinoPlugInManager_GetID(i);
if (id != Guid.Empty && !plug_in_dictionary.ContainsKey(id))
plug_in_dictionary.Add(id, sName);
}
}
}
return plug_in_dictionary;
}