Exemplo n.º 1
0
 public MediaCenterLibraryCache(string baseSearchPath, UnmanagedLibraryAccess mode)
 {
     if (baseSearchPath == null)
         throw new ArgumentNullException();
     this.mode = mode;
     this.SearchPath = baseSearchPath;
 }
Exemplo n.º 2
0
 public UnmanagedLibrary(string file, UnmanagedLibraryAccess mode, ushort? languageID)
 {
     this.fileName = file;
     this.mode = mode;
     this.languageID = languageID;
     this.libraryInfo = (UnmanagedLibrary.LibraryInfo)null;
     lock (UnmanagedLibrary.librariesDict)
     {
         if (!UnmanagedLibrary.librariesDict.TryGetValue(file, out this.libraryInfo) && mode == UnmanagedLibraryAccess.Read)
         {
             this.libraryInfo = new UnmanagedLibrary.LibraryInfo();
             this.libraryInfo.File = file;
             this.libraryInfo.Handle = NativeMethods.LoadLibraryEx(file, IntPtr.Zero, 2U);
             if (this.libraryInfo.Handle == IntPtr.Zero)
                 throw new Win32Exception();
             UnmanagedLibrary.librariesDict[file] = this.libraryInfo;
         }
         if (this.libraryInfo != null)
         {
             if (mode != UnmanagedLibraryAccess.Read)
                 throw new InvalidOperationException(string.Format("Cannot open {0} for updating as it is already open for reading.", (object)file));
             ++this.libraryInfo.ReferenceCount;
         }
     }
     if (mode != UnmanagedLibraryAccess.Write)
         return;
     this.stringTables = new Dictionary<int, UnmanagedLibrary.StringTable>();
     this.resourceHandle = NativeMethods.BeginUpdateResource(file, false);
     if (this.resourceHandle == IntPtr.Zero)
         throw new Win32Exception();
 }
Exemplo n.º 3
0
 public MediaCenterLibraryCache(string baseSearchPath, UnmanagedLibraryAccess mode)
 {
     if (baseSearchPath == null)
     {
         throw new ArgumentNullException();
     }
     this.mode       = mode;
     this.SearchPath = baseSearchPath;
 }
Exemplo n.º 4
0
 public MediaCenterUnmanagedLibrary(string file, UnmanagedLibraryAccess mode)
     : base(file, mode)
 {
     this.mode = mode;
     if (mode != UnmanagedLibraryAccess.Write)
         return;
     this.muiFile = this.GetMUIFile();
     if (this.muiFile == null)
         return;
     this.GetMUI().Update((byte[])null, new ushort?((ushort)1033));
 }
Exemplo n.º 5
0
 public MediaCenterUnmanagedLibrary(string file, UnmanagedLibraryAccess mode)
     : base(file, mode)
 {
     this.mode = mode;
     if (mode != UnmanagedLibraryAccess.Write)
     {
         return;
     }
     this.muiFile = this.GetMUIFile();
     if (this.muiFile == null)
     {
         return;
     }
     this.GetMUI().Update((byte[])null, new ushort?((ushort)1033));
 }
Exemplo n.º 6
0
 public UnmanagedLibrary(string file, UnmanagedLibraryAccess mode, ushort?languageID)
 {
     this.fileName    = file;
     this.mode        = mode;
     this.languageID  = languageID;
     this.libraryInfo = (UnmanagedLibrary.LibraryInfo)null;
     lock (UnmanagedLibrary.librariesDict)
     {
         if (!UnmanagedLibrary.librariesDict.TryGetValue(file, out this.libraryInfo) && mode == UnmanagedLibraryAccess.Read)
         {
             this.libraryInfo        = new UnmanagedLibrary.LibraryInfo();
             this.libraryInfo.File   = file;
             this.libraryInfo.Handle = NativeMethods.LoadLibraryEx(file, IntPtr.Zero, 2U);
             if (this.libraryInfo.Handle == IntPtr.Zero)
             {
                 throw new Win32Exception();
             }
             UnmanagedLibrary.librariesDict[file] = this.libraryInfo;
         }
         if (this.libraryInfo != null)
         {
             if (mode != UnmanagedLibraryAccess.Read)
             {
                 throw new InvalidOperationException(string.Format("Cannot open {0} for updating as it is already open for reading.", (object)file));
             }
             ++this.libraryInfo.ReferenceCount;
         }
     }
     if (mode != UnmanagedLibraryAccess.Write)
     {
         return;
     }
     this.stringTables   = new Dictionary <int, UnmanagedLibrary.StringTable>();
     this.resourceHandle = NativeMethods.BeginUpdateResource(file, false);
     if (this.resourceHandle == IntPtr.Zero)
     {
         throw new Win32Exception();
     }
 }
Exemplo n.º 7
0
 public UnmanagedLibrary(string file, UnmanagedLibraryAccess mode)
     : this(file, mode, new ushort?())
 {
 }
Exemplo n.º 8
0
 public UnmanagedLibrary(string file, UnmanagedLibraryAccess mode)
     : this(file, mode, new ushort?())
 {
 }