当前位置: 首页>>代码示例>>C#>>正文


C# Interop.Instance类代码示例

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


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


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