Ejemplo n.º 1
0
        internal SwDm3rdPartyStream(ISwDMDocument19 doc, string name, AccessType_e access)
            : base(AccessTypeHelper.GetIsWriting(access), false)
        {
            m_Doc      = doc;
            m_Name     = name;
            m_IsActive = false;

            try
            {
                var stream = m_Doc.Get3rdPartyStorage(name, AccessTypeHelper.GetIsWriting(access)) as IStream;

                if (stream != null)
                {
                    Load(stream);
                    m_IsActive = true;
                }
                else
                {
                    throw new Exception("Stream doesn't exist");
                }
            }
            catch
            {
                m_Doc.Release3rdPartyStorage(m_Name);
                throw;
            }

            Seek(0, SeekOrigin.Begin);
        }
        internal SwDm3rdPartyStorage(ISwDMDocument19 doc, string name, AccessType_e access)
            : base(AccessTypeHelper.GetIsWriting(access))
        {
            m_Doc      = doc;
            m_Name     = name;
            m_IsActive = false;

            try
            {
                var storage = m_Doc.Get3rdPartyStorageStore(name, AccessTypeHelper.GetIsWriting(access)) as IComStorage;

                if (storage != null)
                {
                    Load(storage);
                    m_IsActive = true;
                }
                else
                {
                    throw new Exception("Storage doesn't exist");
                }
            }
            catch
            {
                m_Doc.Release3rdPartyStorageStore(m_Name);
                throw;
            }
        }
        internal Sw3rdPartyStorage(IModelDoc2 model, string name, AccessType_e access)
            : base(AccessTypeHelper.GetIsWriting(access))
        {
            m_Model    = model;
            m_Name     = name;
            m_IsActive = false;

            try
            {
                var storage = model.Extension.IGet3rdPartyStorageStore(name, AccessTypeHelper.GetIsWriting(access)) as IComStorage;

                if (storage != null)
                {
                    Load(storage);
                    m_IsActive = true;
                }
                else
                {
                    throw new Exception("Storage doesn't exist");
                }
            }
            catch
            {
                m_Model.Extension.IRelease3rdPartyStorageStore(m_Name);
                throw;
            }
        }
Ejemplo n.º 4
0
 public static IStorage TryOpenStorage(this IXDocument doc, string name, AccessType_e access)
 {
     try
     {
         return(doc.OpenStorage(name, access));
     }
     catch
     {
         return(null);
     }
 }
Ejemplo n.º 5
0
        public static bool GetIsWriting(AccessType_e type)
        {
            switch (type)
            {
            case AccessType_e.Write:
                return(true);

            case AccessType_e.Read:
                return(false);

            default:
                throw new NotSupportedException();
            }
        }