Пример #1
0
        internal static UniqueInstancesCollection <M> FromNew(Identity id, M modl)
        {
            var collection = new UniqueInstancesCollection <M>(id);

            collection.ReadFromInstance(modl);
            collection.AddInstance(modl);

            return(collection);
        }
Пример #2
0
        internal static UniqueInstancesCollection <M> FromStorage(Identity id, IEnumerable <Container> storage)
        {
            var collection = new UniqueInstancesCollection <M>(id);

            collection.Backer.SetValuesFromStorage(storage);
            collection.Backer.ResetValuesToUnmodified();
            collection.Backer.IsNew = false;

            return(collection);
        }
Пример #3
0
        public UniqueInstancesCollection <M> AddNewInstance(Identity id, M modl)
        {
            if (HasCollection(id))
            {
                throw new InvalidIdException($"There is already a collection with id '{id}'");
            }

            var collection = UniqueInstancesCollection <M> .FromNew(id, modl);

            Collections.Add(id, collection);

            return(collection);
        }
Пример #4
0
        public UniqueInstancesCollection <M> AddInstanceFromStorage(Identity id, IEnumerable <Container> storage)
        {
            if (HasCollection(id))
            {
                throw new InvalidIdException($"There is already a collection with id '{id}'");
            }

            var collection = UniqueInstancesCollection <M> .FromStorage(id, storage);

            Collections.Add(id, collection);

            return(collection);
        }