Ejemplo n.º 1
0
 static IEnumerable <ObjectId> OfTypeIterator <T>(this IEnumerable <ObjectId> ids)
     where T : DBObject
 {
     foreach (ObjectId id in ids)
     {
         if (RXClass <T> .IsAssignableFrom(id.ObjectClass))
         {
             yield return(id);
         }
     }
 }
Ejemplo n.º 2
0
        static IEnumerable <ObjectId> OfTypeIterator <T>(this ObjectIdCollection ids)
            where T : DBObject
        {
            int cnt = ids.Count;

            for (int i = 0; i < cnt; i++)
            {
                ObjectId id = ids[i];
                if (RXClass <T> .IsAssignableFrom(id.ObjectClass))
                {
                    yield return(id);
                }
            }
        }
Ejemplo n.º 3
0
        // ObjectId.IsTypeOf<T>() extension method:
        //
        // returns true if the managed wrapper returned
        // by opening the given ObjectId is an instance
        // of the generic argument type or a derived type.
        //
        // Example: Tells if the DBObject referenced by
        // the given ObjectId is an instance of a Curve:
        //
        //   ObjectId id = GetSomeObjectId();
        //
        //   bool isCurve = id.IsTypeOf<Curve>();
        //
        // The advantage in the above use of IsTypeOf<T>() is
        // that it doesn't require the RXClass for Curve to be
        // fetched on each call, because it is already cached
        // in a static member of the generic RXClass<Curve> type.
        //
        // The other benefit is that IsTypeOf<T>() can be
        // used anywhere, and without a transaction, since
        // it doesn't need to open the database object.
        //
        // The same can also be done more directly,
        // but less-intuitively:
        //
        //   bool isCurve = id.ObjectClass.IsAssignableTo<Curve>();
        //
        //
        // And of course, without using any of these helper APIs,
        // one would need to do:
        //
        //   bool isCurve = id.ObjectClass.IsDerivedFrom(
        //                       RXClass.GetClass( typeof( Curve ) )
        //                  );
        //

        public static bool IsTypeOf <T>(this ObjectId id)
            where T : DBObject
        {
            return(RXClass <T> .IsAssignableFrom(id.ObjectClass));
        }