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


C# Set.Add方法代码示例

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


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

示例1: IsSimple

 /// <summary>
 /// A MultiPoint is simple if it has no repeated points.
 /// </summary>
 public bool IsSimple(IMultiPoint mp)
 {
     if (mp.IsEmpty) 
         return true;
     Set<ICoordinate> points = new Set<ICoordinate>();
     for (int i = 0; i < mp.NumGeometries; i++)
     {
         IPoint pt = (IPoint) mp.GetGeometryN(i);
         ICoordinate p = pt.Coordinate;
         if (points.Contains(p))
             return false;
         points.Add(p);
     }
     return true;
 }   
开发者ID:lishxi,项目名称:_SharpMap,代码行数:18,代码来源:IsSimpleOp.cs

示例2: IntersectionTest

        public void IntersectionTest()
        {
            Set<int> a = new Set<int>();
            for(int i = 0; i < 16; i += 2)
                a.Add(i);

            Set<int> b = new Set<int>();
            for(int i = 0; i < 16; i += 3)
                b.Add(i);

            Set<int> inter = a.Intersect(b);

            Assert.AreEqual(3, inter.Count, "A01");
            Assert.AreEqual(0, inter[0], "A02");
            Assert.AreEqual(6, inter[1], "A03");
            Assert.AreEqual(12, inter[2], "A04");
        }
开发者ID:idaohang,项目名称:Helicopter-Autopilot-Simulator,代码行数:17,代码来源:SetTest.cs

示例3: Init

		public void Init(FdoCache cache, bool enableCancel)
		{
			CheckDisposed();

			m_cache = cache;
			m_btnCancel.Visible = enableCancel;
			Set<int> revIdxWs = new Set<int>(4);
			foreach (IReversalIndex ri in cache.LangProject.LexDbOA.ReversalIndexesOC)
				revIdxWs.Add(ri.WritingSystemRAHvo);
			// Include only the analysis writing systems chosen by the user.  See LT-7514 and LT-7239.
			Set<int> activeWs = new Set<int>(8);
			foreach (int ws in cache.LangProject.AnalysisWssRC.HvoArray)
				activeWs.Add(ws);
			m_cbWritingSystems.Sorted = true;
			m_cbWritingSystems.DisplayMember = "Name";
			NamedWritingSystem nwsSelected = null;
			foreach (NamedWritingSystem nws in cache.LangProject.GetDbNamedWritingSystems())
			{
				if (revIdxWs.Contains(nws.Hvo))
				{
					AddLanguageForExistingRevIdx(nws.IcuLocale);
					continue;
				}
				if (!activeWs.Contains(nws.Hvo))
					continue;
				m_cbWritingSystems.Items.Add(nws);
				if (nwsSelected == null && !LanguageMatchesExistingRevIdx(nws.IcuLocale))
					nwsSelected = nws;
			}
			if (nwsSelected != null)
				m_cbWritingSystems.SelectedItem = nwsSelected;
			if (m_cbWritingSystems.Items.Count > 0 && m_cbWritingSystems.SelectedIndex < 0)
				m_cbWritingSystems.SelectedIndex = 0;
			if (!enableCancel && m_cbWritingSystems.Items.Count == 0)
				throw new ApplicationException("Cancel is disabled, but there are none to choose, so the user has no way to get out of this dialog.");
		}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:36,代码来源:CreateReversalIndexDlg.cs

