상속: MonoBehaviour
예제 #1
0
        /// <summary>
        /// Saves a collection of <see cref="IShipRateTier"/>
        /// </summary>
        /// <param name="shipRateTierList">The collection of <see cref="IShipRateTier"/> to save</param>
        /// <param name="raiseEvents">Optional boolean indicating whether or not to raise events.</param>
        public void Save(IEnumerable <IShipRateTier> shipRateTierList, bool raiseEvents = true)
        {
            var shipRateTiersArray = shipRateTierList as IShipRateTier[] ?? shipRateTierList.ToArray();

            if (raiseEvents)
            {
                Saving.RaiseEvent(new SaveEventArgs <IShipRateTier>(shipRateTiersArray), this);
            }

            using (new WriteLock(Locker))
            {
                var uow = UowProvider.GetUnitOfWork();
                using (var repository = RepositoryFactory.CreateShipRateTierRepository(uow))
                {
                    foreach (var shipRateTier in shipRateTiersArray)
                    {
                        repository.AddOrUpdate(shipRateTier);
                    }
                    uow.Commit();
                }
            }

            if (raiseEvents)
            {
                Saved.RaiseEvent(new SaveEventArgs <IShipRateTier>(shipRateTiersArray), this);
            }
        }
예제 #2
0
        /// <summary>
        /// Saves a single <see cref="IShipMethod"/>
        /// </summary>
        /// <param name="shipMethod">The <see cref="IShipMethod"/> to save</param>
        /// <param name="raiseEvents">Optional boolean indicating whether or not to raise events.</param>
        public void Save(IShipMethod shipMethod, bool raiseEvents = true)
        {
            if (raiseEvents)
            {
                if (Saving.IsRaisedEventCancelled(new SaveEventArgs <IShipMethod>(shipMethod), this))
                {
                    ((ShipMethod)shipMethod).WasCancelled = true;
                    return;
                }
            }

            using (new WriteLock(Locker))
            {
                var uow = _uowProvider.GetUnitOfWork();
                using (var repository = _repositoryFactory.CreateShipMethodRepository(uow))
                {
                    repository.AddOrUpdate(shipMethod);
                    uow.Commit();
                }
            }

            if (raiseEvents)
            {
                Saved.RaiseEvent(new SaveEventArgs <IShipMethod>(shipMethod), this);
            }
        }
예제 #3
0
        /// <summary>
        /// Saves a collection of <see cref="INotificationMessage"/>s
        /// </summary>
        /// <param name="notificationMessages">The collection of <see cref="INotificationMessage"/>s to be saved</param>
        /// <param name="raiseEvents">Optional boolean indicating whether or not to raise events</param>
        public void Save(IEnumerable <INotificationMessage> notificationMessages, bool raiseEvents = true)
        {
            var notificationMessagesArray = notificationMessages as INotificationMessage[] ?? notificationMessages.ToArray();

            if (raiseEvents)
            {
                Saving.RaiseEvent(new SaveEventArgs <INotificationMessage>(notificationMessagesArray), this);
            }

            using (new WriteLock(Locker))
            {
                var uow = UowProvider.GetUnitOfWork();
                using (var repository = RepositoryFactory.CreateNotificationMessageRepository(uow))
                {
                    foreach (var notificationMessage in notificationMessagesArray)
                    {
                        repository.AddOrUpdate(notificationMessage);
                    }
                    uow.Commit();
                }
            }

            if (raiseEvents)
            {
                Saved.RaiseEvent(new SaveEventArgs <INotificationMessage>(notificationMessagesArray), this);
            }
        }
        public Attempt <IUserContent> Save(IUserContent content)
        {
            if (Saving.IsRaisedEventCancelled(new SaveEventArgs <TUserContent>((TUserContent)content), this))
            {
                return(Attempt.Fail <IUserContent>(content, new Exception("blocked by delegated event")));
            }

            if (content.ParentKey == null)
            {
                content.ParentKey = Guid.Empty;
            }

            content.UpdatedDate = DateTime.Now;

            if (content.Key != null && content.Key != Guid.Empty)
            {
                var existing = _userRepo.Get(content.Key);
                if (existing != null)
                {
                    var updatedItem = _userRepo.Update(content);
                    return(Attempt.Succeed <IUserContent>(updatedItem));
                }
            }

            content.Key         = Guid.NewGuid();
            content.CreatedDate = DateTime.Now;

            var obj = _userRepo.Create(content);

            _cacheRefresher.RefreshAll();

            Saved.RaiseEvent(new SaveEventArgs <TUserContent>((TUserContent)obj), this);
            return(Attempt.Succeed <IUserContent>(obj));
        }
