Ejemplo n.º 1
0
 /// <summary>
 /// Gets a string, supplied by the WindowsTask Scheduler, of a bound Trigger.
 /// For an unbound trigger, returns "Unbound Trigger".
 /// </summary>
 /// <returns>String representation of the trigger.</returns>
 public override string ToString()
 {
     if (iTaskTrigger != null)
     {
         IntPtr lpwstr;
         iTaskTrigger.GetTriggerString(out lpwstr);
         return(CoTaskMem.LPWStrToString(lpwstr));
     }
     else
     {
         return("Unbound " + this.GetType().ToString());
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Opens a file by its index key.
        /// </summary>
        /// <remarks>
        /// An index key is a binary representation of a file.  I do not know what it comes from; I know that it's used to identify files inside of CASC,
        /// but I don't know how someone obtains the index key.  They are not produced in the public API of CascLib.
        /// </remarks>
        /// <param name="indexKey">The index key to search.</param>
        /// <returns>A CascFileStream, which implements a Stream.</returns>
        /// <exception cref="ObjectDisposedException">Thrown if the CascStorageContext has been disposed.</exception>
        /// <exception cref="System.IO.FileNotFoundException">Thrown if the file does not exist within the CASC storage container.</exception>
        public CascFileStream OpenFileByIndexKey(byte[] indexKey)
        {
            if (_handle == null || _handle.IsInvalid)
            {
                throw new ObjectDisposedException("CascStorageContext");
            }

            using (CoTaskMem mem = CoTaskMem.FromBytes(indexKey))
            {
                QueryKey qk = new QueryKey();
                qk.cbData = unchecked ((uint)indexKey.Length);
                qk.pbData = mem.Pointer;

                CascStorageFileSafeHandle hFile;
                if (!_api.CascOpenFileByIndexKey(_handle, ref qk, 0, out hFile))
                {
                    throw new CascException();
                }

                hFile.Api = _api;

                return(new CascFileStream(hFile, _api));
            }
        }