public UpdateOpeningDateShuld() { AuctionFactory = new AuctionFactory(); AuctionStrategyFactory = new AuctionStrategyFactory(); _updateOpeningDateStrategy = AuctionStrategyFactory.Make <UpdateOpeningParameter>(StrategyTypeEnum.UpdateOpeningDate); Sut = AuctionFactory.Make(AuctionTypeEnum.Complete); }
private R(Delegate computeFunc, List <ReactiveBase> children) { this.computeFunc = (Func <object[], T>)computeFunc; this.Children = children; updateStrategy = new ImmediateUpdateStrategy <T>(); Configure(); }
public R(T value) { Value = value; OnValueObjectChanged(value); ValueChanged?.Invoke(this, value); updateStrategy = new ImmediateUpdateStrategy <T>(); }
public DecoratorAuctionMilestoneStrategyTest() { _auctionsDecoratorsFactory = new AuctionsMilestonesDecoratorsFactory(); AuctionFactory = new AuctionFactory(); Auction = AuctionFactory.Make(AuctionTypeEnum.Complete); _sut = _auctionsDecoratorsFactory.Make <UpdateOpeningParameter>(DecoratorsEnum.DecoratorAuctionMilestone); _updateOpeningDateStrategy = AuctionStrategyFactory.Make <UpdateOpeningParameter>(StrategyTypeEnum.UpdateOpeningDate); }
public Quest(string name, string description, World world, IQuestCompletedStrategy questCompletedStrategy, IUpdateStrategy updateStrategy) { IsCompleted = false; Name = name; Description = description; _world = world; _questCompletedStrategy = questCompletedStrategy; _updateStrategy = updateStrategy; }
/// <summary> /// Creates a new strategy for updating the specified type. /// </summary> /// <param name="typeName">The short name of the type involved in the strategy.</param> static public IUpdateStrategy New(string typeName) { IUpdateStrategy strategy = null; using (LogGroup logGroup = LogGroup.Start("Creating new update strategy.", NLog.LogLevel.Debug)) { LogWriter.Debug("Type name: " + typeName); strategy = StrategyState.Strategies.Creator.NewUpdater(typeName); } return(strategy); }
public ComplexStore( IFactory <TKey, TItem> keyFactory, Func <TLifetimeManager> lifetimeFactory, IInitialisationStrategy <TItem> initialisation, IUpdateStrategy <TItem> update, IDisposableStrategy <TItem> dispose) : base(keyFactory, lifetimeFactory) { this.initialisation = initialisation; this.update = update; this.dispose = dispose; }
public void SetUpdateStrategy(ItemCategory category) { _strategy = category switch { ItemCategory.General => new GeneralItemStrategy(), ItemCategory.Aged => new AgedItemStrategy(), ItemCategory.Conjured => new ConjuredItemStrategy(), ItemCategory.Pass => new PassItemStrategy(), ItemCategory.Legendary => new LegendaryItemStrategy(), _ => throw new ArgumentOutOfRangeException(nameof(category), category, null) }; }
public void UpdateItems() { //for (var i = 0; i < Items.Count; i++) foreach (Item item in Items) { IUpdateStrategy strat = UpdateStrategyFactory.Create(item); if (strat != null) { strat.Update(item); } } }
/// <summary> /// Creates a new strategy for updating the specified type. /// </summary> /// <param name="typeName">The short name of the type involved in the strategy.</param> /// <param name="requiresAuthorisation">A value indicating whether the strategy requires authorisation.</param> static public IUpdateStrategy New(IEntity entity, bool requiresAuthorisation) { IUpdateStrategy strategy = null; using (LogGroup logGroup = LogGroup.Start("Creating new update strategy.", NLog.LogLevel.Debug)) { LogWriter.Debug("Type name: " + entity.ShortTypeName); strategy = StrategyState.Strategies.Creator.NewUpdater(entity.ShortTypeName); strategy.RequireAuthorisation = requiresAuthorisation; } return(strategy); }
/// <summary> /// Given the provided strategies, manipulate all entities to correct any violations /// of the current policy. If no strategies are provided, the policy's default /// strategies are used. An exception is thrown if the provided strategies are not /// valid for the current policy. /// </summary> /// <param name="Item">The item.</param> /// <param name="Entity">The entity.</param> /// <param name="PreferredUpdateStrategy">The preferred update strategy.</param> /// <param name="PreferredUpdateStrategyForDuplicateDates">The preferred update strategy for duplicate dates.</param> /// <exception cref="System.ArgumentNullException"></exception> /// <exception cref="System.InvalidOperationException"> /// The requested strategy is not available for this policy. /// or /// The requested strategy is not available for this policy. /// </exception> public void PerformUpdate(Item Item, EntityBase Entity, IUpdateStrategy PreferredUpdateStrategy = null, IUpdateStrategy PreferredUpdateStrategyForDuplicateDates = null) { if (Item == null) { throw new ArgumentNullException(nameof(Item)); } if (Entity == null) { throw new ArgumentNullException(nameof(Entity)); } IUpdateStrategy Strategy = Entity.GetUpdateStrategy(); IUpdateStrategy StrategyForDuplicateDates = Entity.GetUpdateStrategyForDuplicateDates(); if (PreferredUpdateStrategy != null) { if (!Entity.GetUpdatePolicy().GetAvailableStrategies().Any(s => s.GetType() == PreferredUpdateStrategy.GetType())) { throw new InvalidOperationException("The requested strategy is not available for this policy."); } Strategy = PreferredUpdateStrategy; } if (PreferredUpdateStrategyForDuplicateDates != null) { if (!Entity.GetUpdatePolicy().GetAvailableStrategies().Any(s => s.GetType() == PreferredUpdateStrategyForDuplicateDates.GetType())) { throw new InvalidOperationException("The requested strategy is not available for this policy."); } StrategyForDuplicateDates = PreferredUpdateStrategyForDuplicateDates; } var AllEntities = Item.AllEntities.ToArray(); for (int i = 0; i < AllEntities.Count(); i++) { var OtherEntity = AllEntities.ElementAt(i); if (OtherEntity.EffectiveDate == Entity.EffectiveDate && OtherEntity.EndEffectiveDate == Entity.EndEffectiveDate) { StrategyForDuplicateDates.PerformUpdate(OtherEntity, Entity); } else { Strategy.PerformUpdate(OtherEntity, Entity); } } }
protected Gist<string, string> CreateGist(IBlockCollection blocks, IUpdateStrategy<string, string> updateStrategy) { return new Gist<string, string>( blocks.MasterBlockReference, new GistConfig<string, string> { Blocks = blocks, Ext = new OrderedGistExtension<string, string>( new GistStringType(), new GistStringType() ), UpdateStrategy = updateStrategy } ); }
protected Gist <string, string> CreateGist(IBlockCollection blocks, IUpdateStrategy <string, string> updateStrategy) { return(new Gist <string, string>( blocks.MasterBlockReference, new GistConfig <string, string> { Blocks = blocks, Ext = new OrderedGistExtension <string, string>( new GistStringType(), new GistStringType() ), UpdateStrategy = updateStrategy } )); }
public VerseListViewModel(DataSource source, DbList list) { if (list == null) throw new ArgumentNullException("list", "list cannot be null."); if (source == null) throw new ArgumentNullException("source", "source cannot be null."); var pageFactory = new VersePageFactory(source, list); var insertionStrategy = new VerseInsertionStrategy(source, list); _verseUpdateStrategy = new VerseUpdateStrategy(source, list); _verseList = new LazyLoadList<VerseViewModel>(pageFactory, insertionStrategy); Verses = _verseList; Title = list.Name; SelectedVerseIndex = -1; _dbList = list; ListId = _dbList.Id; }
public void Test_Update() { TestArticle article = CreateStrategy.New <TestArticle>(false).Create <TestArticle>(); article.ID = Guid.NewGuid(); article.Title = "Mock Title"; Data.DataAccess.Data.Saver.Save(article); string newTitle = "Updated"; article.Title = newTitle; IUpdateStrategy strategy = UpdateStrategy.New <TestArticle>(false); strategy.Update(article); TestArticle foundArticle = Data.DataAccess.Data.Reader.GetEntity <TestArticle>("ID", article.ID); Assert.IsNotNull(foundArticle); Assert.AreEqual(newTitle, foundArticle.Title, "Title wasn't updated."); }
public void SetUp() { _strategy = new SulfurasUpdateStrategy(); }
public override void OnApplyTemplate() { var window = Window.GetWindow(this); _windowHandle = window is null ? IntPtr.Zero : new WindowInteropHelper(window).Handle; _hwnd = new HwndSource(0, 0, 0, 0, 0, "Offscreen Window", _windowHandle); _windowInfo = Utilities.CreateWindowsWindowInfo(_hwnd.Handle); _wpfImage = new Image() { RenderTransformOrigin = new Point(0.5, 0.5), RenderTransform = new ScaleTransform(1, -1) }; var grid = new Grid(); _framesTextBlock = new TextBlock() { HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Top, Margin = new Thickness(5), Foreground = new SolidColorBrush(Colors.Blue), FontWeight = FontWeights.Bold }; Panel.SetZIndex(_framesTextBlock, 1); grid.Children.Add(_framesTextBlock); grid.Children.Add(_wpfImage); AddChild(grid); switch (UpdateStrategy) { case UpdateStrategy.WriteableBitmapImage: _updateStrategy = new UpdateStrategyWriteableBitmap(); break; case UpdateStrategy.D3DSurface: _updateStrategy = new UpdateStrategyD3D(); break; } if (UseSeperateRenderThread) { _cts = new CancellationTokenSource(); _renderThread = new Thread((object boxedToken) => { InitOpenGLContext(); while (!_cts.IsCancellationRequested) { UpdateFramerate(); if (_wasResized) { _wasResized = false; _updateStrategy.Resize((int)Math.Round(ActualWidth), (int)Math.Round(ActualHeight)); Dispatcher.Invoke(() => _wpfImage.Source = _updateStrategy.CreateImageSource()); } GLRender?.Invoke(this, EventArgs.Empty); _updateStrategy?.Draw(); Dispatcher.Invoke(() => _updateStrategy.InvalidateImageSource()); } _renderThread.Join(); }) { IsBackground = true, Priority = ThreadPriority.Highest }; _renderThread.Start(_cts); _stopwatch.Start(); } else { _dt = new DispatcherTimer(DispatcherPriority.Send) { Interval = TimeSpan.FromMilliseconds(1) }; InitOpenGLContext(); _dt.Tick += (o, e) => { UpdateFramerate(); if (_wasResized) { _wasResized = false; _updateStrategy.Resize((int)Math.Round(ActualWidth), (int)Math.Round(ActualHeight)); _wpfImage.Source = _updateStrategy.CreateImageSource(); } GLRender?.Invoke(this, EventArgs.Empty); _updateStrategy.Draw(); _updateStrategy.InvalidateImageSource(); }; _dt.Start(); _stopwatch.Start(); } base.OnApplyTemplate(); }
public Wrist(IUpdateStrategy updateStrategy) { _updateStrategy = updateStrategy; }
public NumberConversionService(IUpdateStrategy updateStrategy) { _updateStrategy = updateStrategy; }
public ShelveItem(Item item, IUpdateStrategy strategy) { _item = item; _strategy = strategy; }
public void SetUp() { _strategy = new ConjuredUpdateStrategy(); }
public void SetUp() { _strategy = new BackstagePassUpdateStrategy(); }
private void OnLoaded(object sender, RoutedEventArgs e) { if (!DesignerProperties.GetIsInDesignMode(new DependencyObject())) { Window.GetWindow(this).Closing += (ss, ee) => { mCts?.Cancel(); } } ; var ptr = DXInterop.Direct3DCreate9(DXInterop.D3D_SDK_VERSION); var window = Window.GetWindow(this); mWndHandle = window is null ? IntPtr.Zero : new WindowInteropHelper(window).Handle; mHwnd = new HwndSource(0, 0, 0, 0, 0, "Offscreen Window", mWndHandle); mWindowInfo = Utilities.CreateWindowsWindowInfo(mHwnd.Handle); mTargetFramerate = FramerateLimit > 0 ? TimeSpan.FromMilliseconds(1000.0d / FramerateLimit) : TimeSpan.Zero; switch (UpdateStrategy) { case UpdateStrategy.WriteableBitmapImage: mUpdateStrategy = new UpdateStrategyWriteableBitmap(); break; case UpdateStrategy.D3DImage: mUpdateStrategy = new UpdateStrategyD3D(); break; } mRenderTread = new Thread((object boxedToken) => { InitOpenGLContext(); while (!mCts.IsCancellationRequested) { ++mFrames; if (mWasResized) { mWasResized = false; mUpdateStrategy.Resize((int)Math.Round(ActualWidth), (int)Math.Round(ActualHeight)); Dispatcher.Invoke(() => mRenderedImg = mUpdateStrategy.CreateImageSource()); } var rt = Render(); var sleep = mTargetFramerate - rt; mAccumulatedDt += rt; if (FramerateLimit > 0) { mAccumulatedDt += sleep; } if (mAccumulatedDt >= TimeSpan.FromSeconds(1)) { mLastFrames = mFrames; mFrames = 0; mAccumulatedDt = TimeSpan.Zero; } if (FramerateLimit > 0) { Thread.Sleep(sleep > TimeSpan.Zero ? sleep : TimeSpan.Zero); } Dispatcher.Invoke(() => InvalidateVisual()); } mRenderTread.Join(); }) { IsBackground = true }; mRenderTread.Start(mCts); }
public DataManager(IUpdateStrategy updateStrategy, IFeedLoader feedLoader) { _updateStrategy = updateStrategy; _feedLoader = feedLoader; }
public void Update <TParameters>(IUpdateStrategy <Auction, TParameters> updateStrategy, TParameters parameters) where TParameters : IParameters { base.Update <TParameters>(this, updateStrategy, parameters); }
public Rotation(IUpdateStrategy updateStrategy) { _updateStrategy = updateStrategy; }
public void Update <TParameters>(EntityToExecuteStrategy entityToExecuteStrategy, IUpdateStrategy <EntityToExecuteStrategy, TParameters> updateStrategy, TParameters parameters) where TParameters : IParameters { updateStrategy.Execute(entityToExecuteStrategy, parameters); }
public void SetUp() { _strategy = new BrieUpdateStrategy(); }
public void SetUp() { _strategy = new DefaultUpdateStrategy(); }