Beispiel #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);
     }
 }
Beispiel #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>());
        }
Beispiel #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);
         }
     }
 }
Beispiel #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);
            }
        }