IO
Static methods for safe reading and writing to and from IStorable implementations.
Methods
Duplicate
#Duplicate an instance of an IStorable type using (de)serialization.
Parameters:
| instance (IStorable) | Instance to duplicate. |
Returns: Duplicated instance.
Duplicate<T>
#public static T Duplicate<T>(T instance)
Duplicate an instance of an IStorable type using (de)serialization.
Parameters:
| instance (T) | Instance to duplicate. |
Returns: Duplicated instance.
Gets the value of the identifier attribute associated with a type. If the type doesn't have the IdentifierAttribute, an exception will be thrown.
GetIStorableConstructor
#Gets the constructor of a type which takes a single IReader argument. If such a constructor does not exist null will be returned.
Parameters:
| type (Type) | |
| constructor (out ConstructorInfo) |
Gets the value of the identifier attribute associated with a type. If the type doesn't have the IdentifierAttribute, an exception will be thrown.
ReadNodeFromByteArray
#Read a node directly from a byte array.
ReadNodeFromFile
#Read a node from a file.
Parameters:
| path (string) | File path. |
Returns: Deserialized node.
ReadNodeFromStream
#Read a node from a binary reader.
Parameters:
| reader (BinaryReader) | Binary reader. |
| context (ReadContext) | Deserialisation context. |
Returns: Deserialized node.
ReadNodeFromStream
#Read a node from a stream.
Parameters:
| stream (Stream) | Data stream. |
| context (ReadContext) | Deserialisation context. |
Returns: Deserialized node.
ReadStorableFromByteArray<T>
#Deserialise a byte array into an IStorable instance.
ReadStorableFromFile
#Read an IStorable object from a file.
Parameters:
| path (string) | File. |
Returns: Deserialised object.
ReadStorableFromFile<T>
#Read an IStorable object from a file.
Parameters:
| path (string) | File. |
Returns: Deserialised object.
ReadStorableFromStream
#Read an IStorable object from a binary reader.
Parameters:
| reader (BinaryReader) | Binary reader. |
| context (ReadContext) | Deserialisation context. |
Returns: Deserialised object.
ReadStorableFromStream
#Read an IStorable object from a stream.
Parameters:
| stream (Stream) | Data stream. |
| context (ReadContext) | Deserialisation context. |
Returns: Deserialised object.
ReadStorableFromStream<T>
#Read an IStorable object from a binary reader.
Parameters:
| reader (BinaryReader) | Binary reader. |
| context (ReadContext) | Deserialisation context. |
Returns: Deserialised object.
ReadStorableFromStream<T>
#Read an IStorable object from a stream.
Parameters:
| stream (Stream) | Data stream. |
| context (ReadContext) | Deserialisation context. |
Returns: Deserialised object.
RegisterRestorableType
#Add a type to the known set of restorable types. Consider using the overload which only takes a single type parameter to ensure your registration is correct.
RegisterRestorableType
#Add a type to the known set of restorable types. The type must have an IoIdAttribute attribute associated with it.
Parameters:
| type (Type) | Type to add. |
Returns: True if registration was successful.
ResolveType
#Try and get the type associated with a particular identifier.
Parameters:
| identifier (Guid) |
Gets the value of the IoId attribute associated with a type.
ValidateIStorable
#Validate the design of a type which implements the IStorable interface.
Parameters:
| type (Type) | Type of IStorable. |
| constructor (out ConstructorInfo) | The restoration constructor will be returned here. |
| reason (out string) | If this method returns false, the reason for the invalid type. |
Returns: True if instance is valid.
ValidateIStorable
#Validate the design of a type which implements the IStorable interface.
WriteNodeToByteArray
#Serialize a node directly to a byte array.
WriteNodeToFile
#Write a node to a file.
WriteNodeToStream
#Append a node to a stream using a binary writer.
Parameters:
| node (IWriter) | Node to serialize. |
| writer (BinaryWriter) | Binary writer. |
| context (WriteContext) | Serialisation context. |
WriteNodeToStream
#Append a node to a stream.
Parameters:
| node (IWriter) | Node to serialize. |
| stream (Stream) | Stream to write to. |
| context (WriteContext) | Deserialisation context. |
WriteStorableToByteArray
#Serialise an IStorable instance to a byte array.
WriteStorableToFile
#Write a storable object to a file.
WriteStorableToStream
#public static void WriteStorableToStream(IStorable storable, BinaryWriter writer, WriteContext context)
Append a storable object to a stream.
Parameters:
| storable (IStorable) | Storable object. |
| writer (BinaryWriter) | Writer to use. |
| context (WriteContext) | Serialisation context. |
WriteStorableToStream
#Append a storable object to a stream.
Parameters:
| storable (IStorable) | Storable object. |
| stream (Stream) | File stream to write to. |
| context (WriteContext) | Serialisation context. |
Events
LinkType
#This event is raised whenever a specific type implementation is required during deserialisation. Normally, all deserialisable types will have been registered with GrasshopperIO.IO ahead of time, but it is possible some types were omitted from standard registration due to their non-publicness, or maybe because they need to be loaded on demand.