예제 #5
0
 public bool Save()
 {
     if (item.Name == null || item.Name.Length == 0)
     {
         MessageBox.Show("Unable to save without a name");
         return(false);
     }
     try
     {
         bool saved = item.Save(false);
         if (!saved && MessageBox.Show("File exists! Overwrite?", "File exists", MessageBoxButtons.YesNo) == DialogResult.Yes)
         {
             saved = item.Save(true);
         }
         if (saved)
         {
             UnsavedChanges = 0;
             Saved?.Invoke(this, item.Name + " " + ConfigManager.SourceSeperator + " " + item.Source);
         }
         return(saved);
     } catch (Exception e)
     {
         MessageBox.Show(e.Message);
         return(false);
     }
 }
        /// <summary>
        /// Saves a collection of <see cref="IAppliedPayment"/>
        /// </summary>
        /// <param name="appliedPayments">The collection of <see cref="IAppliedPayment"/>s to be saved</param>
        /// <param name="raiseEvents">Optional boolean indicating whether or not to raise events</param>
        public void Save(IEnumerable <IAppliedPayment> appliedPayments, bool raiseEvents = true)
        {
            var paymentsArray = appliedPayments as IAppliedPayment[] ?? appliedPayments.ToArray();

            if (raiseEvents)
            {
                Saving.RaiseEvent(new SaveEventArgs <IAppliedPayment>(paymentsArray), this);
            }

            using (new WriteLock(Locker))
            {
                var uow = UowProvider.GetUnitOfWork();
                using (var repository = RepositoryFactory.CreateAppliedPaymentRepository(uow))
                {
                    foreach (var appliedPayment in paymentsArray)
                    {
                        repository.AddOrUpdate(appliedPayment);
                    }

                    uow.Commit();
                }
            }

            if (raiseEvents)
            {
                Saved.RaiseEvent(new SaveEventArgs <IAppliedPayment>(paymentsArray), this);
            }
        }
예제 #7
0
        /// <summary>
        /// Saves a collection of <see cref="IWarehouse"/> objects.
        /// </summary>
        /// <param name="warehouseList">Collection of <see cref="Warehouse"/> to save</param>
        /// <param name="raiseEvents">Optional boolean indicating whether or not to raise events</param>
        public void Save(IEnumerable <IWarehouse> warehouseList, bool raiseEvents = true)
        {
            var warehouseArray = warehouseList as IWarehouse[] ?? warehouseList.ToArray();

            if (raiseEvents)
            {
                Saving.RaiseEvent(new SaveEventArgs <IWarehouse>(warehouseArray), this);
            }

            using (new WriteLock(Locker))
            {
                var uow = _uowProvider.GetUnitOfWork();
                using (var repository = _repositoryFactory.CreateWarehouseRepository(uow))
                {
                    foreach (var warehouse in warehouseArray)
                    {
                        repository.AddOrUpdate(warehouse);
                    }
                    uow.Commit();
                }
            }

            if (raiseEvents)
            {
                Saved.RaiseEvent(new SaveEventArgs <IWarehouse>(warehouseArray), this);
            }
        }
        /// <summary>
        /// Saves a single instance of a <see cref="IProductVariant"/>
        /// </summary>
        /// <param name="productVariant"></param>
        /// <param name="raiseEvents">Optional boolean indicating whether or not to raise events</param>
        public void Save(IProductVariant productVariant, bool raiseEvents = true)
        {
            if (raiseEvents)
            {
                if (Saving.IsRaisedEventCancelled(new SaveEventArgs <IProductVariant>(productVariant), this))
                {
                    ((ProductVariant)productVariant).WasCancelled = true;
                    return;
                }
            }

            using (new WriteLock(Locker))
            {
                var uow = _uowProvider.GetUnitOfWork();
                using (var repository = _repositoryFactory.CreateProductVariantRepository(uow))
                {
                    repository.AddOrUpdate(productVariant);
                    uow.Commit();
                }
            }

            if (raiseEvents)
            {
                Saved.RaiseEvent(new SaveEventArgs <IProductVariant>(productVariant), this);
            }
        }
