public static void dictionaryIteration() { Console.WriteLine("# Dictionary Iteration Sample"); Dictionary<Int32, String> map = new Dictionary<Int32, String>(); map[10] = "Hello"; map[20] = "Lorem"; map[30] = "Ipsum"; Dictionary<Int32, String>.Enumerator iterator = map.GetEnumerator(); while (iterator.MoveNext()) { KeyValuePair<Int32, String> pair = iterator.Current; Console.WriteLine(pair.Key + " : " + pair.Value); } IEnumerator<KeyValuePair<Int32, String>> iterator2 = map.GetEnumerator(); while (iterator2.MoveNext()) { KeyValuePair<Int32, String> pair = iterator2.Current; Console.WriteLine(pair.Key + " : " + pair.Value); } foreach (KeyValuePair<Int32, String> pair in map) { Console.WriteLine(pair.Key + " : " + pair.Value); } }
public Task Run() { var allTestMethods = testMethodExtractor.GetTestMethods(); var testMethodsDistribution = new Dictionary<ITestRunner, IList<IMethodInfo>>(); foreach (var runner in testRunners) { testMethodsDistribution.Add(runner, new List<IMethodInfo>()); } var testMethodsDistributionEnum = testMethodsDistribution.GetEnumerator(); foreach (var testMethod in allTestMethods) { KeyValuePair<ITestRunner, IList<IMethodInfo>> distribution; if (testMethodsDistributionEnum.MoveNext()) { distribution = testMethodsDistributionEnum.Current; } else { testMethodsDistributionEnum = testMethodsDistribution.GetEnumerator(); testMethodsDistributionEnum.MoveNext(); distribution = testMethodsDistributionEnum.Current; } distribution.Value.Add(testMethod); } var allRunnersTasks = testMethodsDistribution.Select(r=>r.Key.Run(r.Value.ToArray())); return Task.Factory.StartNew( () => Task.WaitAll(allRunnersTasks.ToArray())); }
public void foo() { long n = long.Parse(Console.ReadLine()); string[] sp = Console.ReadLine().Split(' '); Dictionary<long, long> dict = new Dictionary<long, long>(); for (long i = 0; i < n; i++) { long a = long.Parse(sp[i]); if (dict.ContainsKey(a)) { dict[a]++; } else { dict.Add(a, 1); } } Dictionary<long, long> dict1 = new Dictionary<long, long>(); var e = dict.GetEnumerator(); while (e.MoveNext()) { var p = e.Current; dict1.Add(p.Key, p.Value); } sp = Console.ReadLine().Split(' '); for (long i = 0; i < n - 1; i++) { long a = long.Parse(sp[i]); dict[a]--; if (dict[a] == 0) dict.Remove(a); } e = dict.GetEnumerator();e.MoveNext(); Console.WriteLine(e.Current.Key); dict1[e.Current.Key]--; if (dict1[e.Current.Key] == 0) dict1.Remove(e.Current.Key); sp = Console.ReadLine().Split(' '); for (long i = 0; i < n - 2; i++) { long a = long.Parse(sp[i]); dict1[a]--; if (dict1[a] == 0) dict1.Remove(a); } e = dict1.GetEnumerator();e.MoveNext(); Console.WriteLine(e.Current.Key); }
private void SetFunctions(Dictionary<string, int> functions) { this.m_FunctionsListInputData.m_ListElements.Clear(); if (functions == null) this.m_FunctionsListInputData.NewOrMatchingElement("Querying instrumentable functions...").enabled = false; else if (functions.Count == 0) { this.m_FunctionsListInputData.NewOrMatchingElement("No instrumentable child functions found").enabled = false; } else { this.m_FunctionsListInputData.m_MaxCount = Mathf.Clamp(functions.Count + 1, 0, 30); if (this.m_ShowAllCheckbox) { this.m_AllCheckbox = new PopupList.ListElement(" All", false, float.MaxValue); this.m_FunctionsListInputData.m_ListElements.Add(this.m_AllCheckbox); } using (Dictionary<string, int>.Enumerator enumerator = functions.GetEnumerator()) { while (enumerator.MoveNext()) { KeyValuePair<string, int> current = enumerator.Current; PopupList.ListElement listElement = new PopupList.ListElement(current.Key, current.Value != 0); listElement.ResetScore(); this.m_FunctionsListInputData.m_ListElements.Add(listElement); } } if (!this.m_ShowAllCheckbox) return; this.UpdateAllCheckbox(); } }
public JSONStructIterator(JSONEntry oEntry, String strName) { m_object = (Dictionary<string, object>)oEntry.getObject(strName); m_enumStruct = m_object.GetEnumerator(); if (m_enumStruct.MoveNext()) m_strCurKey = m_enumStruct.Current.Key; }
public bool PosTest2() { bool retVal = true; TestLibrary.TestFramework.BeginScenario("PosTest2:Invoke the method GetEnumerator in ValueCollection Generic IEnumerable 2"); try { Dictionary<TestClass, TestClass> dic = new Dictionary<TestClass, TestClass>(); TestClass TKey1 = new TestClass(); TestClass TVal1 = new TestClass(); TestClass TKey2 = new TestClass(); TestClass TVal2 = new TestClass(); dic.Add(TKey1, TVal1); dic.Add(TKey2, TVal2); IEnumerable<TestClass> ienumer = (IEnumerable<TestClass>)new Dictionary<TestClass, TestClass>.ValueCollection(dic); IEnumerator<TestClass> ienumerator = ienumer.GetEnumerator(); Dictionary<TestClass, TestClass>.Enumerator dicEnumer = dic.GetEnumerator(); while (ienumerator.MoveNext() && dicEnumer.MoveNext()) { if (!ienumerator.Current.Equals(dicEnumer.Current.Value)) { TestLibrary.TestFramework.LogError("003", "the ExpecResult is not the ActualResult"); retVal = false; } } } catch (Exception e) { TestLibrary.TestFramework.LogError("004", "Unexpect exception:" + e); retVal = false; } return retVal; }
public bool PosTest2() { bool retVal = true; TestLibrary.TestFramework.BeginScenario("Return the property get_Current in the IEnumerator 2"); try { Dictionary<TestClass, TestClass> dictionary = new Dictionary<TestClass, TestClass>(); TestClass Tkey1 = new TestClass(); TestClass TVal1 = new TestClass(); dictionary.Add(Tkey1, TVal1); Dictionary<TestClass, TestClass>.Enumerator enumer = dictionary.GetEnumerator(); IEnumerator iEnumer = (IEnumerator)enumer; while(iEnumer.MoveNext()) { object objCurrent = iEnumer.Current; KeyValuePair<TestClass, TestClass> keyVal = new KeyValuePair<TestClass, TestClass>(Tkey1, TVal1); if (!objCurrent.Equals(keyVal)) { TestLibrary.TestFramework.LogError("003", "the ExpectResult is not the ActualResult"); retVal = false; } } } catch (Exception e) { TestLibrary.TestFramework.LogError("004", "Unexpect exception:" + e); retVal = false; } return retVal; }
/// <summary> /// /// </summary> /// <param name="url"></param> /// <param name="referer"></param> /// <returns></returns> protected HttpWebRequest PostRequest(string url, string referer, Dictionary<string,string> prams) { HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(url); req.Proxy = Proxy; req.AllowAutoRedirect = false; req.UserAgent = ConstData.UserAgent; req.Referer = referer; req.Headers.Add("Cookie", Cookie); req.Timeout = 30 * 1000; req.Method = "POST"; req.ContentType = "application/x-www-form-urlencoded"; System.Text.StringBuilder sb = new StringBuilder(); Dictionary<string, string>.Enumerator e = prams.GetEnumerator(); while (e.MoveNext()) { sb.AppendFormat("{0}={1}&", e.Current.Key, e.Current.Value); } req.ContentLength = System.Text.Encoding.UTF8.GetByteCount(sb.ToString()); using(System.IO.StreamWriter sw = new System.IO.StreamWriter(req.GetRequestStream())) { sw.Write(sb.ToString()); } return req; }
public bool PosTest1() { bool retVal = true; TestLibrary.TestFramework.BeginScenario("Return the property get_Current in the IEnumerator 1"); try { Dictionary<string, string> dictionary = new Dictionary<string, string>(); dictionary.Add("str1", "helloworld"); Dictionary<string, string>.Enumerator enumer = dictionary.GetEnumerator(); IEnumerator iEnumer = (IEnumerator)enumer; while (iEnumer.MoveNext()) { object objCurrent = iEnumer.Current; KeyValuePair<string, string> keyVal = new KeyValuePair<string, string>("str1", "helloworld"); if (!objCurrent.Equals(keyVal)) { TestLibrary.TestFramework.LogError("001", "the ExpectResult is not the ActualResult"); retVal = false; } } } catch (Exception e) { TestLibrary.TestFramework.LogError("002", "Unexpect exception:" + e); retVal = false; } return retVal; }
public bool PosTest1() { bool retVal = true; TestLibrary.TestFramework.BeginScenario("PosTest1:Invoke the method GetEnumerator in ValueCollection Generic IEnumerable 1"); try { Dictionary<string, string> dic = new Dictionary<string, string>(); dic.Add("str1", "Test1"); dic.Add("str2", "Test2"); IEnumerable<string> ienumer = (IEnumerable<string>)new Dictionary<string, string>.ValueCollection(dic); IEnumerator<string> ienumerator = ienumer.GetEnumerator(); Dictionary<string, string>.Enumerator dicEnumer = dic.GetEnumerator(); while (ienumerator.MoveNext() && dicEnumer.MoveNext()) { if (!ienumerator.Current.Equals(dicEnumer.Current.Value)) { TestLibrary.TestFramework.LogError("001", "the ExpecResult is not the ActualResult"); retVal = false; } } } catch (Exception e) { TestLibrary.TestFramework.LogError("002", "Unexpect exception:" + e); retVal = false; } return retVal; }
public int countBananaSplits(string[] ingredients) { Dictionary<string, int> dict = new Dictionary<string, int>(); for (int i = 0; i < ingredients.Length; i++) { if (dict.ContainsKey(ingredients[i])) { dict[ingredients[i]]++; } else { dict.Add(ingredients[i], 1); } } if (!dict.ContainsKey("ice cream")) { return 0; } if (!dict.ContainsKey("banana")) { return 0; } int ret = 1; Dictionary<string, int>.Enumerator e = dict.GetEnumerator(); while (e.MoveNext()) { if (e.Current.Key != "ice cream" && e.Current.Key != "banana") ret *= (e.Current.Value + 1); } return dict["ice cream"]*dict["banana"]*(ret - 1); }
public static void ShowSensorSelectionWindow(Vector2 nSize, Rect nPosition, VRPNDataObject nInFront) { size = nSize; pos = nPosition; inFront = nInFront; sensors = VRPNEditEditor.Instance.GetSensors(inFront.dataName, inFront.originalDataTime, inFront.dataDevice); disabledSensors = VRPNEditEditor.Instance.GetDisabledSensors(inFront.dataName, inFront.originalDataTime, inFront.dataDevice); states = new bool[sensors.Count]; sensorsE = sensors.GetEnumerator(); //Initial sensors state int numSensor = 0; while (sensorsE.MoveNext()) { int test; if (disabledSensors.TryGetValue(sensorsE.Current.Key, out test)) { states[numSensor] = false; } else { states[numSensor] = true; } numSensor++; } VRPNSensorSelectionWindow window = VRPNSensorSelectionWindow.CreateInstance<VRPNSensorSelectionWindow>(); window.ShowAsDropDown(pos, size); }
public bool PosTest2() { bool retVal = true; TestLibrary.TestFramework.BeginScenario("Return the property Current of in the Dictionary Enumerator 2"); try { Dictionary<string, string> dictionary = new Dictionary<string, string>(); dictionary.Add("str1", "helloworld"); Dictionary<string, string>.Enumerator enumer = dictionary.GetEnumerator(); if (enumer.MoveNext()) { KeyValuePair<string, string> keyVal = enumer.Current; if (keyVal.Key != "str1" || keyVal.Value != "helloworld") { TestLibrary.TestFramework.LogError("003", "the ExpectResult is not the ActualResult"); retVal = false; } } } catch (Exception e) { TestLibrary.TestFramework.LogError("004", "Unexpect exception:" + e); retVal = false; } return retVal; }
public bool PosTest2() { bool retVal = true; TestLibrary.TestFramework.BeginScenario("Return the property get_Entry in the IDictionaryEnumerator 2"); try { Dictionary<TestClass,TestClass> dictionary = new Dictionary<TestClass,TestClass>(); TestClass Tkey1 = new TestClass(); TestClass TVal1 = new TestClass(); dictionary.Add(Tkey1,TVal1); Dictionary<TestClass,TestClass>.Enumerator enumer = dictionary.GetEnumerator(); IDictionaryEnumerator idicEnumer = (IDictionaryEnumerator)enumer; if (idicEnumer.MoveNext()) { DictionaryEntry entryVal = idicEnumer.Entry; if (entryVal.Key != Tkey1 || entryVal.Value != TVal1) { TestLibrary.TestFramework.LogError("003", "the ExpectResult is not the ActualResult"); retVal = false; } } } catch (Exception e) { TestLibrary.TestFramework.LogError("004", "Unexpect exception:" + e); retVal = false; } return retVal; }
public JSONStructIterator(JSONEntry oEntry) { m_object = oEntry.getObject(); m_enumStruct = m_object.GetEnumerator(); if (m_enumStruct.MoveNext()) m_strCurKey = m_enumStruct.Current.Key; }
public bool PosTest2() { bool retVal = true; TestLibrary.TestFramework.BeginScenario("Invoke the method Reset in the IEnumerator 2"); try { Dictionary<string, string> dictionary = new Dictionary<string, string>(); dictionary.Add("str1", "helloworld"); Dictionary<string, string>.Enumerator enumer = dictionary.GetEnumerator(); IEnumerator iEnumer = (IEnumerator)enumer; while (iEnumer.MoveNext()) { } iEnumer.Reset(); while (iEnumer.MoveNext()) { KeyValuePair<string, string> keyVal1 = (KeyValuePair<string, string>)iEnumer.Current; if (keyVal1.Key != "str1" || keyVal1.Value != "helloworld") { TestLibrary.TestFramework.LogError("001", "the ExpectResult is not the ActualResult"); retVal = false; } } } catch (Exception e) { TestLibrary.TestFramework.LogError("002", "Unexpect exception:" + e); retVal = false; } return retVal; }
public bool PosTest1() { bool retVal = true; TestLibrary.TestFramework.BeginScenario("Return the property get_Entry in the IDictionaryEnumerator 1"); try { Dictionary<string, string> dictionary = new Dictionary<string, string>(); dictionary.Add("str1", "helloworld"); Dictionary<string, string>.Enumerator enumer = dictionary.GetEnumerator(); IDictionaryEnumerator idicEnumer = (IDictionaryEnumerator)enumer; if (idicEnumer.MoveNext()) { DictionaryEntry entryVal = idicEnumer.Entry; if (entryVal.Key.ToString() != "str1" || entryVal.Value.ToString() != "helloworld") { TestLibrary.TestFramework.LogError("001", "the ExpectResult is not the ActualResult"); retVal = false; } } } catch (Exception e) { TestLibrary.TestFramework.LogError("002", "Unexpect exception:" + e); retVal = false; } return retVal; }
public void foo() { int q = int.Parse(Console.ReadLine()); Dictionary<string, string> ch = new Dictionary<string, string>(); for (int i = 0; i < q; i++) { string[] sp = Console.ReadLine().Split(' '); string o = sp[0]; string n = sp[1]; if (ch.ContainsKey(o)) { ch.Add(n, ch[o]); ch.Remove(o); } else { ch.Add(n, o); } } Console.WriteLine(ch.Count); Dictionary<string, string>.Enumerator e = ch.GetEnumerator(); while(e.MoveNext()) { Console.WriteLine(e.Current.Value + " " + e.Current.Key); } }
public void GetEnumerator_KeyCollectionWithOneElementDictionary_NotNull() { var dictionary = new Dictionary<int, int>(); dictionary.Add(1, 1); var keyCollection = new Dictionary<int, int>.KeyCollection(dictionary); // Assert.NotNull(keyCollection.GetEnumerator()); }
public void Print(Dictionary<string, object> dic) { var enumer = dic.GetEnumerator(); while (enumer.MoveNext()) { Debug.Log(enumer.Current.Key + " : " + enumer.Current.Value); } }
public void ImportConditionTable( Dictionary< string /*Chapter*/ , string > _Set ) { Dictionary<string,string>.Enumerator i = _Set.GetEnumerator() ; while( i.MoveNext() ) { AddConditionTable( i.Current.Key , i.Current.Value ) ; } }
public JSONStructIterator(String szData) { m_object = (Dictionary<string, object>)JsonParser.JsonDecode(szData); m_enumStruct = m_object.GetEnumerator(); if ( m_enumStruct.MoveNext() ) m_strCurKey = m_enumStruct.Current.Key; }
public void ImportStandardParameter( Dictionary< string , StandardParameter > _ParameterMap ) { Dictionary< string , StandardParameter >.Enumerator i = _ParameterMap.GetEnumerator() ; while( i.MoveNext() ) { AssignStandardParameter( i.Current.Key , i.Current.Value ) ; } }
/// <summary> /// Populates the page with content passed during navigation. Any saved state is also /// provided when recreating a page from a prior session. /// </summary> /// <param name="navigationParameter">The parameter value passed to /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested. /// </param> /// <param name="pageState">A dictionary of state preserved by this page during an earlier /// session. This will be null the first time a page is visited.</param> protected override void LoadState(Object navigationParameter, Dictionary<String, Object> pageState) { if (pageState != null) { var enumerator = pageState.GetEnumerator(); do { var pair = enumerator.Current; var control = Util.FindControl(this, pair.Key); var textBox = control as TextBox; if (textBox != null) { textBox.Text = pair.Value as String; continue; } var comboBox = control as ComboBox; if (comboBox != null) { if (pair.Key == this.comboBoxDevices1.Name) { this.previousSelectedDeviceId1 = pair.Value as String; } else if (pair.Key == this.comboBoxDevices2.Name) { this.previousSelectedDeviceId2 = pair.Value as String; } else for (int j = 0; j < comboBox.Items.Count; j ++) { var comboBoxItem = comboBox.Items[j] as ComboBoxItem; if (comboBoxItem.Content as String == pair.Value as String) { comboBox.SelectedIndex = j; break; } } continue; } } while (enumerator.MoveNext()); } // Dispose all devices which are used in Scenario1 to 3. UsbCdcControl.UsbDeviceList.Singleton.DisposeAll(); foreach (var deviceList in UsbCdcControl.DeviceList.Instances) { foreach (var info in deviceList.Devices) { this.OnDeviceAdded(this, new UsbDeviceInfo(info)); } } UsbCdcControl.UsbDeviceList.Singleton.DeviceAdded += this.OnDeviceAdded; UsbCdcControl.UsbDeviceList.Singleton.DeviceRemoved += this.OnDeviceRemoved; this.buttonLoopbackTest.IsEnabled = false; this.buttonStopLoopback.IsEnabled = false; }
internal void FindJobDefinitionsByName(string[] names, Action<ScheduledJobDefinition> itemFound, bool writeErrorsAndWarnings = true) { HashSet<string> strs = new HashSet<string>(names); Dictionary<string, WildcardPattern> strs1 = new Dictionary<string, WildcardPattern>(); string[] strArrays = names; for (int i = 0; i < (int)strArrays.Length; i++) { string str = strArrays[i]; if (!strs1.ContainsKey(str)) { strs1.Add(str, new WildcardPattern(str, WildcardOptions.IgnoreCase)); } } Dictionary<string, Exception> strs2 = ScheduledJobDefinition.RefreshRepositoryFromStore((ScheduledJobDefinition definition) => { foreach (KeyValuePair<string, WildcardPattern> pattern in strs1) { if (!pattern.Value.IsMatch(definition.Name) || !this.ValidateJobDefinition(definition)) { continue; } itemFound(definition); if (!strs.Contains(pattern.Key)) { continue; } strs.Remove(pattern.Key); } } ); foreach (KeyValuePair<string, Exception> keyValuePair in strs2) { Dictionary<string, WildcardPattern>.Enumerator enumerator = strs1.GetEnumerator(); try { while (enumerator.MoveNext()) { var keyValuePair1 = enumerator.Current; if (!keyValuePair1.Value.IsMatch(keyValuePair.Key)) { continue; } this.HandleLoadError(keyValuePair.Key, keyValuePair.Value); } } finally { enumerator.Dispose(); } } if (writeErrorsAndWarnings) { foreach (string str1 in strs) { this.WriteDefinitionNotFoundByNameError(str1); } } }
public void Dispose_OneElementDictionary_NotNull() { var dictionary = new Dictionary<int, int>(); dictionary.Add(1, 1); var keyCollection = new Dictionary<int, int>.KeyCollection(dictionary); var enumerator = keyCollection.GetEnumerator(); // enumerator.Dispose(); }
public void MoveNext_OneElementDictionary_EqualsTrue() { var dictionary = new Dictionary<int, int>(); dictionary.Add(1, 1); var keyCollection = new Dictionary<int, int>.KeyCollection(dictionary); var enumerator = keyCollection.GetEnumerator(); // Assert.True(enumerator.MoveNext()); }
private String GetText(Dictionary<UInt32, ThreadStack> threadStacks) { Dictionary<UInt32, ThreadStack>.Enumerator enumer = threadStacks.GetEnumerator(); if(enumer.MoveNext()) { ThreadStack threadStack = enumer.Current.Value; return "AppDomain (" + r_manager.GetValue(threadStack.DomainId) + ") " + threadStack.DomainName; } return r_appDomainNode.Text; }
public void getCurrent_OneElementDictionary_NotNull() { var dictionary = new Dictionary<int, int>(); dictionary.Add(1, 1); var keyCollection = new Dictionary<int, int>.KeyCollection(dictionary); var enumerator = dictionary.GetEnumerator(); enumerator.MoveNext(); // Assert.NotNull(enumerator.Current); }
//PROTOBUF public override void ExecuteCommand(ClientManager clientManager, Alachisoft.NCache.Common.Protobuf.Command command) { CommandInfo cmdInfo; try { cmdInfo = ParseCommand(command, clientManager); } catch (Exception exc) { if (!base.immatureId.Equals("-2")) _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID)); return; } Cache cache = null; try { string server = ConnectionManager.ServerIpAddress; int port = ConnectionManager.ServerPort; Dictionary<string, int> runningServers = new Dictionary<string, int>(); cache = CacheProvider.Provider.GetCacheInstanceIgnoreReplica(cmdInfo.CacheId); if (cache == null) throw new Exception("Cache is not registered"); if (!cache.IsRunning) throw new Exception("Cache is not running"); runningServers = cache.GetRunningServers(server, port); Alachisoft.NCache.Common.Protobuf.Response response = new Alachisoft.NCache.Common.Protobuf.Response(); Alachisoft.NCache.Common.Protobuf.GetRunningServersResponse getRunningServerResponse = new Alachisoft.NCache.Common.Protobuf.GetRunningServersResponse(); if (runningServers != null) { Dictionary<string, int>.Enumerator ide = runningServers.GetEnumerator(); while (ide.MoveNext()) { Common.Protobuf.KeyValuePair pair = new Common.Protobuf.KeyValuePair(); pair.key = ide.Current.Key; pair.value = ide.Current.Value.ToString(); getRunningServerResponse.keyValuePair.Add(pair); } } response.requestId = Convert.ToInt64(cmdInfo.RequestId); response.getRunningServer = getRunningServerResponse; response.responseType = Alachisoft.NCache.Common.Protobuf.Response.Type.GET_RUNNING_SERVERS; _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response)); } catch (Exception exc) { _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID)); } }
IEnumerator <KeyValuePair <string, Starcraft> > IEnumerable <KeyValuePair <string, Starcraft> > .GetEnumerator() { return(m_ConfigurationDictionary.GetEnumerator()); }
public IEnumerator <KeyValuePair <int, string> > GetEnumerator() { return(_backingDictionary.GetEnumerator()); }
public Dictionary <string, Func <byte[]> > .Enumerator GetEnumerator() { return(plan.GetEnumerator()); }
public IEnumerator GetEnumerator() { return(_Items.GetEnumerator()); }
public IEnumerator <KeyValuePair <string, ModelState> > GetEnumerator() { return(_innerDictionary.GetEnumerator()); }
public override void Draw(Rect parentPosition, Vector2 mousePosition, int mouseButtonId, bool hasKeyboadFocus) { base.Draw(parentPosition, mousePosition, mouseButtonId, hasKeyboadFocus); if (m_previousWindowIsFunction != ParentWindow.IsShaderFunctionWindow) { m_forceUpdate = true; } m_previousWindowIsFunction = ParentWindow.IsShaderFunctionWindow; List <ContextMenuItem> allItems = ParentWindow.ContextMenuInstance.MenuItems; if (m_searchLabelSize < 0) { m_searchLabelSize = GUI.skin.label.CalcSize(new GUIContent(m_searchFilterStr)).x; } if (m_foldoutStyle == null) { m_foldoutStyle = new GUIStyle(GUI.skin.GetStyle("foldout")); m_foldoutStyle.fontStyle = FontStyle.Bold; } if (m_buttonStyle == null) { m_buttonStyle = UIUtils.Label; } GUILayout.BeginArea(m_transformedArea, m_content, m_style); { for (int i = 0; i < m_initialSeparatorAmount; i++) { EditorGUILayout.Separator(); } if (Event.current.type == EventType.KeyDown) { KeyCode key = Event.current.keyCode; //if ( key == KeyCode.Return || key == KeyCode.KeypadEnter ) // OnEnterPressed(); if ((Event.current.keyCode == KeyCode.KeypadEnter || Event.current.keyCode == KeyCode.Return) && Event.current.type == EventType.KeyDown) { int index = m_currentItems.FindIndex(x => GUI.GetNameOfFocusedControl().Equals(x.ItemUIContent.text + m_resizable)); if (index > -1) { OnEnterPressed(index); } else { OnEnterPressed(); } } if (key == KeyCode.Escape) { OnEscapePressed(); } if (m_isMouseInside || hasKeyboadFocus) { if (key == ShortcutsManager.ScrollUpKey) { m_currentScrollPos.y -= 10; if (m_currentScrollPos.y < 0) { m_currentScrollPos.y = 0; } Event.current.Use(); } if (key == ShortcutsManager.ScrollDownKey) { m_currentScrollPos.y += 10; Event.current.Use(); } } } float width = EditorGUIUtility.labelWidth; EditorGUIUtility.labelWidth = m_searchLabelSize; EditorGUI.BeginChangeCheck(); { GUI.SetNextControlName(m_searchFilterControl + m_resizable); m_searchFilter = EditorGUILayout.TextField(m_searchFilterStr, m_searchFilter); if (m_focusOnSearch) { m_focusOnSearch = false; EditorGUI.FocusTextInControl(m_searchFilterControl + m_resizable); } } if (EditorGUI.EndChangeCheck()) { m_forceUpdate = true; } EditorGUIUtility.labelWidth = width; bool usingSearchFilter = (m_searchFilter.Length == 0); m_currScrollBarDims.x = m_transformedArea.width; m_currScrollBarDims.y = m_transformedArea.height - 2 - 16 - 2 - 7 * m_initialSeparatorAmount - 2; m_currentScrollPos = EditorGUILayout.BeginScrollView(m_currentScrollPos /*, GUILayout.Width( 242 ), GUILayout.Height( 250 - 2 - 16 - 2 - 7 - 2) */); { if (m_forceUpdate) { m_forceUpdate = false; m_currentItems.Clear(); m_currentCategories.Clear(); if (usingSearchFilter) { for (int i = 0; i < allItems.Count; i++) { m_currentItems.Add(allItems[i]); if (!m_currentCategories.ContainsKey(allItems[i].Category)) { m_currentCategories.Add(allItems[i].Category, new PaletteFilterData(m_defaultCategoryVisible)); //m_currentCategories[ allItems[ i ].Category ].HasCommunityData = allItems[ i ].NodeAttributes.FromCommunity || m_currentCategories[ allItems[ i ].Category ].HasCommunityData; } m_currentCategories[allItems[i].Category].Contents.Add(allItems[i]); } } else { for (int i = 0; i < allItems.Count; i++) { if (allItems[i].Name.IndexOf(m_searchFilter, StringComparison.InvariantCultureIgnoreCase) >= 0 || allItems[i].Category.IndexOf(m_searchFilter, StringComparison.InvariantCultureIgnoreCase) >= 0 ) { m_currentItems.Add(allItems[i]); if (!m_currentCategories.ContainsKey(allItems[i].Category)) { m_currentCategories.Add(allItems[i].Category, new PaletteFilterData(m_defaultCategoryVisible)); //m_currentCategories[ allItems[ i ].Category ].HasCommunityData = allItems[ i ].NodeAttributes.FromCommunity || m_currentCategories[ allItems[ i ].Category ].HasCommunityData; } m_currentCategories[allItems[i].Category].Contents.Add(allItems[i]); } } } var categoryEnumerator = m_currentCategories.GetEnumerator(); while (categoryEnumerator.MoveNext()) { categoryEnumerator.Current.Value.Contents.Sort((x, y) => x.CompareTo(y, usingSearchFilter)); } } string watching = string.Empty; //bool downDirection = true; if (Event.current.keyCode == KeyCode.Tab) { ContextMenuItem item = m_currentItems.Find(x => GUI.GetNameOfFocusedControl().Equals(x.ItemUIContent.text + m_resizable)); if (item != null) { watching = item.ItemUIContent.text + m_resizable; //if ( Event.current.modifiers == EventModifiers.Shift ) //downDirection = false; } } //if ( ( Event.current.keyCode == KeyCode.KeypadEnter || Event.current.keyCode == KeyCode.Return ) && Event.current.type == EventType.KeyDown ) //{ // Debug.Log("mau"); // int index = m_currentItems.FindIndex( x => GUI.GetNameOfFocusedControl().Equals( x.ItemUIContent.text + m_resizable ) ); // if ( index > -1 ) // OnEnterPressed( index ); // else // OnEnterPressed(); //} float currPos = 0; var enumerator = m_currentCategories.GetEnumerator(); float cache = EditorGUIUtility.labelWidth; while (enumerator.MoveNext()) { var current = enumerator.Current; bool visible = GUILayout.Toggle(current.Value.Visible, current.Key, m_foldoutStyle); if (m_validButtonId == mouseButtonId) { current.Value.Visible = visible; } currPos += ItemSize; if (m_searchFilter.Length > 0 || current.Value.Visible) { for (int i = 0; i < current.Value.Contents.Count; i++) { //if ( !IsItemVisible( currPos ) ) //{ // // Invisible // GUILayout.Space( ItemSize ); //} //else { currPos += ItemSize; // Visible EditorGUILayout.BeginHorizontal(); GUILayout.Space(16); //if ( m_isMouseInside ) //{ // //GUI.SetNextControlName( current.Value.Contents[ i ].ItemUIContent.text ); // if ( CheckButton( current.Value.Contents[ i ].ItemUIContent, m_buttonStyle, mouseButtonId ) ) // { // int controlID = GUIUtility.GetControlID( FocusType.Passive ); // GUIUtility.hotControl = controlID; // OnPaletteNodeCreateEvt( current.Value.Contents[ i ].NodeType, current.Value.Contents[ i ].Name, current.Value.Contents[ i ].Function ); // } //} //else { Rect thisRect = EditorGUILayout.GetControlRect(false, 16f, EditorStyles.label); //if ( m_resizable ) { if (GUI.RepeatButton(thisRect, string.Empty, EditorStyles.label)) { int controlID = GUIUtility.GetControlID(FocusType.Passive); GUIUtility.hotControl = controlID; OnPaletteNodeCreateEvt(current.Value.Contents[i].NodeType, current.Value.Contents[i].Name, current.Value.Contents[i].Function); //unfocus to make it focus the next text field correctly GUI.FocusControl(null); } } GUI.SetNextControlName(current.Value.Contents[i].ItemUIContent.text + m_resizable); //EditorGUI.SelectableLabel( thisRect, current.Value.Contents[ i ].ItemUIContent.text, EditorStyles.label ); //float cache = EditorGUIUtility.labelWidth; EditorGUIUtility.labelWidth = thisRect.width; EditorGUI.Toggle(thisRect, current.Value.Contents[i].ItemUIContent.text, false, EditorStyles.label); EditorGUIUtility.labelWidth = cache; if (watching == current.Value.Contents[i].ItemUIContent.text + m_resizable) { bool boundBottom = currPos - m_currentScrollPos.y > m_currScrollBarDims.y; bool boundTop = currPos - m_currentScrollPos.y - 4 <= 0; if (boundBottom) { m_currentScrollPos.y = currPos - m_currScrollBarDims.y + 2; } else if (boundTop) { m_currentScrollPos.y = currPos - 18; } //else if ( boundBottom && !downDirection ) // m_currentScrollPos.y = currPos - m_currScrollBarDims.y + 2; //else if ( boundTop && downDirection ) // m_currentScrollPos.y = currPos - 18; } } EditorGUILayout.EndHorizontal(); } //currPos += ItemSize; } } } EditorGUIUtility.labelWidth = cache; } EditorGUILayout.EndScrollView(); } GUILayout.EndArea(); }
public IEnumerator <KeyValuePair <string, string> > GetEnumerator() { return(_dictionary.GetEnumerator()); }
public IEnumerator <KeyValuePair <TKey, List <TValue> > > GetEnumerator() { return(innerValues.GetEnumerator()); }
/// <summary> /// Sequence of all traces /// </summary> /// <returns>sequence</returns> public IEnumerator <KeyValuePair <string, PerformanceTraceSettingCollection> > GetEnumerator() { return(_repository.GetEnumerator()); }
public IEnumerator <KeyValuePair <uint, PathLineMapType> > GetEnumerator() { return(map.GetEnumerator()); }
private void rebuild() { object wasCheckedKey = null; if (m_CheckedElement!=null) wasCheckedKey = m_CheckedElement.Key; m_CheckedElement = null; deleteAllButtons(); if (m_Items.Count==0) return; int fh = Host.CurrentFontHeight; int clientHeight = Region.Height - Padding.Vertical; int rowHeight = fh + m_ButtonVSpacing; int rowCount = clientHeight / rowHeight; //see if last row fits without trailing spacing if ((clientHeight-(rowCount*rowHeight))>=fh) rowCount++; if (rowCount<1) rowCount =1; int colCount = (int)(m_Items.Count / rowCount) + (((m_Items.Count % rowCount)>0)? 1 : 0); int colWidth = (int)((Region.Width- Padding.Horizontal) / colCount); RadioButtonElement btn; TextLabelElement lbl; int x = Region.Left+m_Padding.Left; IDictionaryEnumerator enm = m_Items.GetEnumerator(); try { for (int col = 1; col <= colCount; col++) { int y = Region.Top + m_Padding.Top; for (int row = 1; row <= rowCount; row++) { if (!enm.MoveNext()) return; m_RadioList.Add(btn = new RadioButtonElement(Host)); btn.Region = new Rectangle(x, y, fh, fh); btn.ZOrder = ZOrder + 1; btn.MouseClick += buttonClick; btn.Key = enm.Key; btn.OwnedElements.Add(lbl = new TextLabelElement(Host)); if (wasCheckedKey!=null) if (enm.Key==wasCheckedKey) { btn.Checked = true; m_CheckedElement = btn; } lbl.Region = new Rectangle(x + fh, y, colWidth - fh, fh); lbl.ZOrder = btn.ZOrder; lbl.Text = (enm.Value != null)? " "+enm.Value.ToString() : string.Empty; lbl.MouseClick += buttonClick; lbl.Tags[BUTTON_TAG] = btn; y += fh + m_ButtonVSpacing; } x+= colWidth; } } finally { FieldControlContextChanged(); } }
public virtual Dictionary <PdfName, PdfObject> .Enumerator GetEnumerator() { return(hashMap.GetEnumerator()); }
/// <summary> /// /// </summary> /// <returns></returns> IEnumerator <KeyValuePair <string, object> > IEnumerable <KeyValuePair <string, object> > .GetEnumerator() { return(properties.GetEnumerator()); }
public IEnumerator <KeyValuePair <IQuerySource, object> > GetEnumerator() { return(_resultObjectsBySource.GetEnumerator()); }
public IEnumerator <KeyValuePair <string, string> > GetEnumerator() { return(tags?.GetEnumerator()); }
/// <summary> /// 压缩AssetBundle /// </summary> public static bool CompressAssetBundles(ResourcesManifest old_resources_manifest, ref ResourcesManifest resources_manifest) { if (resources_manifest == null) { return(false); } if (resources_manifest.Data == null) { return(false); } if (resources_manifest.Data.AssetBundles == null) { return(false); } // 通过记录新旧版本中压缩标记 // 判定资源是否需要压缩、删除压缩包 Dictionary <string, int> dic = new Dictionary <string, int>(); int old_version_bit = 0x1; // 旧版本中压缩 int new_version_bit = 0x2; // 新版本中压缩 if (old_resources_manifest.Data != null && old_resources_manifest.Data.AssetBundles != null) { var itr = old_resources_manifest.Data.AssetBundles.GetEnumerator(); while (itr.MoveNext()) { if (itr.Current.Value.IsCompress) { string name = itr.Current.Value.AssetBundleName; if (!dic.ContainsKey(name)) { dic.Add(name, old_version_bit); } else { dic[name] |= old_version_bit; } } } } { var itr = resources_manifest.Data.AssetBundles.GetEnumerator(); while (itr.MoveNext()) { if (itr.Current.Value.IsCompress) { string name = itr.Current.Value.AssetBundleName; if (!dic.ContainsKey(name)) { dic.Add(name, new_version_bit); } else { dic[name] |= new_version_bit; } } } } float current = 0f; float total = resources_manifest.Data.AssetBundles.Count; var itr1 = dic.GetEnumerator(); while (itr1.MoveNext()) { string name = itr1.Current.Key; int mask = itr1.Current.Value; //过滤主AssetBundle文件 if (name == Common.MAIN_MANIFEST_FILE_NAME) { continue; } string action; string file_name = EditorCommon.BUILD_PATH + "/" + name; if ((mask & old_version_bit) > 0 && (mask & new_version_bit) == 0) { // 旧版本中存在,新版本不存在 // 删除压缩包 string compress_file = Compress.GetCompressFileName(file_name); File.Delete(compress_file); File.Delete(compress_file + Common.NATIVE_MANIFEST_EXTENSION); //重写ResourcesManifest数据 var ab = resources_manifest.Data.AssetBundles[name]; ab.CompressSize = 0; action = "Delete Compress"; } else if ((mask & new_version_bit) > 0) { //新版本中存在,压缩文件 Compress.CompressFile(file_name); //重写ResourcesManifest数据 var ab = resources_manifest.Data.AssetBundles[name]; ab.CompressSize = zcode.FileHelper.GetFileSize(Compress.GetCompressFileName(file_name)); action = "Compress"; } else { action = "Ignore"; } //更新进度条 if (ShowProgressBar("", action + " " + name, current / total)) { EditorUtility.ClearProgressBar(); return(false); } } EditorUtility.ClearProgressBar(); return(true); }
/// <summary> /// Returns the enumerator that allows iteration over the /// <see cref="Statistic"/> instances. /// </summary> /// <returns> /// An <see cref="IEnumerator<T>"/> that allows iteration over the /// <see cref="Statistic"/> instances. /// </returns> public IEnumerator <KeyValuePair <Type, Statistic> > GetEnumerator() { return(_statistics.GetEnumerator()); }
IEnumerator IEnumerable.GetEnumerator() { return(_tagMap.GetEnumerator()); }
public IEnumerator <KeyValuePair <string, IncludeTree> > GetEnumerator() { return(_children.GetEnumerator()); }
public bool ShouldSerializeproperties() => properties?.GetEnumerator().MoveNext() ?? false;
IEnumerator <KeyValuePair <TKey, TValue> > IEnumerable <KeyValuePair <TKey, TValue> > .GetEnumerator() { return(Dictionary?.GetEnumerator() ?? Enumerable.Empty <KeyValuePair <TKey, TValue> >().GetEnumerator()); }
public void GetEnumeratorTest() { Assert.AreEqual(baseObject.GetEnumerator(), testObject.GetEnumerator()); Assert.AreEqual(baseObject.GetEnumerator(), ((IEnumerable)testObject).GetEnumerator()); }
public IEnumerator <JsonPair> GetEnumerator() { return(map.GetEnumerator()); }
public IEnumerator <KeyValuePair <TKey, TValue> > GetEnumerator() { return(_dict?.GetEnumerator() ?? GetEnumeratorWorker()); }
private void AnalizeGameGraph(Dictionary <int, DialogPoint> pointDict) { // it should contain start-state (with number 0) // (throws exception) DialogPoint start = null; { bool containsStart = pointDict.TryGetValue(0, out start); if (!containsStart || (start.Links == null || start.Links.Length == 0)) { throw new ApplicationException("Game doesn't contain the start-state (state with number 0)"); } } // looking for defined dialog points, which don't exist // (adds warnings) using (var dictEnumer = pointDict.GetEnumerator()) { while (dictEnumer.MoveNext()) { var currPoint = dictEnumer.Current.Value; if (currPoint.Links == null) { continue; } for (int i = 0; i < currPoint.Links.Length; ++i) { var nextPoint = currPoint.Links[i].NextPoint; if (nextPoint.Links == null || nextPoint.Links.Length == 0) { var notDefinedNextPointWarning = $"in point({currPoint.ID}) in {i} position - " + $"transition to point({nextPoint.ID}), which hadn't been read (incorrect transition)"; nextPoint = currPoint; nextPoint.Text += "(INVALID TRANSITION)"; warnings.Add(notDefinedNextPointWarning); } } } } // find not-linked components var notConnectedPoints = new Dictionary <int, DialogPoint>(); using (var dictEnumer = pointDict.GetEnumerator()) { while (dictEnumer.MoveNext()) { notConnectedPoints.Add(dictEnumer.Current.Key, dictEnumer.Current.Value); } } using (var dictEnumer = notConnectedPoints.GetEnumerator()) { var pointQueue = new Queue <DialogPoint>(); var connectedPoints = new Dictionary <int, DialogPoint>(); pointQueue.Enqueue(start); while (pointQueue.Count > 0) { var currPoint = pointQueue.Dequeue(); for (int i = 0; i < currPoint.Links.Length; ++i) { } } } }
public IEnumerator<KeyValuePair<string, ExternalMod>> GetEnumerator() { return mods.GetEnumerator(); }
IEnumerator <KeyValuePair <TKey, TValue> > IEnumerable <KeyValuePair <TKey, TValue> > .GetEnumerator() { return(_cacheMap.GetEnumerator()); }
IDictionaryEnumerator IDictionary.GetEnumerator() { return(Dictionary.GetEnumerator()); }
public IEnumerator <KeyValuePair <IOption, IOptionCollection> > GetEnumerator() { return(_optionCollections.GetEnumerator()); }
public override Enumerator GetEnumerator() { return(new Enumerator(m_Dict.GetEnumerator())); }