protected override void LoadCache(string tableType, CacheUpdater updateCache) { Dictionary <string, Dictionary <string, Header> > data = new Dictionary <string, Dictionary <string, Header> >(); foreach (SalesTerritory_ReadListOutput row in ReadList()) { string type = "sales territory"; Dictionary <string, Header> tbl; if (!data.TryGetValue(type, out tbl)) { data[type] = tbl = new Dictionary <string, Header>(); } string id = "" + row.TerritoryId; Header h; if (!tbl.TryGetValue(id, out h)) { tbl[id] = h = new Header(type, id, row.Name); } h.AddToAttribute("country region code", row.CountryRegionCode); h.AddToAttribute("group", row.Group); } // if no data is returned we still need to update cache to get the notify listener removed if (data.Count == 0) { updateCache(new LookupTable(tableType, new List <Header>(), true)); } foreach (string type in data.Keys) { updateCache(new LookupTable(type, data[type].Values, true)); } }
protected override void LoadCache(string tableType, CacheUpdater updateCache) { Dictionary <string, Dictionary <string, Header> > data = new Dictionary <string, Dictionary <string, Header> >(); foreach (ShipMethod_ReadListOutput row in ReadList()) { string type = "ship method"; Dictionary <string, Header> tbl; if (!data.TryGetValue(type, out tbl)) { data[type] = tbl = new Dictionary <string, Header>(); } string id = "" + row.ShipMethodId; Header h; if (!tbl.TryGetValue(id, out h)) { tbl[id] = h = new Header(type, id, row.Name); } } // if no data is returned we still need to update cache to get the notify listener removed if (data.Count == 0) { updateCache(new LookupTable(tableType, new List <Header>(), true)); } foreach (string type in data.Keys) { updateCache(new LookupTable(type, data[type].Values, true)); } }
protected override void LoadCache(string tableType, CacheUpdater updateCache) { Dictionary<string, Dictionary<string, Header>> data = new Dictionary<string, Dictionary<string, Header>>(); foreach (PersonCreditCard_ReadListOutput row in ReadList()) { string type = "person credit card"; Dictionary<string, Header> tbl; if (!data.TryGetValue(type, out tbl)) data[type] = tbl = new Dictionary<string, Header>(); string id = "" + row.CreditCardId; Header h; if (!tbl.TryGetValue(id, out h)) { tbl[id] = h = new Header(type, id, row.CreditCardName); } h.AddToAttribute("person name", row.PersonName); h.AddToAttribute("card type", row.CardType); h.AddToAttribute("card number", row.CardNumber); h.AddToAttribute("exp month", row.ExpMonth); h.AddToAttribute("exp year", row.ExpYear); } // if no data is returned we still need to update cache to get the notify listener removed if (data.Count == 0) updateCache(new LookupTable(tableType, new List<Header>(), true)); foreach (string type in data.Keys) updateCache(new LookupTable(type, data[type].Values, true)); }
protected override void LoadCache(string tableType, CacheUpdater updateCache) { Dictionary <string, Dictionary <string, Header> > data = new Dictionary <string, Dictionary <string, Header> >(); foreach (PersonCreditCard_ReadListOutput row in ReadList()) { string type = "person credit card"; Dictionary <string, Header> tbl; if (!data.TryGetValue(type, out tbl)) { data[type] = tbl = new Dictionary <string, Header>(); } string id = "" + row.CreditCardId; Header h; if (!tbl.TryGetValue(id, out h)) { tbl[id] = h = new Header(type, id, row.CreditCardName); } h.AddToAttribute("person name", row.PersonName); h.AddToAttribute("card type", row.CardType); h.AddToAttribute("card number", row.CardNumber); h.AddToAttribute("exp month", row.ExpMonth); h.AddToAttribute("exp year", row.ExpYear); } // if no data is returned we still need to update cache to get the notify listener removed if (data.Count == 0) { updateCache(new LookupTable(tableType, new List <Header>(), true)); } foreach (string type in data.Keys) { updateCache(new LookupTable(type, data[type].Values, true)); } }
protected override void LoadCache(string tableType, CacheUpdater updateCache) { Dictionary <string, Dictionary <string, Header> > data = new Dictionary <string, Dictionary <string, Header> >(); foreach (SpecialOffer_ReadListOutput row in ReadList()) { string type = "special offer"; Dictionary <string, Header> tbl; if (!data.TryGetValue(type, out tbl)) { data[type] = tbl = new Dictionary <string, Header>(); } string id = "" + row.SpecialOfferId; Header h; if (!tbl.TryGetValue(id, out h)) { tbl[id] = h = new Header(type, id, row.Description); h.IsActive = row.IsActive; } h.AddToAttribute("category", row.Category); } // if no data is returned we still need to update cache to get the notify listener removed if (data.Count == 0) { updateCache(new LookupTable(tableType, new List <Header>(), true)); } foreach (string type in data.Keys) { updateCache(new LookupTable(type, data[type].Values, true)); } }
protected override void LoadCache(string tableType, CacheUpdater updateCache) { Dictionary <string, Dictionary <string, Header> > data = new Dictionary <string, Dictionary <string, Header> >(); var output = ReadList(); foreach (var row in output.Result) { string type = "sales person"; if (!data.TryGetValue(type, out Dictionary <string, Header> tbl)) { data[type] = tbl = new Dictionary <string, Header>(); } string id = "" + row.BusinessEntityId; if (!tbl.TryGetValue(id, out Header h)) { tbl[id] = h = new Header(type, id, row.Name); h.IsActive = row.IsCurrent; } h.AddToAttribute("territory id", row.TerritoryId); } // if no data is returned we still need to update cache to get the notify listener removed if (data.Count == 0) { updateCache(new LookupTable(tableType, new List <Header>(), true)); } foreach (string type in data.Keys) { updateCache(new LookupTable(type, data[type].Values, true)); } }
protected override void LoadCache(string tableType, CacheUpdater updateCache) { Dictionary<string, Dictionary<string, Header>> data = new Dictionary<string, Dictionary<string, Header>>(); foreach (BusinessEntityAddress_ReadListOutput row in ReadList()) { string type = "business entity address"; Dictionary<string, Header> tbl; if (!data.TryGetValue(type, out tbl)) data[type] = tbl = new Dictionary<string, Header>(); string id = "" + row.AddressId; Header h; if (!tbl.TryGetValue(id, out h)) { tbl[id] = h = new Header(type, id, row.AddressType); } h.AddToAttribute("address line1", row.AddressLine1); h.AddToAttribute("address line2", row.AddressLine2); h.AddToAttribute("city", row.City); h.AddToAttribute("state", row.State); h.AddToAttribute("postal code", row.PostalCode); h.AddToAttribute("country", row.Country); } // if no data is returned we still need to update cache to get the notify listener removed if (data.Count == 0) updateCache(new LookupTable(tableType, new List<Header>(), true)); foreach (string type in data.Keys) updateCache(new LookupTable(type, data[type].Values, true)); }
protected override void LoadCache(string tableType, CacheUpdater updateCache) { Dictionary <string, Dictionary <string, Header> > data = new Dictionary <string, Dictionary <string, Header> >(); foreach (Product_ReadListOutput row in ReadList()) { string type = "product"; Dictionary <string, Header> tbl; if (!data.TryGetValue(type, out tbl)) { data[type] = tbl = new Dictionary <string, Header>(); } string id = "" + row.ProductId; Header h; if (!tbl.TryGetValue(id, out h)) { tbl[id] = h = new Header(type, id, row.Name); h.IsActive = row.IsActive; } h.AddToAttribute("product subcategory id", row.ProductSubcategoryId); h.AddToAttribute("product model id", row.ProductModelId); } // if no data is returned we still need to update cache to get the notify listener removed if (data.Count == 0) { updateCache(new LookupTable(tableType, new List <Header>(), true)); } foreach (string type in data.Keys) { updateCache(new LookupTable(type, data[type].Values, true)); } }
protected override void LoadCache(string tableType, CacheUpdater updateCache) { Dictionary <string, Dictionary <string, Header> > data = new Dictionary <string, Dictionary <string, Header> >(); var output = ReadList(default(int)); foreach (var row in output.Result) { string type = "business entity address"; if (!data.TryGetValue(type, out Dictionary <string, Header> tbl)) { data[type] = tbl = new Dictionary <string, Header>(); } string id = "" + row.AddressId; if (!tbl.TryGetValue(id, out Header h)) { tbl[id] = h = new Header(type, id, row.AddressType); } h.AddToAttribute("address line 1", row.AddressLine1); h.AddToAttribute("address line 2", row.AddressLine2); h.AddToAttribute("city", row.City); h.AddToAttribute("state", row.State); h.AddToAttribute("postal code", row.PostalCode); h.AddToAttribute("country", row.Country); } // if no data is returned we still need to update cache to get the notify listener removed if (data.Count == 0) { updateCache(new LookupTable(tableType, new List <Header>(), true)); } foreach (string type in data.Keys) { updateCache(new LookupTable(type, data[type].Values, true)); } }
/// <summary>Synchronize cached information with actual data.</summary> public void Refresh() { IList <ConfigParameterData> config; switch (_configFile) { case ConfigFile.Other: config = _configAccessor.QueryConfig.Invoke( new QueryConfigParameters(_fileName)); break; case ConfigFile.Repository: config = _configAccessor.QueryConfig.Invoke( new QueryConfigParameters()); break; case ConfigFile.System: case ConfigFile.User: config = _configAccessor.QueryConfig.Invoke( new QueryConfigParameters(_configFile)); break; default: throw new ApplicationException( string.Format(CultureInfo.InvariantCulture, "Unknown ConfigFile value: {0}", _configFile)); } lock (SyncRoot) { if (_repository != null) { CacheUpdater.UpdateObjectDictionary( _parameters, null, null, config, configParameterData => ObjectFactories.CreateConfigParameter(_repository, configParameterData), ObjectFactories.UpdateConfigParameter, InvokeCreated, InvokeDeleted, true); } else { CacheUpdater.UpdateObjectDictionary( _parameters, null, null, config, configParameterData => ObjectFactories.CreateConfigParameter(_configAccessor, configParameterData), ObjectFactories.UpdateConfigParameter, InvokeCreated, InvokeDeleted, true); } } }
private void UpdatePictures(string path) { CacheUpdater CacheUpd = new CacheUpdater(path, imageTools); System.Threading.Thread WorkThread = new System.Threading.Thread( new System.Threading.ThreadStart(CacheUpd.UpdateAll)); // WorkThread.IsBackground = true; WorkThread.Start(); }
public void Main(bool b) { var databaseSaver = new DatabaseSaverListener(new DatabaseSaver()); databaseSaver.DataSaved += (sender, args) => { var mailSender = new MailSender(); var cacheUpdated = new CacheUpdater(); mailSender.Send(""); cacheUpdated.UpdateCache(); }; DoSmth(databaseSaver); }
private void lnkSaveUpdate_Click(object sender, System.EventArgs e) { Save(); ImageTools it = new ImageTools(this); string path = it.GetPath(it.cfg.PictureVirtualDirectory); CacheUpdater CacheUpd = new CacheUpdater(path, it); System.Threading.Thread WorkThread = new System.Threading.Thread( new System.Threading.ThreadStart(CacheUpd.UpdateAll)); // WorkThread.IsBackground = true; WorkThread.Start(); RedirectBack(); }
/// <summary>Updates remote branch cache.</summary> /// <param name="branches">Actual remote branch data.</param> private void RefreshInternal(IEnumerable <BranchData> branches) { lock (SyncRoot) { CacheUpdater.UpdateObjectDictionary <RemoteBranch, BranchData>( ObjectStorage, null, branchData => branchData.IsRemote, branches, remoteBranchData => ObjectFactories.CreateRemoteBranch(Repository, remoteBranchData), ObjectFactories.UpdateRemoteBranch, InvokeObjectAdded, InvokeObjectRemoved, true); } }
private void RefreshInternal(IEnumerable <TagData> tagDataList) { lock (SyncRoot) { CacheUpdater.UpdateObjectDictionary( ObjectStorage, null, null, tagDataList, tagData => ObjectFactories.CreateTag(Repository, tagData), ObjectFactories.UpdateTag, InvokeObjectAdded, InvokeObjectRemoved, true); } }
/// <summary> /// Loads Xomega enumerations in Xomega XML format into the current cache from the given stream. /// </summary> /// <param name="tableType">The lookup table type to load.</param> /// <param name="updateCache">The method to call to store the loaded lookup table in the cache.</param> /// <param name="token">Cancellation token.</param> protected override async Task LoadCacheAsync(string tableType, CacheUpdater updateCache, CancellationToken token = default) { await base.LoadCacheAsync(tableType, updateCache, token); string ns = "http://www.xomega.net/omodel"; foreach (XElement enm in doc.Descendants(XName.Get("enum", ns))) { string type = enm.Attribute(XName.Get("name")).Value; List <Header> data = new List <Header>(); foreach (XElement itemNode in enm.Elements(XName.Get("item", ns))) { XElement textNode = itemNode.Element(XName.Get("text", ns)); string text = (textNode != null) ? textNode.Value : itemNode.Attribute(XName.Get("name")).Value; string id = itemNode.Attribute(XName.Get("value")).Value; Header item = new Header(type, id, text); foreach (XElement prop in itemNode.Elements(XName.Get("prop", ns))) { string pName = prop.Attribute(XName.Get("ref")).Value; string pVal = prop.Attribute(XName.Get("value")).Value; if (item[pName] == null) { item[pName] = pVal; } else { item.AddToAttribute(pName, pVal); } } XElement properties = itemNode.Parent.Element(XName.Get("properties", ns)); if (properties != null) { foreach (XElement prop in properties.Elements(XName.Get("property", ns))) { XAttribute def = prop.Attribute(XName.Get("default")); string pName = prop.Attribute(XName.Get("name")).Value; if (def != null && item[pName] == null) { item[pName] = def.Value; } } } data.Add(item); } updateCache(new LookupTable(type, data, caseSensitive)); } }
protected override async Task LoadCacheAsync(string tableType, CacheUpdater updateCache, CancellationToken token = default) { Dictionary <string, Dictionary <string, Header> > data = new Dictionary <string, Dictionary <string, Header> >(); var output = await ReadListAsync(); if (output?.Messages != null) { output.Messages.AbortIfHasErrors(); } else if (output?.Result == null) { return; } foreach (var row in output.Result) { string type = "business entity address"; if (!data.TryGetValue(type, out Dictionary <string, Header> tbl)) { data[type] = tbl = new Dictionary <string, Header>(); } string id = "" + row.AddressId; if (!tbl.TryGetValue(id, out Header h)) { tbl[id] = h = new Header(type, id, row.AddressType); } h.AddToAttribute("address line1", row.AddressLine1); h.AddToAttribute("address line2", row.AddressLine2); h.AddToAttribute("city", row.City); h.AddToAttribute("state", row.State); h.AddToAttribute("postal code", row.PostalCode); h.AddToAttribute("country", row.Country); } // if no data is returned we still need to update cache to mark it as loaded if (data.Count == 0) { updateCache(new LookupTable(tableType, new List <Header>(), true)); } foreach (string type in data.Keys) { updateCache(new LookupTable(type, data[type].Values, true)); } }
protected override async Task LoadCacheAsync(string tableType, CacheUpdater updateCache, CancellationToken token = default) { Dictionary <string, Dictionary <string, Header> > data = new Dictionary <string, Dictionary <string, Header> >(); var output = await ReadListAsync(); if (output?.Messages != null) { output.Messages.AbortIfHasErrors(); } else if (output?.Result == null) { return; } foreach (var row in output.Result) { string type = "person credit card"; if (!data.TryGetValue(type, out Dictionary <string, Header> tbl)) { data[type] = tbl = new Dictionary <string, Header>(); } string id = "" + row.CreditCardId; if (!tbl.TryGetValue(id, out Header h)) { tbl[id] = h = new Header(type, id, row.CreditCardName); } h.AddToAttribute("person name", row.PersonName); h.AddToAttribute("card type", row.CardType); h.AddToAttribute("card number", row.CardNumber); h.AddToAttribute("exp month", row.ExpMonth); h.AddToAttribute("exp year", row.ExpYear); } // if no data is returned we still need to update cache to mark it as loaded if (data.Count == 0) { updateCache(new LookupTable(tableType, new List <Header>(), true)); } foreach (string type in data.Keys) { updateCache(new LookupTable(type, data[type].Values, true)); } }
/// <summary>Sync information on remotes: removes non-existent, adds new, updates url.</summary> public void Refresh() { var remotes = Repository.Accessor.QueryRemotes.Invoke( new QueryRemotesParameters()); lock (SyncRoot) { CacheUpdater.UpdateObjectDictionary <Remote, RemoteData>( ObjectStorage, null, null, remotes, remoteData => ObjectFactories.CreateRemote(Repository, remoteData), ObjectFactories.UpdateRemote, InvokeObjectAdded, InvokeObjectRemoved, true); } }
public void Refresh() { var users = Repository.Accessor.QueryUsers.Invoke( new QueryUsersParameters()); lock (SyncRoot) { CacheUpdater.UpdateObjectDictionary <User, UserData>( ObjectStorage, null, null, users, userData => ObjectFactories.CreateUser(Repository, userData), ObjectFactories.UpdateUser, InvokeObjectAdded, InvokeObjectRemoved, true); } }
public void Refresh() { var config = Repository.Accessor.QueryConfig.Invoke( new QueryConfigParameters()); lock (SyncRoot) { CacheUpdater.UpdateObjectDictionary <ConfigParameter, ConfigParameterData>( _parameters, null, null, config, configParameterData => ObjectFactories.CreateConfigParameter(Repository, configParameterData), ObjectFactories.UpdateConfigParameter, InvokeParameterCreated, InvokeParameterDeleted, true); } }
public void Refresh() { var notes = Repository.Accessor.QueryNotes.Invoke( new QueryNotesParameters()); lock (SyncRoot) { CacheUpdater.UpdateObjectDictionary <Note, NoteData>( _notes, null, null, notes, noteData => ObjectFactories.CreateNote(Repository, noteData), ObjectFactories.UpdateNode, InvokeCreated, InvokeDeleted, true); } }
protected override async Task LoadCacheAsync(string tableType, CacheUpdater updateCache, CancellationToken token = default) { Dictionary <string, Dictionary <string, Header> > data = new Dictionary <string, Dictionary <string, Header> >(); var output = await ReadListAsync(); if (output?.Messages != null) { output.Messages.AbortIfHasErrors(); } else if (output?.Result == null) { return; } foreach (var row in output.Result) { string type = "product"; if (!data.TryGetValue(type, out Dictionary <string, Header> tbl)) { data[type] = tbl = new Dictionary <string, Header>(); } string id = "" + row.ProductId; if (!tbl.TryGetValue(id, out Header h)) { tbl[id] = h = new Header(type, id, row.Name); h.IsActive = IsActive(row.IsActive); } h.AddToAttribute("product subcategory id", row.ProductSubcategoryId); h.AddToAttribute("product model id", row.ProductModelId); h.AddToAttribute("list price", row.ListPrice); } // if no data is returned we still need to update cache to mark it as loaded if (data.Count == 0) { updateCache(new LookupTable(tableType, new List <Header>(), true)); } foreach (string type in data.Keys) { updateCache(new LookupTable(type, data[type].Values, true)); } }
protected override async Task LoadCacheAsync(string tableType, CacheUpdater updateCache, CancellationToken token = default) { Dictionary <string, Dictionary <string, Header> > data = new Dictionary <string, Dictionary <string, Header> >(); var output = await ReadListAsync(); if (output?.Messages != null) { output.Messages.AbortIfHasErrors(); } else if (output?.Result == null) { return; } foreach (var row in output.Result) { string type = "special offer product"; if (!data.TryGetValue(type, out Dictionary <string, Header> tbl)) { data[type] = tbl = new Dictionary <string, Header>(); } string id = "" + row.SpecialOfferId; if (!tbl.TryGetValue(id, out Header h)) { tbl[id] = h = new Header(type, id, row.Description); h.IsActive = IsActive(row.Active); } h.AddToAttribute("discount", row.Discount); h.AddToAttribute("min qty", row.MinQty); h.AddToAttribute("max qty", row.MaxQty); } // if no data is returned we still need to update cache to mark it as loaded if (data.Count == 0) { updateCache(new LookupTable(tableType, new List <Header>(), true)); } foreach (string type in data.Keys) { updateCache(new LookupTable(type, data[type].Values, true)); } }
protected override void LoadCache(string tableType, CacheUpdater updateCache) { Dictionary<string, Dictionary<string, Header>> data = new Dictionary<string, Dictionary<string, Header>>(); foreach (ShipMethod_ReadListOutput row in ReadList()) { string type = "ship method"; Dictionary<string, Header> tbl; if (!data.TryGetValue(type, out tbl)) data[type] = tbl = new Dictionary<string, Header>(); string id = "" + row.ShipMethodId; Header h; if (!tbl.TryGetValue(id, out h)) { tbl[id] = h = new Header(type, id, row.Name); } } // if no data is returned we still need to update cache to get the notify listener removed if (data.Count == 0) updateCache(new LookupTable(tableType, new List<Header>(), true)); foreach (string type in data.Keys) updateCache(new LookupTable(type, data[type].Values, true)); }
protected override async Task LoadCacheAsync(string tableType, CacheUpdater updateCache, CancellationToken token = default) { Dictionary <string, Dictionary <string, Header> > data = new Dictionary <string, Dictionary <string, Header> >(); var output = await ReadListAsync(); if (output?.Messages != null) { output.Messages.AbortIfHasErrors(); } else if (output?.Result == null) { return; } foreach (var row in output.Result) { string type = "sales reason"; if (!data.TryGetValue(type, out Dictionary <string, Header> tbl)) { data[type] = tbl = new Dictionary <string, Header>(); } string id = "" + row.SalesReasonId; if (!tbl.TryGetValue(id, out Header h)) { tbl[id] = h = new Header(type, id, row.Name); } } // if no data is returned we still need to update cache to mark it as loaded if (data.Count == 0) { updateCache(new LookupTable(tableType, new List <Header>(), true)); } foreach (string type in data.Keys) { updateCache(new LookupTable(type, data[type].Values, true)); } }
protected override void LoadCache(string tableType, CacheUpdater updateCache) { Dictionary<string, Dictionary<string, Header>> data = new Dictionary<string, Dictionary<string, Header>>(); foreach (SpecialOffer_ReadListOutput row in ReadList()) { string type = "special offer"; Dictionary<string, Header> tbl; if (!data.TryGetValue(type, out tbl)) data[type] = tbl = new Dictionary<string, Header>(); string id = "" + row.SpecialOfferId; Header h; if (!tbl.TryGetValue(id, out h)) { tbl[id] = h = new Header(type, id, row.Description); h.IsActive = row.IsActive; } h.AddToAttribute("category", row.Category); } // if no data is returned we still need to update cache to get the notify listener removed if (data.Count == 0) updateCache(new LookupTable(tableType, new List<Header>(), true)); foreach (string type in data.Keys) updateCache(new LookupTable(type, data[type].Values, true)); }
protected override void LoadCache(string tableType, CacheUpdater updateCache) { Dictionary<string, Dictionary<string, Header>> data = new Dictionary<string, Dictionary<string, Header>>(); foreach (SalesPerson_ReadListOutput row in ReadList()) { string type = "sales person"; Dictionary<string, Header> tbl; if (!data.TryGetValue(type, out tbl)) data[type] = tbl = new Dictionary<string, Header>(); string id = "" + row.BusinessEntityId; Header h; if (!tbl.TryGetValue(id, out h)) { tbl[id] = h = new Header(type, id, row.Name); h.IsActive = row.IsCurrent; } h.AddToAttribute("territory id", row.TerritoryId); } // if no data is returned we still need to update cache to get the notify listener removed if (data.Count == 0) updateCache(new LookupTable(tableType, new List<Header>(), true)); foreach (string type in data.Keys) updateCache(new LookupTable(type, data[type].Values, true)); }
public SourceUpdaterFixture() { _cache = new ChangeAwareCache <Person, string>(); _updater = new CacheUpdater <Person, string>(_cache, new KeySelector <Person, string>(p => p.Name)); }
/// <summary> /// Loads Xomega enumerations in Xomega XML format into the current cache from the given stream. /// </summary> /// <param name="tableType">The lookup table type to load.</param> /// <param name="updateCache">The method to call to store the loaded lookup table in the cache.</param> protected override void LoadCache(string tableType, CacheUpdater updateCache) { string ns = "http://www.xomega.net/omodel"; foreach (XElement enm in doc.Descendants(XName.Get("enum", ns))) { string type = enm.Attribute(XName.Get("name")).Value; List<Header> data = new List<Header>(); foreach (XElement itemNode in enm.Elements(XName.Get("item", ns))) { XElement textNode = itemNode.Element(XName.Get("text", ns)); string text = (textNode != null) ? textNode.Value : itemNode.Attribute(XName.Get("name")).Value; string id = itemNode.Attribute(XName.Get("value")).Value; Header item = new Header(type, id, text); foreach (XElement prop in itemNode.Elements(XName.Get("prop", ns))) { string pName = prop.Attribute(XName.Get("ref")).Value; string pVal = prop.Attribute(XName.Get("value")).Value; if (item[pName] == null) item[pName] = pVal; else item.AddToAttribute(pName, pVal); } XElement properties = itemNode.Parent.Element(XName.Get("properties", ns)); if (properties != null) { foreach (XElement prop in properties.Elements(XName.Get("property", ns))) { XAttribute def = prop.Attribute(XName.Get("default")); string pName = prop.Attribute(XName.Get("name")).Value; if (def != null && item[pName] == null) item[pName] = def.Value; } } data.Add(item); } updateCache(new LookupTable(type, data, caseSensitive)); } }
public void Refresh() { var submodules = new Dictionary <string, SubmoduleData>(); var cfg = Path.Combine(Repository.WorkingDirectory, GitConstants.SubmodulesConfigFile); bool skipUpdate = false; if (File.Exists(cfg)) { ConfigurationFile cfgFile = null; try { cfgFile = new ConfigurationFile(Repository, GitConstants.SubmodulesConfigFile, true); } catch (Exception exc) when(!exc.IsCritical()) { skipUpdate = true; } if (cfgFile != null) { foreach (var param in cfgFile) { if (param.Name.StartsWith("submodule.")) { int p = param.Name.LastIndexOf('.', param.Name.Length - 1, param.Name.Length - "submodule.".Length); if (p != -1 && p != param.Name.Length - 1) { var p3 = param.Name.Substring(p + 1); bool valueIsPath = false; bool valueIsUrl = false; switch (p3) { case "path": valueIsPath = true; break; case "url": valueIsUrl = true; break; default: continue; } var name = param.Name.Substring("submodule.".Length, p - "submodule.".Length); SubmoduleData info; if (!submodules.TryGetValue(name, out info)) { info = new SubmoduleData(name); submodules.Add(name, info); } if (valueIsPath) { info.Path = param.Value; } if (valueIsUrl) { info.Url = param.Value; } } } } } } if (!skipUpdate) { lock (SyncRoot) { CacheUpdater.UpdateObjectDictionary <Submodule, SubmoduleData>( ObjectStorage, null, null, submodules, submoduleData => ObjectFactories.CreateSubmodue(Repository, submoduleData), ObjectFactories.UpdateSubmodule, InvokeObjectAdded, InvokeObjectRemoved, true); } } }
public void Initialise() { _cache = new ChangeAwareCache <Person, string>(); _updater = new CacheUpdater <Person, string>(_cache, new KeySelector <Person, string>(p => p.Name)); }
public void Initialise() { _cache = new ChangeAwareCache <Person, string>(); _updater = new CacheUpdater <Person, string>(_cache); }
public CacheUpdaterDecorator(IDatabaseSaver saver, CacheUpdater cacheUpdater) : base(saver) { this.cacheUpdater = cacheUpdater; }
public ChildDecorator(IDatabaseSaver databaseSaver, MailSender mailSender, CacheUpdater cacheUpdater) : base(databaseSaver) { this.mailSender = mailSender; this.cacheUpdater = cacheUpdater; }
public CustomCacheUpdater(IDatabaseSaver saver, CacheUpdater cacheUpdater) : base(saver) { this.cacheUpdater = cacheUpdater; }
/// <summary> /// Subroutine implemented by subclasses to perform the actual loading /// of the lookup table and storing it in the cache using the provided updateCache delegate. /// The loading process can be either synchronous or asynchronous. /// </summary> /// <param name="tableType">The lookup table type to load.</param> /// <param name="updateCache">The method to call to store the loaded lookup table in the cache.</param> protected abstract void LoadCache(string tableType, CacheUpdater updateCache);