• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Interop.Instance类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Microsoft.Isam.Esent.Interop.Instance的典型用法代码示例。如果您正苦于以下问题:C# Instance类的具体用法?C# Instance怎么用?C# Instance使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Instance类属于Microsoft.Isam.Esent.Interop命名空间,在下文中一共展示了Instance类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: CreateBasicTableColumnIndex3OnXp

        public void CreateBasicTableColumnIndex3OnXp()
        {
            var tablecreate = new JET_TABLECREATE { szTableName = "table" };

            string directory = SetupHelper.CreateRandomDirectory();
            string database = Path.Combine(directory, "test.db");

            using (var instance = new Instance("XpCreateBasicTableColumnIndex3"))
            {
                instance.Parameters.Recovery = false;
                instance.Parameters.NoInformationEvent = true;
                instance.Parameters.MaxTemporaryTables = 0;
                instance.Init();
                using (var session = new Session(instance))
                {
                    JET_DBID dbid;
                    Api.JetCreateDatabase(session, database, String.Empty, out dbid, CreateDatabaseGrbit.None);
                    using (var transaction = new Transaction(session))
                    {
                        Api.JetCreateTableColumnIndex3(session, dbid, tablecreate);
                        Assert.AreNotEqual(JET_TABLEID.Nil, tablecreate.tableid);
                        Assert.AreEqual(tablecreate.cCreated, 1);
                        Api.JetCloseTable(session, tablecreate.tableid);
                        transaction.Commit(CommitTransactionGrbit.LazyFlush);
                    }
                }
            }
        }
开发者ID:j2jensen,项目名称:ravendb,代码行数:28,代码来源:XpCompatabilityTests.cs


示例2: TestJetRestoreInstanceThrowsExceptionWhenSourceIsNull

 public void TestJetRestoreInstanceThrowsExceptionWhenSourceIsNull()
 {
     using (var instance = new Instance("RestoreNullSource"))
     {
         Api.JetRestoreInstance(instance, null, "somewhere", null);
     }
 }
开发者ID:925coder,项目名称:ravendb,代码行数:7,代码来源:BackupRestoreTests.cs


示例3: EsentChainStateManager

        public EsentChainStateManager(string baseDirectory)
        {
            this.baseDirectory = baseDirectory;
            this.jetDirectory = Path.Combine(baseDirectory, "ChainState");
            this.jetDatabase = Path.Combine(this.jetDirectory, "ChainState.edb");

            this.jetInstance = new Instance(Guid.NewGuid().ToString());
            var success = false;
            try
            {
                EsentStorageManager.InitInstanceParameters(jetInstance, jetDirectory);
                this.jetInstance.Init();

                this.CreateOrOpenDatabase();

                this.cursorCache = new DisposableCache<IChainStateCursor>(1024,
                    createFunc: () => new EsentChainStateCursor(this.jetDatabase, this.jetInstance),
                    prepareAction: cursor =>
                    {
                        // rollback any open transaction before returning the cursor to the cache
                        if (cursor.InTransaction)
                            cursor.RollbackTransaction();
                    });

                success = true;
            }
            finally
            {
                if (!success)
                {
                    this.cursorCache?.Dispose();
                    this.jetInstance.Dispose();
                }
            }
        }
开发者ID:cole2295,项目名称:BitSharp,代码行数:35,代码来源:EsentChainStateManager.cs


示例4: CreateDatabase

        private static void CreateDatabase()
        {
            using (var databaseInstance = new Instance(DatabasePath))
            {
                InitializeDatabaseInstance(databaseInstance);

                if (File.Exists(DatabasePath))
                {
                    return;
                }

                using (var session = new Session(databaseInstance))
                {
                    JET_DBID dbid;
                    Api.JetCreateDatabase(session, DatabasePath, null, out dbid, CreateDatabaseGrbit.OverwriteExisting);
                    using (var transaction = new Transaction(session))
                    {
                        JET_TABLEID tableid;
                        Api.JetCreateTable(session, dbid, "Message", 0, 100, out tableid);

                        CreateIdColumn(session, tableid);
                        CreateDateCreatedColumn(session, tableid);
                        CreateIndexes(session, tableid);

                        transaction.Commit(CommitTransactionGrbit.LazyFlush);
                    }

                    Api.JetCloseDatabase(session, dbid, CloseDatabaseGrbit.None);
                    Api.JetDetachDatabase(session, DatabasePath);
                }
            }
        }
开发者ID:seantarogers,项目名称:ReliableSignalRMessaging,代码行数:32,代码来源:MessageStoreServiceTests.cs