예제 #9
0
        /// <summary>
        /// Saves a collection of entity collections.
        /// </summary>
        /// <param name="entityCollections">
        /// The entity collections.
        /// </param>
        /// <param name="raiseEvents">
        /// Optional boolean indicating whether or not to raise events
        /// </param>
        public void Save(IEnumerable <IEntityCollection> entityCollections, bool raiseEvents = true)
        {
            var collectionsArray = entityCollections as IEntityCollection[] ?? entityCollections.ToArray();

            if (raiseEvents)
            {
                Saving.RaiseEvent(new SaveEventArgs <IEntityCollection>(collectionsArray), this);
            }

            using (new WriteLock(Locker))
            {
                var uow = _uowProvider.GetUnitOfWork();
                using (var repository = _repositoryFactory.CreateEntityCollectionRepository(uow))
                {
                    foreach (var collection in collectionsArray)
                    {
                        repository.AddOrUpdate(collection);
                    }

                    uow.Commit();
                }
            }

            if (raiseEvents)
            {
                Saved.RaiseEvent(new SaveEventArgs <IEntityCollection>(collectionsArray), this);
            }
        }
예제 #10
0
        /// <summary>
        /// Deletes a single entity collection.
        /// </summary>
        /// <param name="entityCollection">
        /// The entity collection.
        /// </param>
        /// <param name="raiseEvents">
        /// Optional boolean indicating whether or not to raise events.
        /// </param>
        public void Delete(IEntityCollection entityCollection, bool raiseEvents = true)
        {
            if (raiseEvents)
            {
                if (Deleting.IsRaisedEventCancelled(new DeleteEventArgs <IEntityCollection>(entityCollection), this))
                {
                    ((EntityCollection)entityCollection).WasCancelled = true;
                    return;
                }
            }

            DeleteAllChildCollections(entityCollection);

            UpdateSiblingSortOrders(entityCollection);

            using (new WriteLock(Locker))
            {
                var uow = _uowProvider.GetUnitOfWork();
                using (var repository = _repositoryFactory.CreateEntityCollectionRepository(uow))
                {
                    repository.Delete(entityCollection);
                    uow.Commit();
                }
            }

            if (raiseEvents)
            {
                Saved.RaiseEvent(new SaveEventArgs <IEntityCollection>(entityCollection), this);
            }
        }
예제 #11
0
        /// <summary>
        /// Saves a collection of <see cref="IItemCache"/> objects.
        /// </summary>
        /// <param name="itemCaches">Collection of <see cref="ItemCache"/> to save</param>
        /// <param name="raiseEvents">Optional boolean indicating whether or not to raise events</param>
        public void Save(IEnumerable <IItemCache> itemCaches, bool raiseEvents = true)
        {
            var basketArray = itemCaches as IItemCache[] ?? itemCaches.ToArray();

            if (raiseEvents)
            {
                Saving.RaiseEvent(new SaveEventArgs <IItemCache>(basketArray), this);
            }

            using (new WriteLock(Locker))
            {
                var uow = _uowProvider.GetUnitOfWork();
                using (var repository = _repositoryFactory.CreateItemCacheRepository(uow))
                {
                    foreach (var basket in basketArray)
                    {
                        repository.AddOrUpdate(basket);
                    }

                    uow.Commit();
                }
            }

            if (raiseEvents)
            {
                Saved.RaiseEvent(new SaveEventArgs <IItemCache>(basketArray), this);
            }
        }
예제 #12
0
        /// <summary>
        /// Saves a collection of <see cref="IProduct"/> objects.
        /// </summary>
        /// <param name="productList">Collection of <see cref="ProductVariant"/> to save</param>
        /// <param name="raiseEvents">Optional boolean indicating whether or not to raise events</param>
        public void Save(IEnumerable <IProduct> productList, bool raiseEvents = true)
        {
            var productArray = productList as IProduct[] ?? productList.ToArray();

            if (raiseEvents)
            {
                Saving.RaiseEvent(new SaveEventArgs <IProduct>(productArray), this);
            }

            using (new WriteLock(Locker))
            {
                var uow = _uowProvider.GetUnitOfWork();
                using (var repository = _repositoryFactory.CreateProductRepository(uow))
                {
                    foreach (var product in productArray)
                    {
                        repository.AddOrUpdate(product);
                    }

                    uow.Commit();
                }

                // Synchronize the products array
                EnsureVariants(productArray);
            }

            if (raiseEvents)
            {
                Saved.RaiseEvent(new SaveEventArgs <IProduct>(productArray), this);
            }

            // verify that all variants of these products still have attributes - or delete them
            _productVariantService.EnsureProductVariantsHaveAttributes(productArray);
        }
