Ejemplo n.º 1
0
        private static TypeEngine Create(Type type)
        {
            TypeEngine descriptor = new TypeEngine();

            descriptor.Persist = new DataPersist(type, null, AllowNull.AllButTop);

            if (DataTypeUtils.IsAllPrimitive(type) || type == typeof(Guid))
            {
                descriptor.Comparer         = new DataComparer(type);
                descriptor.EqualityComparer = new DataEqualityComparer(type);

                if (type != typeof(Guid))
                {
                    descriptor.IndexerPersist = new DataIndexerPersist(type);
                }
            }

            return(descriptor);
        }
Ejemplo n.º 2
0
        private void DoPrepare()
        {
            Debug.Assert(KeyType != null);
            Debug.Assert(RecordType != null);

            //keys
            if (KeyComparer == null || KeyEqualityComparer == null || (KeyPersist == null || KeyIndexerPersist == null))
            {
                if (keyEngine == null)
                {
                    keyEngine = TypeEngine.Default(KeyType);
                }

                if (KeyComparer == null)
                {
                    KeyComparer = keyEngine.Comparer;
                }

                if (KeyEqualityComparer == null)
                {
                    KeyEqualityComparer = keyEngine.EqualityComparer;
                }

                if (KeyPersist == null)
                {
                    KeyPersist = keyEngine.Persist;
                }

                if (KeyIndexerPersist == null)
                {
                    KeyIndexerPersist = keyEngine.IndexerPersist;
                }
            }

            //records
            if (RecordPersist == null || RecordIndexerPersist == null)
            {
                if (recEngine == null)
                {
                    recEngine = TypeEngine.Default(RecordType);
                }

                if (RecordPersist == null)
                {
                    RecordPersist = recEngine.Persist;
                }

                if (RecordIndexerPersist == null)
                {
                    RecordIndexerPersist = recEngine.IndexerPersist;
                }
            }

            //container
            if (OrderedSetPersist == null)
            {
                if (KeyIndexerPersist != null && RecordIndexerPersist != null)
                {
                    OrderedSetPersist = new OrderedSetPersist(KeyIndexerPersist, RecordIndexerPersist, OrderedSetFactory);
                }
                else
                {
                    OrderedSetPersist = new OrderedSetPersist(KeyPersist, RecordPersist, OrderedSetFactory);
                }
            }

            //operations
            if (OperationsPersist == null)
            {
                OperationsPersist = new OperationCollectionPersist(KeyPersist, RecordPersist, OperationCollectionFactory);
            }

            IsReady = true;
        }