示例5: VerifyInstanceDoesNotCallJetTermWhenCreateInstanceFails

        public void VerifyInstanceDoesNotCallJetTermWhenCreateInstanceFails()
        {
            var mocks = new MockRepository();
            var mockApi = mocks.StrictMock<IJetApi>();
            using (new ApiTestHook(mockApi))
            {
                Expect.Call(
                    mockApi.JetCreateInstance2(
                        out Arg<JET_INSTANCE>.Out(JET_INSTANCE.Nil).Dummy,
                        Arg<string>.Is.Anything,
                        Arg<string>.Is.Anything,
                        Arg<CreateInstanceGrbit>.Is.Anything))
                    .Return((int) JET_err.InvalidName);
                mocks.ReplayAll();

                try
                {
                    using (var instance = new Instance("testfail"))
                    {
                        Assert.Fail("Expected an EsentErrorException");
                    }
                }
                catch (EsentErrorException)
                {
                    // expected
                }

                mocks.VerifyAll();
            }
        }
开发者ID:Rationalle,项目名称:ravendb,代码行数:30,代码来源:InstanceTests.cs


示例6: OpenDatabase

        public static void OpenDatabase(string jetDatabase, Instance jetInstance, bool readOnly)
        {
            using (var jetSession = new Session(jetInstance))
            {
                var attachGrbit = AttachDatabaseGrbit.None;
                if (readOnly)
                    attachGrbit |= AttachDatabaseGrbit.ReadOnly;
                if (EsentVersion.SupportsWindows7Features)
                    attachGrbit |= Windows7Grbits.EnableAttachDbBackgroundMaintenance;

                Api.JetAttachDatabase(jetSession, jetDatabase, attachGrbit);
                var success = false;
                try
                {
                    using (var cursor = new EsentChainStateCursor(jetDatabase, jetInstance))
                    {
                        // reset flush column
                        using (var jetUpdate = cursor.jetSession.BeginUpdate(cursor.flushTableId, JET_prep.Replace))
                        {
                            Api.SetColumn(cursor.jetSession, cursor.flushTableId, cursor.flushColumnId, 0);

                            jetUpdate.Save();
                        }
                    }

                    success = true;
                }
                finally
                {
                    if (!success)
                        Api.JetDetachDatabase(jetSession, jetDatabase);
                }
            }
        }
开发者ID:ArsenShnurkov,项目名称:BitSharp,代码行数:34,代码来源:EsentChainStateSchema.cs


示例7: CreateDatabase

        /// <summary>
        /// Create a new database and return a connection to
        /// the database. The database will be overwritten if
        /// it already exists.
        /// </summary>
        /// <param name="database">The path to the database.</param>
        /// <param name="mode">Creation mode for the database.</param>
        /// <returns>A new connection to the database.</returns>
        public virtual Connection CreateDatabase(string database, DatabaseCreationMode mode)
        {
            database = Path.GetFullPath(database);

            lock (this.lockObject)
            {
                this.SetGlobalParameters();
                this.Tracer.TraceInfo("create database '{0}'", database);

                // Create the database then open it
                using (var instance = new Instance(this.GetNewInstanceName()))
                {
                    SetParametersAndInitializeInstance(database, instance);

                    using (var session = new Session(instance))
                    {
                        CreateDatabaseGrbit grbit = (DatabaseCreationMode.OverwriteExisting == mode) ?
                            CreateDatabaseGrbit.OverwriteExisting : CreateDatabaseGrbit.None;

                        JET_DBID dbid;
                        Api.JetCreateDatabase(session, database, String.Empty, out dbid, grbit);
                        Api.JetCloseDatabase(session, dbid, CloseDatabaseGrbit.None);
                        Api.JetDetachDatabase(session, database);
                    }
                }

                return this.AttachDatabase(database, DatabaseOpenMode.ReadWrite);
            }
        }
开发者ID:nzdunic,项目名称:ravendb,代码行数:37,代码来源:ConnectionManager.cs


示例8: EsentBlockTxesStorage

        public EsentBlockTxesStorage(string baseDirectory, int? index = null)
        {
            this.jetDirectory = Path.Combine(baseDirectory, "BlockTxes");
            if (index.HasValue)
                this.jetDirectory = Path.Combine(jetDirectory, index.Value.ToString());
            this.jetDatabase = Path.Combine(this.jetDirectory, "BlockTxes.edb");

            this.cursorCache = new DisposableCache<EsentBlockTxesCursor>(1024,
                createFunc: () => new EsentBlockTxesCursor(this.jetDatabase, this.jetInstance));

            this.jetInstance = new Instance(Guid.NewGuid().ToString());
            var success = false;
            try
            {
                EsentStorageManager.InitInstanceParameters(jetInstance, jetDirectory);
                this.jetInstance.Init();
                this.CreateOrOpenDatabase();
                success = true;
            }
            finally
            {
                if (!success)
                    this.jetInstance.Dispose();
            }
        }
