Remarks
See Also
Developer's Guide
Members
Constructors
Creates a new instance of GraphMLIOHandler.
Properties
If set to true, an existing graph instance will be cleared before the graph is read into this instance, otherwise the loaded graph will be merged into the existing one.
The default is true.
Gets the mapper for the overrides of the deserialization properties.
Gets the mapper for the overrides of the serialization properties.
Methods
This method can optionally use a custom event handler for the actual deserialization.
This method creates and configures the necessary handler itself.
Parameters
- dataType: Constructor<TValue>
- The type of the mapper values
- keyDefinitionPredicate: function(Element): boolean
- Predicate function to select the correct GraphML attribute
- graphData: function(IGraph, TValue): void
- Delegate that stores the graph data dynamically
- deserializationCallback?: function(IParseContext, Node, Constructor): TValue
- Custom deserialization callback.
This method can optionally use a custom event handler for the actual deserialization.
This method creates and configures the necessary handler itself.
Parameters
- dataType: Constructor<TValue>
- The type of the mapper values
- name: string
- The name of the attribute
- graphData: function(IGraph, TValue): void
- Delegate that stores the graph data dynamically
- deserializationCallback?: function(IParseContext, Node, Constructor): TValue
- custom deserialization callback.
- uri?: string
- The optional URI of the key definition to disambiguate keys.
This method can optionally use a custom event handler for the actual serialization.
This method creates and configures the necessary handler itself.
Parameters
- dataType: Constructor<TValue>
- The type of the mapper values
- name: string
- The name of the attribute
- graphData: TValue
- the data that is written at the top level
- serializationCallback?: function(IWriteContext, TValue, Constructor): void
- custom serialization callback.
- declaredKeyType?: KeyType
- The key type to write in the declaration. If this is omitted or
null, the type is inferred automatically fromTValue - uri?: string
- The optional URI to add to the key definition to disambiguate keys.
This method can optionally use a custom event handler for the actual serialization.
This method creates and configures the necessary handler itself.
Parameters
- dataType: Constructor<TValue>
- The type of the mapper values
- name: string
- The name of the attribute
- graphData: function(IGraph): TValue
- Delegate that retrieves the graph data dynamically
- serializationCallback?: function(IWriteContext, TValue, Constructor): void
- custom serialization callback.
- declaredKeyType?: KeyType
- The key type to write in the declaration. If this is omitted or
null, the type is inferred automatically fromTValue - uri?: string
- The optional URI to add to the key definition to disambiguate keys.
Register an IMapper<K, V> instance for use as an input data target.
Parameters
- keyType: Constructor<TKey>
- The type of the mapper keys
- dataType: Constructor<TData>
- The type of the mapper values
- name: string
- The name of the attribute
- mapper: IMapper<TKey, TData>
- the mapper that serves as data source
See Also
Developer's Guide
addInputMapper
<TKey, TData> (keyType: Constructor<TKey>dataType: Constructor<TData>keyDefinitionPredicate: function(Element): boolean)Register an IMapper<K, V> instance for use as an input data target.
addInputMapper
<TKey, TData> (This method uses a custom event handler for the actual deserialization.
This method creates and configures the necessary handler itself.
Parameters
- keyType: Constructor<TKey>
- The type of the mapper keys
- dataType: Constructor<TData>
- The type of the mapper values
- keyDefinitionPredicate: function(Element): boolean
- The predicate function that will determine whether to create an IInputHandler for the given key definition.
- mapper: IMapper<TKey, TData>
- the mapper that serves as data source
- deserializationCallback: function(IParseContext, Node, Constructor): TData
- custom deserialization callback.
Parameters
- namespaceURI: string
- The namespace URI
- shortName: string
- The namespace prefix
Throws
- Exception ({ name: 'ArgumentError' })
- If
namespaceURIisnull.
addOutputMapper
<TModelItem, TValue> (modelItemType: Constructor<TModelItem>dataType: Constructor<TValue>name: string)Register an IMapper<K, V> instance for use as an output data source
addOutputMapper
<TModelItem, TValue> (Parameters
- modelItemType: Constructor<TModelItem>
- The type of the mapper keys
- dataType: Constructor<TValue>
- The type of the mapper values
- name: string
- The name of the attribute
- mapper: IMapper<TModelItem, TValue>
- the mapper that serves as data source
See Also
Developer's Guide
addOutputMapper
<TModelItem, TValue> (modelItemType: Constructor<TModelItem>dataType: Constructor<TValue>name: stringuri: string)Register an IMapper<K, V> instance for use as an output data source.
addOutputMapper
<TModelItem, TValue> (This method uses a custom event handler for the actual serialization.
This method creates and configures the necessary handler itself.
Parameters
- modelItemType: Constructor<TModelItem>
- The type of the mapper keys
- dataType: Constructor<TValue>
- The type of the mapper values
- name: string
- The name of the attribute
- uri: string
- The URI to add to the key definition to disambiguate keys.
- mapper: IMapper<TModelItem, TValue>
- the mapper that serves as data source
- serializationCallback: function(IWriteContext, TValue, Constructor): void
- custom serialization callback.
- declaredKeyType: KeyType
- The key type to write in the declaration.
Parameters
- schemaNamespace: string
- The namespace URI for this schema location
- schemaLocation: string
- The schema location
Throws
- Exception ({ name: 'ArgumentError' })
- If
schemaNamespaceisnull.
Parameters
- tType: Constructor<T>
- metadata: TypeMetadata<T>
- The metadata for the type and its properties.
See Also
Developer's Guide
API
- addXamlNamespaceMapping
The module is an object where the keys are XML tag names and the values are the types to be mapped.
This is used both for writing and parsing objects.
Parameters
- xmlNamespace: string
- The XML namespace that corresponds to
module. - module: any
- The module that is mapped to the XML namespace. The keys are the names of the XML tags. The values are the types.
See Also
Developer's Guide
API
- IXamlNameMapper, createXamlNameMapper, addTypeInformation
Allows for configuration of the initial IParseContext that is used for reading a GraphML file.
rootContext instance or a new IParseContext instance that wraps the given rootContext instance. Thus, it is recommended to create an instance of ChildParseContext that wraps the given rootContext instance if custom configuration is necessary.Parameters
- rootContext: IParseContext
- The initial parse context that is created by the framework.
Return Value
- IParseContext
- A suitably configured parse context.
Allows for configuration of the initial IWriteContext that is used for writing a GraphML file.
rootContext via the IWriteContext interface. Instead, create an instance of ChildWriteContext that wraps the provided context and configure that one.Parameters
- rootContext: IWriteContext
- The initial write context that is created by the framework.
Return Value
- IWriteContext
- A suitably configured write context.
Creates the default value serializer context and returns it.
Return Value
- IValueSerializerContext
- An implementation of the IValueSerializerContext interface.
Configure mappings from CLR to XML names.
Return Value
- IXamlNameMapper
- The configured IXamlNameMapper.
Configure mappings from XML namespaces to prefixes.
Return Value
- IXamlPrefixMapper
- The configured IXamlPrefixMapper.
Factory method that creates and configures a suitable IXmlWriter implementation.
Return Value
- IXmlWriter
- A suitable IXmlWriter instance for the serialization
See Also
API
- writer
Parses the XML document document into an graph instance.
document into an graph instance.Parameters
- graph: IGraph
- The graph instance that is populated.
- document: Document
- The XML document instance to parse.
- context: IParseContext
- The initial parse context.
Return Value
- Promise<IGraph>
- A
Promisethat will resolve once thegraphis populated with the content read from thedocument.
See Also
Parameters
- graph: IGraph
- The graph that is to be populated with nodes and edges as read from the document.
- document: Document
- The XML document.
Return Value
- Promise<IGraph>
- A
Promisethat will resolve once thegraphis populated with the content read from thedocument.
Throws
- Exception ({ name: 'ArgumentError' })
documentis null.- Exception ({ name: 'ArgumentError' })
graphis null.
See Also
Developer's Guide
Parameters
- graph: IGraph
- The Graph object that is to be populated with nodes and edges as read from the GraphML data.
- data: string
- A string that contains GraphML data.
Return Value
- Promise<IGraph>
- A
Promisethat will resolve once thegraphis populated with the content read from thedata.
See Also
Developer's Guide
Parameters
- graph: IGraph
- The graph that is to be populated with nodes and edges as read from the URL.
- url: string
- The URL of the file to be read.
Return Value
- Promise<IGraph>
- A
Promisethat will resolve once thegraphis populated with the content read from theurl.
Throws
- Exception ({ name: 'ArgumentError' })
urlis null.- Exception ({ name: 'ArgumentError' })
graphis null.
See Also
Developer's Guide
Events
Occurs when XML content is about to be deserialized.
Subscribe to this event to provide custom deserialization handling for XML content.
The event handlers added to this event are called in inverse order, i.e. handlers that have been added later are called earlier.
The current XML content is provided by xmlNode. If you want to return deserialized content, set the value of the result property.
Properties of
HandleDeserializationEventArgs- context: IParseContext
- Gets the context in which the xmlNode shall be deserialized.
- handled: booleanwritable
- Gets or sets a value indicating whether this HandleDeserializationEventArgs is handled.
- result: anywritable
- Gets or sets the result of the deserialization, which is
nullinitially. - targetType: Constructor
- Gets the type of the resulting instance that is required by the requesting deserializer or
nullif the target type is not known in advance. - xmlNode: Node
- Gets the XML node that contains the data to deserialize.
See Also
Developer's Guide
Occurs when XML content is about to be serialized.
Subscribe to this event to provide custom serialization handling for XML content.
The event handlers added to this event are called in reverse order, i.e. handlers that have been added later are called earlier.
The current item is provided by item.
Properties of
HandleSerializationEventArgs- context: IWriteContext
- Gets the context to be used for writing.
- handled: booleanwritable
- Gets or sets a value indicating whether this HandleSerializationEventArgs is handled.
- item: any
- Gets the item that should be serialized.
- sourceType: Constructor
- Gets the type in the inheritance of the item that should be used for serialization.
- writer: IXmlWriter
- Gets the writer for writing the XML output.
See Also
Developer's Guide
Occurs before inline references are evaluated.
Properties of
ResolveReferenceEventArgs- context: IParseContext
- Gets the current parse context that can be used by the event handler for additional information.
- handled: boolean
- Gets whether the last event handler invocation has actually handled the event.
- referenceId: string
- Gets the reference ID that should be evaluated by the event handler.
- value: anywritable
- Gets or sets the reference value that is encapsulated by this instance.
See Also
Occurs when the document has been parsed.
Properties of
ParseEventArgs- context: IParseContext
- Gets the context that is being used for parsing.
- element: Element
- Gets the XML element that is currently parsed.
See Also
Developer's Guide
Occurs when the parsing of a document is just about to begin.
Properties of
ParseEventArgs- context: IParseContext
- Gets the context that is being used for parsing.
- element: Element
- Gets the XML element that is currently parsed.
See Also
Developer's Guide
Occurs when a GraphML attribute is about to be read.
Subscribe to this event to dynamically register one or more IInputHandler instance(s) for a given GraphML attribute key definition.
The current key definition is provided by keyDefinition. If you want to register an IInputHandler for this GraphML attribute, you can add the handler with addInputHandler method. Implementations should also consider the handled property.
Properties of
QueryInputHandlersEventArgs- context: IParseContext
- Gets the IParseContext instance that can be queried for further information.
- handled: booleanwritable
- Gets or sets whether the current GraphML attribute has been processed.
- handlers: IEnumerable<IInputHandler>
- Gets the IInputHandlers that have been registered on this event argument instance so far.
- keyDefinition: Element
- Gets the key definition of the GraphML attribute.
See Also
Developer's Guide
Occurs when a name is queried.
This event can be used to override name mappings to XML names in XAML.
If the event handler determines that it map resolve type to a xml name, it should place the result into the result property and thus mark the event as handled.
It is valid to provide only part of the XML name by setting the other part to null. In that case, the default name determination rules are used for that part.
Properties of
QueryNameEventArgs- context: IWriteContext
- Gets the context in which the type shall be mapped.
- handled: booleanwritable
- Gets or sets a value indicating whether this QueryNameEventArgs is handled.
- result: XmlNamewritable
- Gets or sets the result of the name query, which is
nullinitially. - type: Constructor
- Gets the type for which the XML name is queried.
Occurs when a GraphML attribute is about to be written.
Subscribe to this event to dynamically register one or more IOutputHandler instance(s) for a given GraphML attribute key definition.
The event handlers added to this event are called in inverse order, i.e. handlers that have been added later are called earlier.
If you want to register an IOutputHandler for this GraphML attribute, you can add the handler with addOutputHandler.
Properties of
QueryOutputHandlersEventArgs- context: IWriteContext
- Gets the context for which the handlers are queried.
- handlers: IEnumerable<IOutputHandler>
- Gets the IOutputHandlers that have been registered on this event argument instance so far.
- scope: KeyScope
- Gets the scope where the handlers should be added.
See Also
Developer's Guide
Occurs when a reference is queried.
This event can be used to provide names of external or internal references for objects.
The reference targets are not serialized to the GraphML file if they are set to EXTERNAL. To resolve these references when parsing, you typically have to subscribe to the resolve-reference event.
Properties of
QueryReferenceIdEventArgs- context: IWriteContext
- Gets the current write context that can be used by the event handler for additional information.
- handled: boolean
- Gets whether the last event handler invocation has actually handled the event.
- referenceId: stringwritable
- Gets or sets the reference id that should be evaluated by the event handler.
- referenceType: GraphMLReferenceTypewritable
- Gets or sets the type of the reference being queried.
- value: any
- Gets the reference value that is encapsulated by this instance.
See Also
Developer's Guide
API
- referenceId, referenceType
Occurs when a type is queried.
Properties of
QueryTypeEventArgs- context: IParseContext
- Gets the context in which the shall be mapped.
- handled: booleanwritable
- Gets or sets a value indicating whether this QueryTypeEventArgs is handled.
- result: Constructorwritable
- Gets or sets the result of the type query, which is
nullinitially. - xmlName: XmlName
- Gets the fully qualified XML name that should be resolved to a type.
See Also
Occurs after references are evaluated.
Properties of
ResolveReferenceEventArgs- context: IParseContext
- Gets the current parse context that can be used by the event handler for additional information.
- handled: boolean
- Gets whether the last event handler invocation has actually handled the event.
- referenceId: string
- Gets the reference ID that should be evaluated by the event handler.
- value: anywritable
- Gets or sets the reference value that is encapsulated by this instance.
See Also
Developer's Guide
API
- override-resolve-reference
Occurs when the writing of a document is just about to begin.
Properties of
WriteEventArgs- context: IWriteContext
- Gets the context that is being used for writing.
- item: any
- Gets the item that is currently being written or
nullif nothing is applicable.
See Also
Developer's Guide
Occurs when the writing of a document has been finished.
Properties of
WriteEventArgs- context: IWriteContext
- Gets the context that is being used for writing.
- item: any
- Gets the item that is currently being written or
nullif nothing is applicable.
See Also
Developer's Guide
Static Methods
createMapperInputHandler
<TKey, TData> (modelItemType: Constructor<TKey>dataType: Constructor<TData>): MapperInputHandler<TKey, TData>static
createMapperInputHandler
<TKey, TData> (TKey and TData.Parameters
- modelItemType: Constructor<TKey>
- The type of the mapper keys
- dataType: Constructor<TData>
- The type of the mapper entries
- mapper: IMapper<TKey, TData>
- The mapper to use.
- deserializationCallback: function(IParseContext, Node, Constructor): TData
- Optional deserialization callback for complex data.
Return Value
- MapperInputHandler<TKey, TData>
- A suitable MapperInputHandler<TKey, TData> implementation
createMapperOutputHandler
<TKey, TData> (modelItemType: Constructor<TKey>dataType: Constructor<TData>name: string): MapperOutputHandler<TKey, TData>static
createMapperOutputHandler
<TKey, TData> (TKey and TData.Parameters
- modelItemType: Constructor<TKey>
- The type of the mapper keys
- dataType: Constructor<TData>
- The type of the mapper entries
- name: string
- The name of the graphml attribute
- mapper: IMapper<TKey, TData>
- The mapper to use.
- serializationCallback: function(IWriteContext, TData, Constructor): void
- Optional serialization callback for complex data.
Return Value
- MapperOutputHandler<TKey, TData>
- A suitable MapperOutputHandler<TKey, TData> implementation
Parameters
- definition: Element
- The key definition to check
- name: string
- The name that should be matched
Return Value
- boolean
trueif the name attribute indefinitionmatchesname
Checks whether the scope attribute in definition matches scope
scope attribute in definition matches scopeParameters
- definition: Element
- The key definition to check
- scope: KeyScope
- The scope that should be matched
Return Value
- boolean
trueif the scope attribute indefinitionmatchesscope
Checks whether the type attribute in definition matches type
type attribute in definition matches typeParameters
- definition: Element
- The key definition to check
- type: KeyType
- The type that should be matched
Return Value
- boolean
trueif the type attribute indefinitionmatchestype