示例4: FindReachableTypes

        /// <summary>
        ///     Determines which types are produced by this mapping.
        /// </summary>
        private Set<EntityType> FindReachableTypes(
            DomainConstraintConversionContext<string, ValueCondition> converter, Vertex[] mappingConditions)
        {
            // For each entity type, create a candidate function that evaluates to true given
            // discriminator assignments iff. all of that type's conditions evaluate to true
            // and its negative conditions evaluate to false.
            var candidateFunctions = new Vertex[MappedEntityTypes.Count];
            for (var i = 0; i < candidateFunctions.Length; i++)
            {
                // Seed the candidate function conjunction with 'true'.
                var candidateFunction = Vertex.One;
                for (var j = 0; j < NormalizedEntityTypeMappings.Count; j++)
                {
                    var entityTypeMapping = NormalizedEntityTypeMappings[j];

                    // Determine if this mapping is a positive or negative case for the current type.
                    if (entityTypeMapping.ImpliedEntityTypes[i])
                    {
                        candidateFunction = converter.Solver.And(candidateFunction, mappingConditions[j]);
                    }
                    else
                    {
                        candidateFunction = converter.Solver.And(candidateFunction, converter.Solver.Not(mappingConditions[j]));
                    }
                }
                candidateFunctions[i] = candidateFunction;
            }

            // Make sure that for each type there is an assignment that resolves to only that type.
            var reachableTypes = new Set<EntityType>();
            for (var i = 0; i < candidateFunctions.Length; i++)
            {
                // Create a function that evaluates to true iff. the current candidate function is true
                // and every other candidate function is false.
                var isExactlyThisTypeCondition = converter.Solver.And(
                    candidateFunctions.Select(
                        (typeCondition, ordinal) => ordinal == i
                                                        ? typeCondition
                                                        : converter.Solver.Not(typeCondition)));

                // If the above conjunction is satisfiable, it means some row configuration exists producing the type.
                if (!isExactlyThisTypeCondition.IsZero())
                {
                    reachableTypes.Add(MappedEntityTypes[i]);
                }
            }

            return reachableTypes;
        }
开发者ID:christiandpena,项目名称:entityframework,代码行数:52,代码来源:FunctionImportStructuralTypeMappingKB.cs

示例5: ConsumeParsingQueue

		static void ConsumeParsingQueue ()
		{
			int pending = 0;
			IProgressMonitor monitor = null;
			
			try {
				Set<ProjectDom> dbsToFlush = new Set<ProjectDom> ();
				do {
					if (pending > 5 && monitor == null) {
						monitor = GetParseProgressMonitor ();
						monitor.BeginTask (GettextCatalog.GetString ("Generating database"), 0);
					}
					
					ParsingJob job = DequeueParseJob ();
					
					if (job != null) {
						try {
							job.ParseCallback (job.File, monitor);
							if (job.Database != null)
								dbsToFlush.Add (job.Database);
						} catch (Exception ex) {
							if (monitor == null)
								monitor = GetParseProgressMonitor ();
							monitor.ReportError (null, ex);
						}
					}
					
					pending = PendingJobCount;
					
				}
				while (pending > 0);
				
				queueEmptied.Set ();
				
				// Flush the parsed databases
				foreach (ProjectDom db in dbsToFlush)
					db.Flush ();
				
			} finally {
				if (monitor != null) monitor.Dispose ();
			}
		}
开发者ID:Poiros,项目名称:monodevelop,代码行数:42,代码来源:ProjectDomService.cs

示例6: GetAllProjects

		/**
		 * returns a set of projects that a combine contains and a set of projects
		 * that are referenced from combine projects but not part of the combine
		 */
		void GetAllProjects (SolutionFolder folder, SolutionConfiguration config, out Set<SolutionFolderItem> projects, out Set<SolutionFolderItem> references)
		{
			List<SolutionFolderItem> subitems = new List<SolutionFolderItem> ();
			GetSubItems (subitems, folder);

			projects = (Set<SolutionFolderItem>) combineProjects [folder];
			if (projects != null) {
				references = (Set<SolutionFolderItem>) combineReferences [folder];
				return;
			}

			projects = new Set<SolutionFolderItem>();
			references = new Set<SolutionFolderItem>();
			
			foreach (SolutionFolderItem item in subitems) 
			{
				if (item is SolutionItem)
				{
					SolutionItem entry = (SolutionItem) item;
					if (!config.BuildEnabledForItem (entry))
						continue;
					projects.Add (entry);
					references.Union (entry.GetReferencedItems (config.Selector));
				}
				else if (item is SolutionFolder) 
				{
					Set<SolutionFolderItem> subProjects;
					Set<SolutionFolderItem> subReferences;
					GetAllProjects ((SolutionFolder)item, config, out subProjects, out subReferences);
					projects.Union (subProjects);
					references.Union (subReferences);
				}
			}
			
			references.Without (projects);
			combineProjects [folder] = projects;
			combineReferences [folder] = references;
		}
