zoukankan      html  css  js  c++  java
  • .NET 对实现IPersistStream接口的对象进行保存和读取

    我们可以对实现IPersistStream接口的类的对象进行保存和读取,如Element,Map等等

    以下为应用IPersistStream接口保存当前视图(Map)至文件读取文件并在当前视图展示的代码

     

     

                //保存当前视图至文件

                IMemoryBlobStream pMemoryBlobStream = new MemoryBlobStreamClass();

           IObjectStream pObjectStream = new ObjectStreamClass();

                pObjectStream.Stream = pMemoryBlobStream;

                 IPersistStream pPersistStream = (IPersistStream)m_map;

                 pPersistStream.Save((IStream)pObjectStream, 0);

                 pMemoryBlobStream.SaveToFile(@"e:myfile.blb");

                //读取文件并在当前视图展现

                 IMemoryBlobStream pMemoryBlobStream = new MemoryBlobStreamClass();

                 pMemoryBlobStream.LoadFromFile(@"e:myfile.blb");

                 IObjectStream pObjectStream = new ObjectStreamClass();

                 pObjectStream.Stream=pMemoryBlobStream;

                 IPersistStream pPersistStream = (IPersistStream)m_map;

                 pPersistStream.Load((IStream)pObjectStream);

                 m_activeView.Refresh();

      要素写入Oracle的Blob字段

                if (LayerIndex == -1)
                {
                    Guid guid;
                    object obj2;
                    IPersistStream stream = (IPersistStream)Layer;
                    IMemoryBlobStream stream2 = new MemoryBlobStreamClass();
                    stream.GetClassID(out guid);
                    stream.Save(stream2, 1);
                    ((IMemoryBlobStreamVariant)stream2).ExportToVariant(out obj2);
                    byte[] buffer = (byte[])obj2;
                    sql = String.Format("{0}={1} and {2}={3}", TableHelper.FDLNodeId, NodeId, TableHelper.FDPrjId, nProjectId);
                    DBHelper.DataAccess.SaveBLOB(TableHelper.TBLayerNode, TableHelper.FDLNodeRender, sql, buffer);
                }
  • 相关阅读:
    TO DO List
    springboot 热部署
    <dependencyManagement>的作用
    人体工程学座椅
    temp
    temp
    声明式编程和命令式编程的本质区别
    weak first question
    Spring依赖注入方式和依赖来源
    SpringBoot 整合 H2 数据库
  • 原文地址:https://www.cnblogs.com/cglNet/p/12435247.html
Copyright © 2011-2022 走看看