C# Class SIL.FieldWorks.FDO.Infrastructure.FdoMetaDataCacheDecoratorBase

Implementation of the IFwMetaDataCacheManaged interface which works with a stateful FDO system for most data issues. For cases where there is a need to store 'fake' data (i.e., not properties of CmObjects), clients should subclass this class and override the relevant methods and read/write that fake meta data in their own internal caches. They should pass the request through to the FdoMetaDataCache (IFwMetaDataCacheManaged) for regular metadata access.
Inheritance: IFwMetaDataCacheManaged
Show file Open project: sillsdev/FieldWorks

Public Methods

Method Description
AddVirtualProp ( string bstrClass, string bstrField, int luFlid, int type ) : void

A virtual property. The type can be one of the original types, or any other made up type.

This method must be overridden by subclasses, so they can add non-model properties.

ClassExists ( string className ) : bool

Pass it on by default.

FieldExists ( int flid ) : bool

Return true if the specified field exists.

FieldExists ( int classId, string fieldName, bool includeBaseClasses ) : bool

Pass it on by default.

FieldExists ( string className, string fieldName, bool includeBaseClasses ) : bool

Pass it on by default.

GetAbstract ( int luClid ) : bool

Indicates whether a class is abstract or concrete.

GetAllSubclasses ( int luClid, int cluMax, int &_cluOut, SIL.FieldWorks.Common.COMInterfaces.ArrayPtr _rgluSubclasses ) : void

Gets all subclasses of the given class, including itself (which is always the first result in the list, so it can easily be skipped if desired). The list is therefore a complete list of the classes which are valid to store in a property whose signature is the class identified by luClid.

GetBaseClsId ( int luClid ) : int

Gets the base class id for a given class.

GetBaseClsName ( int luClid ) : string

Gets the name of the base class for a given class.

GetClassId ( string bstrClassName ) : int

:>:> Reverse access methods :> Get the ID of the class having the specified name. Returns 0 if not found.

GetClassIds ( int cclid, SIL.FieldWorks.Common.COMInterfaces.ArrayPtr rgclid ) : void

Gets the list of class identification numbers (in no particular order). If the array provided is too small, only an arbitrary subset of cclid values is returned. If the array provided is too large, the excess entries are set to zero.

GetClassName ( int luClid ) : string

Gets the name of the class.

GetDirectSubclasses ( int luClid, int cluMax, int &_cluOut, SIL.FieldWorks.Common.COMInterfaces.ArrayPtr _rgluSubclasses ) : void

Gets the direct subclasses of the given class (not including itself).

GetDstClsId ( int luFlid ) : int

Gets the "Id" of the destination class that corresponds to this field. This is the "Id" of the class that is either owned or referred to by another class.

GetDstClsName ( int luFlid ) : string

Gets the name of the destination class that corresponds to this field. This is the name of the class that is either owned or referred to by another class.

GetFieldHelp ( int luFlid ) : string

Gets the help string of a field.

GetFieldId ( string bstrClassName, string bstrFieldName, bool fIncludeBaseClasses ) : int

Gets the field ID given the class and field names. Returns 0 if not found. Searches superclasses as well as actual class given.

GetFieldId2 ( int luClid, string bstrFieldName, bool fIncludeBaseClasses ) : int

This is more efficient if the client already has the classID specified classID and field name. Returns 0 if not found. Searches superclasses as well as actual class given.

GetFieldIds ( int cflid, SIL.FieldWorks.Common.COMInterfaces.ArrayPtr rgflid ) : void

Gets the list of field identification numbers (in no particular order). If the array provided is too small, only an arbitrary set of cflid values is returned. If the array provided is too large, the excess entries are set to zero.

GetFieldLabel ( int luFlid ) : string

Gets the user label of a field.

GetFieldListRoot ( int luFlid ) : System.Guid

Gets the listRoot of the field.

GetFieldName ( int luFlid ) : string

Gets the name of a field.

GetFieldNameOrNull ( int luFlid ) : string

Gets the name of a field.

GetFieldType ( int luFlid ) : int

Gets the type of the field. This value indicates if the field is a primitive data type or a MultiStr/MultiTxt value or describes the relationship between two classes (i.e. owning/reference and atomic/collection/sequence). These numeric values are defined in the ~FWROOT\src\cellar\lib\CmTypes.h file.

GetFieldWs ( int luFlid ) : int

Gets the Ws of the field.

GetFieldXml ( int luFlid ) : string

Gets the Xml UI of a field.

