Click or drag to resize
Connection Constructor (String, EncryptionType, String, Boolean)
Initializes a new instance of the Connection class.

Namespace: Obujekutoru
Assembly: obujekutoru (in obujekutoru.dll) Version: 1.1.0.25794
Syntax
public Connection(
	string persistentObjectDataFolderPath,
	EncryptionType encryptionType,
	string encryptionKey,
	bool createDataFolderPath = false
)

Parameters

persistentObjectDataFolderPath
Type: SystemString
The persistent object data folder path.
encryptionType
Type: ObujekutoruEncryptionType
The data encryption type.
encryptionKey
Type: SystemString
The data encryption key.
createDataFolderPath (Optional)
Type: SystemBoolean
If set to true, creates the persistent object data folder.
Exceptions
ExceptionCondition
ArgumentNullException Stored object data folder path is null, encryption type is null, or encryption key is null.
InvalidOperationExceptionStored object data folder does not exist.
Examples
using System;
using System.Collections;
using System.Collections.Generic;

using Obujekutoru;

namespace ObujekutoruExamples.ConnectionCtor2Example
{
    class Program
    {
        static void Main(string[] args)
        {
            String dataFolderPath = @"C:\Temp\ObujekutoruData";
            EncryptionType encryptionType = EncryptionType.DESEncryption;
            String encryptionKey = "A proavo habui, quod publicos litterarum ludos non frequentavi, et domi bonis praeceptoribus usus...";

            using (Connection connection = new Connection(dataFolderPath, encryptionType, encryptionKey, true))
            {
                PersistentObjectE persistentObjectE1 = new PersistentObjectE("persistent object E1");
                PersistentObjectE persistentObjectE2 = new PersistentObjectE("persistent object E2");
                PersistentObjectE persistentObjectE3 = new PersistentObjectE("persistent object E3");

                connection.InsertPersistentObject(persistentObjectE1);
                connection.InsertPersistentObject(persistentObjectE2);
                connection.InsertPersistentObject(persistentObjectE3);

                List<PersistentObject> persistentObjects = connection.SelectPersistentObject(
                    typeof(PersistentObjectE),
                    PersistentObjectFieldFilterCollection.Empty(),
                    PersistentObjectFieldSorterCollection.Empty().And(
                        "persistentObjectName", PersistentObjectFieldSortOperator.Ascending),
                    1, Int32.MaxValue);

                Console.WriteLine("persistentObjects[0] = {0}", (persistentObjects[0] as PersistentObjectE).PersistentObjectName);
                Console.WriteLine("persistentObjects[1] = {0}", (persistentObjects[1] as PersistentObjectE).PersistentObjectName);
                Console.WriteLine("persistentObjects[2] = {0}", (persistentObjects[2] as PersistentObjectE).PersistentObjectName);
            }
        }
    }

    [PersistentObject("PersistentObjectE")]
    internal class PersistentObjectE : PersistentObject
    {
        [PersistentObjectField("persistentObjectName", true)]
        private String _persistentObjectName;

        public PersistentObjectE()
        { }
        public PersistentObjectE(String persistentObjectName)
        {
            _persistentObjectName = persistentObjectName;
        }

        public String PersistentObjectName
        {
            get { return _persistentObjectName; }
            set
            {
                _persistentObjectName = value;

                OnObjectUpdated();
            }
        }
    }
}
See Also