开发者ID:cole2295,项目名称:BitSharp,代码行数:25,代码来源:EsentBlockTxesStorage.cs


示例9: Cursor

 public Cursor(Instance instance, string databaseFileName)
 {
     m_DatabaseFileName = databaseFileName;
     Session = new Session(instance);
     Api.JetAttachDatabase(Session, databaseFileName, AttachDatabaseGrbit.None);
     Api.JetOpenDatabase(Session, databaseFileName, null, out Dbid, OpenDatabaseGrbit.None);
 }
开发者ID:fzhenmei,项目名称:study,代码行数:7,代码来源:Cursor.cs


示例10: Setup

        public void Setup()
        {
            this.instance = new Instance(Guid.NewGuid().ToString(), "RetrieveColumnsPerfTest");
            this.instance.Parameters.NoInformationEvent = true;
            this.instance.Parameters.Recovery = false;
            this.instance.Init();

            this.session = new Session(this.instance);

            // turn off logging so initialization is faster
            this.columnidDict = SetupHelper.CreateTempTableWithAllColumns(this.session, TempTableGrbit.ForceMaterialization, out this.tableid);

            // Insert a record and position the tableid on it
            using (var transaction = new Transaction(this.session))
            using (var update = new Update(this.session, this.tableid, JET_prep.Insert))
            {
                Api.SetColumn(this.session, this.tableid, this.columnidDict["boolean"], this.expectedBool);
                Api.SetColumn(this.session, this.tableid, this.columnidDict["int32"], this.expectedInt32);
                Api.SetColumn(this.session, this.tableid, this.columnidDict["int64"], this.expectedInt64);
                Api.SetColumn(this.session, this.tableid, this.columnidDict["guid"], this.expectedGuid);
                Api.SetColumn(this.session, this.tableid, this.columnidDict["unicode"], this.expectedString, Encoding.Unicode);

                update.Save();
                transaction.Commit(CommitTransactionGrbit.None);
            }

            Api.TryMoveFirst(this.session, this.tableid);
            Thread.CurrentThread.Priority = ThreadPriority.Highest;
            Thread.BeginThreadAffinity();
        }
开发者ID:nzdunic,项目名称:ravendb,代码行数:30,代码来源:RetrieveColumnsPerfTest.cs


示例11: Initialize

        public void Initialize()
        {
            _instance = CreateEsentInstance();
            _primarySessionId = new Session(_instance);

            InitializeDatabaseAndTables();
        }
开发者ID:Rickinio,项目名称:roslyn,代码行数:7,代码来源:EsentStorage.cs


示例12: InstanceCanConvertToJetInstance

 public void InstanceCanConvertToJetInstance()
 {
     using (var instance = new Instance("converttoinstance"))
     {
         JET_INSTANCE jetinstance = instance;
         Assert.AreEqual(jetinstance, instance.JetInstance);
     }
 }
开发者ID:Rationalle,项目名称:ravendb,代码行数:8,代码来源:InstanceTests.cs


示例13: SetAndGetAsciiSystemPath

 public void SetAndGetAsciiSystemPath()
 {
     using (var instance = new Instance("asciisystempath"))
     {
         instance.Parameters.SystemDirectory = this.directory;
         StringAssert.Contains(instance.Parameters.SystemDirectory, this.directory);
     }
 }
开发者ID:jtmueller,项目名称:ravendb,代码行数:8,代码来源:AsciiPathTests.cs


示例14: EsentDb

 public EsentDb(string dbname)
 {
     this.dbname = dbname;
       instance = OpenInstance(dbname);
       session = CreateSession(instance);
       dbid = CreateDatabase(dbname, instance, session);
       table = CreateTable(session, dbid, "store", new Tuple<string, JET_coltyp>[] { Tuple.Create("key", JET_coltyp.Long), Tuple.Create("data", JET_coltyp.LongText) });
 }
开发者ID:925coder,项目名称:library,代码行数:8,代码来源:EsentDb.cs


示例15: InsertMessageIntoDatabase

 private static void InsertMessageIntoDatabase(Guid messageId)
 {
     using (var databaseInstance = new Instance(DatabasePath))
     {
         InitializeDatabaseInstance(databaseInstance);
         InsertMessage(databaseInstance, messageId);
     }
 }
开发者ID:seantarogers,项目名称:ReliableSignalRMessaging,代码行数:8,代码来源:MessageStoreService.cs


