예제 #1
0
 /// <summary>
 /// Obtains the object of an alternate type than the default
 /// </summary>
 /// <typeparam name="OtherType">Other type</typeparam>
 public OtherType ObjectOfType <OtherType>()
 {
     using (TypedStream <OtherType> t = OpenForReading <OtherType>())
     {
         return(t.Object);
     }
 }
예제 #2
0
        /// <summary>
        /// Opens a specific typed stream cast to TSomething.
        /// </summary>
        /// <typeparam name="TSomething"></typeparam>
        /// <param name="type"></param>
        /// <param name="mode"></param>
        /// <returns></returns>
        public TypedStream <TSomething> Open <TSomething>(Type type, OpenMode mode)
        {
            TypedStream <object> t = Open(type, mode);

            if (t == null)
            {
                return(null);
            }
            return(t.As <TSomething>());
        }
예제 #3
0
 /// <summary>
 /// Clears the typed stream.
 /// </summary>
 /// <typeparam name="TData"></typeparam>
 public void ClearTypedStream(Type type)
 {
     using (TypedStream <object> ts = Open(type, OpenMode.Write))
     {
         uint[] locations = ts.ObjectLocations;
         for (int i = 0; i < locations.Length; i++)
         {
             ts.Erase(locations[i], 1, true);
         }
     }
 }
예제 #4
0
        /// <summary>
        /// Obtains an array of an alternate type than the default
        /// </summary>
        /// <typeparam name="OtherType">Other type</typeparam>
        public OtherType[] ArrayOfType <OtherType>()
        {
            using (TypedStream <OtherType> t = OpenForReading <OtherType>())
            {
                if (t == null)
                {
                    return(new OtherType[0]);
                }

                return(t.Array);
            }
        }