Ejemplo n.º 1
0
        public OperationCollectionPersist(IPersist <IData> keyPersist, IPersist <IData> recordPersist, IOperationCollectionFactory collectionFactory)
        {
            KeyPersist    = keyPersist;
            RecordPersist = recordPersist;

            writes = new Action <BinaryWriter, IOperation> [OperationCode.MAX];
            writes[OperationCode.REPLACE]          = WriteReplaceOperation;
            writes[OperationCode.INSERT_OR_IGNORE] = WriteInsertOrIgnoreOperation;
            writes[OperationCode.DELETE]           = WriteDeleteOperation;
            writes[OperationCode.DELETE_RANGE]     = WriteDeleteRangeOperation;
            writes[OperationCode.CLEAR]            = WriteClearOperation;

            reads = new Func <BinaryReader, IOperation> [OperationCode.MAX];
            reads[OperationCode.REPLACE]          = ReadReplaceOperation;
            reads[OperationCode.INSERT_OR_IGNORE] = ReadInsertOrIgnoreOperation;
            reads[OperationCode.DELETE]           = ReadDeleteOperation;
            reads[OperationCode.DELETE_RANGE]     = ReadDeleteRangeOperation;
            reads[OperationCode.CLEAR]            = ReadClearOperation;

            CollectionFactory = collectionFactory;
        }
Ejemplo n.º 2
0
        public Locator(long id, string name, int structureType, DataType keyDataType, DataType recordDataType, Type keyType, Type recordType)
        {
            if (keyDataType == null)
            {
                throw new ArgumentException("keyDataType");
            }
            if (recordDataType == null)
            {
                throw new ArgumentException("recordDataType");
            }

            ID            = id;
            Name          = name;
            StructureType = structureType;

            hashCode = ID.GetHashCode();

            //apply
            switch (structureType)
            {
            case STSdb4.Database.StructureType.XTABLE: Apply = new XTableApply(this); break;

            case STSdb4.Database.StructureType.XFILE: Apply = new XStreamApply(this); break;
            }

            KeyDataType    = keyDataType;
            RecordDataType = recordDataType;

            KeyType    = keyType;
            RecordType = recordType;

            CreateTime   = DateTime.Now;
            ModifiedTime = CreateTime;
            AccessTime   = CreateTime;

            OperationCollectionFactory = new OperationCollectionFactory(this);
            DataContainerFactory       = new DataContainerFactory(this);
        }