Class Doc
Base class for any data document. This class has two direct subtypes - DynamicDoc and TypedDoc.
Documents are NOT THREAD SAFE by definition
Inheritance
System.Object
Doc
Implements
System.Collections.Generic.IEnumerable<System.Object>
System.Collections.IEnumerable
Inherited Members
System.Object.Equals(System.Object, System.Object)
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Assembly: Azos.dll
Syntax
[Serializable]
public abstract class Doc : IConfigurable, IConfigurationPersistent, IEquatable<Doc>, IEnumerable<object>, IEnumerable, IValidatable, IJSONWritable
Properties
Item[Int32]
Gets/sets field values by positional index(Order)
Declaration
public object this[int fieldIdx] { get; set; }
Parameters
Type |
Name |
Description |
System.Int32 |
fieldIdx |
|
Property Value
Type |
Description |
System.Object |
|
Item[String]
Gets/sets field values by name
Declaration
public object this[string fieldName] { get; set; }
Parameters
Type |
Name |
Description |
System.String |
fieldName |
|
Property Value
Type |
Description |
System.Object |
|
Schema
References a schema for a table that this row is part of
Declaration
public abstract Schema Schema { get; }
Property Value
Methods
ApplyDefaultFieldValues(String, Boolean)
Writes default values specified in schema into fields.
Pass overwrite=true to force defaults over non-null existing values (false by default)
Declaration
public void ApplyDefaultFieldValues(string targetName = null, bool overwrite = false)
Parameters
Type |
Name |
Description |
System.String |
targetName |
|
System.Boolean |
overwrite |
|
CheckMinMax(FieldAttribute, String, IComparable)
Declaration
protected Exception CheckMinMax(FieldAttribute atr, string fName, IComparable val)
Parameters
Type |
Name |
Description |
FieldAttribute |
atr |
|
System.String |
fName |
|
System.IComparable |
val |
|
Returns
Type |
Description |
System.Exception |
|
In base class applies Config attribute. Useful for typed rows
Declaration
public virtual void Configure(IConfigSectionNode node)
Parameters
ConvertFieldValueToDef(Schema.FieldDef, Object)
Converts field value to the type specified by Schema.FieldDef. For example converts GDID->ulong or ulong->GDID.
This method can be overridden to perform custom handling of types,
for example one can assign bool field as "Si" that would convert to TRUE.
This method is called by SetFieldValue(...) before assigning actual field buffer
Declaration
public virtual object ConvertFieldValueToDef(Schema.FieldDef fdef, object value)
Parameters
Type |
Name |
Description |
Schema.FieldDef |
fdef |
Field being converted
|
System.Object |
value |
Value to convert
|
Returns
Type |
Description |
System.Object |
Converted value before assignment to field buffer
|
CopyFields(Doc, String, Boolean, Boolean, Func<String, Schema.FieldDef, Boolean>, Func<String, String, Boolean>)
Copies fields from this doc into another doc/form.
Note: this is shallow copy, as field values for complex types are just copied over
Declaration
public void CopyFields(Doc other, string target = null, bool includeAmorphousData = true, bool invokeAmorphousAfterLoad = true, Func<string, Schema.FieldDef, bool> fieldFilter = null, Func<string, string, bool> amorphousFieldFilter = null)
Parameters
Type |
Name |
Description |
Doc |
other |
|
System.String |
target |
|
System.Boolean |
includeAmorphousData |
|
System.Boolean |
invokeAmorphousAfterLoad |
|
System.Func<System.String, Schema.FieldDef, System.Boolean> |
fieldFilter |
|
System.Func<System.String, System.String, System.Boolean> |
amorphousFieldFilter |
|
Equals(Doc)
Override to perform custom row equality comparison.
Default implementation equates rows using their key fields
Declaration
public virtual bool Equals(Doc other)
Parameters
Type |
Name |
Description |
Doc |
other |
|
Returns
Type |
Description |
System.Boolean |
|
Equals(Object)
Object override - sealed. Override Equals(doc) instead
Declaration
public override sealed bool Equals(object obj)
Parameters
Type |
Name |
Description |
System.Object |
obj |
|
Returns
Type |
Description |
System.Boolean |
|
Overrides
System.Object.Equals(System.Object)
FilterJSONSerializerField(Schema.FieldDef, JSONWritingOptions, out String)
Override to filter-out some fields from serialization to JSON, or change field values.
Return name null to indicate that field should be filtered-out(excluded from serialization to JSON)
Declaration
protected virtual object FilterJSONSerializerField(Schema.FieldDef def, JSONWritingOptions options, out string name)
Parameters
Returns
Type |
Description |
System.Object |
|
GetClientFieldDef(Schema.FieldDef, String, String)
Override to perform dynamic substitute of field def for the specified field.
This method is used by client ui/scaffolding to extract dynamic definition for a field
(i.e. field description, requirement, value list etc.) as dictated by business logic.
This method IS NOT used by doc validation, only by client that feeds from doc metadata.
The default implementation returns the original field def, you can return a substituted field def
per particular business logic
Declaration
public virtual Schema.FieldDef GetClientFieldDef(Schema.FieldDef fdef, string targetName, string isoLang)
Parameters
Type |
Name |
Description |
Schema.FieldDef |
fdef |
|
System.String |
targetName |
|
System.String |
isoLang |
|
Returns
GetClientFieldValue(Schema.FieldDef, String, String)
Override to perform dynamic substitute of field value for the specified field.
This method is used by client ui/scaffolding to extract field values for a field as dictated by business logic.
This method IS NOT used by doc validation, only by client that feeds from doc metadata.
The default implementation returns the original GetFieldValue(fdef), you can return a substituted field value
per particular business logic
Declaration
public virtual object GetClientFieldValue(Schema.FieldDef fdef, string targetName, string isoLang)
Parameters
Type |
Name |
Description |
Schema.FieldDef |
fdef |
|
System.String |
targetName |
|
System.String |
isoLang |
|
Returns
Type |
Description |
System.Object |
|
GetClientFieldValueList(Schema.FieldDef, String, String)
Override to perform dynamic lookup of field value list for the specified field.
This method is used by client ui/scaffolding to extract dynamic lookup values
as dictated by business logic. This method IS NOT used by doc validation, only by client
that feeds from doc metadata.
This is a simplified version of GetClientFieldDef
Declaration
public virtual JSONDataMap GetClientFieldValueList(Schema.FieldDef fdef, string targetName, string isoLang)
Parameters
Type |
Name |
Description |
Schema.FieldDef |
fdef |
|
System.String |
targetName |
|
System.String |
isoLang |
|
Returns
GetDataStoreKey(String)
Returns values for fields that represent row's primary key
Declaration
public IDataStoreKey GetDataStoreKey(string targetName = null)
Parameters
Type |
Name |
Description |
System.String |
targetName |
|
Returns
GetDisplayFieldValue(Int32, String, Func<Object, Object>)
Returns field value as string formatted per target DisplayFormat attribute
Declaration
public string GetDisplayFieldValue(int fieldIndex, string targetName = null, Func<object, object> transform = null)
Parameters
Type |
Name |
Description |
System.Int32 |
fieldIndex |
|
System.String |
targetName |
|
System.Func<System.Object, System.Object> |
transform |
|
Returns
Type |
Description |
System.String |
|
GetDisplayFieldValue(String, String, Func<Object, Object>)
Returns field value as string formatted per target DisplayFormat attribute
Declaration
public string GetDisplayFieldValue(string fieldName, string targetName = null, Func<object, object> transform = null)
Parameters
Type |
Name |
Description |
System.String |
fieldName |
|
System.String |
targetName |
|
System.Func<System.Object, System.Object> |
transform |
|
Returns
Type |
Description |
System.String |
|
GetEnumerator()
Declaration
public IEnumerator<object> GetEnumerator()
Returns
Type |
Description |
System.Collections.Generic.IEnumerator<System.Object> |
|
GetFieldValue(Schema.FieldDef)
Gets value of the field, for typeddocs it accesses property using reflection; for dynamic rows it reads data from
row buffer array using field index(order)
Declaration
public abstract object GetFieldValue(Schema.FieldDef fdef)
Parameters
Returns
Type |
Description |
System.Object |
|
GetFieldValueDescription(Int32, String, Boolean)
For fields with ValueList returns value's description per specified targeted schema
Declaration
public string GetFieldValueDescription(int fieldIndex, string targetName = null, bool caseSensitiveKeys = false)
Parameters
Type |
Name |
Description |
System.Int32 |
fieldIndex |
|
System.String |
targetName |
|
System.Boolean |
caseSensitiveKeys |
|
Returns
Type |
Description |
System.String |
|
GetFieldValueDescription(String, String, Boolean)
For fields with ValueList returns value's description per specified targeted schema
Declaration
public string GetFieldValueDescription(string fieldName, string targetName = null, bool caseSensitiveKeys = false)
Parameters
Type |
Name |
Description |
System.String |
fieldName |
|
System.String |
targetName |
|
System.Boolean |
caseSensitiveKeys |
|
Returns
Type |
Description |
System.String |
|
GetHashCode()
Object override - gets hash code from key fields
Declaration
public override int GetHashCode()
Returns
Type |
Description |
System.Int32 |
|
Overrides
System.Object.GetHashCode()
MakeDoc(Schema, Type)
Factory method that makes an appropriate data document type. For performance purposes,
this method does not check passed type for Doc-derivation and returns null instead if type was invalid
Declaration
public static Doc MakeDoc(Schema schema, Type tDoc = null)
Parameters
Type |
Name |
Description |
Schema |
schema |
Schema, which is used for creation of DynamicDocs and their derivatives
|
System.Type |
tDoc |
A type of doc to create, if the type is TypedDoc-descending then a parameterless .ctor is called,
otherwise a type must have a .ctor that takes schema as a sole argument
|
Returns
Type |
Description |
Doc |
Row instance or null if wrong type was passed. For performance purposes,
this method does not check passed type for Row-derivation and returns null instead if type was invalid
|
PersistConfiguration(ConfigSectionNode)
The base class does not implement this method. Override to persist row fields into config node
Declaration
public virtual void PersistConfiguration(ConfigSectionNode node)
Parameters
SetFieldValue(Schema.FieldDef, Object)
Sets value of the field, for typeddocs it accesses property using reflection; for dynamic rows it sets data into
row buffer array using field index(order)
Declaration
public abstract void SetFieldValue(Schema.FieldDef fdef, object value)
Parameters
SimpleFilterPredicate(String, Boolean)
Returns true if this row satisfies simple filter - it contains the supplied filter string.
The filter pattern may start or end with "*" char that denotes a wildcard. A wildcard is permitted on both sides of the filter value
Declaration
public bool SimpleFilterPredicate(string filter, bool caseSensitive = false)
Parameters
Type |
Name |
Description |
System.String |
filter |
|
System.Boolean |
caseSensitive |
|
Returns
Type |
Description |
System.Boolean |
|
TryFillFromJSON(Doc, IJSONDataObject, SetFieldFunc)
Tries to fill the document with data returning true if field count matched
Declaration
public static bool TryFillFromJSON(Doc doc, IJSONDataObject jsonData, SetFieldFunc setFieldFunc = null)
Parameters
Returns
Type |
Description |
System.Boolean |
|
Validate()
Performs validation of data in the row returning exception object that provides description
in cases when validation does not pass. Validation is performed not targeting any particular backend
Declaration
public virtual Exception Validate()
Returns
Type |
Description |
System.Exception |
|
Validate(String)
Validates row using row schema and supplied field definitions.
Override to perform custom validations,
i.e. TypeRows may directly access properties and write some validation type-safe code
The method is not expected to throw exception in case of failed validation, rather return exception instance because
throwing exception really hampers validation performance when many rows need to be validated
Declaration
public virtual Exception Validate(string targetName)
Parameters
Type |
Name |
Description |
System.String |
targetName |
|
Returns
Type |
Description |
System.Exception |
|
ValidateField(String, Schema.FieldDef)
Validates row field using Schema.FieldDef settings.
This method is invoked by base Validate() implementation.
The method is not expected to throw exception in case of failed validation, rather return exception instance because
throwing exception really hampers validation performance when many rows need to be validated
Declaration
public virtual Exception ValidateField(string targetName, Schema.FieldDef fdef)
Parameters
Returns
Type |
Description |
System.Exception |
|
ValidateField(String, String)
Validates row field by name.
Shortcut to ValidateField(Schema.FieldDef)
Declaration
public Exception ValidateField(string targetName, string fname)
Parameters
Type |
Name |
Description |
System.String |
targetName |
|
System.String |
fname |
|
Returns
Type |
Description |
System.Exception |
|
WriteAsJSON(TextWriter, Int32, JSONWritingOptions)
Writes row as JSON either as an array or map depending on JSONWritingOptions.RowsAsMap setting.
Do not call this method directly, instead call rowset.ToJSON() or use JSONWriter class
Declaration
public void WriteAsJSON(TextWriter wri, int nestingLevel, JSONWritingOptions options = null)
Parameters
Type |
Name |
Description |
System.IO.TextWriter |
wri |
|
System.Int32 |
nestingLevel |
|
JSONWritingOptions |
options |
|
Explicit Interface Implementations
IEnumerable.GetEnumerator()
Declaration
IEnumerator IEnumerable.GetEnumerator()
Returns
Type |
Description |
System.Collections.IEnumerator |
|
Implements
System.IEquatable<T>
System.Collections.Generic.IEnumerable<T>
System.Collections.IEnumerable
Extension Methods