GetFields ( int luClid, bool fIncludeSuperclasses, int grfcpt, int cflidMax, SIL.FieldWorks.Common.COMInterfaces.ArrayPtr _rgflid ) : int

Gets a list of the fields for the specified class. Gets all fields whose types match the specified argument, which should be a combination of the fcpt values defined in CmTypes.h, e.g., to get all owning properties pass kfcptOwningCollection | kfcptOwningAtom | kfcptOwningSequence. Returns E_FAIL if the array is too small. cflidMax 0 may be passed to obtain the required size. Fields of superclasses are also returned, if the relevant flag is true. [Note: The special CmObject fields are not returned, for now, but the plan to include them before too long.]

GetIncomingFields ( int clid, int fieldTypes ) : IEnumerable

Pass it on. Only real fields are interesting here.

GetOwnClsId ( int luFlid ) : int

Gets the "Id" value of the class that contains this field.

GetOwnClsName ( int luFlid ) : string

Gets the name of the class that contains this field.

InitXml ( string bstrPathname, bool fClearPrevCache ) : void

Alternative way to initialize, passing an XML file (like Ling.cm). <class num="int" id="className" base="baseClassName" abstract="true"> <props> <basic num="int" id="FieldName" sig="Boolean/Integer/Time/String/MultiString/MultiUnicode" /> <rel/owning num="int" id="FieldName" card="atomic/seq/col" sig="classname"/> currently doesn't initialize some less essential stuff like help strings and labels. Set fClearPrevCache to false to read in multiple XML files. Enhance JohnT: support attributes to handle these.

IsValueType ( CellarPropertyType type ) : bool

Returns true for Binary, Boolean, GenDate, Integer and Time

get_IsValidClass ( int luFlid, int luClid ) : bool

Given a field id and a class id, this returns true it it is legal to store this class of object in the field.

get_IsVirtual ( int luFlid ) : bool

Protected Methods

Method Description
FdoMetaDataCacheDecoratorBase ( IFwMetaDataCacheManaged metaDataCache ) : System

Constructor.

The hvo values are true 'handles' in that they are valid for one session, but may not be the same integer for another session for the 'same' object. Therefore, one should not use them for multi-session identity. CmObject identity can only be guaranteed by using their Guids (or using '==' in code).

Private Methods

Method Description
AddCustomField ( string className, string fieldName, CellarPropertyType fieldType, int destinationClass ) : int
AddCustomField ( string className, string fieldName, CellarPropertyType fieldType, int destinationClass, string fieldHelp, int fieldWs, System.Guid fieldListRoot ) : int
DeleteCustomField ( int flid ) : void
GetAllSubclasses ( int clid ) : int[]
GetClassIds ( ) : int[]
GetDirectSubclasses ( int clid ) : int[]
GetFieldIds ( ) : int[]
GetFields ( int clid, bool includeSuperclasses, int fieldTypes ) : int[]
IsCustom ( int flid ) : bool
UpdateCustomField ( int flid, string fieldHelp, int fieldWs, string userLabel ) : void

Method Details

AddVirtualProp() public abstract method

A virtual property. The type can be one of the original types, or any other made up type.
This method must be overridden by subclasses, so they can add non-model properties.
public abstract AddVirtualProp ( string bstrClass, string bstrField, int luFlid, int type ) : void
bstrClass string
bstrField string
luFlid int
type int
return void

ClassExists() public method

Pass it on by default.
public ClassExists ( string className ) : bool
className string
return bool

FdoMetaDataCacheDecoratorBase() protected method

Constructor.
The hvo values are true 'handles' in that they are valid for one session, but may not be the same integer for another session for the 'same' object. Therefore, one should not use them for multi-session identity. CmObject identity can only be guaranteed by using their Guids (or using '==' in code).
protected FdoMetaDataCacheDecoratorBase ( IFwMetaDataCacheManaged metaDataCache ) : System
metaDataCache IFwMetaDataCacheManaged The FDO FdoMetaDataCache implementation, /// which is used to get the basic FDO data.
return System

FieldExists() public method

Return true if the specified field exists.
public FieldExists ( int flid ) : bool
flid int
return bool

FieldExists() public method

Pass it on by default.
public FieldExists ( int classId, string fieldName, bool includeBaseClasses ) : bool
classId int
fieldName string
includeBaseClasses bool
return bool

FieldExists() public method

Pass it on by default.
public FieldExists ( string className, string fieldName, bool includeBaseClasses ) : bool
className string
fieldName string
includeBaseClasses bool
return bool

GetAbstract() public method