开发者ID:pabloescribanoloza,项目名称:monodevelop,代码行数:42,代码来源:SolutionMakefileHandler.cs

示例7: IncludeFileToProject

		public void IncludeFileToProject ()
		{
			Set<IWorkspaceFileObject> projects = new Set<IWorkspaceFileObject> ();
			var nodesByProject = CurrentNodes.GroupBy (n => n.GetParentDataItem (typeof(Project), true) as Project);
			
			foreach (var projectGroup in nodesByProject) {
				Project project = projectGroup.Key;
				List<FilePath> newFiles = new List<FilePath> ();
				foreach (ITreeNavigator node in projectGroup) {
					SystemFile file = (SystemFile) node.DataItem;
					if (project != null) {
						newFiles.Add (file.Path);
						projects.Add (project);
					}
					else {
						SolutionFolder folder = node.GetParentDataItem (typeof(SolutionFolder), true) as SolutionFolder;
						if (folder != null) {
							folder.Files.Add (file.Path);
							projects.Add (folder.ParentSolution);
						}
						else {
							Solution sol = node.GetParentDataItem (typeof(Solution), true) as Solution;
							sol.RootFolder.Files.Add (file.Path);
							projects.Add (sol);
						}
					}
				}
				if (newFiles.Count > 0)
					project.AddFiles (newFiles);
			}
			IdeApp.ProjectOperations.SaveAsync (projects);
		}
开发者ID:FreeBSD-DotNet,项目名称:monodevelop,代码行数:32,代码来源:SystemFileNodeBuilder.cs

示例8: OnRefresh

		/// <summary>
		/// On Refresh, we want to reload the XML configuration files.  This greatly facilitates developing
		/// those files, even though it's not as useful for normal use.  It might prove useful whenever we
		/// get around to allowing user customization (or it might not).
		/// </summary>
		/// <param name="sender"></param>
		/// <returns></returns>
		public bool OnRefresh(object sender)
		{
			CheckDisposed();
			Set<string> setDatabases = new Set<string>();
			foreach (FwXWindow wnd in m_rgMainWindows)
			{
				string sDatabase = wnd.Cache.DatabaseName;
				if (setDatabases.Contains(sDatabase))
					continue;
				setDatabases.Add(sDatabase);
				Inventory.GetInventory("layouts", sDatabase).ReloadIfChanges();
				Inventory.GetInventory("parts", sDatabase).ReloadIfChanges();
			}
			return false;
		}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:22,代码来源:LexTextApp.cs

