Beispiel #1
0
        /// <summary>
        /// Loads the cached instance or creates new object
        /// </summary>
        /// <param name="instanceID">The instance identifier.</param>
        /// <returns></returns>
        public T loadObjectCacheOrNew(String instanceID)
        {
            cacheResponseForType <T> output = loadObjectCacheAndMeta(instanceID, true);

            output.getCacheFromHarddisk <T>(hourslimit, customSubdirectory);

            return((T)output.instance);
        }
Beispiel #2
0
        /// <summary>
        /// Loads the cache file for the <c>instanceID</c> if file jounger than <c>limithours</c>
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="instanceID">The instance identifier.</param>
        /// <param name="limithours">The limithours.</param>
        /// <param name="directory">The directory.</param>
        /// <returns></returns>
        public static cacheResponseForType loadObjectCache <T>(String instanceID, Int32 limithours, folderNode directory) where T : class, new()
        {
            cacheResponseForType <T> output = new cacheResponseForType <T>(instanceID, directory);

            try
            {
                output.getCacheFromHarddisk <T>(limithours);
            }
            catch (Exception ex)
            {
                // aceLog.log(ex, "cacheSystem (" + instanceID + ") loadObjectCache()", logType.CriticalWarning);
                throw;
            }
            return(output);
        }
Beispiel #3
0
        /// <summary>
        /// Loads the object cached values to target.
        /// </summary>
        /// <param name="target">The target.</param>
        /// <param name="instanceID">The instance identifier.</param>
        /// <returns></returns>
        public cacheResponseForType <T> loadObjectCachedValuesToTarget(T target, String instanceID = "")
        {
            if (instanceID.isNullOrEmpty())
            {
                instanceID = getInstanceID(target);
            }

            cacheResponseForType <T> output = loadObjectCacheAndMeta(instanceID, false);

            if (output.cacheInstanceLoaded)
            {
                target.setObjectBySource(output.instance);
            }
            return(output);
        }
Beispiel #4
0
        /// <summary>
        /// Loads the object cache and meta returns all meta information
        /// </summary>
        /// <param name="instanceID">The instance identifier.</param>
        /// <param name="createNewIfNotFound">if set to <c>true</c> [create new if not found].</param>
        /// <returns></returns>
        public cacheResponseForType <T> loadObjectCacheAndMeta(String instanceID, Boolean createNewIfNotFound = false)
        {
            instanceID = instanceID.ensureEndsWith(typeInfo.GetSignature());

            cacheResponseForType <T> output = new cacheResponseForType <T>(instanceID, directory, createNewIfNotFound);

            if (cacheLoadDisabled)
            {
                output.getCacheFromHarddisk <T>(0, "_loadDisabled for [" + typeof(T).Name + "]");
            }
            else
            {
                output.getCacheFromHarddisk <T>(hourslimit, customSubdirectory);
            }

            return(output);
        }