Indicates whether a class is abstract or concrete.
public GetAbstract ( int luClid ) : bool
luClid int Class identification number. In the database, this corresponds to "Id" /// column in the Class$ table.
return bool

GetAllSubclasses() public method

Gets all subclasses of the given class, including itself (which is always the first result in the list, so it can easily be skipped if desired). The list is therefore a complete list of the classes which are valid to store in a property whose signature is the class identified by luClid.
public GetAllSubclasses ( int luClid, int cluMax, int &_cluOut, SIL.FieldWorks.Common.COMInterfaces.ArrayPtr _rgluSubclasses ) : void
luClid int
cluMax int
_cluOut int
_rgluSubclasses SIL.FieldWorks.Common.COMInterfaces.ArrayPtr
return void

GetBaseClsId() public method

Gets the base class id for a given class.
public GetBaseClsId ( int luClid ) : int
luClid int Class identification number. In the database, this corresponds to "Id" /// column in the Class$ table.
return int

GetBaseClsName() public method

Gets the name of the base class for a given class.
public GetBaseClsName ( int luClid ) : string
luClid int Class identification number. In the database, this corresponds to "Id" /// column in the Class$ table.
return string

GetClassId() public method

:>:> Reverse access methods :> Get the ID of the class having the specified name. Returns 0 if not found.
public GetClassId ( string bstrClassName ) : int
bstrClassName string
return int

GetClassIds() public method

Gets the list of class identification numbers (in no particular order). If the array provided is too small, only an arbitrary subset of cclid values is returned. If the array provided is too large, the excess entries are set to zero.
public GetClassIds ( int cclid, SIL.FieldWorks.Common.COMInterfaces.ArrayPtr rgclid ) : void
cclid int The size of the output array.
rgclid SIL.FieldWorks.Common.COMInterfaces.ArrayPtr An integer array for returning the class identification numbers.
return void

GetClassName() public method

Gets the name of the class.
public GetClassName ( int luClid ) : string
luClid int Class identification number. In the database, this corresponds to "Id" /// column in the Class$ table.
return string

GetDirectSubclasses() public method

Gets the direct subclasses of the given class (not including itself).
public GetDirectSubclasses ( int luClid, int cluMax, int &_cluOut, SIL.FieldWorks.Common.COMInterfaces.ArrayPtr _rgluSubclasses ) : void
luClid int
cluMax int
_cluOut int
_rgluSubclasses SIL.FieldWorks.Common.COMInterfaces.ArrayPtr
return void

GetDstClsId() public method

Gets the "Id" of the destination class that corresponds to this field. This is the "Id" of the class that is either owned or referred to by another class.
public GetDstClsId ( int luFlid ) : int
luFlid int Field identification number. In the database, this corresponds to the "Id" /// column in the Field$ table.
return int

GetDstClsName() public method

Gets the name of the destination class that corresponds to this field. This is the name of the class that is either owned or referred to by another class.
public GetDstClsName ( int luFlid ) : string
luFlid int Field identification number. In the database, this corresponds to the "Id" /// column in the Field$ table.
return string

GetFieldHelp() public method

Gets the help string of a field.
public GetFieldHelp ( int luFlid ) : string
luFlid int Field identification number. In the database, this corresponds to the "Id" /// column in the Field$ table.
return string

GetFieldId() public method

Gets the field ID given the class and field names. Returns 0 if not found. Searches superclasses as well as actual class given.
public GetFieldId ( string bstrClassName, string bstrFieldName, bool fIncludeBaseClasses ) : int
bstrClassName string
bstrFieldName string
fIncludeBaseClasses bool
return int

GetFieldId2() public method

This is more efficient if the client already has the classID specified classID and field name. Returns 0 if not found. Searches superclasses as well as actual class given.
public GetFieldId2 ( int luClid, string bstrFieldName, bool fIncludeBaseClasses ) : int
luClid int
bstrFieldName string
fIncludeBaseClasses bool
return int

GetFieldIds() public method

Gets the list of field identification numbers (in no particular order). If the array provided is too small, only an arbitrary set of cflid values is returned. If the array provided is too large, the excess entries are set to zero.
public GetFieldIds ( int cflid, SIL.FieldWorks.Common.COMInterfaces.ArrayPtr rgflid ) : void
cflid int The size of the output array.
rgflid SIL.FieldWorks.Common.COMInterfaces.ArrayPtr An integer array for returning the field identification numbers.
return void

GetFieldLabel() public method

Gets the user label of a field.
public GetFieldLabel ( int luFlid ) : string
luFlid int Field identification number. In the database, this corresponds to the "Id" /// column in the Field$ table.
return string