예제 #13
0
        /// <summary>
        /// Saves a collection of <see cref="IDigitalMedia"/>.
        /// </summary>
        /// <param name="digitalMedias">
        /// The digital medias.
        /// </param>
        /// <param name="raiseEvents">
        /// Optional boolean indicating whether or not to raise events.
        /// </param>
        public void Save(IEnumerable <IDigitalMedia> digitalMedias, bool raiseEvents = true)
        {
            var digitalMediaArray = digitalMedias as IDigitalMedia[] ?? digitalMedias.ToArray();

            if (raiseEvents)
            {
                Saving.RaiseEvent(new SaveEventArgs <IDigitalMedia>(digitalMediaArray), this);
            }

            using (new WriteLock(Locker))
            {
                var uow = UowProvider.GetUnitOfWork();

                using (var repository = RepositoryFactory.CreateDigitalMediaRepository(uow))
                {
                    foreach (var digitalMedia in digitalMediaArray)
                    {
                        repository.AddOrUpdate(digitalMedia);
                    }

                    uow.Commit();
                }
            }

            if (raiseEvents)
            {
                Saved.RaiseEvent(new SaveEventArgs <IDigitalMedia>(digitalMediaArray), this);
            }
        }
예제 #14
0
        /// <summary>
        /// Saves a collection of <see cref="ICustomerAddress"/>
        /// </summary>
        /// <param name="addresses">
        /// The addresses.
        /// </param>
        /// <param name="raiseEvents">
        /// The raise events.
        /// </param>
        /// <remarks>
        /// TODO - come up with a validation strategy on batch saves that protects default address settings
        /// </remarks>
        public void Save(IEnumerable <ICustomerAddress> addresses, bool raiseEvents = true)
        {
            var addressArray = addresses as ICustomerAddress[] ?? addresses.ToArray();

            if (raiseEvents)
            {
                Saving.RaiseEvent(new SaveEventArgs <ICustomerAddress>(addressArray), this);
            }

            using (new WriteLock(Locker))
            {
                var uow = _uowProvider.GetUnitOfWork();
                using (var repository = _repositoryFactory.CreateCustomerAddressRepository(uow))
                {
                    foreach (var address in addressArray)
                    {
                        repository.AddOrUpdate(address);
                    }

                    uow.Commit();
                }
            }

            if (raiseEvents)
            {
                Saved.RaiseEvent(new SaveEventArgs <ICustomerAddress>(addressArray), this);
            }
        }
예제 #15
0
        private async Task CoreHandler()
        {
            var canEnter = await once.WaitAsync(BindSettings.DelayTime);

            if (canEnter && Interlocked.CompareExchange(ref notify, 0, 1) == 1)
            {
                try
                {
                    var infos = ChangeWatcher.ChangeInfos;
                    ChangeWatcher.Clear();
                    var repo  = ChangeReport.FromChanges(GetConfiguration(), infos);
                    var saver = new ChangeSaver(repo, BindSettings.Conditions);
                    saver.EmitAndSave();
                    OnConfigChanged(infos);
                    Saved?.Invoke(this, infos);
                }
                catch (Exception ex)
                {
                    SaveException?.Invoke(this, ex);
                }
                finally
                {
                    Interlocked.Exchange(ref notify, 1);
                }
            }
        }
예제 #16
0
        /// <summary>
        /// Saves a collection of <see cref="IOfferRedeemed"/>
        /// </summary>
        /// <param name="redemptions">
        /// The redemptions.
        /// </param>
        /// <param name="raiseEvents">
        /// Optional boolean indicating whether or not to raise events
        /// </param>
        public void Save(IEnumerable <IOfferRedeemed> redemptions, bool raiseEvents = true)
        {
            var redemptionsArray = redemptions as IOfferRedeemed[] ?? redemptions.ToArray();

            if (raiseEvents)
            {
                Saving.RaiseEvent(new SaveEventArgs <IOfferRedeemed>(redemptionsArray), this);
            }

            using (new WriteLock(Locker))
            {
                var uow = _uowProvider.GetUnitOfWork();
                using (var repository = _repositoryFactory.CreateOfferRedeemedRepository(uow))
                {
                    foreach (var redemption in redemptionsArray)
                    {
                        repository.AddOrUpdate(redemption);
                    }

                    uow.Commit();
                }
            }

            if (raiseEvents)
            {
                Saved.RaiseEvent(new SaveEventArgs <IOfferRedeemed>(redemptionsArray), this);
            }
        }
