当前位置: 首页>>代码示例>>C#>>正文


C# Set.ToArray方法代码示例

本文整理汇总了C#中System.Collections.Set.ToArray方法的典型用法代码示例。如果您正苦于以下问题:C# Set.ToArray方法的具体用法?C# Set.ToArray怎么用?C# Set.ToArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Collections.Set的用法示例。


在下文中一共展示了Set.ToArray方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CommitReversalEntriesText


//.........这里部分代码省略.........
				if (hvoIndex != 0)
					wsIndex = m_cache.GetIntProperty(hvoIndex, (int)ReversalIndex.ReversalIndexTags.kflidWritingSystem);
				if (wsIndex == ws)
				{
					string form = rie.LongName;
					if (formsColl.Contains(form))
					{
						// Recycling an entry.
						survivingEntries.Add(rie.Hvo);
						formsColl.Remove(form); // Don't need to mess with it later on.
					}
					else
					{
						// It is being removed from the extant reference property,
						// so needs to recompute its back ref virtual handler.
						entriesNeedingPropChangeBackRef.Add(rie.Hvo);
					}
				}
				else
				{
					// These are all in some other ws, so they certainly must survive (cf. LT-3391).
					// Any entries that are reused will get added to this array later on.
					survivingEntries.Add(rie.Hvo);
				}
			}

			// Start Undoable section of code.
			m_cache.BeginUndoTask(Strings.ksUndoMakeRevEntries, Strings.ksRedoMakeRevEntries);
			ISilDataAccess sda = m_cache.MainCacheAccessor;
			IActionHandler acth = sda.GetActionHandler();
			try
			{
				// add undo actions to reload the virtual handler and send prop changes to update displays
				if (acth != null)
				{
					List<PropChangedInfo> pciList = new List<PropChangedInfo>();
					pciList.Add(new PropChangedInfo(m_hvo, vh.Tag, ws, 0, 0));
					acth.AddAction(new PropChangedUndoAction(m_cache, true, PropChangeType.kpctNotifyAll, pciList));
					acth.AddAction(new ReloadVirtualHandlerUndoAction(m_cache, true, vh, m_hvo, vh.Tag, ws));
				}

				int cOldEntries = revIndex.EntriesOC.Count;
				foreach (string currentForm in formsColl)
				{
					int idRevEntry = revIndex.FindOrCreateReversalEntry(currentForm);
					entriesNeedingPropChangeBackRef.Add(idRevEntry);
					survivingEntries.Add(idRevEntry);
				}

				// Notify everyone, and his brother, about the changes done here.
				// PropChanged (1 of 3) Main: Replace main sense property with current set of entries.
				sda.Replace(m_hvo, (int)LexSense.LexSenseTags.kflidReversalEntries, 0, originalSenseEntriesCount,
					survivingEntries.ToArray(), survivingEntries.Count);
				sda.PropChanged(null, (int)PropChangeType.kpctNotifyAll, m_hvo,
					(int)LexSense.LexSenseTags.kflidReversalEntries, 0, survivingEntries.Count, originalSenseEntriesCount);

				// remove entries from the index that are no longer valid
				foreach (int rieHvo in senseEntries)
				{
					if (!survivingEntries.Contains(rieHvo))
					{
						// the entry is no longer a reversal entry for this sense
						ReversalIndexEntry rie = new ReversalIndexEntry(m_cache, rieHvo);
						if (rie.SenseIds.Count == 0)
							// the entry is longer a reversal entry for any sense
							revIndex.EntriesOC.Remove(rie);
					}
				}

				// PropChanged (2 of 3) Affected Entries: (Re)compute
				// on the virtual property of select reversal index entries.
				ReversalIndexEntry.ResetReferringSenses(m_cache, entriesNeedingPropChangeBackRef);

				// PropChanged (3 of 3) Index Entries: Simulate a complete replacement of the entries collection,
				// BUT only if new entries were added in this method.
				int cNewEntries = revIndex.EntriesOC.Count;
				if (cNewEntries > cOldEntries)
				{
					sda.PropChanged(null, (int)PropChangeType.kpctNotifyAll, indexId,
						(int)ReversalIndex.ReversalIndexTags.kflidEntries,
						0, cNewEntries, cOldEntries);
				}

				// add redo actions to reload the virtual handler and send prop changes to update displays
				if (acth != null)
				{
					acth.AddAction(new ReloadVirtualHandlerUndoAction(m_cache, false, vh, m_hvo, vh.Tag, ws));
					List<PropChangedInfo> pciList = new List<PropChangedInfo>();
					pciList.Add(new PropChangedInfo(m_hvo, vh.Tag, ws, 0, 0));
					acth.AddAction(new PropChangedUndoAction(m_cache, false, PropChangeType.kpctNotifyAll, pciList));
				}
			}
			finally
			{
				if (acth != null && Marshal.IsComObject(acth))
					Marshal.ReleaseComObject(acth);
			}
			// End undoable section of code.
			m_cache.EndUndoTask();
		}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:101,代码来源:LingOverrides.cs