GetFieldListRoot() public method

Gets the listRoot of the field.
public GetFieldListRoot ( int luFlid ) : System.Guid
luFlid int Field identification number. In the database, this corresponds to the "Id" /// column in the Field$ table.
return System.Guid

GetFieldName() public method

Gets the name of a field.
public GetFieldName ( int luFlid ) : string
luFlid int Field identification number. In the database, this corresponds to the "Id" /// column in the Field$ table.
return string

GetFieldNameOrNull() public method

Gets the name of a field.
public GetFieldNameOrNull ( int luFlid ) : string
luFlid int Field identification number. In the database, this corresponds to the "Id" /// column in the Field$ table.
return string

GetFieldType() public method

Gets the type of the field. This value indicates if the field is a primitive data type or a MultiStr/MultiTxt value or describes the relationship between two classes (i.e. owning/reference and atomic/collection/sequence). These numeric values are defined in the ~FWROOT\src\cellar\lib\CmTypes.h file.
public GetFieldType ( int luFlid ) : int
luFlid int Field identification number. In the database, this corresponds to the "Id" /// column in the Field$ table. /// Historical note: at one point, the result could include the virtual bit, kcptVirtual, or'd /// with one of the other kcpt values. This caused endless bugs and has been removed.
return int

GetFieldWs() public method

Gets the Ws of the field.
public GetFieldWs ( int luFlid ) : int
luFlid int Field identification number. In the database, this corresponds to the "Id" /// column in the Field$ table.
return int

GetFieldXml() public method

Gets the Xml UI of a field.
public GetFieldXml ( int luFlid ) : string
luFlid int Field identification number. In the database, this corresponds to the "Id" /// column in the Field$ table.
return string

GetFields() public method

Gets a list of the fields for the specified class. Gets all fields whose types match the specified argument, which should be a combination of the fcpt values defined in CmTypes.h, e.g., to get all owning properties pass kfcptOwningCollection | kfcptOwningAtom | kfcptOwningSequence. Returns E_FAIL if the array is too small. cflidMax 0 may be passed to obtain the required size. Fields of superclasses are also returned, if the relevant flag is true. [Note: The special CmObject fields are not returned, for now, but the plan to include them before too long.]
public GetFields ( int luClid, bool fIncludeSuperclasses, int grfcpt, int cflidMax, SIL.FieldWorks.Common.COMInterfaces.ArrayPtr _rgflid ) : int
luClid int
fIncludeSuperclasses bool
grfcpt int
cflidMax int
_rgflid SIL.FieldWorks.Common.COMInterfaces.ArrayPtr
return int

GetIncomingFields() public method

Pass it on. Only real fields are interesting here.
public GetIncomingFields ( int clid, int fieldTypes ) : IEnumerable
clid int
fieldTypes int
return IEnumerable

GetOwnClsId() public method

Gets the "Id" value of the class that contains this field.
public GetOwnClsId ( int luFlid ) : int
luFlid int Field identification number. In the database, this corresponds to the "Id" /// column in the Field$ table.
return int

GetOwnClsName() public method

Gets the name of the class that contains this field.
public GetOwnClsName ( int luFlid ) : string
luFlid int Field identification number. In the database, this corresponds to the "Id" /// column in the Field$ table.
return string

InitXml() public method

Alternative way to initialize, passing an XML file (like Ling.cm). <class num="int" id="className" base="baseClassName" abstract="true"> <props> <basic num="int" id="FieldName" sig="Boolean/Integer/Time/String/MultiString/MultiUnicode" /> <rel/owning num="int" id="FieldName" card="atomic/seq/col" sig="classname"/> currently doesn't initialize some less essential stuff like help strings and labels. Set fClearPrevCache to false to read in multiple XML files. Enhance JohnT: support attributes to handle these.
public InitXml ( string bstrPathname, bool fClearPrevCache ) : void
bstrPathname string
fClearPrevCache bool
return void

IsValueType() public method

Returns true for Binary, Boolean, GenDate, Integer and Time
public IsValueType ( CellarPropertyType type ) : bool
type CellarPropertyType
return bool

get_IsValidClass() public method

Given a field id and a class id, this returns true it it is legal to store this class of object in the field.
public get_IsValidClass ( int luFlid, int luClid ) : bool
luFlid int Field identification number.
luClid int Class identification number.
return bool

get_IsVirtual() public method

public get_IsVirtual ( int luFlid ) : bool
luFlid int
return bool