Please remember this is a work in progress. Home » Classes

Classes

 

TIWAppCache

 

This class was introduced in IntraWeb XIV and is responsible for creation of application cache files. All public methods are class methods, so this class does not need to be instantiated.

Unit

IWAppCache

Class hierarchy

TObject -> TIWAppCache

Methods

NewCacheStream [Public]

Declaration: class procedure NewCacheStream(Sender: TObject; const AContentType: string; ACacheType: TCacheType; out ACacheStream: TCacheStream; out AFileHRef: string);

Description: General method for cache stream creation.

Parameters:

  • Sender (TObject): May have one of these values
    • If you are creating a Form cache file, Sender must be an instance of TIWForm class.
    • If you are creating a Session cache file, Sender must be an instance of TIWApplication class, or TIWForm class
    • If you are creating an Application cache file, this parameter is ignored, so NIL may be used.
  • AContentType (string): Content type of the stream.
  • ACacheType (TCacheType): Type of cache that will be used. See TCacheType definition.
  • out ACacheStream (TCacheStream): The TCacheStream created.
  • out AFileHRef (string): Contains the URL of the cache file.

NewAppCacheStream [Public]

Declaration: class procedure NewAppCacheStream(Sender: TObject; const AContentType: string; out ACacheStream: TCacheStream; out AFileHRef: string);

Description: General method for application (or global) cache file creation.

Parameters:

  • Sender (TObject): Ignored for this method.
  • AContentType (string): Content type of the stream.
  • out ACacheStream (TCacheStream): The TCacheStream created.
  • out AFileHRef (string): Contains the URL of the cache file.

NewSessionCacheStream [Public]

Declaration: class procedure NewSessionCacheStream(Sender: TObject; const AContentType: string; out ACacheStream: TCacheStream; out AFileHRef: string);

Description: General method for session cache file creation.

Parameters:

  • Sender (TObject): Sender must be an instance of TIWApplication class, or TIWForm class
  • AContentType (string): Content type of the stream.
  • out ACacheStream (TCacheStream): Stream whose content will be saved into the cache file.
  • out AFileHRef (string): Contains the URL of the cache file.

NewFormCacheStream [Public]

Declaration: class procedure NewFormCacheStream(Sender: TObject; const AContentType: string; out ACacheStream: TCacheStream; out AFileHRef: string);

Description: General method for form cache file creation.

Parameters:

  • Sender (TObject): an instance of TIWForm class, the owner of the cache file.
  • AContentType (string): Content type of the stream.
  • out ACacheStream (TCacheStream): Stream whose content will be saved into the cache file.
  • out AFileHRef (string): Contains the URL of the cache file.

StreamToCacheFile [Public]

Declaration: class function StreamToCacheFile(Sender: TObject; AStream: TStream; const AContentType: string; const ACacheType: TCacheType = ctSession): string;

Description: Creates a new cache file and save AStream content into it.

Parameters:

  • Sender (TObject): May have one of these values
    • If you are creating a Form cache file, Sender must be an instance of TIWForm class.
    • If you are creating a Session cache file, Sender must be an instance of TIWApplication class, or TIWForm class
    • If you are creating an Application cache file, this parameter is ignored, so NIL may be used.
  • AStream (TStream): Stream whose content will be saved into the cache file.
  • AContentType (string): Content type of the stream.
  • ACacheType (TCacheType, default ctSession): Type of cache that will be used. See TCacheType definition.

Result: (string) Contains the URL of the cache file.

Example:

uses
  IWAppCache,      // TIWAppCache
  IW.CacheStream,  // needed because of ACacheType
  Windows;         // needed because of RT_RCDATA reference

procedure TIWForm6.IWAppFormCreate(Sender: TObject);
var
  MyStream: TStream;
  HRef: string;
  xResName: string;
begin
  xResName := 'MYIMAGEFILE';
  // get the resource stream containing the image I want to show
  MyStream := TResourceStream.Create(0, PChar(xResName), RT_RCDATA);
  try
    // then create a new cache file and save the image to it. 
    //This cache file will be "alive" during the whole user session (ACacheType = ctSession)
    // this function returns the URL to the cache file.
    // We could also use other methods of TIWAppCache
    HRef := TIWAppCache.StreamToCacheFile(Self, MyStream, 'image/gif', ctSession);
    // Set URL of IWImageFile1 with the value returned by TIWAppCache.StreamToCacheFile
    IWImageFile1.ImageFile.URL := HRef;
  finally
    MyStream.Free;
  end;
end;

GraphicToCacheFile [Public]

Declaration: class function GraphicToCacheFile(Sender: TObject; AGraphic: TGraphic; const ACacheType: TCacheType = ctSession; const PreferPNG: boolean = True): string; overload;

Description: Creates a new cache file and writes AGraphic content to it. Image conversion may also be performed.

Parameters:

  • Sender (TObject): May have one of these values
    • If you are creating a Form cache file, Sender must be an instance of TIWForm class.
    • If you are creating a Session cache file, Sender must be an instance of TIWApplication class, or TIWForm class
    • If you are creating an Application cache file, this parameter is ignored, so NIL may be used.
  • AGraphic (TGraphic): The instance of the graphic image to be saved to the cache file.
  • ACacheType (TCacheType, default ctSession): Type of cache that will be used. See TCacheType definition.
  • PreferPNG (Boolean, default True): If False, the generated output file will have the same image format of AGraphic, otherwise it will be converted to PNG if required.

Result: (string) Contains the URL of the cache file.


GraphicToCacheFile [Public]

Declaration: class function GraphicToCacheFile(Sender: TObject; AGraphic: TGraphic; imgType :TIWImageOutput; const ACacheType: TCacheType = ctSession): string; overload;

Description: Creates a new cache file and writes AGraphic content to it. Image conversion may also be performed.

Parameters:

  • Sender (TObject): May have one of these values
    • If you are creating a Form cache file, Sender must be an instance of TIWForm class.
    • If you are creating a Session cache file, Sender must be an instance of TIWApplication class, or TIWForm class
    • If you are creating an Application cache file, this parameter is ignored, so NIL may be used.
  • AGraphic (TGraphic): The instance of the graphic image to be saved to the cache file.
  • imgType (TIWImageOutput): Type of image format used for output. See TIWImageOutput definition.
  • ACacheType (TCacheType): Type of cache that will be used. See TCacheType definition.

Result: (string) Contains the URL of the cache file.


ClearCache [Public]

Declaration: class function ClearCache(ACacheList: TStrings): Integer;

Description: Delete all files from ACacheList and remove the reference from the list. This method is used internally by IntraWeb. There is seldom, if ever, any reason to call this method directly.

Parameters:

  • ACacheList (TStrings): List of files in cache.

Result: (Integer) Returns zero if all files are deleted, or the number of files not deleted.


 

Terms of Use | Privacy Statement © 2002 - 2024 Atozed Software