internal override IEnumerable <CustomFormFunction> GetCustomFunctions(string recordType, RecordEntryFormViewModel recordForm) { var type = ObjectRecordService.GetClassType(recordType); var customGridFunctions = new List <CustomFormFunction>(); var typesToResolve = GetTypesToResolve(type); foreach (var typeToResolve in typesToResolve) { var injectedFunctions = recordForm.ApplicationController.ResolveInstance(typeof(CustomFormFunctions), typeToResolve.AssemblyQualifiedName) as CustomFormFunctions; customGridFunctions.AddRange(injectedFunctions.CustomFunctions); } return(customGridFunctions); }
internal override IEnumerable <CustomGridFunction> GetCustomFunctionsFor(string referenceName, RecordEntryFormViewModel recordForm) { var functions = new Dictionary <string, Action>(); var recordType = recordForm.GetEnumerableFieldViewModel(referenceName).RecordType; if (recordType == null) { return(new CustomGridFunction[0]); } var enumeratedType = ObjectRecordService.GetClassType(recordType); var customFunctions = enumeratedType.GetCustomAttributes <CustomFunction>(); if (customFunctions != null) { foreach (var item in customFunctions) { functions.Add(item.GetFunctionLabel(), item.GetCustomFunction(recordForm, referenceName)); } } var allowDownloadAttribute = ObjectRecordService.GetPropertyInfo(referenceName, recordForm.RecordType).GetCustomAttribute <AllowDownload>(); if (allowDownloadAttribute != null) { functions.Add("Download CSV", () => { recordForm.GetEnumerableFieldViewModel(referenceName).DynamicGridViewModel.DownloadCsv(); }); } var customGridFunctions = functions.Select(kv => new CustomGridFunction(kv.Key, kv.Key, kv.Value)).ToList(); var typesToResolve = GetTypesToResolve(enumeratedType); foreach (var typeToResolve in typesToResolve) { var injectedFunctions = recordForm.ApplicationController.ResolveInstance(typeof(CustomGridFunctions), typeToResolve.AssemblyQualifiedName) as CustomGridFunctions; customGridFunctions.AddRange(injectedFunctions.CustomFunctions); } return(customGridFunctions); }