} // enum public Backpack(StorageBag storageLevel, ColorType color, int serialNumber, string name, string uriImg, double price, int currentAmout, int starterAmount) : base(serialNumber, name, uriImg, price, currentAmout, starterAmount) { StorageLevel = storageLevel; Color = color; ObjType = AbstractItemId.Backpack; } // ctor
private void Sync() { IEnumerable <IStorageSecurityItem> storageSecurityItems = _securityStorage.GetItems <IStorageSecurityItem>(); IEnumerable <IStorageSecurityItemRelation> storageSecurityItemRelations = _securityStorage.GetItems <IStorageSecurityItemRelation>(); IEnumerable <IStorageSecurityIdentity> storageSecurityIdentities = _securityStorage.GetItems <IStorageSecurityIdentity>(); IEnumerable <IStorageSecurityIdentityRelation> storageSecurityIdentityRelations = _securityStorage.GetItems <IStorageSecurityIdentityRelation>(); IEnumerable <IStorageAccessAuthorization> storageAccessAuthorizations = _securityStorage.GetItems <IStorageAccessAuthorization>(); IEnumerable <IStorageConditionAuthorization> storageConditionAuthorizations = _securityStorage.GetItems <IStorageConditionAuthorization>(); IEnumerable <IStorageBag> storageBags = _securityStorage.GetItems <IStorageBag>(); _ignoreEvents = true; Suspend(); try { Dictionary <string, ISecurityItem> securityItems = SyncSecurityItems(storageSecurityItems); SyncSecurityItemRelations(storageSecurityItemRelations, securityItems); Dictionary <string, ISecurityIdentity> securityIdentities = SyncSecurityIdentity(storageSecurityIdentities); SyncSecurityIdentityRelations(storageSecurityIdentityRelations, securityIdentities); Dictionary <string, IAuthorization> accessAuthorizations = SyncAccessAuthorizations(storageAccessAuthorizations, securityItems, securityIdentities); Dictionary <string, IAuthorization> conditionAuthorizations = SyncConditionAuthorizations(storageConditionAuthorizations, securityItems, securityIdentities); HashSet <IStorageBag> bags = new HashSet <IStorageBag>(storageBags, new StorageBagComparer()); foreach (IStorageBag storageBag in bags) { if (securityItems.TryGetValue(storageBag.TargetId, out ISecurityItem securityItem)) { securityItem.Bag[storageBag.Key] = storageBag.Value; } if (securityIdentities.TryGetValue(storageBag.TargetId, out ISecurityIdentity securityIdentity)) { securityIdentity.Bag[storageBag.Key] = storageBag.Value; } if (accessAuthorizations.TryGetValue(storageBag.TargetId, out IAuthorization accessAuthorization)) { accessAuthorization.Bag[storageBag.Key] = storageBag.Value; } if (conditionAuthorizations.TryGetValue(storageBag.TargetId, out IAuthorization conditionAuthorization)) { conditionAuthorization.Bag[storageBag.Key] = storageBag.Value; } } HashSet <IStorageBag> newBags = new HashSet <IStorageBag>(new StorageBagComparer()); foreach (IBagObject bagObject in _store.SecurityItems.Cast <IBagObject>().Concat(_store.Authorizations).Concat(_store.SecurityIdentities)) { foreach (string bagKey in bagObject.Bag.Keys) { StorageBag storageBag = new StorageBag(bagObject.Id, bagKey, bagObject.Bag[bagKey]); if (!bags.Contains(storageBag)) { newBags.Add(storageBag); } } } if (newBags.Count > 0) { AddNewAction(StorageActionType.Add, newBags); } } finally { _ignoreEvents = false; Resume(); } }