CarotDav_decompile/CarotDAV/CacheManager.cs

841 lines
29 KiB
C#

// Decompiled with JetBrains decompiler
// Type: CarotDAV.CacheManager
// Assembly: CarotDAV, Version=1.13.2.18337, Culture=neutral, PublicKeyToken=null
// MVID: C31F2651-A4A8-4D09-916A-8C6106F5E7C8
// Assembly location: F:\Eigene Dateien\Dropbox\portable Collection\Progs\CarotDAV\CarotDAV.exe
using Microsoft.VisualBasic.CompilerServices;
using Rei.Fs;
using System;
using System.Collections.Generic;
using System.IO;
namespace CarotDAV
{
public class CacheManager
{
public Dictionary<Uri, ResourceInfo> infodic;
public Dictionary<Uri, List<Uri>> entriesdic;
public Uri watchuri;
public CacheManager()
{
this.infodic = new Dictionary<Uri, ResourceInfo>();
this.entriesdic = new Dictionary<Uri, List<Uri>>();
}
public event CacheManager.ResourceChangedEventHandler ResourceChanged;
public void RegisterWatchUri(Uri target)
{
lock (this.infodic)
this.watchuri = target;
}
public void Clear()
{
lock (this.infodic)
{
this.infodic.Clear();
this.entriesdic.Clear();
}
}
public ResourceInfo GetInfo(FsBase fs, ResourceId id, bool enablecache)
{
lock (this.infodic)
{
if (enablecache)
{
if (this.infodic.ContainsKey(id.Uri))
return this.infodic[id.Uri];
}
}
Uri parent = UriUtil.GetParent(id.Uri);
ResourceInfo info;
try
{
info = fs.GetInfo(id);
}
catch (RemoteResourceNotFoundException ex)
{
ProjectData.SetProjectError((Exception) ex);
lock (this.infodic)
this.InnerUpdateNotFound(id.Uri);
throw;
}
ResourceChangedEventArgs e = (ResourceChangedEventArgs) null;
lock (this.infodic)
{
if (this.infodic.ContainsKey(info.Id.Uri))
this.infodic[info.Id.Uri] = info;
else
this.infodic.Add(info.Id.Uri, info);
if (this.entriesdic.ContainsKey(parent) && !this.entriesdic[parent].Contains(info.Id.Uri))
this.entriesdic.Remove(parent);
if (!(this.watchuri == id.Uri))
{
if (!(this.watchuri == parent))
goto label_21;
}
e = new ResourceChangedEventArgs((ReturnedInfo) info);
}
label_21:
if (e != null)
{
CacheManager.ResourceChangedEventHandler resourceChangedEvent = this.ResourceChangedEvent;
if (resourceChangedEvent != null)
resourceChangedEvent((object) this, e);
}
return info;
}
public ResourceInfo GetInfo(FsBase fs, ResourceId parentid, string name, bool enablecache)
{
if (enablecache)
{
lock (this.infodic)
{
if (this.entriesdic.ContainsKey(parentid.Uri))
{
int num1 = 0;
int num2 = checked (this.entriesdic[parentid.Uri].Count - 1);
int index = num1;
while (index <= num2)
{
if (Operators.CompareString(name, UriUtil.GetLastName(this.entriesdic[parentid.Uri][index]), false) == 0)
{
if (this.infodic.ContainsKey(this.entriesdic[parentid.Uri][index]))
return this.infodic[this.entriesdic[parentid.Uri][index]];
goto label_11;
}
else
checked { ++index; }
}
throw new RemoteResourceNotFoundException(UriUtil.CombineName(parentid.Uri, name), (Exception) null);
}
}
}
label_11:
ResourceInfo info;
try
{
info = fs.GetInfo(parentid, name);
}
catch (RemoteResourceNotFoundException ex)
{
ProjectData.SetProjectError((Exception) ex);
Uri target = UriUtil.CombineName(parentid.Uri, name);
lock (this.infodic)
this.InnerUpdateNotFound(target);
throw;
}
ResourceChangedEventArgs e = (ResourceChangedEventArgs) null;
lock (this.infodic)
{
if (this.infodic.ContainsKey(info.Id.Uri))
this.infodic[info.Id.Uri] = info;
else
this.infodic.Add(info.Id.Uri, info);
if (this.entriesdic.ContainsKey(parentid.Uri) && !this.entriesdic[parentid.Uri].Contains(info.Id.Uri))
this.entriesdic.Remove(parentid.Uri);
if (!(this.watchuri == info.Id.Uri))
{
if (!(this.watchuri == parentid.Uri))
goto label_27;
}
e = new ResourceChangedEventArgs((ReturnedInfo) info);
}
label_27:
if (e != null)
{
CacheManager.ResourceChangedEventHandler resourceChangedEvent = this.ResourceChangedEvent;
if (resourceChangedEvent != null)
resourceChangedEvent((object) this, e);
}
return info;
}
public ResourceInfo[] GetEntries(FsBase fs, ResourceId id, bool enablecache)
{
if (enablecache)
{
lock (this.infodic)
{
if (this.entriesdic.ContainsKey(id.Uri))
{
List<ResourceInfo> resourceInfoList = new List<ResourceInfo>();
int num1 = 0;
int num2 = checked (this.entriesdic[id.Uri].Count - 1);
int index = num1;
while (index <= num2)
{
if (this.infodic.ContainsKey(this.entriesdic[id.Uri][index]))
{
resourceInfoList.Add(this.infodic[this.entriesdic[id.Uri][index]]);
checked { ++index; }
}
else
goto label_9;
}
return resourceInfoList.ToArray();
}
}
}
label_9:
ResourceInfo[] entries;
try
{
entries = fs.GetEntries(id);
}
catch (RemoteResourceNotFoundException ex)
{
ProjectData.SetProjectError((Exception) ex);
lock (this.infodic)
this.InnerUpdateInfoAndEntries_NotFound(id.Uri);
throw;
}
List<ResourceChangedEventArgs> changedEventArgsList = new List<ResourceChangedEventArgs>();
lock (this.infodic)
{
if (this.entriesdic.ContainsKey(id.Uri))
this.entriesdic[id.Uri].Clear();
else
this.entriesdic.Add(id.Uri, new List<Uri>());
int num1 = 0;
int num2 = checked (entries.Length - 1);
int index1 = num1;
while (index1 <= num2)
{
this.entriesdic[id.Uri].Add(entries[index1].Id.Uri);
if (this.infodic.ContainsKey(entries[index1].Id.Uri))
this.infodic[entries[index1].Id.Uri] = entries[index1];
else
this.infodic.Add(entries[index1].Id.Uri, entries[index1]);
checked { ++index1; }
}
int num3 = 0;
int num4 = checked (entries.Length - 1);
int index2 = num3;
while (index2 <= num4)
{
if (this.watchuri == id.Uri || this.watchuri == entries[index2].Id.Uri)
changedEventArgsList.Add(new ResourceChangedEventArgs((ReturnedInfo) entries[index2]));
checked { ++index2; }
}
}
int num5 = 0;
int num6 = checked (changedEventArgsList.Count - 1);
int index3 = num5;
while (index3 <= num6)
{
CacheManager.ResourceChangedEventHandler resourceChangedEvent = this.ResourceChangedEvent;
if (resourceChangedEvent != null)
resourceChangedEvent((object) this, changedEventArgsList[index3]);
checked { ++index3; }
}
return entries;
}
public ResourceInfo[] GetInfoAndEntries(FsBase fs, Uri targeturi, bool enablecache)
{
if (enablecache)
{
ResourceInfo[] infoAndEntries;
lock (this.infodic)
infoAndEntries = this.InnerFindInfoAndEntries(targeturi);
if (infoAndEntries != null)
return infoAndEntries;
}
ResourceInfo[] infoAndEntries1;
try
{
infoAndEntries1 = fs.GetInfoAndEntries(targeturi);
}
catch (RemoteResourceNotFoundException ex)
{
ProjectData.SetProjectError((Exception) ex);
lock (this.infodic)
this.InnerUpdateInfoAndEntries_NotFound(targeturi);
throw;
}
List<ResourceChangedEventArgs> changedEventArgsList = new List<ResourceChangedEventArgs>();
lock (this.infodic)
{
this.InnerUpdateInfoAndEntries_Success(infoAndEntries1);
if (this.watchuri == UriUtil.GetParent(infoAndEntries1[0].Id.Uri) || this.watchuri == infoAndEntries1[0].Id.Uri)
changedEventArgsList.Add(new ResourceChangedEventArgs((ReturnedInfo) infoAndEntries1[0]));
int num1 = 1;
int num2 = checked (infoAndEntries1.Length - 1);
int index = num1;
while (index <= num2)
{
if (this.watchuri == targeturi || this.watchuri == infoAndEntries1[index].Id.Uri)
changedEventArgsList.Add(new ResourceChangedEventArgs((ReturnedInfo) infoAndEntries1[index]));
checked { ++index; }
}
}
int num3 = 0;
int num4 = checked (changedEventArgsList.Count - 1);
int index1 = num3;
while (index1 <= num4)
{
CacheManager.ResourceChangedEventHandler resourceChangedEvent = this.ResourceChangedEvent;
if (resourceChangedEvent != null)
resourceChangedEvent((object) this, changedEventArgsList[index1]);
checked { ++index1; }
}
return infoAndEntries1;
}
public ResourceInfo[] GetInfoAndEntries(FsBase fs, ResourceId id, bool enablecache)
{
if (enablecache)
{
ResourceInfo[] infoAndEntries;
lock (this.infodic)
infoAndEntries = this.InnerFindInfoAndEntries(id.Uri);
if (infoAndEntries != null)
return infoAndEntries;
}
ResourceInfo[] infoAndEntries1;
try
{
infoAndEntries1 = fs.GetInfoAndEntries(id);
}
catch (RemoteResourceNotFoundException ex)
{
ProjectData.SetProjectError((Exception) ex);
lock (this.infodic)
this.InnerUpdateInfoAndEntries_NotFound(id.Uri);
throw;
}
List<ResourceChangedEventArgs> changedEventArgsList = new List<ResourceChangedEventArgs>();
lock (this.infodic)
{
this.InnerUpdateInfoAndEntries_Success(infoAndEntries1);
if (this.watchuri == UriUtil.GetParent(infoAndEntries1[0].Id.Uri) || this.watchuri == infoAndEntries1[0].Id.Uri)
changedEventArgsList.Add(new ResourceChangedEventArgs((ReturnedInfo) infoAndEntries1[0]));
int num1 = 1;
int num2 = checked (infoAndEntries1.Length - 1);
int index = num1;
while (index <= num2)
{
if (this.watchuri == id.Uri || this.watchuri == infoAndEntries1[index].Id.Uri)
changedEventArgsList.Add(new ResourceChangedEventArgs((ReturnedInfo) infoAndEntries1[index]));
checked { ++index; }
}
}
int num3 = 0;
int num4 = checked (changedEventArgsList.Count - 1);
int index1 = num3;
while (index1 <= num4)
{
CacheManager.ResourceChangedEventHandler resourceChangedEvent = this.ResourceChangedEvent;
if (resourceChangedEvent != null)
resourceChangedEvent((object) this, changedEventArgsList[index1]);
checked { ++index1; }
}
return infoAndEntries1;
}
public ResourceInfo[] GetParentInfoAndEntries(FsBase fs, ResourceId childid, bool enablecache)
{
Uri parent = UriUtil.GetParent(childid.Uri);
if (enablecache)
{
ResourceInfo[] infoAndEntries;
lock (this.infodic)
infoAndEntries = this.InnerFindInfoAndEntries(parent);
if (infoAndEntries != null)
return infoAndEntries;
}
ResourceInfo[] parentInfoAndEntries;
try
{
parentInfoAndEntries = fs.GetParentInfoAndEntries(childid);
}
catch (RemoteResourceNotFoundException ex)
{
ProjectData.SetProjectError((Exception) ex);
lock (this.infodic)
this.InnerUpdateInfoAndEntries_NotFound(parent);
throw;
}
List<ResourceChangedEventArgs> changedEventArgsList = new List<ResourceChangedEventArgs>();
lock (this.infodic)
{
this.InnerUpdateInfoAndEntries_Success(parentInfoAndEntries);
if (this.watchuri == UriUtil.GetParent(parentInfoAndEntries[0].Id.Uri) || this.watchuri == parentInfoAndEntries[0].Id.Uri)
changedEventArgsList.Add(new ResourceChangedEventArgs((ReturnedInfo) parentInfoAndEntries[0]));
int num1 = 1;
int num2 = checked (parentInfoAndEntries.Length - 1);
int index = num1;
while (index <= num2)
{
if (this.watchuri == parentInfoAndEntries[0].Id.Uri || this.watchuri == parentInfoAndEntries[index].Id.Uri)
changedEventArgsList.Add(new ResourceChangedEventArgs((ReturnedInfo) parentInfoAndEntries[index]));
checked { ++index; }
}
}
int num3 = 0;
int num4 = checked (changedEventArgsList.Count - 1);
int index1 = num3;
while (index1 <= num4)
{
CacheManager.ResourceChangedEventHandler resourceChangedEvent = this.ResourceChangedEvent;
if (resourceChangedEvent != null)
resourceChangedEvent((object) this, changedEventArgsList[index1]);
checked { ++index1; }
}
return parentInfoAndEntries;
}
public ReturnedInfo CreateCollection(FsBase fs, ResourceId parentid, string name)
{
ReturnedInfo collection;
try
{
collection = fs.CreateCollection(parentid, name);
}
catch (RemoteResourceNotFoundException ex)
{
ProjectData.SetProjectError((Exception) ex);
lock (this.infodic)
this.InnerUpdateNotFound(parentid.Uri);
throw;
}
ResourceInfo resourceInfo = collection as ResourceInfo;
ResourceId resourceId = resourceInfo != null ? resourceInfo.Id : collection as ResourceId;
ResourceChangedEventArgs e = (ResourceChangedEventArgs) null;
lock (this.infodic)
{
if (resourceInfo != null)
{
if (this.infodic.ContainsKey(resourceInfo.Id.Uri))
this.infodic[resourceInfo.Id.Uri] = resourceInfo;
else
this.infodic.Add(resourceInfo.Id.Uri, resourceInfo);
if (!this.entriesdic.ContainsKey(parentid.Uri))
this.entriesdic.Add(parentid.Uri, new List<Uri>());
if (this.entriesdic[parentid.Uri].Contains(resourceInfo.Id.Uri))
this.entriesdic[parentid.Uri].Remove(resourceInfo.Id.Uri);
this.entriesdic[parentid.Uri].Add(resourceInfo.Id.Uri);
}
else
this.entriesdic.Remove(parentid.Uri);
if (!(this.watchuri == resourceId.Uri))
{
if (!(this.watchuri == parentid.Uri))
goto label_20;
}
e = new ResourceChangedEventArgs(collection, ResourceChangedEventArgs.ChangeType.Create);
}
label_20:
if (e != null)
{
CacheManager.ResourceChangedEventHandler resourceChangedEvent = this.ResourceChangedEvent;
if (resourceChangedEvent != null)
resourceChangedEvent((object) this, e);
}
return collection;
}
public void Delete(FsBase fs, ResourceId id)
{
try
{
fs.Delete(id);
}
catch (RemoteResourceNotFoundException ex)
{
ProjectData.SetProjectError((Exception) ex);
lock (this.infodic)
this.InnerUpdateNotFound(id.Uri);
throw;
}
ResourceChangedEventArgs e = (ResourceChangedEventArgs) null;
lock (this.infodic)
{
this.InnerDiscardList(UriUtil.GetParent(id.Uri));
this.InnerDiscardInfo(id.Uri);
this.InnerDiscardList(id.Uri);
if (!(this.watchuri == id.Uri))
{
if (!(this.watchuri == UriUtil.GetParent(id.Uri)))
goto label_11;
}
e = new ResourceChangedEventArgs((ReturnedInfo) id, ResourceChangedEventArgs.ChangeType.Delete);
}
label_11:
if (e == null)
return;
CacheManager.ResourceChangedEventHandler resourceChangedEvent = this.ResourceChangedEvent;
if (resourceChangedEvent == null)
return;
resourceChangedEvent((object) this, e);
}
public ReturnedInfo Move(FsBase fs, ResourceId id, ResourceId newparentid, string newname, bool overwrite)
{
ReturnedInfo re;
try
{
re = fs.Move(id, newparentid, newname, overwrite);
}
catch (RemoteResourceNotFoundException ex)
{
ProjectData.SetProjectError((Exception) ex);
lock (this.infodic)
this.InnerUpdateNotFound(id.Uri);
throw;
}
ResourceInfo resourceInfo = re as ResourceInfo;
ResourceId resourceId = resourceInfo != null ? resourceInfo.Id : re as ResourceId;
ResourceChangedEventArgs e1 = (ResourceChangedEventArgs) null;
ResourceChangedEventArgs e2 = (ResourceChangedEventArgs) null;
lock (this.infodic)
{
this.infodic.Remove(id.Uri);
this.entriesdic.Remove(id.Uri);
if ((object) newparentid != null)
{
Uri parent = UriUtil.GetParent(id.Uri);
if (this.entriesdic.ContainsKey(parent))
this.entriesdic[parent].Remove(id.Uri);
}
if (resourceInfo != null)
{
if (this.infodic.ContainsKey(resourceInfo.Id.Uri))
this.infodic[resourceInfo.Id.Uri] = resourceInfo;
else
this.infodic.Add(resourceInfo.Id.Uri, resourceInfo);
if ((object) newparentid != null && this.entriesdic.ContainsKey(newparentid.Uri))
{
if (this.entriesdic[newparentid.Uri].Contains(resourceInfo.Id.Uri))
this.entriesdic[newparentid.Uri].Remove(resourceInfo.Id.Uri);
this.entriesdic[newparentid.Uri].Add(resourceInfo.Id.Uri);
}
}
else if ((object) newparentid != null)
this.entriesdic.Remove(newparentid.Uri);
if (this.watchuri == id.Uri || this.watchuri == UriUtil.GetParent(id.Uri))
e1 = new ResourceChangedEventArgs((ReturnedInfo) id, ResourceChangedEventArgs.ChangeType.Delete);
if (!(this.watchuri == resourceId.Uri))
{
if (!(this.watchuri == UriUtil.GetParent(resourceId.Uri)))
goto label_25;
}
e2 = new ResourceChangedEventArgs(re, ResourceChangedEventArgs.ChangeType.Create);
}
label_25:
if (e1 != null)
{
CacheManager.ResourceChangedEventHandler resourceChangedEvent = this.ResourceChangedEvent;
if (resourceChangedEvent != null)
resourceChangedEvent((object) this, e1);
}
if (e2 != null)
{
CacheManager.ResourceChangedEventHandler resourceChangedEvent = this.ResourceChangedEvent;
if (resourceChangedEvent != null)
resourceChangedEvent((object) this, e2);
}
return re;
}
public ReturnedInfo Copy(FsBase fs, ResourceId id, ResourceId newparentid, string newname, bool overwrite)
{
ReturnedInfo re;
try
{
re = fs.Copy(id, newparentid, newname, overwrite);
}
catch (RemoteResourceNotFoundException ex)
{
ProjectData.SetProjectError((Exception) ex);
lock (this.infodic)
this.InnerUpdateNotFound(id.Uri);
throw;
}
ResourceInfo resourceInfo = re as ResourceInfo;
ResourceId resourceId = resourceInfo != null ? resourceInfo.Id : re as ResourceId;
ResourceChangedEventArgs e = (ResourceChangedEventArgs) null;
lock (this.infodic)
{
if (resourceInfo != null)
{
if (this.infodic.ContainsKey(resourceInfo.Id.Uri))
this.infodic[resourceInfo.Id.Uri] = resourceInfo;
else
this.infodic.Add(resourceInfo.Id.Uri, resourceInfo);
if ((object) newparentid != null && this.entriesdic.ContainsKey(newparentid.Uri))
{
if (this.entriesdic[newparentid.Uri].Contains(resourceInfo.Id.Uri))
this.entriesdic[newparentid.Uri].Remove(resourceInfo.Id.Uri);
this.entriesdic[newparentid.Uri].Add(resourceInfo.Id.Uri);
}
}
else if ((object) newparentid != null)
this.entriesdic.Remove(newparentid.Uri);
if (!(this.watchuri == resourceId.Uri))
{
if (!(this.watchuri == UriUtil.GetParent(resourceId.Uri)))
goto label_20;
}
e = new ResourceChangedEventArgs(re, ResourceChangedEventArgs.ChangeType.Create);
}
label_20:
if (e != null)
{
CacheManager.ResourceChangedEventHandler resourceChangedEvent = this.ResourceChangedEvent;
if (resourceChangedEvent != null)
resourceChangedEvent((object) this, e);
}
return re;
}
public ReturnedInfo SetResourceInfo(FsBase fs, ResourceInfo newinfo, ResourceInfo originalinfo)
{
ReturnedInfo returnedInfo;
try
{
returnedInfo = fs.SetResourceInfo(newinfo, originalinfo);
}
catch (RemoteResourceNotFoundException ex)
{
ProjectData.SetProjectError((Exception) ex);
lock (this.infodic)
this.InnerUpdateNotFound(originalinfo.Id.Uri);
throw;
}
ResourceInfo resourceInfo = returnedInfo as ResourceInfo;
ResourceId resourceId = resourceInfo != null ? resourceInfo.Id : returnedInfo as ResourceId;
ResourceChangedEventArgs e = (ResourceChangedEventArgs) null;
lock (this.infodic)
{
if (resourceInfo != null)
{
if (this.infodic.ContainsKey(resourceInfo.Id.Uri))
this.infodic[resourceInfo.Id.Uri] = resourceInfo;
else
this.infodic.Add(resourceInfo.Id.Uri, resourceInfo);
}
else
this.infodic.Remove(resourceId.Uri);
if (!(this.watchuri == originalinfo.Id.Uri))
{
if (!(this.watchuri == UriUtil.GetParent(originalinfo.Id.Uri)))
goto label_15;
}
e = new ResourceChangedEventArgs((ReturnedInfo) originalinfo.Id, ResourceChangedEventArgs.ChangeType.PropertyChange);
}
label_15:
if (e != null)
{
CacheManager.ResourceChangedEventHandler resourceChangedEvent = this.ResourceChangedEvent;
if (resourceChangedEvent != null)
resourceChangedEvent((object) this, e);
}
return returnedInfo;
}
public ReturnedInfo SetTimes(FsBase fs, ResourceId id, DateTime lastmodifiedtime, DateTime creationtime, DateTime lastaccesstime)
{
ReturnedInfo re;
try
{
re = fs.SetTimes(id, lastmodifiedtime, creationtime, lastaccesstime);
}
catch (RemoteResourceNotFoundException ex)
{
ProjectData.SetProjectError((Exception) ex);
lock (this.infodic)
this.InnerUpdateNotFound(id.Uri);
throw;
}
ResourceInfo resourceInfo = re as ResourceInfo;
ResourceId resourceId = resourceInfo != null ? resourceInfo.Id : re as ResourceId;
ResourceChangedEventArgs e = (ResourceChangedEventArgs) null;
lock (this.infodic)
{
if (resourceInfo != null)
{
if (this.infodic.ContainsKey(resourceInfo.Id.Uri))
this.infodic[resourceInfo.Id.Uri] = resourceInfo;
else
this.infodic.Add(resourceInfo.Id.Uri, resourceInfo);
}
else
this.infodic.Remove(resourceId.Uri);
if (!(this.watchuri == id.Uri))
{
if (!(this.watchuri == UriUtil.GetParent(id.Uri)))
goto label_15;
}
e = new ResourceChangedEventArgs(re, ResourceChangedEventArgs.ChangeType.PropertyUpdate);
}
label_15:
if (e != null)
{
CacheManager.ResourceChangedEventHandler resourceChangedEvent = this.ResourceChangedEvent;
if (resourceChangedEvent != null)
resourceChangedEvent((object) this, e);
}
return re;
}
public Stream OpenRead(FsBase fs, Uri targeturi)
{
return fs.OpenRead(targeturi);
}
public Stream OpenRead(FsBase fs, ResourceId id, ref long start, ref long length)
{
return fs.OpenRead(id, ref start, ref length);
}
public Stream OpenWrite(FsBase fs, ResourceId parentid, string name, long length)
{
return fs.OpenWrite(parentid, name, length);
}
public Stream OpenWriteOver(FsBase fs, ResourceId id, long length)
{
return fs.OpenWriteOver(id, length);
}
public Stream OpenWriteResume(FsBase fs, ResourceId id, ref long start, ref long length)
{
return fs.OpenWriteResume(id, ref start, ref length);
}
public ReturnedInfo CloseWrite(FsBase fs, Stream st)
{
ReturnedInfo re = fs.CloseWrite(st);
ResourceInfo resourceInfo = re as ResourceInfo;
ResourceId resourceId = resourceInfo != null ? resourceInfo.Id : re as ResourceId;
ResourceChangedEventArgs e = (ResourceChangedEventArgs) null;
lock (this.infodic)
{
Uri parent = UriUtil.GetParent(resourceId.Uri);
if (resourceInfo != null)
{
if (this.infodic.ContainsKey(resourceInfo.Id.Uri))
this.infodic[resourceInfo.Id.Uri] = resourceInfo;
else
this.infodic.Add(resourceInfo.Id.Uri, resourceInfo);
if (!this.entriesdic.ContainsKey(parent))
this.entriesdic.Add(parent, new List<Uri>());
if (this.entriesdic[parent].Contains(resourceInfo.Id.Uri))
this.entriesdic[parent].Remove(resourceInfo.Id.Uri);
this.entriesdic[parent].Add(resourceInfo.Id.Uri);
}
else
this.entriesdic.Remove(parent);
if (!(this.watchuri == resourceId.Uri))
{
if (!(this.watchuri == UriUtil.GetParent(resourceId.Uri)))
goto label_15;
}
e = new ResourceChangedEventArgs(re, ResourceChangedEventArgs.ChangeType.Create);
}
label_15:
if (e != null)
{
CacheManager.ResourceChangedEventHandler resourceChangedEvent = this.ResourceChangedEvent;
if (resourceChangedEvent != null)
resourceChangedEvent((object) this, e);
}
return re;
}
private void InnerUpdateNotFound(Uri target)
{
Uri parent = UriUtil.GetParent(target);
this.infodic.Remove(target);
if (!this.entriesdic.ContainsKey(parent) || !this.entriesdic[parent].Contains(target))
return;
this.entriesdic.Remove(parent);
}
private ResourceInfo[] InnerFindInfoAndEntries(Uri target)
{
if (!this.infodic.ContainsKey(target) || !this.entriesdic.ContainsKey(target))
return (ResourceInfo[]) null;
List<ResourceInfo> resourceInfoList = new List<ResourceInfo>();
resourceInfoList.Add(this.infodic[target]);
int num1 = 0;
int num2 = checked (this.entriesdic[target].Count - 1);
int index = num1;
while (index <= num2)
{
if (!this.infodic.ContainsKey(this.entriesdic[target][index]))
return (ResourceInfo[]) null;
resourceInfoList.Add(this.infodic[this.entriesdic[target][index]]);
checked { ++index; }
}
return resourceInfoList.ToArray();
}
private void InnerUpdateInfoAndEntries_Success(ResourceInfo[] ris)
{
Uri parent = UriUtil.GetParent(ris[0].Id.Uri);
if (this.infodic.ContainsKey(ris[0].Id.Uri))
this.infodic[ris[0].Id.Uri] = ris[0];
else
this.infodic.Add(ris[0].Id.Uri, ris[0]);
if (this.entriesdic.ContainsKey(parent) && !this.entriesdic[parent].Contains(ris[0].Id.Uri))
this.entriesdic.Remove(parent);
if (this.entriesdic.ContainsKey(ris[0].Id.Uri))
this.entriesdic[ris[0].Id.Uri].Clear();
else
this.entriesdic.Add(ris[0].Id.Uri, new List<Uri>());
int num1 = 1;
int num2 = checked (ris.Length - 1);
int index = num1;
while (index <= num2)
{
this.entriesdic[ris[0].Id.Uri].Add(ris[index].Id.Uri);
if (this.infodic.ContainsKey(ris[index].Id.Uri))
this.infodic[ris[index].Id.Uri] = ris[index];
else
this.infodic.Add(ris[index].Id.Uri, ris[index]);
checked { ++index; }
}
}
private void InnerUpdateInfoAndEntries_NotFound(Uri targeturi)
{
Uri parent = UriUtil.GetParent(targeturi);
if (this.infodic.ContainsKey(targeturi))
this.infodic.Remove(targeturi);
if (this.entriesdic.ContainsKey(parent) && this.entriesdic[parent].Contains(targeturi))
this.entriesdic.Remove(targeturi);
if (!this.entriesdic.ContainsKey(targeturi))
return;
int num1 = 0;
int num2 = checked (this.entriesdic[targeturi].Count - 1);
int index = num1;
while (index <= num2)
{
this.infodic.Remove(this.entriesdic[targeturi][index]);
checked { ++index; }
}
this.entriesdic.Remove(targeturi);
}
private void InnerDiscardInfo(Uri targeturi)
{
this.infodic.Remove(targeturi);
}
private void InnerDiscardList(Uri targeturi)
{
this.entriesdic.Remove(targeturi);
}
public delegate void ResourceChangedEventHandler(object sender, ResourceChangedEventArgs e);
}
}