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


C# Instance.Init方法代码示例

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


在下文中一共展示了Instance.Init方法的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: 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

示例3: 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

示例4: Initialise

        public override void Initialise()
        {
            instance = new Instance(string.Empty);
            instance.Parameters.MaxVerPages = 1024;
            instance.Init();

            using (var session = new Session(instance))
                if (!fileSystem.FileExists(GetDatabaseFileName()))
                    CreateDatabaseAndTables(session, GetDatabaseFileName());
        }
开发者ID:SystemDot,项目名称:SystemDotServiceBus,代码行数:10,代码来源:EsentChangeStore.cs

示例5: CreateDatabase

 /// <summary>
 /// Creates the message store.
 /// </summary>
 /// <param name="database">The database.</param>
 public static void CreateDatabase()
 {
     using (var instance = new Instance("createdatabase"))
     {
         instance.Parameters.CircularLog = true;
         instance.Init();
         using (var session = new Session(instance))
         {
             JET_DBID dbid;
             Api.JetCreateDatabase(session, DatabaseName, null, out dbid, CreateDatabaseGrbit.OverwriteExisting);
         }
     }
 }
开发者ID:nka1,项目名称:Daytona,代码行数:17,代码来源:EsentConfig.cs

示例6: IinsertAndReadOneMessage

        public void IinsertAndReadOneMessage()
        {
            TestHelper.CreateDatabase("EsentTestsDummy");
            using (var instance = new Instance("MyInstanceName"))
            {
                instance.Parameters.CircularLog = true;
                instance.Init();
                using (var session = new Session(instance))
                {
                    JET_DBID dbid;
                    Api.JetAttachDatabase(session, DatabaseName, AttachDatabaseGrbit.None);
                    Api.JetOpenDatabase(session, DatabaseName, null, out dbid, OpenDatabaseGrbit.None);

                    JET_TABLEID tableid;

                    if (Api.TryOpenTable(session, dbid, "EsentTestsDummymessages", OpenTableGrbit.None, out tableid))
                    {
                        IDictionary<string, JET_COLUMNID> columnids = Api.GetColumnDictionary(session, tableid);
                        JET_COLUMNID columnidMessage = columnids["message"];
                        JET_COLUMNID columnidMetaData = columnids["metadata"];

                        Assert.IsInstanceOfType(columnidMessage, typeof(JET_COLUMNID));
                        Assert.IsInstanceOfType(columnidMetaData, typeof(JET_COLUMNID));
                        AddMessage(session, tableid, ref columnidMessage, ref columnidMetaData);

                        var results = TestHelper.DumpByIndex(session, tableid, null, columnids);
                        Assert.IsNotNull(results);
                        Assert.IsTrue(results.Count == 1);
                        Assert.AreEqual("Hi this is the message", results[0]);
                    }
                    else
                    {
                        using (var table = new Table(session, dbid, "EsentTestsDummymessages", OpenTableGrbit.None))
                        {
                            IDictionary<string, JET_COLUMNID> columnids = Api.GetColumnDictionary(session, table);
                            JET_COLUMNID columnidMessage = columnids["message"];
                            JET_COLUMNID columnidMetaData = columnids["metadata"];

                            Assert.IsInstanceOfType(columnidMessage, typeof(JET_COLUMNID));
                            Assert.IsInstanceOfType(columnidMetaData, typeof(JET_COLUMNID));
                            AddMessage(session, table, ref columnidMessage, ref columnidMetaData);

                            var results = TestHelper.DumpByIndex(session, table, null, columnids);
                            Assert.IsNotNull(results);
                            Assert.IsTrue(results.Count == 1);
                            Assert.AreEqual("Hi this is the message", results[0]);
                        }
                    }
                }
            }
        }
开发者ID:nanderto,项目名称:PubSub,代码行数:51,代码来源:DatabaseTests.cs