示例9: DeleteMultipleItems

        public override void DeleteMultipleItems()
        {
            var projects = new Set<SolutionEntityItem> ();
            var folders = new List<ProjectFolder> ();
            foreach (ITreeNavigator node in CurrentNodes)
                folders.Add ((ProjectFolder) node.DataItem);

            var removeButton = new AlertButton (GettextCatalog.GetString ("_Remove from Project"), Gtk.Stock.Remove);
            var question = new QuestionMessage () {
                AllowApplyToAll = folders.Count > 1,
                SecondaryText = GettextCatalog.GetString (
                "The Delete option permanently removes the directory and any files it contains from your hard disk. " +
                "Click Remove from Project if you only want to remove it from your current solution.")
            };
            question.Buttons.Add (AlertButton.Cancel);
            question.Buttons.Add (AlertButton.Delete);
            question.Buttons.Add (removeButton);

            var deleteOnlyQuestion = new QuestionMessage () {
                AllowApplyToAll = folders.Count > 1,
                SecondaryText = GettextCatalog.GetString ("The directory and any files it contains will be permanently removed from your hard disk. ")
            };
            deleteOnlyQuestion.Buttons.Add (AlertButton.Cancel);
            deleteOnlyQuestion.Buttons.Add (AlertButton.Delete);

            foreach (var folder in folders) {
                var project = folder.Project;

                AlertButton result;

                if (project == null) {
                    deleteOnlyQuestion.Text = GettextCatalog.GetString ("Are you sure you want to remove directory {0}?", folder.Name);
                    result = MessageService.AskQuestion (deleteOnlyQuestion);
                    if (result == AlertButton.Delete) {
                        DeleteFolder (folder);
                        continue;
                    } else
                        break;
                }

                var folderRelativePath = folder.Path.ToRelative (project.BaseDirectory);
                var files = project.Files.GetFilesInVirtualPath (folderRelativePath).ToList ();
                var folderPf = project.Files.GetFileWithVirtualPath (folderRelativePath);
                bool isProjectFolder = files.Count == 0 && folderPf == null;

                //if the parent directory has already been removed, there may be nothing to do
                if (isProjectFolder) {
                    deleteOnlyQuestion.Text = GettextCatalog.GetString ("Are you sure you want to remove directory {0}?", folder.Name);
                    result = MessageService.AskQuestion (deleteOnlyQuestion);
                    if (result != AlertButton.Delete)
                        break;
                }
                else {
                    question.Text = GettextCatalog.GetString ("Are you sure you want to remove directory {0} from project {1}?",
                        folder.Name, project.Name);
                    result = MessageService.AskQuestion (question);
                    if (result != removeButton && result != AlertButton.Delete)
                        break;

                    projects.Add (project);

                    //remove the files and link files in the directory
                    foreach (var f in files)
                        project.Files.Remove (f);

                    // also remove the folder's own ProjectFile, if it exists
                    // FIXME: it probably was already in the files list
                    if (folderPf != null)
                        project.Files.Remove (folderPf);
                }

                if (result == AlertButton.Delete) {
                    DeleteFolder (folder);
                } else {
                    //explictly remove the node from the tree, since it currently only tracks real folder deletions
                    folder.Remove ();
                }

                if (isProjectFolder && folder.Path.ParentDirectory != project.BaseDirectory) {
                    // If it's the last item in the parent folder, make sure we keep a reference to the parent
                    // folder, so it is not deleted from the tree.
                    var inParentFolder = project.Files.GetFilesInVirtualPath (folderRelativePath.ParentDirectory);
                    if (!inParentFolder.Skip (1).Any ()) {
                        project.Files.Add (new ProjectFile (folder.Path.ParentDirectory) {
                            Subtype = Subtype.Directory,
                        });
                    }
                }
            }
            IdeApp.ProjectOperations.Save (projects);
        }
开发者ID:brantwedel,项目名称:monodevelop,代码行数:91,代码来源:ProjectFolderNodeBuilder.cs

示例10: TryFirstWsInList

		static internal bool TryFirstWsInList(SIL.FieldWorks.Common.COMInterfaces.ISilDataAccess sda, int hvo, int flid,
			int[] wssToTry, ref Set<int> wssTried, out int retWs, out ITsString retTss)
		{
			retTss = null;
			retWs = 0;
			foreach (int wsLoop in wssToTry)
			{
				if (wssTried.Contains(wsLoop))
					continue;
				wssTried.Add(wsLoop);
				retTss = sda.get_MultiStringAlt(hvo, flid, wsLoop);
				if (retTss.Length > 0)
				{
					retWs = wsLoop;
					return true;
				}
			}
			return false;
		}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:19,代码来源:LangProject.cs