예제 #17
0
        /// <summary>
        /// Saves a single <see cref="IProduct"/> object
        /// </summary>
        /// <param name="product">The <see cref="IProductVariant"/> to save</param>
        /// <param name="raiseEvents">Optional boolean indicating whether or not to raise events.</param>
        public void Save(IProduct product, bool raiseEvents = true)
        {
            if (raiseEvents)
            {
                if (Saving.IsRaisedEventCancelled(new SaveEventArgs <IProduct>(product), this))
                {
                    ((Product)product).WasCancelled = true;
                    return;
                }
            }

            using (new WriteLock(Locker))
            {
                var uow = _uowProvider.GetUnitOfWork();
                using (var repository = _repositoryFactory.CreateProductRepository(uow))
                {
                    repository.AddOrUpdate(product);
                    uow.Commit();
                }
            }

            if (raiseEvents)
            {
                Saved.RaiseEvent(new SaveEventArgs <IProduct>(product), this);
            }

            // verify that all variants of this product still have attributes - or delete them
            _productVariantService.EnsureProductVariantsHaveAttributes(product);

            // save any remaining variants changes in the variants collection
            if (product.ProductVariants.Any())
            {
                _productVariantService.Save(product.ProductVariants);
            }
        }
        /// <summary>
        /// Saves a collection of <see cref="IProductVariant"/>
        /// </summary>
        /// <param name="productVariantList">The collection of <see cref="IProductVariant"/> to be saved</param>
        /// <param name="raiseEvents">Optional boolean indicating whether or not to raise events</param>
        public void Save(IEnumerable <IProductVariant> productVariantList, bool raiseEvents = true)
        {
            var productVariants = productVariantList as IProductVariant[] ?? productVariantList.ToArray();

            if (raiseEvents)
            {
                Saving.RaiseEvent(new SaveEventArgs <IProductVariant>(productVariants), this);
            }

            using (new WriteLock(Locker))
            {
                var uow = _uowProvider.GetUnitOfWork();
                using (var repository = _repositoryFactory.CreateProductVariantRepository(uow))
                {
                    foreach (var variant in productVariants)
                    {
                        repository.AddOrUpdate(variant);
                    }
                    uow.Commit();
                }
            }

            if (raiseEvents)
            {
                Saved.RaiseEvent(new SaveEventArgs <IProductVariant>(productVariants), this);
            }
        }
        /// <summary>
        /// Saves a single <see cref="IWarehouseCatalog"/>.
        /// </summary>
        /// <param name="warehouseCatalog">
        /// The warehouse catalog.
        /// </param>
        /// <param name="raiseEvents">Optional boolean indicating whether or not to raise events</param>
        public void Save(IWarehouseCatalog warehouseCatalog, bool raiseEvents = true)
        {
            if (raiseEvents)
            {
                if (Saving.IsRaisedEventCancelled(new SaveEventArgs <IWarehouseCatalog>(warehouseCatalog), this))
                {
                    ((WarehouseCatalog)warehouseCatalog).WasCancelled = true;
                    return;
                }
            }

            using (new WriteLock(Locker))
            {
                var uow = _uowProvider.GetUnitOfWork();
                using (var repository = _repositoryFactory.CreateWarehouseCatalogRepository(uow))
                {
                    repository.AddOrUpdate(warehouseCatalog);
                    uow.Commit();
                }
            }

            if (raiseEvents)
            {
                Saved.RaiseEvent(new SaveEventArgs <IWarehouseCatalog>(warehouseCatalog), this);
            }
        }
        /// <summary>
        /// Saves an <see cref="IAppliedPayment"/>
        /// </summary>
        /// <param name="appliedPayment">The <see cref="IAppliedPayment"/> to be saved</param>
        /// <param name="raiseEvents">Optional boolean indicating whether or not to raise events</param>
        public void Save(IAppliedPayment appliedPayment, bool raiseEvents = true)
        {
            if (raiseEvents)
            {
                if (Saving.IsRaisedEventCancelled(new SaveEventArgs <IAppliedPayment>(appliedPayment), this))
                {
                    ((AppliedPayment)appliedPayment).WasCancelled = true;
                    return;
                }
            }

            using (new WriteLock(Locker))
            {
                var uow = UowProvider.GetUnitOfWork();
                using (var repository = RepositoryFactory.CreateAppliedPaymentRepository(uow))
                {
                    repository.AddOrUpdate(appliedPayment);
                    uow.Commit();
                }
            }

            if (raiseEvents)
            {
                Saved.RaiseEvent(new SaveEventArgs <IAppliedPayment>(appliedPayment), this);
            }
        }
        /// <summary>
        /// Saves a collection of <see cref="IWarehouseCatalog"/>.
        /// </summary>
        /// <param name="warehouseCatalogs">
        /// The warehouse catalogs.
        /// </param>
        /// <param name="raiseEvents">Optional boolean indicating whether or not to raise events</param>
        public void Save(IEnumerable <IWarehouseCatalog> warehouseCatalogs, bool raiseEvents = true)
        {
            var catalogsArray = warehouseCatalogs as IWarehouseCatalog[] ?? warehouseCatalogs.ToArray();

            if (raiseEvents)
            {
                Saving.RaiseEvent(new SaveEventArgs <IWarehouseCatalog>(catalogsArray), this);
            }

            using (new WriteLock(Locker))
            {
                var uow = _uowProvider.GetUnitOfWork();
                using (var repository = _repositoryFactory.CreateWarehouseCatalogRepository(uow))
                {
                    foreach (var catalog in catalogsArray)
                    {
                        repository.AddOrUpdate(catalog);
                    }

                    uow.Commit();
                }
            }

            if (raiseEvents)
            {
                Saved.RaiseEvent(new SaveEventArgs <IWarehouseCatalog>(catalogsArray), this);
            }
        }