示例7: CreateInstanceInitTerm

 public void CreateInstanceInitTerm()
 {
     string dir = SetupHelper.CreateRandomDirectory();
     using (var instance = new Instance("theinstance"))
     {
         instance.Parameters.LogFileDirectory = dir;
         instance.Parameters.SystemDirectory = dir;
         instance.Parameters.TempDirectory = dir;
         instance.Parameters.NoInformationEvent = true;
         instance.Init();
         instance.Term();
         Directory.Delete(dir, true);    // only works if the instance is terminated
     }
 }
开发者ID:ayende,项目名称:managed-esent,代码行数:14,代码来源:InstanceTests.cs

示例8: CreateDatabaseAndActorStore

 /// <summary>
 /// Creates the message store.
 /// </summary>
 /// <param name="database">The database.</param>
 public static void CreateDatabaseAndActorStore(string messageTypeName)
 {
     using (var instance = new Instance("createdatabase"))
     {
         instance.Parameters.CircularLog = true;
         instance.Init();
         using (var session = new Session(instance))
         {
             JET_DBID dbid;
             Api.JetCreateDatabase(session, DatabaseName, null, out dbid, CreateDatabaseGrbit.OverwriteExisting);
             CreateMessageTable(messageTypeName, session, dbid);
         }
     }
 }
开发者ID:nka1,项目名称:Daytona,代码行数:18,代码来源:EsentConfig.cs

示例9: CreateIndexesOnXp

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

            using (var instance = new Instance("XPcreateindexes"))
            {
                instance.Parameters.Recovery = false;
                instance.Parameters.NoInformationEvent = true;
                instance.Parameters.MaxTemporaryTables = 0;
                instance.Parameters.TempDirectory = directory;
                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))
                    {
                        JET_TABLEID tableid;
                        Api.JetCreateTable(session, dbid, "table", 0, 100, out tableid);
                        JET_COLUMNID columnid;
                        Api.JetAddColumn(
                            session,
                            tableid,
                            "column1",
                            new JET_COLUMNDEF { coltyp = JET_coltyp.Long },
                            null,
                            0,
                            out columnid);

                        var indexcreates = new[]
                        {
                            new JET_INDEXCREATE
                            {
                                szKey = "+column1\0",
                                cbKey = 10,
                                szIndexName = "index1",
                                pidxUnicode = new JET_UNICODEINDEX { lcid = 1033 },
                            },
                        };

                        Api.JetCreateIndex2(session, tableid, indexcreates, indexcreates.Length);
                        transaction.Commit(CommitTransactionGrbit.LazyFlush);
                    }
                }
            }

            Cleanup.DeleteDirectoryWithRetry(directory);
        }
开发者ID:ayende,项目名称:managed-esent,代码行数:49,代码来源:XpCompatabilityTests.cs

示例10: CreateDatabase

 public override void CreateDatabase()
 {
     try {
         using (Instance instance = new Instance("newdb")) {
             instance.Init();
             using (Session session = new Session(instance)) {
                 JET_DBID dbid;
                 Api.JetCreateDatabase(session, filename, null, out dbid, CreateDatabaseGrbit.None);
             }
         }
     } catch {
         // TODO: Wrap database already exists exception
         throw;
     }
 }
开发者ID:purplecow,项目名称:simplestorageengine,代码行数:15,代码来源:EseConnectionManager.cs

示例11: CreateInstanceInit

        public void CreateInstanceInit()
        {
            string dir = SetupHelper.CreateRandomDirectory();
            using (var instance = new Instance("createinit"))
            {
                instance.Parameters.LogFileDirectory = dir;
                instance.Parameters.SystemDirectory = dir;
                instance.Parameters.TempDirectory = dir;
                instance.Parameters.LogFileSize = 512; // 512Kb
                instance.Parameters.NoInformationEvent = true;
                instance.Init();
            }

            Cleanup.DeleteDirectoryWithRetry(dir);
        }
开发者ID:ayende,项目名称:managed-esent,代码行数:15,代码来源:InstanceTests.cs

