/// <summary> /// Gets the lookup table for the property from a lookup cache using <see cref="TableType"/>, and loads it asynchronously as needed. /// </summary> /// <param name="row">Data row for which to get the lookup table, or null if the property is not in a data list object.</param> /// <param name="token">Cancellation token.</param> /// <returns>The lookup table to be used for the property.</returns> protected async virtual Task <LookupTable> GetLookupTableAsync(DataRow row = null, CancellationToken token = default) { LookupCache cache = row?.GetLookupCache(this) ?? LocalCacheLoader?.LocalCache ?? LookupCache.Get(parent?.ServiceProvider ?? DI.DefaultServiceProvider, CacheType); return(await cache?.GetLookupTableAsync(TableType, token)); }
private void lookUpEdit_Reg_EditValueChanged(object sender, EventArgs e) { #region Change rayon list if (lookUpEdit_Reg.EditValue != null) { var rayons = LookupCache.Get(LookupTables.Rayon); rayons.RowFilter = string.Format("idfsRegion = {0} OR idfsRegion = {1}", lookUpEdit_Reg.EditValue, -101); lookUpEdit_Ryn.SuspendLayout(); lookUpEdit_Ryn.Properties.Columns.Clear(); lookUpEdit_Ryn.Properties.Columns.Add(new LookUpColumnInfo("strRayonName", "", 200, FormatType.None, "", true, HorzAlignment.Near)); lookUpEdit_Ryn.Properties.PopupWidth = lookUpEdit_Ryn.Width; lookUpEdit_Ryn.Properties.DataSource = rayons; lookUpEdit_Ryn.Properties.DisplayMember = "strRayonName"; lookUpEdit_Ryn.Properties.ValueMember = "idfsRayon"; lookUpEdit_Ryn.EditValue = null; lookUpEdit_Ryn.ResumeLayout(); } else { lookUpEdit_Ryn.EditValue = null; } #endregion }
/// <summary> /// Creates a function for the given conversion where neither input and output are an <see cref="Enum"/>. /// </summary> /// <param name="input">The <see cref="Type"/> to convert from.</param> /// <param name="output">The <see cref="Type"/> to convert to.</param> /// <returns>The function that converts an object of the given <see cref="Type"/> to the specified <see cref="Type"/>.</returns> protected override Func <object, object> Lookup(Type input, Type output) { if (output == typeof(string)) { return(Conversions.ObjectToString); } if (output.IsAssignableFrom(input)) { return(Conversions.None); } Tuple <Type, Type> inout = Tuple.Create(input, output); if (!LookupCache.TryGetValue(inout, out Func <object, object> converter)) { converter = (input == typeof(string) ? Conversions.TryParse(output) : null) ?? Conversions.ImplicitCast(input, output) ?? Conversions.ExplicitCast(input, output) ?? Conversions.TypeConverter(input, output); if (converter != null) { LookupCache[inout] = converter; } else { converter = InvalidConversion; } } return(converter); }
public void Get_returns_same_object_for_same_id() { // arrange LookupCache <AccessLevel> target; Dictionary <string, object> props; AccessLevel expected; AccessLevel actual; target = new LookupCache <AccessLevel>(null); props = new Dictionary <string, object> { { "id", 90 }, { "name", "alpha" }, { "label", "beta" } }; expected = target.Get(props); // act actual = target.Get(expected.Id); // assert Assert.AreSame(expected, actual); }
public void Get_returns_existing_item_from_id() { // arrange LookupCache <AccessLevel> target; AccessLevel expected; AccessLevel actual; Dictionary <int, AccessLevel> dict; target = new LookupCache <AccessLevel>(null); dict = (Dictionary <int, AccessLevel>)target.GetType().GetField("_cache", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(target); expected = new AccessLevel { Id = 90, Name = "alpha", Label = "beta" }; dict.Add(expected.Id, expected); // act actual = target.Get(expected.Id); // assert Assert.AreSame(expected, actual); }
//[HttpPost] // public ActionResult OnSaveFieldChanges() public ActionResult AggregateFunctionChanged(string aggregateFunctionId) { AvrPivotGridModel model = GetModelFromSession(); if (model == null) { return(View("AvrServiceError", (object)m_ErrorMessage)); } int intPrecision = -1; if (model.PivotSettings.SelectedField != null) { long aggrId = bv.common.Core.Utils.ToLong(aggregateFunctionId); CustomSummaryType summaryTypeType = AvrPivotGridHelper.ParseSummaryType(aggrId); if (model.PivotSettings.SelectedField.PrecisionDictionary.ContainsKey(summaryTypeType)) { intPrecision = model.PivotSettings.SelectedField.PrecisionDictionary[summaryTypeType]; } else { string strPrecision = LookupCache.GetLookupValue((long)summaryTypeType, LookupTables.AggregateFunction, "intDefaultPrecision"); intPrecision = int.TryParse(strPrecision, out intPrecision) ? intPrecision : -1; } } return(new JsonResult { Data = new { precision = (decimal)intPrecision }, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
/// <summary> /// Gets the lookup table for the property from a lookup cache using <see cref="TableType"/>. /// </summary> /// <param name="cachedOnly">True to return only the cached lookup table, False to try to load it, if it's not cached.</param> /// <param name="row">Data row for which to get the lookup table, or null if the property is not in a data list object.</param> /// <returns>The lookup table to be used for the property.</returns> protected virtual LookupTable GetLookupTable(bool cachedOnly = false, DataRow row = null) { LookupCache cache = row?.GetLookupCache(this) ?? LocalCacheLoader?.LocalCache ?? LookupCache.Get(parent?.ServiceProvider ?? DI.DefaultServiceProvider, CacheType); return(cache?.GetLookupTable(TableType, cachedOnly)); }
/// <summary> /// Constructs a <see cref="TypeConvertBase"/> and copies the conversions from another <see cref="TypeConvertBase"/>. /// </summary> /// <param name="threadSafe">Determines if custom conversions use a <see cref="ConcurrentDictionary{TKey, TValue}"/>.</param> /// <param name="copyFrom">The <see cref="TypeConvertBase"/> to copy converters from.</param> public TypeConvertBase(bool threadSafe, TypeConvertBase copyFrom) : this(threadSafe) { if (copyFrom != null) { foreach (var kv in copyFrom.LookupCache) { LookupCache.Add(kv.Key, kv.Value); } for (int i = 2; i < 19; i++) { Func <object, object>[] arr = converterArray[i]; Func <object, object>[] copyArr = copyFrom.converterArray[i]; for (int j = 0; j < 19; j++) { arr[j] = copyArr[j]; } } } else { for (int i = 2; i < 19; i++) { Func <object, object>[] arr = converterArray[i]; for (int j = 0; j < 19; j++) { arr[j] = InvalidConversion; } arr[i] = Conversions.None; } converterArray[17][17] = InvalidConversion; } }
public static DataView GetAggregateFunctionsView() { DataView dataView = LookupCache.Get(LookupTables.AggregateFunction.ToString()); dataView.RowFilter = "blnPivotGridFunction=1"; return(dataView); }
/// <summary> /// Generates the view for the GetApplicationAsWordDocument action. /// </summary> /// <param name="id">The identifier.</param> /// <returns>The action result for the view.</returns> public ActionResult Export(int id) { var model = this.GetDetailsViewModel(id); ViewBag.Title = "Export"; var htmlResult = this.RenderActionResultToString(View("Export", model)); //get program year description for file name var criteria = new ProviderApplicationDTO(); criteria.ProviderApplicationId = id; var provApp = _providerApplicationService.ReadProviderApplication(criteria); var pyDesc = string.Empty; var programYears = LookupCache.GetProgramYears(); foreach (var py in programYears) { if (py.ProgramYearId == provApp.ProgramYearId) { pyDesc = py.ProgramYearDesc; break; } } var fileName = string.Format( pyDesc + "_ProviderApplication_{0}_{1}.doc", model.ProviderID, model.ProviderApplicationId); var fileContents = Encoding.UTF8.GetBytes(htmlResult); return(this.File(fileContents, "application/vnd.ms-word", fileName)); }
private void GenerateLookupPermutation(Generator generator, LoadableValue context, LookupCache cache, int index, LoadableCache[] values, LoadableValue source_reference, Block block) { if (index >= values.Length) { block(context, cache); generator.DebugPosition(this); return; } var labels = new Label[values[index].Types.Length]; for (var it = 0; it < labels.Length; it++) { labels[it] = generator.Builder.DefineLabel(); values[index].Value.Load(generator); generator.Builder.Emit(OpCodes.Isinst, values[index].Types[it]); generator.Builder.Emit(OpCodes.Brtrue, labels[it]); } generator.EmitTypeError(source_reference, String.Format("Expected type {0} for “{1}”, but got {2}.", String.Join(" or ", from t in values[index].Types select Stringish.NameForType(t)), values[index].NameInfo.Name, "{0}"), values[index].Value); for (var it = 0; it < labels.Length; it++) { generator.Builder.MarkLabel(labels[it]); var sub_cache = new LookupCache(cache); sub_cache[values[index].NameInfo] = new AutoUnboxValue(values[index].Value, values[index].Types[it]); var builder = generator.Builder; GenerateLookupPermutation(generator, context, sub_cache, index + 1, values, source_reference, block); generator.Builder = builder; } }
public static bool IsLookupCacheInitialized() { LookupTableInfo lookupTable = LookupCache.LookupTables[LookupTables.QuerySearchField.ToString()]; DataTable result = LookupCache.Fill(lookupTable); return(result != null); }
public void TestUserQuit() { foreach (int user in users) { AddStep($"mark user {user} quit", () => Client.RemoveUser(LookupCache.GetUserAsync(user).Result.AsNonNull())); } }
// public static void UpdateSummaryType // (Dictionary<string, CustomSummaryType> summaryTypes, IAvrPivotGridField field) // { // CustomSummaryType summaryTypeType = // summaryTypes.ContainsKey( // field.FieldName) // ? summaryTypes[field.FieldName] // : field.GetDefaultSummaryType(); // if (!summaryTypes.ContainsKey(field.FieldName)) // { // summaryTypes.Add( // field.FieldName, summaryTypeType); // } // else // summaryTypes[field.FieldName] = summaryTypeType; // PivotSummaryType summaryType = summaryTypeType == CustomSummaryType.Count // ? PivotSummaryType.Count // : PivotSummaryType.Custom; // field.CustomSummaryType = summaryTypeType; // field.SummaryType = summaryType; // // // } private static SearchFieldType GetSearchFieldType(WebPivotGridField webField) { string fieldName = webField.Name; //DataView view = null; DataRow fieldRow; bool isLookup; int pos = fieldName.IndexOf("__", StringComparison.Ordinal); if (pos > 0) { string[] fieldParts = webField.OriginalFieldName.Split(new[] { "__" }, StringSplitOptions.RemoveEmptyEntries); int i = SearchFieldLookup.Find(fieldParts[0]); DataRow paramRow = LookupCache.GetLookupRow(webField.OriginalFieldName, LookupTables.ParameterForFFType.ToString()); object referenceType = paramRow["idfsReferenceType"]; isLookup = !bv.common.Core.Utils.IsEmpty(referenceType); fieldRow = SearchFieldLookup[i].Row; } else { int i = SearchFieldLookup.Find(webField.OriginalFieldName); fieldRow = SearchFieldLookup[i].Row; isLookup = IsLookupField(fieldRow); } if (isLookup) { return(SearchFieldType.ID); } return((SearchFieldType)fieldRow["idfsSearchFieldType"]); }
internal ComponentDataFromEntity(int typeIndex, EntityComponentStore *entityComponentStoreComponentStore) { m_TypeIndex = typeIndex; m_EntityComponentStore = entityComponentStoreComponentStore; m_Cache = default; m_GlobalSystemVersion = entityComponentStoreComponentStore->GlobalSystemVersion; }
public LookupTableController(IServiceProvider serviceProvider) { if (serviceProvider == null) { throw new ArgumentNullException("serviceProvider"); } globalCache = LookupCache.Get(serviceProvider, LookupCache.Global); }
internal BufferFromEntity(int typeIndex, EntityComponentStore *entityComponentStoreComponentStore, bool isReadOnly) { m_TypeIndex = typeIndex; m_EntityComponentStore = entityComponentStoreComponentStore; m_IsReadOnly = isReadOnly; m_Cache = default; m_GlobalSystemVersion = entityComponentStoreComponentStore->GlobalSystemVersion; m_InternalCapacity = TypeManager.GetTypeInfo <T>().BufferCapacity; }
public LookupTableController(IServiceProvider serviceProvider, ResourceManager resourceManager) { if (serviceProvider == null) { throw new ArgumentNullException(nameof(serviceProvider)); } globalCache = LookupCache.Get(serviceProvider, LookupCache.Global); resMgr = resourceManager ?? Messages.ResourceManager; }
// Static initializer to register generated cache loaders. // This will ensure they will be registered only once. static LookupCacheLoaders() { LookupCache.AddCacheLoader(new ProductReadListCacheLoader()); LookupCache.AddCacheLoader(new ShipMethodReadListCacheLoader()); LookupCache.AddCacheLoader(new SalesPersonReadListCacheLoader()); LookupCache.AddCacheLoader(new SalesReasonReadListCacheLoader()); LookupCache.AddCacheLoader(new SalesTerritoryReadListCacheLoader()); LookupCache.AddCacheLoader(new SpecialOfferReadListCacheLoader()); }
public static long GetFirstlayoutId() { DataView layoutLookup = LookupCache.Get(LookupTables.Layout); layoutLookup.Sort = "idflLayout"; return(layoutLookup.Count > 0 ? (long)layoutLookup[0]["idflLayout"] : -1); }
internal ComponentDataFromEntity(int typeIndex, EntityComponentStore *entityComponentStoreComponentStore, AtomicSafetyHandle safety) { m_Safety = safety; m_TypeIndex = typeIndex; m_EntityComponentStore = entityComponentStoreComponentStore; m_Cache = default; m_GlobalSystemVersion = entityComponentStoreComponentStore->GlobalSystemVersion; m_IsZeroSized = ComponentType.FromTypeIndex(typeIndex).IsZeroSized; }
/// <summary> /// Constructs a new lookup table controller. /// </summary> /// <param name="errorList">An error list for the current errors.</param> /// <param name="errorParser">An injected error parser.</param> /// <param name="cacheProvider">An injected instance of the cache provider.</param> public LookupTableController(ErrorList errorList, ErrorParser errorParser, ILookupCacheProvider cacheProvider) : base(errorList, errorParser) { if (cacheProvider == null) { throw new ArgumentNullException(nameof(cacheProvider)); } globalCache = cacheProvider.GetLookupCache(LookupCache.Global); }
public FluentRecordBase AddLookupCache() { if (_dbFactory == null) { AddDBFactory(); } _lcache = new LookupCache(_dbFactory); _lcache.getCache(); return(this); }
/// <summary> /// Initilizes trains , tracks, stations, speeds, distances etc /// </summary> private static void InitializeData() { try { // Randomly generating different but constant speeds, shipment capacity & track distances. Random randomNumberGenerator = new Random(); for (int i = 0; i < _noOfStations; i++) { _distances[i] = randomNumberGenerator.Next(3, 11) * 10; } for (int i = 0; i < _noOfTrains; i++) { _speeds[i] = randomNumberGenerator.Next(3, 25) * 10; } // Global cache var cache = LookupCache.GetInstance(); // Initilize train tracks & trains Dictionary <string, TrainTrack> _dicTracks = new Dictionary <string, TrainTrack>(); for (int i = 1; i <= _noOfStations; i++) { Station station = new Station(i, "Station" + i.ToString()); cache.AddStation(station); if (i == _noOfStations) { String key = "Station" + i.ToString() + "ToStation" + (i + 1).ToString(); TrainTrack track = new TrainTrack(i, 1, _distances[i - 1]); _dicTracks.Add(key, track); } else { String key = "Station" + i.ToString() + "To" + "Station1"; TrainTrack track = new TrainTrack(i, 1 + i, _distances[i - 1]); _dicTracks.Add(key, track); } } // adding train tracks to cache cache.AddTracks(_dicTracks); for (int i = 1; i <= _noOfTrains; i++) { Train train = new Train(i, "Train" + i.ToString(), _shipmentCapacity[i - 1], _speeds[i - 1]); cache.AddTrain(train); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
/// <summary> /// Gets the lookup table for the property. The default implementation uses the <see cref="EnumType"/> /// to find the lookup table in the lookup cache specified by the <see cref="CacheType"/>. /// </summary> /// <returns>The lookup table to be used for the property.</returns> protected virtual LookupTable GetLookupTable() { if (LocalLookupTable != null) { return(LocalLookupTable); } LookupCache cache = LookupCache.Get(parent != null ? parent.ServiceProvider : DI.DefaultServiceProvider, CacheType); LookupCache.LookupTableReady onReady = null; return(cache == null ? null : cache.GetLookupTable(EnumType, onReady)); }
public ActivityController( IActivityService aServ, LookupCache lc, IDefaults def, IMapper map) { this.lcache = lc; this.serv = aServ; this.map = map; this.def = def; }
public WorkerSigninController(IWorkerSigninService workerSigninService, IWorkerService workerService, LookupCache lc, IDefaults def, IMapper map) { this._serv = workerSigninService; this._wServ = workerService; this.lcache = lc; this.map = map; this.def = def; }
public ActivitySigninController(IActivitySigninService serv, IWorkerService wServ, LookupCache lc, IDefaults def, IMapper map) { this.serv = serv; this.wServ = wServ; this.lcache = lc; this.map = map; this.def = def; }
public static void CheckAndInitEidssCore() { lock (m_SyncRoot) { if (!IsLookupCacheInitialized()) { InitEidssCore(); StoredProcParamsCache.ClearCache(); LookupCache.Reload(); } } }
// // public EventController(IEventService eventService, IImageService imageServ, LookupCache lc, IDefaults def, IMapper map) { this._serv = eventService; this.iServ = imageServ; this.lcache = lc; this.map = map; this.def = def; }