Exemplo n.º 1
0
        internal PObject(IStorage repository, int id, Dictionary<int, IPObject> objectsIndex, bool deferredLoad)
        {
            if (repository == null)
                throw new Exception("Хранилище данных не задано");

            Id = id;
            _ownerCollection = null;

            this.storage = repository;
            this.objectsIndex = objectsIndex;
            this._deferredLoad = deferredLoad;

            // получение значений атрибутов
            _attrs = repository.ListAttributes(Id);

            if (objectsIndex != null)
                objectsIndex.Add(id, this);

            // загрузка коллекций
            _collections = new Dictionary<string, PCollection>();

            List<string> collectsNames = storage.ListCollections(Id);
            foreach (string name in collectsNames)
            {
                string lowName = name.ToLower();
                _collections.Add(lowName, new PCollection(this, lowName, deferredLoad));
            }
        }
Exemplo n.º 2
0
        public IPCollection GetCollection(string name, bool createIfNotFound)
        {
            name = name.ToLower();
            PCollection coll;

            if (this._collections.TryGetValue(name, out coll))
            {
                return coll;
            }
            else if (createIfNotFound)
            {
                coll = new PCollection(this, name, this._deferredLoad);
                _collections.Add(name, coll);
                return coll;
            }
            else
            {
                throw new Exception(string.Format("Коллекция {0} не найдена!", name));
            }
        }