コード例 #1
0
    bool SelectStepCallback(SQLiteQuery qr, bool hasdata, object state)
    {
        TestCallbackData data = state as TestCallbackData;

        if (hasdata)
        {
            // we have something to read!
            // do test readed values...
            string testStringFromSelect = qr.GetString("str_field");
            if (testStringFromSelect != testString)
            {
                throw new Exception("Test string are not equal!");
            }

            byte[] testBlobFromSelect = qr.GetBlob("blob_field");

            if (testBlobFromSelect.Length != testBlob.Length)
            {
                throw new Exception("Test blobs are not equal!");
            }

            for (int i = 0; i < testBlobFromSelect.Length; i++)
            {
                if (testBlobFromSelect[i] != testBlob[i])
                {
                    throw new Exception("Test blobs are not equal!");
                }
            }

            data.Decriment();
        }

        return(hasdata);        // repeat, maybe we have one more record
    }
コード例 #2
0
    void SelectStepCallback(SQLiteQuery qr, bool step, object state)
    {
        TestCallbackData data = state as TestCallbackData;

        if (step)
        {
            // we have something to read!
            // do test readed values...
            string testStringFromSelect = qr.GetString("str_field");
            if (testStringFromSelect != testString)
            {
                throw new Exception("Test string are not equal!");
            }

            byte[] testBlobFromSelect = qr.GetBlob("blob_field");

            if (testBlobFromSelect.Length != testBlob.Length)
            {
                throw new Exception("Test blobs are not equal!");
            }

            for (int i = 0; i < testBlobFromSelect.Length; i++)
            {
                if (testBlobFromSelect[i] != testBlob[i])
                {
                    throw new Exception("Test blobs are not equal!");
                }
            }

            data.Decriment();

            // do next read.
            asyncDB.Step(qr, SelectStepCallback, state);
        }
        else
        {
            // we reach limit or finish reading.
            asyncDB.Release(qr, SelectQueryReleased, null);
        }
    }
コード例 #3
0
    void InsertQueryReleased(object state)
    {
        // well done, we just added one more row!
        // now check 1000 counter!

        TestCallbackData data = state as TestCallbackData;

        // increment counter
        data.Increment();

        // check what to do next?
        if (data.Count < recordsNum)
        {
            // ok, add more please :)
            asyncDB.Query(queryInsert, InsertQueryCreated, data);
        }
        else
        {
            // we just added 1000 records, now read them!
            asyncDB.Query("SELECT * FROM test_values", SelectQueryCreated, data);
        }
    }
コード例 #4
0
    void OnGUI()
    {
        if (demoData == null)
        {
            if (GUI.Button(new Rect(10, 10, 150, 70), "Run asynchronous"))
            {
                // that just show how to pass an object to callback.
                demoData = new TestCallbackData();

                // start from creation of 1000 records
                asyncDB.Query(queryInsert, InsertQueryCreated, demoData);
            }
        }


        // display frame count and records count - to show that game don't stop while we reading or writing.
        string log = "Please, press the button to run test.";

        if (demoData != null)
        {
            log = "Frame: " + frameCount + ", Record Count: " + demoData.Count;
        }
        GUI.Label(new Rect(10, 80, 600, 600), log);
    }
コード例 #5
0
 void SelectQueryReleased(object state)
 {
     // finish
     demoData = null;
 }
コード例 #6
0
ファイル: DemoObject2.cs プロジェクト: Avatarchik/Duel-Off
	void OnGUI()
	{
		if( demoData == null ) 
		{
			if ( GUI.Button(new Rect (10,10,150,70), "Run asynchronous") ) 
			{
				// that just show how to pass an object to callback.
				demoData = new TestCallbackData();
				
				// start from creation of 1000 records
				asyncDB.Query(queryInsert, InsertQueryCreated, demoData);
			}
		}
		
		
		// display frame count and records count - to show that game don't stop while we reading or writing.
		string log = "Please, press the button to run test.";
		if( demoData != null )
		{
			log = "Frame: " + frameCount + ", Record Count: " + demoData.Count;
		}
		GUI.Label (new Rect (10,80,600,600), log);
	}
コード例 #7
0
ファイル: DemoObject2.cs プロジェクト: Avatarchik/Duel-Off
	void SelectQueryReleased(object state)
	{
		// finish
		demoData = null;
	}