示例12: CreateInstanceInitTerm

 public void CreateInstanceInitTerm()
 {
     string dir = SetupHelper.CreateRandomDirectory();
     using (var instance = new Instance("initterm"))
     {
         instance.Parameters.LogFileDirectory = dir;
         instance.Parameters.SystemDirectory = dir;
         instance.Parameters.TempDirectory = dir;
         instance.Parameters.LogFileSize = 256; // 256Kb
         instance.Parameters.NoInformationEvent = true;
         instance.Init();
         instance.Term();
         Cleanup.DeleteDirectoryWithRetry(dir);    // only works if the instance is terminated
     }
 }
开发者ID:ayende,项目名称:managed-esent,代码行数:15,代码来源:InstanceTests.cs

示例13: AttachDatabaseWithAsciiPath2

        public void AttachDatabaseWithAsciiPath2()
        {
            using (var instance = new Instance("asciidbattach2"))
            {
                SetupHelper.SetLightweightConfiguration(instance);
                instance.Parameters.CreatePathIfNotExist = true;
                instance.Init();
                using (var session = new Session(instance))
                {
                    JET_DBID dbid;
                    Api.JetCreateDatabase(session, this.database, String.Empty, out dbid, CreateDatabaseGrbit.None);
                    Api.JetCloseDatabase(session, dbid, CloseDatabaseGrbit.None);
                    Api.JetDetachDatabase(session, this.database);

                    Api.JetAttachDatabase2(session, this.database, 512, AttachDatabaseGrbit.None);
                }
            }
        }
开发者ID:ayende,项目名称:managed-esent,代码行数:18,代码来源:AsciiPathTests.cs

示例14: CreateInstance

 private Instance CreateInstance()
 {
     var instance = new Instance(databasePath)
     {
         Parameters =
         {
             CreatePathIfNotExist = true,
             TempDirectory = Path.Combine(fullPath, "temp"),
             SystemDirectory = Path.Combine(fullPath, "system"),
             LogFileDirectory = Path.Combine(fullPath, "logs"),
             Recovery = true,
             CircularLog = true,
             LogFileSize = 1024,
         },
     };
     instance.Init();
     return instance;
 }
开发者ID:Opiumtm,项目名称:DvachBrowser3,代码行数:18,代码来源:EsentInstanceProvider.cs

示例15: ExecuteInDatabase

        protected void ExecuteInDatabase(Action<Session, JET_DBID> action)
        {
            var instance = new Instance(databasePath);
            try
            {
                instance.Parameters.CircularLog = true;
                instance.Parameters.CreatePathIfNotExist = true;
                instance.Parameters.TempDirectory = Path.Combine(Path.GetDirectoryName(databasePath), "temp");
                instance.Parameters.SystemDirectory = Path.Combine(Path.GetDirectoryName(databasePath), "system");
                instance.Parameters.LogFileDirectory = Path.Combine(Path.GetDirectoryName(databasePath), "logs");
                instance.Init();

                using (var session = new Session(instance))
                {
                    Api.JetAttachDatabase(session, databasePath, AttachDatabaseGrbit.None);
                    try
                    {
                        using (var tx = new Transaction(session))
                        {

                            JET_DBID dbid;
                            Api.JetOpenDatabase(session, databasePath, "", out dbid, OpenDatabaseGrbit.None);
                            try
                            {
                                action(session, dbid);
                                tx.Commit(CommitTransactionGrbit.None);
                            }
                            finally
                            {
                                Api.JetCloseDatabase(session, dbid, CloseDatabaseGrbit.None);
                            }
                        }
                    }
                    finally
                    {
                        Api.JetDetachDatabase(session, databasePath);
                    }
                }
            }
            finally
            {
                instance.Term();
            }
        }
开发者ID:ayende,项目名称:rhino-pht,代码行数:44,代码来源:EsentCommandBase.cs


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