internal static SolidEdgeDocument FromIStorage(IStorage storage)
        {
            if (storage == null)
            {
                throw new ArgumentNullException("storage");
            }

            SolidEdgeDocument document = null;

            System.Runtime.InteropServices.ComTypes.STATSTG statstg = statstg = storage.GetStatistics();

            // For now there is a 1 - 1 mapping.
            Type[] types = System.Reflection.Assembly.GetExecutingAssembly().GetSolidEdgeDocumentTypes(statstg.clsid);

            if (types.Length == 0)
            {
                Marshal.ThrowExceptionForHR(HRESULT.CO_E_CANTDETERMINECLASS);
            }
            else if (types.Length == 1)
            {
                document = InvokeConstructor(types[0], storage, statstg);
            }
            else // Future possibility for multiple types. i.e Guid.Empty
            {
                Marshal.ThrowExceptionForHR(HRESULT.CO_E_CANTDETERMINECLASS);
            }

            return(document);
        }
 public static DocumentStatus GetStatus(string path)
 {
     using (SolidEdgeDocument document = SolidEdgeDocument.Open(path))
     {
         return(document.Status);
     }
 }
        public new static SolidEdgeDocument Open(string path)
        {
            SolidEdgeDocument document = null;
            IStorage          storage  = null;

            try
            {
                storage  = CompoundFile.OpenStorage(path);
                document = FromIStorage(storage);
            }
            catch
            {
                throw;
            }
            finally
            {
                if (document == null)
                {
                    if (storage != null)
                    {
                        storage.FinalRelease();
                    }
                }
            }

            return(document);
        }
 public static Version GetLastSavedVersion(string path)
 {
     using (SolidEdgeDocument document = SolidEdgeDocument.Open(path))
     {
         return(document.LastSavedVersion);
     }
 }
        internal static T Open <T>(string path)
        {
            SolidEdgeDocument document = null;
            bool flag = false;

            try
            {
                document = Open(path);
                return((T)Convert.ChangeType(document, typeof(T)));
            }
            catch
            {
                flag = true;
                throw;
            }
            finally
            {
                if ((flag) && (document != null))
                {
                    document.Close();
                }
            }
        }