示例11: DeleteObjectSideEffects

		/// <summary>
		/// This method is the one to override if you need side effects when DeleteUnderlyingObject
		/// is called. If other objects should be deleted also, do NOT delete them directly; this
		/// tends to produce abysmal performance. Rather, add them to objectsToDeleteAlso, and the
		/// whole lot (including this) will be deleted in one relatively efficient operation.
		/// You should not modify objectsToDeleteAlso except to add HVOs to it.
		/// You must not use the FDO object after calling this, it has been put into the deleted state.
		/// </summary>
		/// <param name="objectsToDeleteAlso">hashtable of HVOs (value typically just true, it's really a set).</param>
		/// <param name="state"></param>
		public override void DeleteObjectSideEffects(Set<int> objectsToDeleteAlso, ProgressState state)
		{
			if (Owner.ClassID == PhMetathesisRule.kclsidPhMetathesisRule)
			{
				// update the StrucChange field to reflect the removed simple context
				IPhMetathesisRule rule = Owner as IPhMetathesisRule;
				int removeCtxt = rule.UpdateStrucChange(rule.GetStrucChangeIndex(Hvo), IndexInOwner, false);
				if (removeCtxt != 0)
					objectsToDeleteAlso.Add(removeCtxt);
			}

			base.DeleteObjectSideEffects(objectsToDeleteAlso, state);
		}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:23,代码来源:LingOverrides.cs

示例12: ReferenceTargetCandidates

		/// <summary>
		/// Get a set of hvos that are suitable for targets to a reference property.
		/// Subclasses should override this method to return a sensible list of IDs.
		/// </summary>
		/// <param name="flid">The reference property that can store the IDs.</param>
		/// <returns>A set of hvos.</returns>
		public override Set<int> ReferenceTargetCandidates(int flid)
		{
			Set<int> set = null;
			switch (flid)
			{
				case (int)PartOfSpeech.PartOfSpeechTags.kflidDefaultInflectionClass:
					set = new Set<int>();
					foreach (IMoInflClass ic in AllInflectionClasses)
						set.Add(ic.Hvo);
					break;
				case (int)PartOfSpeech.PartOfSpeechTags.kflidBearableFeatures:
					set = new Set<int>();
					ILangProject lp = m_cache.LangProject;
					if (lp != null)
					{
						IFsFeatStrucType exceps = lp.ExceptionFeatureType;
						set.AddRange(exceps.FeaturesRS.HvoArray);
					}
					break;
				case (int)PartOfSpeech.PartOfSpeechTags.kflidInflectableFeats:
					set = new Set<int>();
					set.AddRange(m_cache.LangProject.MsFeatureSystemOA.FeaturesOC.HvoArray);
					break;
				default:
					set = base.ReferenceTargetCandidates(flid);
					break;
			}
			return set;
		}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:35,代码来源:LingOverrides.cs

