/// <summary>Create and Initialize PersistentOnlyCacheManager instance with parameters.</summary>
 /// <param name="disableEncryption">if true, cached files will not be encrypted/decrypted to/from persistent storage.</param>
 /// <param name="encryptionKey">encryption key with which cache files will be encrypted/decrypted.</param>
 /// <returns>PersistentOnlyCacheManager instance</returns>
 internal static PersistentOnlyCacheManager CreateInstance(bool disableEncryption, byte[] encryptionKey)
 {
     lock (typeof(PersistentOnlyCacheManager))
     {
         if (_instance == null)
         {
             _instance = new PersistentOnlyCacheManager(disableEncryption, encryptionKey);
         }
     }
     return(_instance);
 }
 /// <summary>
 /// Create empty (not initialized) instance of PersistentOnlyCacheManager.
 /// This instance should be used for accessing the HTTP/cache manager functionality in case the execution properties are not yet known
 /// (and therefore cannot be used to initialize the cache manager) - currently the only such special case is accessing the publish.html file(ClickOnce),
 /// yet this CreateInstance and empty CTOR are not and should not be specific to ClickOnce in any way.
 /// </summary>
 /// <returns>PersistentOnlyCacheManager instance</returns>
 internal static PersistentOnlyCacheManager CreateInstance()
 {
     lock (typeof(PersistentOnlyCacheManager))
     {
         if (_instance == null)
         {
             _instance = new PersistentOnlyCacheManager();
         }
     }
     return(_instance);
 }
        /// <summary>
        /// return (using the two 'out' parameters) the server-side and client-side file names for a given request to retrieve a cached file.
        /// </summary>
        /// <param name="completeCachedFileRetrievalURL">complete cached file retrieval request (including the server-side time stamp),
        /// e.g. http://[server]/[requester]?CTX=&CACHE=MG1VAI3T_MP_0$$$_$_$_N02400$$$$G8FM01_.xml|31/07/2013%2020:15:15</param>
        /// <param name="cachedFileServerFileName">the cached file name on the server, e.g. MG1VAI3T_MP_0$$$_$_$_N02400$$$$G8FM01_.xml</param>
        /// <param name="cachedFileLocalFileName">the cached file name in the client, e.g. C:\Users\[user]\AppData\Local\Temp\MgxpaRIACache\[server]\MG1VAI3T_MP_0$$$_$_$_N02400$$$$G8FM01_.xml</param>
        internal void CompleteCacheRequestURLToFileNames(string completeCachedFileRetrievalURL,
                                                         out string cachedFileServerFileName,
                                                         out string cachedFileLocalFileName)
        {
            // discard the time stamp, leaving only 'cachedFileRetrievalURL', e.g.
            string[] urlAndRemoteTimePair   = HttpUtility.UrlDecode(completeCachedFileRetrievalURL, Encoding.UTF8).Split('|');
            String   cachedFileRetrievalURL = urlAndRemoteTimePair[0]; // the cached file retrieval request without the timestamp, e.g. http://[server]/[requester]?CTX=&CACHE=MG1VAI3T_MP_0$$$_$_$_N02400$$$$G8FM01_.xml

            // get 'cachedFileServerFileName' (i.e. server-side, see the example in the method's comment)  from 'cachedFileRetrievalURL', e.g.
            const string precedingString = "&" + ConstInterface.RC_TOKEN_CACHED_FILE;
            int          pathStartIndex  = cachedFileRetrievalURL.IndexOf(precedingString) + precedingString.Length;

            cachedFileServerFileName = cachedFileRetrievalURL.Substring(pathStartIndex);
            Debug.Assert(cachedFileServerFileName != null);

            // get 'cachedFileLocalFileName' (i.e. client-side, see the example in the method's comment) from 'cachedFileRetrievalURL'
            cachedFileLocalFileName = PersistentOnlyCacheManager.GetInstance().URLToLocalFileName(CacheUtils.URLToFileName(cachedFileRetrievalURL));
        }
 /// <summary>
 /// </summary>
 internal static void DeleteInstance()
 {
     _instance = null;
 }
Exemple #5
0
        /// <summary>convert an HTTP URL to a file name in the cache</summary>
        /// <param name="url"></param>
        internal static String URLToLocalFileName(String url)
        {
            String relativeFileName = URLToFileName(HttpUtility.UrlDecode(url, Encoding.UTF8));

            return(PersistentOnlyCacheManager.GetInstance().URLToLocalFileName(relativeFileName));
        }
Exemple #6
0
        /// <summary> Converts a server file path into the local cached file path
        /// eg. c:\serverfiles\a.jpg --> <cached folder>\c__serverfiles_a.jpg
        /// </summary>
        /// <param name="serverFileName"></param>
        /// <returns></returns>
        internal static String ServerFileToLocalFileName(String serverFileName)
        {
            String fileName = ServerFilePathToFileName(serverFileName);

            return(PersistentOnlyCacheManager.GetInstance().URLToLocalFileName(fileName));
        }