예제 #22
0
        /// <summary>
        /// Saves a single instance of <see cref="INotificationMessage"/>
        /// </summary>
        /// <param name="notificationMessage">The <see cref="INotificationMessage"/> to be saved</param>
        /// <param name="raiseEvents">Optional boolean indicating whether or not to raise events</param>
        public void Save(INotificationMessage notificationMessage, bool raiseEvents = true)
        {
            if (raiseEvents)
            {
                if (Saving.IsRaisedEventCancelled(new SaveEventArgs <INotificationMessage>(notificationMessage), this))
                {
                    ((NotificationMessage)notificationMessage).WasCancelled = true;
                    return;
                }
            }

            using (new WriteLock(Locker))
            {
                var uow = UowProvider.GetUnitOfWork();
                using (var repository = RepositoryFactory.CreateNotificationMessageRepository(uow))
                {
                    repository.AddOrUpdate(notificationMessage);

                    uow.Commit();
                }
            }

            if (raiseEvents)
            {
                Saved.RaiseEvent(new SaveEventArgs <INotificationMessage>(notificationMessage), this);
            }
        }
예제 #23
0
        /// <summary>
        /// Saves the properties to the registry asyncronously.
        /// </summary>
        public virtual async Task SaveAsync()
        {
            ShellSettingsManager manager = await _settingsManager.GetValueAsync();

            WritableSettingsStore settingsStore = manager.GetWritableSettingsStore(SettingsScope.UserSettings);

            if (!settingsStore.CollectionExists(CollectionName))
            {
                settingsStore.CreateCollection(CollectionName);
            }

            foreach (PropertyInfo property in GetOptionProperties())
            {
                string output = SerializeValue(property.GetValue(this));
                settingsStore.SetString(CollectionName, property.Name, output);
            }

            T liveModel = await GetLiveInstanceAsync();

            if (this != liveModel)
            {
                await liveModel.LoadAsync();
            }

            Saved?.Invoke(this, liveModel);
        }
예제 #24
0
    public static void SetTutorial(int type, ObscuredBool isDone)
    {
        switch (type)
        {
        case 1:
            mStartTut = isDone;
            Saved.SetBool(SaveKey.StartTutorial, mStartTut);
            break;

        case 2:
            mGameTut = isDone;
            Saved.SetBool(SaveKey.GameTutorial, mGameTut);
            break;

        case 3:
            mFeverTut = isDone;
            Saved.SetBool(SaveKey.FeverTutorial, mFeverTut);
            break;

        case 4:
            mMissionTut = isDone;
            Saved.SetBool(SaveKey.MissionTutorial, mMissionTut);
            break;
        }
    }
예제 #25
0
 internal async Task OnSaved(ReplicateDataMessage message, IEntity entity, SaveMode mode)
 {
     if (Saved != null)
     {
         await Saved.Raise(new ReplicationSaveMessageProcessedEventArgs(message, entity, mode));
     }
 }
