/// <summary> /// This function will be called at the end of CreateSetupService and UpdateSetupService to setup any /// additional data in the dto used to display dropdownlists etc. /// It is also called at the end of the CreateService or UpdateService if there are errors, so that /// the data is available if the form needs to be reshown. /// This function should be overridden if the dto needs additional data setup /// </summary> /// <returns></returns> internal protected virtual async Task SetupSecondaryDataAsync(IGenericServicesDbContext db, TDto dto) { if (!SupportedFunctions.HasFlag(CrudFunctions.DoesNotNeedSetup)) { throw new InvalidOperationException("SupportedFunctions flags say that setup of secondary data is needed, but did not override the SetupSecondaryData method."); } }
public static void AddFunctionAlias(SupportedFunctions function, params string[] aliases) { foreach (string alias in aliases) { Grammar.FunctionAliases[alias] = function; } }
public FunctionBlockStartRule CopyFrom(FunctionBlockStartRule source) { this.AbsoluteCoincidence = source.AbsoluteCoincidence; ExpectedValues.Clear(); foreach (var item in source.ExpectedValues) { ExpectedValues.Add((new ExpextedValue()).CopyFrom(item)); } Rule = SupportedFunctions.Where(i => i.Name == source.Rule.Name).FirstOrDefault(); return(this); }
//--------------------------------------------------------------------- //private methods /// <summary> /// This sets all the AutoMapper mapping that this dto needs. It is called from the base constructor /// It also makes sure that any associated dto mappings are set up as the order of creation is not fixed /// </summary> private void MapperSetup() { var needsDecompile = false; GenericServicesConfig.AutoMapperConfigs.GetOrAdd(CreateDictionaryKey <TEntity, TDto>(), config => new MapperConfiguration(cfg => CreateReadFromDatabaseMapping(cfg, ref needsDecompile))); //now set up NeedsDecompile any associated mappings. See comments on AssociatedDtoMapping for why these are needed NeedsDecompile = ForceNeedDecompile || CheckComputed.ClassNeedsDecompile(typeof(TEntity)); NeedsDecompile |= needsDecompile; if (SupportedFunctions.HasFlag(CrudFunctions.Update) | SupportedFunctions.HasFlag(CrudFunctions.Create)) { //Only setup TDto->TEntity mapping if needed GenericServicesConfig.AutoMapperConfigs.GetOrAdd(CreateDictionaryKey <TDto, TEntity>(), config => new MapperConfiguration(CreateWriteToDatabaseMapping)); } }