/// <summary> /// Submits a request for prefetching to the bitmap cache. /// </summary> /// <param name="imageRequest"> /// The request to submit. /// </param> /// <param name="callerContext"> /// The caller context for image request. /// </param> /// <returns> /// An IDataSource that can safely be ignored. /// </returns> public IDataSource <object> PrefetchToBitmapCache( ImageRequest imageRequest, object callerContext) { if (!_isPrefetchEnabledSupplier.Get()) { return(DataSources.ImmediateFailedDataSource <object>( new OperationCanceledException("Prefetching is not enabled"))); } try { IProducer <object> producerSequence = _producerSequenceFactory.GetDecodedImagePrefetchProducerSequence(imageRequest); return(SubmitPrefetchRequest( producerSequence, imageRequest, new RequestLevel(RequestLevel.FULL_FETCH), callerContext, Priority.MEDIUM)); } catch (Exception exception) { return(DataSources.ImmediateFailedDataSource <object>(exception)); } }
public void TestGetAllSuppliersReturnsSuppliersListSuccess() { this.MockGetAllSuppliersResponseTables(true); var result = supplierRepositoryMock.Get().Result; Assert.IsTrue(result.Result.Count > 0); Assert.IsTrue(result.Result[0].MGSupplier != null); //Assert.Equals(fakeLsitAgencyResponse, result.Result); }
/// <summary> /// Gets data source from our _dataSourceSupplier and subscribes _dataSubscriber to it. /// Obtained data source is returned. /// </summary> protected IDataSource <object> GetAndSubscribe() { IDataSource <object> dataSource = _dataSourceSupplier.Get(); dataSource.Subscribe(_dataSubscriber, _executor); return(dataSource); }
/// <summary> /// This is an optimization that will fault all the ConcatVectors into memory, and future .get() on the Supplier objs /// will result in a very fast return by reference. /// </summary> /// <remarks> /// This is an optimization that will fault all the ConcatVectors into memory, and future .get() on the Supplier objs /// will result in a very fast return by reference. Basically this works by wrapping the output of the old thunks /// inside new, thinner closures that carry around the answer in memory. This is a no-op if vectors were already /// cached. /// </remarks> public virtual void CacheVectors() { if (originalThunks != null) { return; } originalThunks = new NDArray <ISupplier <ConcatVector> >(GetDimensions()); // OPTIMIZATION: // Rather than use the standard iterator, which creates lots of int[] arrays on the heap, which need to be GC'd, // we use the fast version that just mutates one array. Since this is read once for us here, this is ideal. IEnumerator <int[]> fastPassByReferenceIterator = FastPassByReferenceIterator(); int[] assignment = fastPassByReferenceIterator.Current; while (true) { ISupplier <ConcatVector> originalThunk = GetAssignmentValue(assignment); originalThunks.SetAssignmentValue(assignment, originalThunk); // Construct a new, thinner closure around the cached value ConcatVector result = originalThunk.Get(); SetAssignmentValue(assignment, null); // Set the assignment arrays correctly if (fastPassByReferenceIterator.MoveNext()) { fastPassByReferenceIterator.Current; } else { break; } } }
public override async Task <IActionResult> Get() { try { BaseResult <List <Models.Response.Supplier> > result = await _iSupplierRepository.Get(); if (result.Result == null || result.Result.Count() == 0) { if (result.IsError && result.ExceptionMessage != null) { return(new StatusCodeResult(500)); } else if (result.Result == null || result.Result.Count() == 0) { return(NoContent()); //204 } } return(Ok(result)); } catch (Exception ex) { Dictionary <string, string> inputParameter = new Dictionary <string, string>(); LogHelper.LogError(_iLogger, Constants.AppName, "Get", "Error Occurred. ", "SupplierController", ex, Constants.InternalErrorStatusCode, null); return(new StatusCodeResult(500)); } }
private void SaveItem_Btn_Click(object sender, RoutedEventArgs e) { if (ItemName_Txt.Text == "" || ItemStock_Txt.Text == "" || ItemPrice_Txt.Text == "") { MessageBox.Show(" Error "); return; } if (Convert.ToInt32(Supplier_comboBox.SelectedIndex) == -1) { Supplier_comboBox.SelectedIndex = 0; } item.Name = ItemName_Txt.Text; item.Stock = Convert.ToInt32(ItemStock_Txt.Text); item.Price = Convert.ToInt32(ItemPrice_Txt.Text); item.Suppliers = iSupplier.Get(Convert.ToInt32(Supplier_comboBox.SelectedValue)); if (ItemId_Txt.Text == "") { iItem.Insert(item); } else { iItem.Update(Convert.ToInt32(ItemId_Txt.Text), item); } LoadItem(); clearfield(); }
/// <summary> /// Force updating the cache params. /// </summary> internal void ForceUpdateCacheParams(ISupplier <MemoryCacheParams> cacheParamsSupplier) { lock (_cacheGate) { long currentTime = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond; _lastCacheParamsCheck = currentTime; _memoryCacheParams = cacheParamsSupplier.Get(); } }
private void CreateStorage() { DirectoryInfo rootDirectory = new DirectoryInfo( Path.Combine(_baseDirectoryPathSupplier.Get().FullName, _baseDirectoryName)); CreateRootDirectoryIfNecessary(rootDirectory); IDiskStorage storage = new DefaultDiskStorage( rootDirectory, _version, _cacheErrorLogger, _clock); _currentState = new State(rootDirectory, storage); }
public void LoadGridCombo() { try { SupplierGrid.ItemsSource = _supplier.Get(); KecamatanComboBox.ItemsSource = _kecamatan.Get(); } catch (Exception ex) { Console.Write(ex.InnerException); Console.Write(ex.StackTrace); } }
private void SaveSupplier_Btn_Click(object sender, RoutedEventArgs e) { SupplierId = SupplierId_Txt.Text; if (SupplierId == null || SupplierId == "") { supplier.Name = SupplierName_Txt.Text; iSupplier.Insert(supplier); LoadSupplier(); } else { if (iSupplier.Get(Convert.ToInt32(SupplierId)) != null) { supplier.Name = SupplierName_Txt.Text; iSupplier.Update(Convert.ToInt32(SupplierId), supplier); LoadSupplier(); } } SupplierId_Txt.Clear(); SupplierName_Txt.Clear(); }
/// <summary> /// Updates the cache params (constraints) if enough time has passed /// since the last update. /// </summary> private void MaybeUpdateCacheParams() { lock (_cacheGate) { long currentTime = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond; if (_lastCacheParamsCheck + PARAMS_INTERCHECK_INTERVAL_MS > currentTime) { return; } _lastCacheParamsCheck = currentTime; _memoryCacheParams = _memoryCacheParamsSupplier.Get(); } }
/// <summary>Return the value at the supplier, but make sure that the index is in bounds first.</summary> /// <remarks> /// Return the value at the supplier, but make sure that the index is in bounds first. /// If the index is out of bounds, return /// <see cref="Java.Util.Optional{T}.Empty{T}()"/> /// . /// </remarks> private Optional <E> PadOpt <E>(ISupplier <Optional <E> > value) { if (index < 0) { return(Optional.Empty()); } else { if (index >= sentence.Length()) { return(Optional.Empty()); } else { return(value.Get()); } } }
/// <summary>Return the value at the supplier, but make sure that the index is in bounds first.</summary> /// <remarks> /// Return the value at the supplier, but make sure that the index is in bounds first. /// If the index is out of bounds, return either '^' or '$' depending on whether it's the beginning /// or end of the sentence. /// </remarks> private string Pad(ISupplier <string> value) { if (index < 0) { return("^"); } else { if (index >= sentence.Length()) { return("$"); } else { return(value.Get()); } } }
public void MenuSupplier() { int Choice; Console.WriteLine("====================================="); Console.WriteLine("======= MENU SUPPLIER ======"); Console.WriteLine("====================================="); Console.WriteLine("|| 1. View All Data ||"); Console.WriteLine("|| 2. Insert ||"); Console.WriteLine("|| 3. Update ||"); Console.WriteLine("|| 4 Delete ||"); Console.WriteLine("======================================"); Console.Write("Pilihan....."); Choice = Convert.ToInt16(Console.ReadLine()); switch (Choice) { case 1: iSupplier.Get(); Console.Read(); break; case 2: iSupplier.insert(supplier); Console.Read(); break; case 3: iSupplier.update(Id, supplier); Console.Read(); break; case 4: iSupplier.delete(Id); Console.Read(); break; default: Console.WriteLine("Exiting......"); Console.Read(); break; } }
private bool StartNextDataSource() { ISupplier <IDataSource <T> > dataSourceSupplier = GetNextSupplier(); IDataSource <T> dataSource = (dataSourceSupplier != default(ISupplier <IDataSource <T> >)) ? dataSourceSupplier.Get() : default(IDataSource <T>); if (SetCurrentDataSource(dataSource) && dataSource != default(IDataSource <T>)) { dataSource.Subscribe( new InternalDataSubscriber(this), CallerThreadExecutor.Instance); return(true); } else { CloseSafely(dataSource); return(false); } }
/// <summary> /// Instantiates the <see cref="CountingMemoryCache{K, V}"/>. /// </summary> public CountingMemoryCache( IValueDescriptor <V> valueDescriptor, ICacheTrimStrategy cacheTrimStrategy, ISupplier <MemoryCacheParams> memoryCacheParamsSupplier, PlatformBitmapFactory platformBitmapFactory, bool isExternalCreatedBitmapLogEnabled) { _valueDescriptor = valueDescriptor; _exclusiveEntries = new CountingLruMap <K, Entry>(WrapValueDescriptor(valueDescriptor)); _cachedEntries = new CountingLruMap <K, Entry>(WrapValueDescriptor(valueDescriptor)); _cacheTrimStrategy = cacheTrimStrategy; _memoryCacheParamsSupplier = memoryCacheParamsSupplier; _memoryCacheParams = _memoryCacheParamsSupplier.Get(); _lastCacheParamsCheck = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond; if (isExternalCreatedBitmapLogEnabled) { platformBitmapFactory.SetCreationListener( new BitmapCreationObserverImpl((b, o) => _otherEntries.Add(b, o))); } }
/// <summary> /// Returns a stream from the internal stream supplier if it's not null. /// Otherwise returns an stream for the internal buffer reference if /// valid and null otherwise. /// /// <para />The caller has to close the stream after using it. /// </summary> public Stream GetInputStream() { if (_inputStreamSupplier != null) { return(_inputStreamSupplier.Get()); } CloseableReference <IPooledByteBuffer> pooledByteBufferRef = CloseableReference <IPooledByteBuffer> .CloneOrNull(_pooledByteBufferRef); if (pooledByteBufferRef != null) { try { return(new PooledByteBufferInputStream(pooledByteBufferRef.Get())); } finally { CloseableReference <IPooledByteBuffer> .CloseSafely(pooledByteBufferRef); } } return(null); }
public Supplier GetSupplier(int id) { return(_supplierRepository.Get(id)); }
public void TestInputStream() { EncodedImage encodedImage = new EncodedImage(_inputStreamSupplier); Assert.AreSame(encodedImage.GetInputStream(), _inputStreamSupplier.Get()); }
public ActionResult SupplierEidt(int id = 0) { var model = SupplierBz.Get(o => o.ID == id); return(View(model)); }
/// <summary>Create a new <code>HashIndex</code>, backed by the given collection types.</summary> /// <param name="objLookupFactory"> /// The constructor for the object lookup -- traditionally an /// <see cref="System.Collections.ArrayList{E}"/> /// . /// </param> /// <param name="indexLookupFactory"> /// The constructor for the index lookup -- traditionally a /// <see cref="System.Collections.Hashtable{K, V}"/> /// . /// </param> public HashIndex(ISupplier <IList <E> > objLookupFactory, ISupplier <IDictionary <E, int> > indexLookupFactory) : this(objLookupFactory.Get(), indexLookupFactory.Get()) { }
public void Initialize() { // Initializes mock data _consumer = new BaseConsumerImpl <IDisposable>( (result, isLast) => { ++_consumerOnNewResultCount; _consumerInternalResult = result; _consumerInternalIsLast = isLast; }, (error) => { ++_consumerOnFailureCount; _consumerInternalException = error; }, () => { ++_consumerOnCancellationCount; }, (_) => { }); _producerListener = new ProducerListenerImpl( (requestId, producerName) => { ++_onProducerStartCount; _internalRequestId = requestId; _internalProducerName = producerName; }, (_, __, ___) => { }, (requestId, producerName, extraMap) => { ++_onProducerFinishWithSuccessCount; _internalRequestId = requestId; _internalProducerName = producerName; _internalExtraMap = extraMap; }, (requestId, producerName, error, extraMap) => { ++_onProducerFinishWithFailureCount; _internalRequestId = requestId; _internalProducerName = producerName; _internalException = error; _internalExtraMap = extraMap; }, (requestId, producerName, extraMap) => { ++_onProducerFinishWithCancellationCount; _internalRequestId = requestId; _internalProducerName = producerName; _internalExtraMap = extraMap; }, (_) => { return(_requiresExtraMap); }); _resultSupplier = new SupplierImpl <IDisposable>(() => { if (_throwExceptionInResultSupplierGet) { throw EXCEPTION; } return(RESULT); }); _successMap = new Dictionary <string, string>(); _successMap.Add("state", "success"); _failureMap = new Dictionary <string, string>(); _failureMap.Add("state", "failure"); _cancellationMap = new Dictionary <string, string>(); _cancellationMap.Add("state", "cancelled"); _statefulProducerRunnable = new StatefulProducerRunnableImpl <IDisposable>( _consumer, _producerListener, PRODUCER_NAME, REQUEST_ID, null, null, null, (_) => { return(_successMap); }, (_) => { return(_failureMap); }, () => { return(_cancellationMap); }, (IDisposable result) => { try { result.Dispose(); } catch (Exception e) { throw new Exception("Unexpected IOException", e); } }, () => { return(Task.FromResult(_resultSupplier.Get())); }); _throwExceptionInResultSupplierGet = false; _requiresExtraMap = false; }