public T Request(CacheFlags source, string url, params string[] args) { return(this.Request( source, new Uri(url), args)); }
public Cache(CacheMedium medium, CacheStrategy strategy, CacheFlags flags) { m_Strategy = strategy; m_Medium = medium; m_Flags = flags; }
// Convenience constructors // public Cache() { m_Strategy = CacheStrategy.Balanced; m_Medium = CacheMedium.Memory; m_Flags = 0; m_nextExpire = DateTime.UtcNow + m_expiresTime; m_Strategy = CacheStrategy.Aggressive; }
/// <summary> /// Set cache flag in entity /// </summary> /// <param name="cacheFlag">Cache flag to set</param> /// <param name="value">Cache flag value to set</param> private void SetCacheFlag(CacheFlags cacheFlag, bool value) { if (value) { this.CacheFlags |= cacheFlag; } else { this.CacheFlags &= ~cacheFlag; } }
public T Request(CacheFlags source, Uri uri, params string[] args) { if (args.Length == 0) { throw new ArgumentException("expecting at least 1 argument"); } // Read cache entry, if any. var ce = this.CacheTarget.Retrieve(args); var obj = default(T); if ((source.HasFlag(CacheFlags.ReadCache) && !ce.IsExpired && ce.Data != null)) { // Cache entry appears to be valid. obj = Xml.Deserialize <T>(ce.ToStream(), true); if (obj != null) { return(obj); } } if (source.HasFlag(CacheFlags.ReadLive)) { if (args.Length > 0) { uri = new Uri(String.Format(uri.ToString(), args)); } obj = Xml.Deserialize <T>(uri); if (obj != null) { if (source.HasFlag(CacheFlags.WriteCache)) { this.Cache(obj, args); } return(obj); } } // Retreive old copy from cache if (obj == null && (source.HasFlag(CacheFlags.ReadExpired))) { obj = Xml.Deserialize <T>(ce.ToStream(), true); return(obj); } // Finally, return the object return(obj); }
/////////////////////////////////////////////////////////////////////// #if ARGUMENT_CACHE || LIST_CACHE || PARSE_CACHE || EXECUTE_CACHE || TYPE_CACHE || COM_TYPE_CACHE public static bool HasFlags( CacheFlags flags, CacheFlags hasFlags, bool all ) { if (all) { return((flags & hasFlags) == hasFlags); } else { return((flags & hasFlags) != CacheFlags.None); } }
public Cache(CacheFlags flags) : this(CacheMedium.Memory, CacheStrategy.Balanced, flags) { }
public Cache(CacheStrategy strategy, CacheFlags flags) : this(CacheMedium.Memory, strategy, flags) { }
public Cache(CacheMedium medium, CacheFlags flags) : this(medium, CacheStrategy.Balanced, flags) { }
public static extern int GetCachePath( CacheFlags assemblyCacheFlags, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder cachePath, ref int cachePathSize);
// Convenience constructors // public Cache() { m_Strategy = CacheStrategy.Balanced; m_Medium = CacheMedium.Memory; m_Flags = 0; }
/////////////////////////////////////////////////////////////////////// #region IExecute Members public override ReturnCode Execute( Interpreter interpreter, IClientData clientData, ArgumentList arguments, ref Result result ) { if (interpreter == null) { result = "invalid interpreter"; return(ReturnCode.Error); } if (arguments == null) { result = "invalid argument list"; return(ReturnCode.Error); } if (arguments.Count < 2) { result = "wrong # args: should be \"source ?options? fileName\""; return(ReturnCode.Error); } ReturnCode code = ReturnCode.Ok; OptionDictionary options = new OptionDictionary( new IOption[] { new Option(null, OptionFlags.MustHaveEncodingValue, Index.Invalid, Index.Invalid, "-encoding", null), new Option(null, OptionFlags.MustHaveBooleanValue, Index.Invalid, Index.Invalid, "-withinfo", null), new Option(null, OptionFlags.None, Index.Invalid, Index.Invalid, Option.EndOfOptions, null) }); int argumentIndex = Index.Invalid; if (arguments.Count > 2) { if (interpreter.GetOptions( options, arguments, 0, 1, Index.Invalid, false, ref argumentIndex, ref result) != ReturnCode.Ok) { return(ReturnCode.Error); } } else { argumentIndex = 1; } if ((argumentIndex == Index.Invalid) || ((argumentIndex + 1) != arguments.Count)) { if ((argumentIndex != Index.Invalid) && Option.LooksLikeOption(arguments[argumentIndex])) { result = OptionDictionary.BadOption( options, arguments[argumentIndex]); } else { result = "wrong # args: should be \"source ?options? fileName\""; } return(ReturnCode.Error); } Variant value = null; Encoding encoding = null; if (options.IsPresent("-encoding", ref value)) { encoding = (Encoding)value.Value; } bool withInfo = false; if (options.IsPresent("-withinfo", ref value)) { withInfo = (bool)value.Value; } if (code == ReturnCode.Ok) { string name = StringList.MakeList( "source", arguments[argumentIndex]); ICallFrame frame = interpreter.NewTrackingCallFrame( name, CallFrameFlags.Source); interpreter.PushAutomaticCallFrame(frame); try { #if ARGUMENT_CACHE CacheFlags savedCacheFlags = CacheFlags.None; if (withInfo) { interpreter.BeginNoArgumentCache( ref savedCacheFlags); } try { #endif #if DEBUGGER && BREAKPOINTS InterpreterFlags savedInterpreterFlags = InterpreterFlags.None; if (withInfo) { interpreter.BeginArgumentLocation( ref savedInterpreterFlags); } try { #endif code = interpreter.EvaluateFile( encoding, arguments[argumentIndex], ref result); #if DEBUGGER && BREAKPOINTS } finally { if (withInfo) { interpreter.EndArgumentLocation( ref savedInterpreterFlags); } } #endif #if ARGUMENT_CACHE } finally { if (withInfo) { interpreter.EndNoArgumentCache( ref savedCacheFlags); } } #endif } finally { // // NOTE: Pop the original call frame that we pushed above // and any intervening scope call frames that may be // leftover (i.e. they were not explicitly closed). // /* IGNORED */ interpreter.PopScopeCallFramesAndOneMore(); } } return(code); }
public static extern int GetCachePath( CacheFlags assemblyCacheFlags, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder cachePath, ref int cachePathSize);
public static extern HResult CreateAssemblyEnum(out IAssemblyEnum pEnum, IApplicationContext pAppCtx, IAssemblyName pName, CacheFlags dwFlags, IntPtr pvReserved);
/// <summary> /// Returns a value indicating whether cache flag is set /// </summary> /// <param name="cacheFlag">Cache flag to query</param> /// <returns>A value indicating whether cache flag is set</returns> private bool HasCacheFlag(CacheFlags cacheFlag) { return(this.CacheFlags.HasFlag(cacheFlag)); }