示例13: CommitReversalEntriesText

		/// <summary>
		/// This method is called by the ReversalEntriesText virtual handler when text may have changed in the
		/// property, in order to update the actual list of reversal entries appropriately.
		/// </summary>
		/// <param name="tssVal">The new string.</param>
		/// <param name="ws">The ws.</param>
		public void CommitReversalEntriesText(ITsString tssVal, int ws)
		{
			LexSenseReversalEntriesTextHandler vh = BaseVirtualHandler.GetInstalledHandler(m_cache,
				"LexSense", LexSenseReversalEntriesTextHandler.StandardFieldName) as LexSenseReversalEntriesTextHandler;
			Debug.Assert(vh != null, "The 'LexSenseReversalEntriesTextHandler' virtual handler has to be created at application startup now.");

			ITsString tssOld = vh.GetValue(m_hvo, ws);
			// The old and new values could be in another order, and this test won't catch that case.
			// That condition won't be fatal, however, so don't fret about it.
			if (tssOld.Equals(tssVal))
				return; // no change has occurred

			string val = tssVal.Text;
			if (val == null)
				val = ""; // This will effectively cause any extant entries for the given 'ws' to be removed in the end.

			StringCollection formsColl = new StringCollection();
			foreach (string form in val.Split(';'))
			{
				// These strings will be null, if there are two semi-colons together.
				// Or, it may be just whitespace, if it is '; ;'.
				if (form == null || form.Trim().Length == 0)
					continue;
				formsColl.Add(form.Trim());
			}
			int[] senseEntries = ReversalEntriesRC.HvoArray;
			int originalSenseEntriesCount = senseEntries.Length;
			int indexId;
			DbOps.ReadOneIntFromCommand(m_cache, "SELECT id FROM ReversalIndex WHERE WritingSystem=?", ws, out indexId);
			ReversalIndex revIndex;
			if (indexId == 0)
			{
				// Create the missing reversal index instead of crashing.  See LT-10186.
				ILgWritingSystem lgws = LgWritingSystem.CreateFromDBObject(m_cache, ws);
				IReversalIndex newIdx = m_cache.LangProject.LexDbOA.ReversalIndexesOC.Add(new ReversalIndex());
				newIdx.WritingSystemRA = lgws;
				// Copy any and all alternatives from lgws.Name to newIdx.Name
				foreach (ILgWritingSystem lgwsLoop in m_cache.LanguageEncodings)
				{
					string lgsNameAlt = lgws.Name.GetAlternative(lgwsLoop.Hvo);
					if (lgsNameAlt != null && lgsNameAlt.Length > 0)
						newIdx.Name.SetAlternative(lgsNameAlt, lgws.Hvo);
				}
				revIndex = (ReversalIndex)newIdx;
			}
			else
			{
				revIndex = (ReversalIndex)CmObject.CreateFromDBObject(m_cache, indexId, false);
			}

			// We need the list of ReversalIndexEntries that this sense references, but which belong
			// to another reversal index. Those hvos, plus any entry hvos from the given 'ws' that are reused,
			// get put into 'survivingEntries'.
			Set<int> survivingEntries = new Set<int>(originalSenseEntriesCount + formsColl.Count);
			// 'entriesNeedingPropChangeBackRef' will hold the hvos of all ReversalIndexEntry objects that need to have
			// their 'ReferringSenses' virtual property (re)computed.
			// Any reversal index entry that gains or loses a reference will need this (re)computing.
			List<int> entriesNeedingPropChangeBackRef = new List<int>(originalSenseEntriesCount + formsColl.Count);
			foreach (int entryHvo in senseEntries)
			{
				// Use 'cheapo' FDO object maker, since it is supposed to all be in the cache already.
				ReversalIndexEntry rie = (ReversalIndexEntry)CmObject.CreateFromDBObject(m_cache, entryHvo, false);
				int wsIndex = 0;
				int hvoIndex = m_cache.GetOwnerOfObjectOfClass(rie.Hvo, ReversalIndex.kclsidReversalIndex);
				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();
//.........这里部分代码省略.........
开发者ID:sillsdev,项目名称:WorldPad,代码行数:101,代码来源:LingOverrides.cs

示例14: FindCurves

        public void FindCurves(string whereClause = null)
        {
            IMap pMap = ArcMap.Document.ActiveView.FocusMap;

            if (hasOpenJob())
                return;

            IRelationshipClass relationshipClass = null;
            ISelectionSet relatedSelectionSet = null;

            myAOProgressor progressor = new myAOProgressor();
            try
            {
                Finished = false;

                progressor.setStepProgressorProperties(1, "Initializing");
                ICadastralFabricLayer CFLayer = GetFabricLayer(pMap);

                IFeatureLayer CFLineLayer = CFLayer.get_CadastralSubLayer(esriCadastralFabricRenderer.esriCFRLines);
                IFeatureLayer CFParcelLayer = CFLayer.get_CadastralSubLayer(esriCadastralFabricRenderer.esriCFRParcels);
                                    
                //for each CF line feature class 
                IFeatureSelection CFLineFeatureSelection = (IFeatureSelection)CFLineLayer;
                IFeatureSelection CFParcelFeatureSelection = (IFeatureSelection)CFParcelLayer;

                ISelectionSet selectionSet = null;
                if (CFParcelFeatureSelection.SelectionSet.Count > 0)
                {
                    //parcels selected
                        
                    //Create memory relationship class to help with the mapping
                    IMemoryRelationshipClassFactory MemoryRCF = new MemoryRelationshipClassFactoryClass();
                    relationshipClass = MemoryRCF.Open("Parcel_Layer_Rel", CFParcelLayer.FeatureClass, "ObjectID", CFLineLayer.FeatureClass, "ParcelID", "forward", "backward", esriRelCardinality.esriRelCardinalityOneToMany);

                    //convert selection set to ISet of rows
                    ISet polySet = new Set();
                    ICursor cursor;
                    CFParcelFeatureSelection.SelectionSet.Search(null, false, out cursor);
                    IRow row = null;
                    while((row = cursor.NextRow()) != null)
                        polySet.Add(row);
                    polySet.Reset();

                    //use the relationship class to find related rows
                    ISet lineSet = relationshipClass.GetObjectsRelatedToObjectSet(polySet);

                    //convert set back to selection set
                    lineSet.Reset();
                        
                    //create an empty selection set (there should be a better way to do this....
                        
                    //will only evaluate the lines related to the parcels that are selected
                    //selectionSet = CFLineLayer.FeatureClass.Select(new QueryFilter() { WhereClause = "1=0" }, esriSelectionType.esriSelectionTypeIDSet, esriSelectionOption.esriSelectionOptionNormal, null);

                    //will union the current line selection and the parcel selection
                    relatedSelectionSet = CFLineFeatureSelection.SelectionSet.Select(null, esriSelectionType.esriSelectionTypeIDSet, esriSelectionOption.esriSelectionOptionNormal, null);
                        
                    while ((row = (IRow)lineSet.Next()) != null)
                    {
                        relatedSelectionSet.Add(row.OID);
                        Marshal.ReleaseComObject(row);
                    }
                    Marshal.ReleaseComObject(lineSet);
                    polySet.Reset();
                    while ((row = (IRow)polySet.Next()) != null)
                        Marshal.ReleaseComObject(row);
                    Marshal.ReleaseComObject(polySet);

                    selectionSet = relatedSelectionSet;
                }
                else if (CFLineFeatureSelection.SelectionSet.Count > 0)
                {
                    //lines selected
                    selectionSet = CFLineFeatureSelection.SelectionSet;
                }
                    
                else
                {
                    if (DialogResult.OK != messageBox.Show("You are about to run the add-in on the entire feature class, this could take a long time.  Proceeed?", "Long Operation", MessageBoxButtons.OKCancel))
                        return;
                }

                    
                FindCurves(CFLineLayer.Name, CFLineLayer.FeatureClass, selectionSet, whereClause, progressor);
                if (Curves.Count == 0)
                {
                    messageBox.Show("No inferred curved lines found.");
                    return;
                }
            }
            catch (Exception Exx)
            {
                messageBox.Show(Exx.Message);

                if (relationshipClass != null)
                    Marshal.ReleaseComObject(relationshipClass);
                if (relatedSelectionSet != null)
                    Marshal.ReleaseComObject(relatedSelectionSet);
            }
            finally
//.........这里部分代码省略.........
开发者ID:travisval,项目名称:ParcelFabricCurveByInference,代码行数:101,代码来源:CurveByInference.cs

示例15: IncludeToProject

        public void IncludeToProject()
        {
            Set<SolutionEntityItem> projects = new Set<SolutionEntityItem> ();
            foreach (ITreeNavigator node in CurrentNodes) {
                Project project = node.GetParentDataItem (typeof(Project), true) as Project;
                if (node.HasChildren ()) {
                    List<SystemFile> filesToAdd = new List<SystemFile> ();
                    ITreeNavigator nav = node.Clone ();
                    GetFiles (nav, filesToAdd);

                    foreach (SystemFile file in filesToAdd)
                        project.AddFile (file.Path);

                    projects.Add (project);
                } else {
                    ProjectFolder pf = node.DataItem as ProjectFolder;
                    if (pf != null) {
                        project.AddDirectory (FileService.AbsoluteToRelativePath (project.BaseDirectory, pf.Path));
                        projects.Add (project);
                    }
                }
            }
            IdeApp.ProjectOperations.Save (projects);
        }
开发者ID:brantwedel,项目名称:monodevelop,代码行数:24,代码来源:ProjectFolderNodeBuilder.cs


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