private string GetSnippet(LoadOldItemsInfo info) { return(string.Format( @"var updatedIdsList = updatedNew.Select(item => item.ID).ToList(); var deletedIdsList = deletedIds.Select(item => item.ID).ToList(); var updatedOld = Filter(Query(), updatedIdsList).Select(item => new {{ item.ID{0} }}).ToList(); var deletedOld = Filter(Query(), deletedIdsList).Select(item => new {{ item.ID{0} }}).ToList(); Rhetos.Utilities.Graph.SortByGivenOrder(updatedOld, updatedIdsList, item => item.ID); Rhetos.Utilities.Graph.SortByGivenOrder(deletedOld, deletedIdsList, item => item.ID); ", SelectPropertiesTag.Evaluate(info))); }
private void InjectClearCacheOnSave(List <IConceptInfo> newConcepts, string entityName, string loadOldPropertyValue, string snippetClearCache) { var commonModule = new ModuleInfo { Name = "Common" }; var entity = new EntityInfo { Module = commonModule, Name = entityName }; var usesAuthorizationDataCache = new RepositoryUsesInfo { DataStructure = entity, PropertyType = "Rhetos.Dom.DefaultConcepts.AuthorizationDataCache, Rhetos.Dom.DefaultConcepts", PropertyName = "_authorizationDataCache" }; var saveMethod = new SaveMethodInfo { Entity = entity }; newConcepts.AddRange(new IConceptInfo[] { usesAuthorizationDataCache, saveMethod }); if (loadOldPropertyValue != null) { var loadOldItems = new LoadOldItemsInfo { SaveMethod = saveMethod }; var loadOldItemsProperty = new LoadOldItemsTakeInfo { LoadOldItems = loadOldItems, Path = loadOldPropertyValue }; newConcepts.AddRange(new IConceptInfo[] { loadOldItems, loadOldItemsProperty }); } var clearCache = new OnSaveUpdateInfo { SaveMethod = saveMethod, RuleName = "ClearAuthenticationCache", CsCodeSnippet = snippetClearCache }; newConcepts.AddRange(new IConceptInfo[] { clearCache }); }