예제 #26
0
        /// <summary>
        /// Saves a collection of <see cref="ICustomer"/> objects.
        /// </summary>
        /// <param name="customers">Collection of <see cref="ICustomer"/> to save</param>
        /// <param name="raiseEvents">Optional boolean indicating whether or not to raise events</param>
        internal void Save(IEnumerable <ICustomer> customers, bool raiseEvents = true)
        {
            var customerArray = customers as ICustomer[] ?? customers.ToArray();

            if (raiseEvents)
            {
                Saving.RaiseEvent(new SaveEventArgs <ICustomer>(customerArray), this);
            }

            using (new WriteLock(Locker))
            {
                var uow = _uowProvider.GetUnitOfWork();
                using (var repository = _repositoryFactory.CreateCustomerRepository(uow))
                {
                    foreach (var customer in customerArray)
                    {
                        repository.AddOrUpdate(customer);
                    }
                    uow.Commit();
                }
            }

            if (raiseEvents)
            {
                Saved.RaiseEvent(new SaveEventArgs <ICustomer>(customerArray), this);
            }
        }
예제 #27
0
 public bool UpdateObject(N2.Edit.Workflow.CommandContext value)
 {
     try
     {
         BinderContext = value;
         EnsureChildControls();
         if (ZoneName != null && ZoneName != value.Content.ZoneName)
         {
             value.Content.ZoneName = ZoneName;
         }
         foreach (string key in AddedEditors.Keys)
         {
             BinderContext.GetDefinedDetails().Add(key);
         }
         var modifiedDetails = EditAdapter.UpdateItem(value.Definition, value.Content, AddedEditors, Page.User);
         if (modifiedDetails.Length == 0)
         {
             return(false);
         }
         foreach (string detailName in modifiedDetails)
         {
             BinderContext.GetUpdatedDetails().Add(detailName);
         }
         BinderContext.RegisterItemToSave(value.Content);
         if (Saved != null)
         {
             Saved.Invoke(this, new ItemEventArgs(value.Content));
         }
         return(true);
     }
     finally
     {
         BinderContext = null;
     }
 }
예제 #28
0
        /// <summary>
        /// Saves the <see cref="IAnonymousCustomer"/>
        /// </summary>
        /// <param name="anonymous">
        /// The anonymous customer
        /// </param>
        /// <param name="raiseEvents">
        /// TOptional boolean indicating whether or not to raise events
        /// </param>
        public void Save(IAnonymousCustomer anonymous, bool raiseEvents = true)
        {
            if (raiseEvents)
            {
                if (Saving.IsRaisedEventCancelled(new SaveEventArgs <IAnonymousCustomer>(anonymous), this))
                {
                    return;
                }
            }

            using (new WriteLock(Locker))
            {
                var uow = _uowProvider.GetUnitOfWork();
                using (var repository = _repositoryFactory.CreateAnonymousCustomerRepository(uow))
                {
                    repository.AddOrUpdate(anonymous);
                    uow.Commit();
                }
            }

            if (raiseEvents)
            {
                Saved.RaiseEvent(new SaveEventArgs <IAnonymousCustomer>(anonymous), this);
            }
        }
예제 #29
0
        /// <summary>
        /// Saves a single <see cref="IMedia"/> object
        /// </summary>
        /// <param name="media">The <see cref="IMedia"/> to save</param>
        /// <param name="userId">Id of the User saving the Content</param>
        /// <param name="raiseEvents">Optional boolean indicating whether or not to raise events.</param>
        public void Save(IMedia media, int userId = 0, bool raiseEvents = true)
        {
            if (raiseEvents)
            {
                if (Saving.IsRaisedEventCancelled(new SaveEventArgs <IMedia>(media), this))
                {
                    return;
                }
            }

            using (new WriteLock(Locker))
            {
                var uow = _uowProvider.GetUnitOfWork();
                using (var repository = _repositoryFactory.CreateMediaRepository(uow))
                {
                    media.CreatorId = userId;
                    repository.AddOrUpdate(media);
                    uow.Commit();

                    var xml = media.ToXml();
                    CreateAndSaveMediaXml(xml, media.Id, uow.Database);
                }
            }

            if (raiseEvents)
            {
                Saved.RaiseEvent(new SaveEventArgs <IMedia>(media, false), this);
            }

            Audit.Add(AuditTypes.Save, "Save Media performed by user", userId, media.Id);
        }
