Ejemplo n.º 1
0
        public EmbeddedResource GetResourceFromVirtualPath(string virtualPath)
        {
            var path  = VirtualPathUtility.ToAppRelative(virtualPath).TrimStart('~', '/');
            var index = path.LastIndexOf("/", StringComparison.InvariantCultureIgnoreCase);

            if (index != -1)
            {
                var folder = path.Substring(0, index).Replace("-", "_"); //embedded resources with "-"in their folder names are stored as "_".
                path = folder + path.Substring(index);
            }
            var cleanedPath = path.Replace('/', '.');
            var key         = (cleanedPath).ToUpperInvariant();

            if (resources.ContainsKey(key))
            {
                var resource = UseResource.Invoke(resources[key])
                    ? resources[key]
                    : null;

                if (resource != null && !ShouldUsePrevious(virtualPath, resource))
                {
                    return(resource);
                }
            }
            return(null);
        }
Ejemplo n.º 2
0
 public LockProcess(uint crc, ILockObject locker, UseResource res)
 {
     this._locker = locker;
     this._crc    = crc;
     Task.Run(() => Unlock());
     this._locker.Lock(this._crc);
     this._res = res;
     this._res.Increment();
 }