示例2: SCTextEnum

		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initializes a new instance of the <see cref="SCTextEnum"/> class.
		/// </summary>
		/// <param name="settings">The import settings</param>
		/// <param name="domain">The source domain</param>
		/// <param name="startRef">first reference to retrieve</param>
		/// <param name="endRef">last reference to retrieve</param>
		/// <param name="encConverters">The encoding converters repository</param>
		/// ------------------------------------------------------------------------------------
		public SCTextEnum(IScrImportSet settings, ImportDomain domain,
			BCVRef startRef, BCVRef endRef, IEncConverters encConverters)
		{
			m_settings = settings;
			m_domain = domain;
			m_startRef = new BCVRef(startRef);
			m_endRef = new BCVRef(endRef);
			m_mappingSet = m_settings.GetMappingSetForDomain(domain);

			// Gets the set of encoding converters
			m_encConverters = encConverters;

			// make a list of all of the begin and end markers for inline markers
			// Also build the map of encoding converters
			m_InlineBeginAndEndMarkers = new List<string>();
			foreach (ImportMappingInfo mapping in m_settings.GetMappingListForDomain(domain))
			{
				if (mapping.IsInline || m_settings.ImportTypeEnum == TypeOfImport.Paratext5)
				{
					m_InlineBeginAndEndMarkers.Add(mapping.BeginMarker);
					if (mapping.IsInline)
						m_InlineBeginAndEndMarkers.Add(mapping.EndMarker);
				}
			}

			m_InlineBeginAndEndMarkers.Sort(new StrLengthComparer(false));

			// Build a list of all of the characters that inline markers start with
			Set<char> tempCharList = new Set<char>();
			foreach (string marker in m_InlineBeginAndEndMarkers)
				tempCharList.Add(marker[0]); // Set ignores duplicates.

			m_InlineMarkerStartChars = tempCharList.ToArray();
			// Get the import file source that will provide the files to import.
			m_importSource = settings.GetImportFiles(domain);
			m_importSourceEnum = m_importSource.GetEnumerator();
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:47,代码来源:SCTextEnum.cs

示例3: ToArrayTests2

		public void ToArrayTests2()
		{
			object[] starting = new object[3] { 1, 2, 3 };
			Set<object> set = new Set<object>(starting);
			Assert.AreEqual(3, set.Count, "Set should have three items in it.");

			int[] ending = set.ToArray<int>();
			Assert.AreEqual(3, ending.Length, "Set should have three items in it.");

			int i = 0;
			foreach (int startInt in starting)
			{
				Assert.AreEqual(startInt, ending[i++], "Set should have same three items in it.");
			}
		}
开发者ID:sillsdev,项目名称:FieldWorks,代码行数:15,代码来源:SetTests.cs

示例4: CheckMultiDeleteConditionsAndReport

		/// <summary>
		/// Check whether deleting these objects will be undoable.  In any case, pops up a message
		/// asking the user whether to proceed. The type of message depends somewhat on the situation.
		/// </summary>
		/// <returns>true, if okay to continue with delete</returns>
		private bool CheckMultiDeleteConditionsAndReport(Set<int> idsToDelete, out bool fUndo)
		{
			int cOrphans = 0;
			if (m_expectedListItemsClassId == LexEntry.kclsidLexEntry ||
				m_expectedListItemsClassId == LexSense.kclsidLexSense)
			{
				cOrphans = CmObject.CountOrphanedObjects(m_cache);
			}
			fUndo = cOrphans == 0;
			if (fUndo)
			{
				int iNextGroup = 0;
				DbOps.MakePartialIdList(ref iNextGroup, idsToDelete.ToArray());
				fUndo = iNextGroup == idsToDelete.Count;
			}
			string sMsg = XMLViewsStrings.ksConfirmDeleteMultiMsg;
			string sTitle = XMLViewsStrings.ksConfirmDeleteMulti;
			if (!fUndo)
			{
				sMsg = XMLViewsStrings.ksCannotUndoTooManyDeleted;
			}
			return MessageBox.Show(this, sMsg, sTitle, MessageBoxButtons.OKCancel, MessageBoxIcon.Warning)
					== DialogResult.OK;
		}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:29,代码来源:BulkEditBar.cs

示例5: InsertSliceRange

		protected void InsertSliceRange(int insertPosition, Set<Slice> slices)
		{
			List<Slice> indexableSlices = new List<Slice>(slices.ToArray());
			for (int i = indexableSlices.Count - 1; i >= 0; --i)
			{
				InstallSlice(indexableSlices[i], insertPosition);
			}
			ResetTabIndices(insertPosition);
		}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:9,代码来源:DataTree.cs

示例6: FindSingleVertexGroup

        public void FindSingleVertexGroup()
        {
            Set<int> s = new Set<int>();

            for (int i=0; i<vertexCount; i++)
            {
                if (flag[i] != 0)
                {
                    bool found = false;
                    foreach (int j in adjVV[i])
                        if (flag[j] == flag[i])
                        {
                            found = true;
                            break;
                        }
                    if (!found)
                        s.Add(i);
                }
            }

            int[] arr = s.ToArray();
            Array.Sort(arr);
            this.singleVertexGroup = arr;
        }
开发者ID:GYingchao,项目名称:interactive_cross_boundary_segmentation,代码行数:24,代码来源:Mesh.cs

示例7: GetBestAlt

			private int GetBestAlt(int hvo, int tag, int wsPreferred, int wsDefault, int[] wsList)
			{
				Set<int> wsSet = new Set<int>();
				if (wsPreferred != 0)
					wsSet.Add(wsPreferred);
				wsSet.AddRange(wsList);
				// We're not dealing with a real cache, so can't call something like this:
				//ws = LangProject.InterpretWsLabel(m_caches.MainCache,
				//    LangProject.GetMagicWsNameFromId(ws),
				//    m_caches.MainCache.DefaultAnalWs,
				//    hvo, spec.StringFlid, null);
				int wsActual = 0;
				foreach (int ws1 in wsSet.ToArray())
				{
					ITsString tssTest = m_caches.DataAccess.get_MultiStringAlt(hvo, tag, ws1);
					if (tssTest != null && tssTest.Length != 0)
					{
						wsActual = ws1;
						break;
					}
				}
				// Enhance JohnT: to be really picky here we should do like the real InterpretWsLabel
				// and fall back to default UI language, then English.
				// But we probably aren't even copying those alternatives to the sandbox cache.
				if (wsActual == 0)
					wsActual = wsDefault;
				return wsActual;
			}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:28,代码来源:SandboxBase.cs

示例8: RemoveUnwantedSortItems

		/// <summary>
		/// This will remove the given hvosToRemove (if they exist in our sort items) and any items that refer to invalid objects.
		/// Reload the view if there were any changes, and adjust the CurrentIndex
		/// </summary>
		protected internal void RemoveUnwantedSortItems(List<int> hvosToRemove)
		{
			if (m_sortedObjects == null)
				return;	// nothing to remove.
			bool fUpdatingListOrig = m_fUpdatingList;
			m_fUpdatingList = true;
			try
			{
				int currentIndex = CurrentIndex;
				int cOrigSortObjects = m_sortedObjects.Count;
				// Note: We start with a Set, since it can't have duplicates.
				// First remove the given hvos from our sort items.
				Set<int> unwantedIndices = new Set<int>(IndicesOfSortItems(hvosToRemove));
				// then remove any remaining items that point to invalid objects.
				unwantedIndices.AddRange(IndicesOfInvalidSortItems());
				// Put the now unique indices into a list,
				// so we can make sure they are processed in reverse order.
				List<int> sortedIndices = new List<int>(unwantedIndices.ToArray());
				sortedIndices.Sort();
				sortedIndices.Reverse();
				foreach (int indexOfSortItem in sortedIndices)
				{
					if (indexOfSortItem >= 0)
					{
						m_sortedObjects.RemoveAt(indexOfSortItem);
						if (indexOfSortItem < currentIndex || SortedObjects.Count <= currentIndex)
							currentIndex--;
					}
				}
				if (m_sortedObjects.Count == 0)
					currentIndex = -1;
				else if (currentIndex >= m_sortedObjects.Count)
					currentIndex = m_sortedObjects.Count - 1;
				CurrentIndex = currentIndex;
				if (m_sortedObjects.Count != cOrigSortObjects)
				{
					SendPropChangedOnListChange(CurrentIndex,
						SortedObjects, ListChangedEventArgs.ListChangedActions.Normal);
				}
			}
			finally
			{
				m_fUpdatingList = fUpdatingListOrig;
			}
		}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:49,代码来源:RecordList.cs


注:本文中的System.Collections.Set.ToArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。