예제 #30
0
        /// <summary>
        /// Saves a single <see cref="ICustomerAddress"/>
        /// </summary>
        /// <param name="address">
        /// The address.
        /// </param>
        /// <param name="raiseEvents">
        /// Optional boolean indicating whether or not to raise events
        /// </param>
        public void Save(ICustomerAddress address, bool raiseEvents = true)
        {
            if (raiseEvents)
            {
                if (Saving.IsRaisedEventCancelled(new SaveEventArgs <ICustomerAddress>(address), this))
                {
                    ((CustomerAddress)address).WasCancelled = true;
                    return;
                }
            }

            var count = GetCustomerAddressCount(address.CustomerKey, address.AddressType);

            if (count == 0 || address.IsDefault)
            {
                ClearDefaultCustomerAddress(address.CustomerKey, address.AddressType);
                address.IsDefault = true;
            }


            using (new WriteLock(Locker))
            {
                var uow = _uowProvider.GetUnitOfWork();
                using (var repository = _repositoryFactory.CreateCustomerAddressRepository(uow))
                {
                    repository.AddOrUpdate(address);
                    uow.Commit();
                }
            }

            if (raiseEvents)
            {
                Saved.RaiseEvent(new SaveEventArgs <ICustomerAddress>(address), this);
            }
        }
예제 #31
0
    //Set stage for game, creating characters and the simple GUI implemented.
    public void Start()
    {
        instance = this;
        //construct our 2d array based on the value set in the editor
        distances = new float[numberOfvillagers, numberOfvillagers];

        //reference to Vehicle script component for each flocker
        //Flocking flocker; // reference to flocker scripts
        Villager villager;
        Werewolf werewolf;
        Follow follower;

        obstacles = GameObject.FindGameObjectsWithTag ("Obstacle");

        mayor = GameObject.FindGameObjectWithTag ("Mayor");

        for (int i = 0; i < numberOfvillagers; i++) {
            //Instantiate a flocker prefab, catch the reference, cast it to a GameObject
            //and add it to our list all in one line.
            villagers.Add ((GameObject)Instantiate (villagerPrefab,
                new Vector3 (600 + 5 * i, 5, 400), Quaternion.identity));
            //grab a component reference
            villager = villagers [i].GetComponent<Villager> ();
            // HOW ABOUT NO //villagers[i].GetComponent<MeshRenderer>().material.SetColor("_Color", Color.green);
            //set values in the Vehicle script
            villager.Index = i;

            VillageFollowers.Add((GameObject)Instantiate(followerPrefab,
                new Vector3(600 + 5 * i, 150,400), Quaternion.identity));

            //Create a follower for the minimap
            follower = VillageFollowers[i].GetComponent<Follow> ();
            follower.ToFollow = villagers[i];
            //VillageFollowers[i].GetComponent<MeshRenderer>().material.SetColor("_Color", Color.green);
            villager.Follower = follower;

        }

        for (int i=0; i < numberOfWerewolves; i++)
        {
            if(i == 0)
            {
                werewolves.Add( (GameObject)Instantiate(werewolfPrefab,
                new Vector3(491, 35, 931), Quaternion.identity));
            }
            else if(i == 1)
            {
                werewolves.Add( (GameObject)Instantiate(werewolfPrefab,
                new Vector3(930, 35, 441), Quaternion.identity));
            }
            else if(i == 2)
            {
                werewolves.Add( (GameObject)Instantiate(werewolfPrefab,
                new Vector3(385, 35, 50), Quaternion.identity));
            }
            else if(i == 3)
            {
                werewolves.Add( (GameObject)Instantiate(werewolfPrefab,
                new Vector3(89, 35, 489), Quaternion.identity));
            }
            else
            {
                werewolves.Add( (GameObject)Instantiate(werewolfPrefab,
                new Vector3(700 + 5 * i, 5, 600), Quaternion.identity));
            }

            //grab a component reference
            werewolf = werewolves [i].GetComponent<Werewolf>();
            werewolves[i].GetComponent<MeshRenderer>().material.SetColor("_Color",Color.red);
            //set value in the Vehicle script
            werewolf.Index = i;

            WerewolfFollowers.Add((GameObject)Instantiate(followerPrefab,
                new Vector3(600 + 5 * i, 150,400), Quaternion.identity));
            follower = WerewolfFollowers[i].GetComponent<Follow> ();
            follower.ToFollow = werewolves[i];
            WerewolfFollowers[i].GetComponent<MeshRenderer>().material.SetColor("_Color", Color.red);

        }

        //references to GUI texts in Game
        savedText = GameObject.FindGameObjectWithTag("Saved").GetComponent<Saved>();
        deadText = GameObject.FindGameObjectWithTag("Dead").GetComponent<Dead>();
    }