public PropertyBag EditEntries(PropertyBag bag) { return(CatchCommonExceptions(() => { EditEntriesRequest request = new EditEntriesRequest(bag); HostsFile hostsFile = GetHostsFile(); IEnumerable <HostEntry> hostEntries = hostsFile.Entries; for (int i = 0; i < request.ChangedEntries.Count; i++) { HostEntry originalEntry = request.OriginalEntries[i]; HostEntry changedEntry = request.ChangedEntries[i]; HostEntry hostEntry = FindHostEntry(originalEntry, hostEntries); hostEntry.Address = changedEntry.Address; hostEntry.Hostname = changedEntry.Hostname; hostEntry.Comment = changedEntry.Comment; hostEntry.Enabled = changedEntry.Enabled; } hostsFile.Save(); return new EditEntriesResponse().ToPropertyBag(); })); }
public void EditEntries(IList <HostEntry> originalEntries, IList <HostEntry> changedEntries) { Debug.Assert(originalEntries.Count == changedEntries.Count, "Number of original entries does not match changed entries"); var request = new EditEntriesRequest(originalEntries, changedEntries); PropertyBag responseBag = (PropertyBag)base.Invoke("EditEntries", new object[] { request.ToPropertyBag() }); var response = new EditEntriesResponse(responseBag); }