Beispiel #1
0
        public static IEnumerable <IFeature> GetFeatures(this ISelectionSet set, IQueryFilter filter = null, enumRecyclingPolicy policy = enumRecyclingPolicy.DoNotRecycle)
        {
            ICursor cursor;

            set.Search(filter, enumRecyclingPolicy.Recycle == policy, out cursor);
            var featureCursor = (IFeatureCursor)cursor;

            IFeature feature;

            while (null != (feature = featureCursor.NextFeature()))
            {
                yield return(feature);
            }

            if (Marshal.IsComObject(cursor))
            {
                Marshal.ReleaseComObject(cursor);
            }
        }
Beispiel #2
0
        public static IEnumerable <IFeature> GetFeatures(this IFeatureClass featureClass,
                                                         IQueryFilter queryFilter = null, enumRecyclingPolicy policy = enumRecyclingPolicy.DoNotRecycle)
        {
            IFeatureCursor featureCursor =
                featureClass.Search(queryFilter, enumRecyclingPolicy.Recycle == policy);

            IFeature feature;

            while (null != (feature = featureCursor.NextFeature()))
            {
                yield return(feature);
            }

            if (Marshal.IsComObject(featureCursor))
            {
                Marshal.ReleaseComObject(featureCursor);
            }
        }