SevenZip/LibraryManager.cs
/// <summary>
///   Gets IOutArchive interface to pack 7-zip archives.
/// </summary>
/// <param name = "format">Archive format.</param>
/// <param name = "user">Archive format user.</param>
Gets IOutArchive interface to pack 7-zip archives.
Gets IOutArchive interface to pack 7 - zip archives .
public static IOutArchive OutArchive(OutArchiveFormat format, object user)
        {
#if !WINCE && !MONO
            lock (_libraryFileName)
            {
#endif
                if (_outArchives[user][format] == null)
                {
#if !WINCE && !MONO
                    var sp = new SecurityPermission(SecurityPermissionFlag.UnmanagedCode);
                    sp.Demand();
                    if (_modulePtr == IntPtr.Zero)
                    {
                        throw new SevenZipLibraryException();
                    }
                    var createObject = (NativeMethods.CreateObjectDelegate)
                                       Marshal.GetDelegateForFunctionPointer(
                                           NativeMethods.GetProcAddress(_modulePtr, "CreateObject"),
                                           typeof (NativeMethods.CreateObjectDelegate));
                    if (createObject == null)
                    {
                        throw new SevenZipLibraryException();
                    }
#endif
                    object result;
                    Guid interfaceId =
#if !WINCE && !MONO
                        typeof (IOutArchive).GUID;
#else
                    new Guid(((GuidAttribute)typeof(IOutArchive).GetCustomAttributes(typeof(GuidAttribute), false)[0]).Value);
#endif
                    Guid classID = Formats.OutFormatGuids[format];
                    try
                    {
#if !WINCE && !MONO
                        createObject(ref classID, ref interfaceId, out result);
#elif !MONO
                    	NativeMethods.CreateCOMObject(ref classID, ref interfaceId, out result);
#else
						result = SevenZip.Mono.Factory.CreateInterface<IOutArchive>(classID, interfaceId, user);
#endif
                    }
                    catch (Exception)
                    {
                        throw new SevenZipLibraryException("Your 7-zip library does not support this archive type.");
                    }
                    InitUserOutFormat(user, format);
                    _outArchives[user][format] = result as IOutArchive;
                }
#if !WINCE && !MONO
            }
#endif
            return _outArchives[user][format];
        }
public static IOutArchive OutArchive ( OutArchiveFormat format , object user ) { if ! WINCE && ! MONO lock ( _libraryFileName ) { endif if ( _outArchives [ user ] [ format ] == null ) { if ! WINCE && ! MONO var sp = new SecurityPermission ( SecurityPermissionFlag . UnmanagedCode ) ; sp . Demand ( ) ; if ( _modulePtr == IntPtr . Zero ) { throw new SevenZipLibraryException ( ) ; } var createObject = ( NativeMethods . CreateObjectDelegate ) Marshal . GetDelegateForFunctionPointer ( NativeMethods . GetProcAddress ( _modulePtr , " " ) , typeof ( NativeMethods . CreateObjectDelegate ) ) ; if ( createObject == null ) { throw new SevenZipLibraryException ( ) ; } endif object result ; Guid interfaceId = if ! WINCE && ! MONO typeof ( IOutArchive ) . GUID ; else new Guid ( ( ( GuidAttribute ) typeof ( IOutArchive ) . GetCustomAttributes ( typeof ( GuidAttribute ) , false ) [ 0 ] ) . Value ) ; endif Guid classID = Formats . OutFormatGuids [ format ] ; try { if ! WINCE && ! MONO createObject ( ref classID , ref interfaceId , out result ) ; elif ! MONO NativeMethods . CreateCOMObject ( ref classID , ref interfaceId , out result ) ; else result = SevenZip . Mono . Factory . CreateInterface < IOutArchive > ( classID , interfaceId , user ) ; endif } catch ( Exception ) { throw new SevenZipLibraryException ( " " ) ; } InitUserOutFormat ( user , format ) ; _outArchives [ user ] [ format ] = result as IOutArchive ; } if ! WINCE && ! MONO } endif return _outArchives [ user ] [ format ] ; }
Gets IOutArchive interface to pack 7-zip archives.
Gets IOutArchive interface to pack 7 - zip archives .
format
OutArchiveFormat
None
user
object
Archive format user.
Archive format user .