示例16: SetAndGetAsciiLogPath

 public void SetAndGetAsciiLogPath()
 {
     using (var instance = new Instance("asciilogpath"))
     {
         instance.Parameters.LogFileDirectory = this.directory;
         StringAssert.Contains(instance.Parameters.LogFileDirectory, this.directory);
     }
 }
开发者ID:Rationalle,项目名称:ravendb,代码行数:8,代码来源:AsciiPathTests.cs


示例17: Setup

 public void Setup()
 {
     this.instance = new Instance(Guid.NewGuid().ToString(), "TemporaryTableTests");
     this.instance.Parameters.Recovery = false;
     this.instance.Parameters.NoInformationEvent = true;
     this.instance.Parameters.PageTempDBMin = SystemParameters.PageTempDBSmallest;
     this.instance.Init();
     this.session = new Session(this.instance);
 }
开发者ID:jtmueller,项目名称:ravendb,代码行数:9,代码来源:TemporaryTableTests.cs


示例18: CreateMessageStore

 public static void CreateMessageStore(string MessageTypeName, Instance instance)
 {
     using (var session = new Session(instance))
     {
         JET_DBID dbid;
         Api.JetOpenDatabase(session, DatabaseName, null, out dbid, OpenDatabaseGrbit.None);
         CreateMessageTable(MessageTypeName, session, dbid);
     }
 }
开发者ID:nka1,项目名称:Daytona,代码行数:9,代码来源:EsentConfig.cs


示例19: each_up

        public void each_up()
        {
            var tempDir = Path.Combine(Environment.CurrentDirectory, "with_a_dummy_instance");
            var tempPath = Path.Combine(tempDir, "test.db");
            if(Directory.Exists(tempDir)) Directory.Delete(tempDir, true);

            Instance = new Instance(Guid.NewGuid().ToString());
            Instance.Init();
        }
开发者ID:AndyHitchman,项目名称:Stash,代码行数:9,代码来源:with_dummy_instance.cs


示例20: DumpMetaData

        /// <summary>
        /// Dump the meta-data of the table.
        /// </summary>
        /// <param name="args">Arguments for the command.</param>
        private void DumpMetaData(string[] args)
        {
            if (args.Length != 1)
            {
                throw new ArgumentException("specify the database", "args");
            }

            string database = args[0];

            using (var instance = new Instance("dumpmetadata"))
            {
                instance.Parameters.Recovery = false;
                instance.Init();

                using (var session = new Session(instance))
                {
                    JET_DBID dbid;
                    Api.JetAttachDatabase(session, database, AttachDatabaseGrbit.ReadOnly);
                    Api.JetOpenDatabase(session, database, null, out dbid, OpenDatabaseGrbit.ReadOnly);

                    foreach (string table in Api.GetTableNames(session, dbid))
                    {
                        Console.WriteLine(table);
                        foreach (ColumnInfo column in Api.GetTableColumns(session, dbid, table))
                        {
                            Console.WriteLine("\t{0}", column.Name);
                            Console.WriteLine("\t\tColtyp:     {0}", column.Coltyp);
                            Console.WriteLine("\t\tColumnid:   {0}", column.Columnid);
                            if (JET_coltyp.LongText == column.Coltyp || JET_coltyp.Text == column.Coltyp)
                            {
                                Console.WriteLine("\t\tCode page:  {0}", column.Cp);
                            }

                            Console.WriteLine("\t\tMax length: {0}", column.MaxLength);
                            Console.WriteLine("\t\tGrbit:      {0}", column.Grbit);
                        }

                        foreach (IndexInfo index in Api.GetTableIndexes(session, dbid, table))
                        {
                            Console.WriteLine("\t{0}", index.Name);
                            Console.WriteLine("\t\tGrbit:          {0}", index.Grbit);
                            Console.WriteLine("\t\tCultureInfo:    {0}", index.CultureInfo);
                            Console.WriteLine("\t\tCompareOptions: {0}", index.CompareOptions);

                            foreach (IndexSegment segment in index.IndexSegments)
                            {
                                Console.WriteLine("\t\t\t{0}", segment.ColumnName);
                                Console.WriteLine("\t\t\t\tColtyp:      {0}", segment.Coltyp);
                                Console.WriteLine("\t\t\t\tIsAscending: {0}", segment.IsAscending);
                                Console.WriteLine("\t\t\t\tIsASCII:     {0}", segment.IsASCII);
                            }
                        }
                    }
                }
            }
        }
开发者ID:Rationalle,项目名称:ravendb,代码行数:60,代码来源:DumpMetaData.cs



注:本文中的Microsoft.Isam.Esent.Interop.Instance类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Interop.JET_COLUMNDEF类代码示例发布时间:2022-05-26
下一篇:
C# Interop.ColumnStream类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap