示例#1
0
文件: Program.cs 项目: nemanjazz/iog
        static void Main(string[] args)
        {
            // Initialize IOG storage in the Cassandra storage
            // See App.config for host/port settings of Cassandra instance
            var storage = new AquilesStorage.AquilesStorage("Test Cluster", "IOGKeyspace", "IOGFamily");

            // Create an IOG context in memory which has the data model of IDataModel type
            // Use the created storage for the context data
            Context ctx = new Context(typeof(IDataModel), null, storage);

            // Open workspace for writing
            using (var workspace = ctx.OpenWorkspace <IDataModel>(IsolationLevel.Exclusive))
            {
                // Access the data model via the current workspace
                IDataModel data = workspace.Data;

                // Write out the current data:
                // When running for the first time, data will be empty string
                // When running for the second time, data will be loaded from file
                Console.WriteLine(data.StringValue);

                // Set the value in data model
                data.StringValue = "Hello world!";

                // Commit the change
                workspace.Commit();
            }

            // Open workspace for reading
            using (var workspace = ctx.OpenWorkspace <IDataModel>(IsolationLevel.ReadOnly))
            {
                // Access the data model via the current workspace
                IDataModel data = workspace.Data;

                // Write out the current data
                Console.WriteLine(data.StringValue);
            }

            ctx.Dispose();
        }
示例#2
0
文件: Program.cs 项目: nemanjazz/iog
        static void Main(string[] args)
        {
            // Initialize IOG storage in the Cassandra storage
            // See App.config for host/port settings of Cassandra instance
            var storage = new AquilesStorage.AquilesStorage("Test Cluster", "IOGKeyspace", "IOGFamily");

            // Create an IOG context in memory which has the data model of IDataModel type
            // Use the created storage for the context data
            Context ctx = new Context(typeof(IDataModel), null, storage);

            // Open workspace for writing
            using (var workspace = ctx.OpenWorkspace<IDataModel>(IsolationLevel.Exclusive))
            {
                // Access the data model via the current workspace
                IDataModel data = workspace.Data;

                // Write out the current data:
                // When running for the first time, data will be empty string
                // When running for the second time, data will be loaded from file
                Console.WriteLine(data.StringValue);

                // Set the value in data model
                data.StringValue = "Hello world!";

                // Commit the change
                workspace.Commit();
            }

            // Open workspace for reading
            using (var workspace = ctx.OpenWorkspace<IDataModel>(IsolationLevel.ReadOnly))
            {
                // Access the data model via the current workspace
                IDataModel data = workspace.Data;

                // Write out the current data
                Console.WriteLine(data.StringValue);
            }

            ctx.Dispose();
        }