Class BusinessObject
General abstract class for Business Objects for Energy (BO4E)
Inheritance
Namespace: BO4E.BO
Assembly: BO4Enet.dll
Syntax
public abstract class BusinessObject : IEquatable<BusinessObject>
Constructors
| Improve this Doc View SourceBusinessObject()
generates the BO4E boTyp attribute value (class name as upper case)
Declaration
protected BusinessObject()
Fields
| Improve this Doc View Sourceguid
allows adding a GUID to Business Objects for tracking across systems
Declaration
public string guid
Field Value
Type | Description |
---|---|
System.String |
USER_PROPERTIES_NAME
Fields that are not part of the BO4E-definition are stored in a element, that is accessable under the key defined in userPropertiesName.
Declaration
public const string USER_PROPERTIES_NAME = null
Field Value
Type | Description |
---|---|
System.String |
Examples
{
"boTyp": "MESSLOKATION",
"versionStruktur": 1,
"messLokationsId": "DE123...",
"irgendwas unbekanntes": "xyz"
}
is mapped to
{
"boTyp": "MESSLOKATION",
"versionStruktur": 1,
"messLokationsId": "DE123...",
"userProperties":
{
"irgendwas unbekanntes": "xyz"
}
}
This keeps the Business Object simple but allows for user specific arguments beyond the BO4E standard to be passed along.
| Improve this Doc View SourceversionStruktur
obligatory version of the BO4E definition. Currently hard coded to 1
Declaration
public int versionStruktur
Field Value
Type | Description |
---|---|
System.Int32 |
Examples
1
Properties
| Improve this Doc View SourceBoTyp
obligatory type of the business object in UPPER CASE
Declaration
public string BoTyp { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Examples
'MESSLOKATION', 'MARKTLOKATION'
| Improve this Doc View SourceUserProperties
User properties (non bo4e standard)
Declaration
public IDictionary<string, JToken> UserProperties { get; set; }
Property Value
Type | Description |
---|---|
IDictionary<System.String, JToken> |
Methods
| Improve this Doc View SourceDeserializationFixes(StreamingContext)
converts BoTyp to upper case.
Declaration
protected void DeserializationFixes(StreamingContext context)
Parameters
Type | Name | Description |
---|---|---|
StreamingContext | context |
Equals(BusinessObject)
BO4E Business Objects are considered equal iff all of their elements/fields are equal.
Declaration
public bool Equals(BusinessObject b)
Parameters
Type | Name | Description |
---|---|---|
BusinessObject | b | another Business Object |
Returns
Type | Description |
---|---|
System.Boolean | iff b has the same type as this object and all elements
of this and object b are equal; otherwise
|
Equals(Object)
BO4E Business Objects are considered equal iff all of their elements/fields are equal.
Declaration
public override bool Equals(object b)
Parameters
Type | Name | Description |
---|---|---|
System.Object | b | another object |
Returns
Type | Description |
---|---|
System.Boolean | iff b has the same type as this object and all elements of this and object b are equal; otherwise
|
GetBoKeyNames()
(Some) Business Objects do have keys that should identify them in a unique manner across multiple systems. This method returns a list of these keys. The list contains the key names as they are serialised in JSON. This means that the fields PropertyName is part of the list if JsonPropertyAttribute.PropertyName is set in the Business Objects definition. Please do not use this method trying to access the actual key values. Use the GetBoKeys() or GetBoKeyProps(Type) for this purpose. The list is sorted by the JsonPropertyAttribute.Order, assuming 0 if not specified.
Declaration
public List<string> GetBoKeyNames()
Returns
Type | Description |
---|---|
List<System.String> | A list of the names (not the values) of the (composite) Business Object key or an empty list if no key attributes are defined. |
Examples
Marktlokation malo = ... some initialisation code ...;
malo.GetBoKeyNames()
[ "marktlokationsId" ]
See Also
| Improve this Doc View SourceGetBoKeyNames(Type)
Same as GetBoKeyNames(Type) but allows static calling with a Business Object Type provided.
Declaration
public static List<string> GetBoKeyNames(Type boType)
Parameters
Type | Name | Description |
---|---|---|
Type | boType | Business Object Type |
Returns
Type | Description |
---|---|
List<System.String> | A list just like the result of GetBoKeyNames(Type) |
GetBoKeyProps(Type)
Get a list of FieldInfo objects that contain the key of a Business Object. The list is sorted by the JsonPropertyAttribute.Order, assuming 0 if not specified.
Declaration
public static List<PropertyInfo> GetBoKeyProps(Type boType)
Parameters
Type | Name | Description |
---|---|---|
Type | boType | Business Object type |
Returns
Type | Description |
---|---|
List<PropertyInfo> | A list of FieldInfos to be used for accessing the key values. |
GetBoKeys()
Get a dictionary containing the key values of this Business Object. The dictionary has the JsonPropertyAttribute.PropertyName or FieldName of the key as key and the actual key value as value.
Declaration
public Dictionary<string, object> GetBoKeys()
Returns
Type | Description |
---|---|
Dictionary<System.String, System.Object> | A dictionary with key value pairs. |
See Also
| Improve this Doc View SourceGetBoTyp()
return BoTyp (as string, not as type)
Declaration
public string GetBoTyp()
Returns
Type | Description |
---|---|
System.String |
GetExpandableFieldNames(String)
Declaration
public static Dictionary<string, Type> GetExpandableFieldNames(string boTypeName)
Parameters
Type | Name | Description |
---|---|---|
System.String | boTypeName | name of the business object as string |
Returns
Type | Description |
---|---|
Dictionary<System.String, Type> |
GetExpandablePropertyNames(Type)
This method returns information about the object structure, especially if there are nested field, that could be used, e.g. to expand OData queries.
Declaration
public static Dictionary<string, Type> GetExpandablePropertyNames(Type boType)
Parameters
Type | Name | Description |
---|---|---|
Type | boType | valid business object type
|
Returns
Type | Description |
---|---|
Dictionary<System.String, Type> | A dictionary with field names as keys (or the different JSON property name if set) and the type of the property as value. Nesting and different layers are denoted by using "." |
GetExpandablePropertyNames(Type, Boolean)
recursive function to return all expandable fields for a given type type
.
Set rootLevel
when calling from outside the function itself.
Declaration
protected static Dictionary<string, Type> GetExpandablePropertyNames(Type type, bool rootLevel = true)
Parameters
Type | Name | Description |
---|---|---|
Type | type | Type inherited from Business Object |
System.Boolean | rootLevel | true iff calling from outside the function itself / default |
Returns
Type | Description |
---|---|
Dictionary<System.String, Type> | HashSet of strings |
GetHashCode()
override hash code generation
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
System.Int32 | hash code as int |
GetJsonSchema(Type)
returns a JSON scheme for the given type boType
Declaration
public static JSchema GetJsonSchema(Type boType)
Parameters
Type | Name | Description |
---|---|---|
Type | boType | a type derived from BusinessObject |
Returns
Type | Description |
---|---|
JSchema | a JSON scheme |
GetJsonScheme()
returns a JSON scheme for the Business Object
Declaration
public JSchema GetJsonScheme()
Returns
Type | Description |
---|---|
JSchema | a JSON scheme |
GetURI(Boolean)
Get a BO4E compliant URI for this business object.
Declaration
public Bo4eUri GetURI(bool includeUserProperties = false)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | includeUserProperties |
Returns
Type | Description |
---|---|
Bo4eUri | a BO4E compliant URI object |
IsValid()
Tests if the object does contain all mandatory information / fields.
To do so, the function tries to serialize the object as JSON.
If the serialization fails due to fields that are
Declaration
public virtual bool IsValid()
Returns
Type | Description |
---|---|
System.Boolean | true if COM object is compatible with BO4E standards |
SetBoTyp(String)
This method is just to make sure the mapping actually makes sense.
Declaration
protected void SetBoTyp(string s)
Parameters
Type | Name | Description |
---|---|---|
System.String | s | name of the business object |