An object that represents a file that can be accessed via the server.
More...
Inherits UnifiedAutomation.UaServer.BaseObjectModel, UnifiedAutomation.UaServer.IMethodDispatcher, UnifiedAutomation.UaServer.IFileMethods, and IDisposable.
Inherited by UnifiedAutomation.UaServer.AddressSpaceFileModel, and UnifiedAutomation.UaServer.TrustListModel.
|
void | Dispose () |
| Frees any unmanaged resources. More...
|
|
virtual StatusCode | Open (RequestContext context, FileModel model, byte mode, out uint fileHandle) |
| Used to open a file represented by an Object of FileType. More...
|
|
virtual StatusCode | Close (RequestContext context, FileModel model, uint fileHandle) |
| Closes a file represented by a FileType. More...
|
|
virtual StatusCode | Read (RequestContext context, FileModel model, uint fileHandle, int length, out byte[] data) |
| Reads a part of the file starting from the current file position. More...
|
|
virtual StatusCode | Write (RequestContext context, FileModel model, uint fileHandle, byte[] data) |
| Writes a part of the file starting from the current file position. More...
|
|
virtual StatusCode | SetPosition (RequestContext context, FileModel model, uint fileHandle, ulong position) |
| Used to set the current position of the FileHandle. More...
|
|
virtual StatusCode | GetPosition (RequestContext context, FileModel model, uint fileHandle, out ulong position) |
| Provides the current position of the FileHandle. More...
|
|
| FileModel () |
| Initializes a new instance of the FileModel class. More...
|
|
| FileModel (FileModel template) |
| Initializes a new instance of the FileModel class. More...
|
|
virtual CallMethodEventHandler | GetMethodDispatcher (RequestContext context, NodeId objectId, NodeId methodId) |
| Gets the method dispatcher. More...
|
|
virtual StatusCode | DispatchMethod (RequestContext context, MethodHandle methodHandle, IList< Variant > inputArguments, List< StatusCode > inputArgumentResults, List< Variant > outputArguments) |
| Dispatches the method. More...
|
|
| BaseObjectModel () |
| Initializes a new instance of the BaseObjectModel class. More...
|
|
| BaseObjectModel (BaseObjectModel template) |
| Initializes a new instance of the BaseObjectModel class. More...
|
|
virtual ModelHandle | GetModelHandle (StringTable namespaceUris, object instance) |
| Gets the metadata handle. More...
|
|
virtual DataValue | GetValue (IMapperContext context, ModelMapping mapping) |
| Gets the value associated with the mapping. More...
|
|
virtual bool | SetValue (IMapperContext context, ModelMapping mapping, DataValue value) |
| Sets the value associated with the mapping. More...
|
|
|
object | Lock = new object() |
| An object used to synchronize access to the file object. More...
|
|
|
FileInfo | FileOnDisk [get, set] |
| Gets or sets the disk file which can be accessed via the file object. More...
|
|
int | MaxFileSize [get, set] |
| Gets or sets the maximum size of the file in bytes. More...
|
|
INodeAccessInfo | NodeAccessInfo [get, set] |
| Gets or sets the NodeAccessInfo to specify user access in Open method. More...
|
|
uint | NextFileHandle [get, set] |
| Gets or sets the next file handle to assign. More...
|
|
string | MimeType [get, set] |
| Contains the media type of the file based on RFC 2046. More...
|
|
ushort | OpenCount [get, set] |
| Indicates the number of currently valid file handles on the file. More...
|
|
ulong | Size [get, set] |
| Defines the size of the file in Bytes. More...
|
|
bool | UserWritable [get, set] |
| Indicates whether the file is writable, taking user access rights into account. More...
|
|
bool | Writable [get, set] |
| Indicates whether the file is writable. More...
|
|
IFileMethods | FileMethods [get, set] |
| Gets or sets the File methods. More...
|
|
ModelHandle | ModelHandle [get, set] |
| Gets or sets the metadata handle. More...
|
|
object | UserData [get, set] |
| Gets or sets the user data. More...
|
|
An object that represents a file that can be accessed via the server.
This ObjectType defines a type for files.
This class implements support for the FileType object on the server side.
Any number of open read handles is allowed but only one handle may be open for write at a time. Subclasses may be used to replace the FileStream with other abstract stream implementations. There are two events (OpenRequested and CloseRequested) which can be used to determine permissions.
See FileModel Example for example code.
Note that all methods on a file require a FileHandle, which is returned in the UnifiedAutomation.UaServer.IFileMethods.Open method.
UnifiedAutomation.UaServer.FileModel.FileModel |
( |
| ) |
|
|
inline |
Initializes a new instance of the FileModel class.
UnifiedAutomation.UaServer.FileModel.FileModel |
( |
FileModel |
template | ) |
|
|
inline |
Initializes a new instance of the FileModel class.
- Parameters
-
void UnifiedAutomation.UaServer.FileModel.CleanupExpiredHandles |
( |
| ) |
|
|
inlineprotected |
Cleans up any expired handles.
Closes a file represented by a FileType.
When a client closes a file, the handle becomes invalid.
- Parameters
-
context | |
model | |
fileHandle | A handle returned by the Open method, indicating the access request and thus indirectly the position inside the file. |
- Returns
- The result of the operation.
Implements UnifiedAutomation.UaServer.IFileMethods.
void UnifiedAutomation.UaServer.FileModel.CloseHandle |
( |
OpenFileHandle |
handle | ) |
|
|
inlineprotected |
Closes the stream associated with the handle and sets the size of the File object.
- Parameters
-
void UnifiedAutomation.UaServer.FileModel.Dispose |
( |
| ) |
|
|
inline |
Frees any unmanaged resources.
virtual void UnifiedAutomation.UaServer.FileModel.Dispose |
( |
bool |
disposing | ) |
|
|
inlineprotectedvirtual |
An overrideable version of the Dispose.
Finds the handle.
- Parameters
-
context | The context. |
fileHandle | The file handle. |
- Returns
- An open handle.
Determines whether the current context has specified access to the file.
- Parameters
-
context | The request context. |
accessMasks | The desired access masks. UserAccessMask.Read and UserAccessMask.Write will be evaluated. |
- Returns
true
, if the specified context has access; otherwise, false
.
Used to open a file represented by an Object of FileType.
When a client opens a file, it gets a FileHandle that is valid while the session is open. Clients shall use the UnifiedAutomation.UaServer.IFileMethods.Close Method to release the handle when they do not need access to the file anymore. Clients can open the same file several times for reading. A request to open for writing shall return Bad_NotWritable when the file is already opened.
- Parameters
-
context | The context. |
model | The model. |
mode | Indicates whether the file should be opened only for read operations or for read and write operations and where the initial position is set. The mode is an 8-bit unsigned integer used as bit mask with the structure defined in the following table:
See also FileAccessModes enumeration. |
fileHandle | A handle for the file used in other method calls indicating not the file (this is done by the Object of the Method call) but the access request and thus the position in the file. The FileHandle is generated by the server and is unique for the Session. Clients cannot transfer the FileHandle to another Session but need to get a new FileHandle by calling the UnifiedAutomation.UaServer.IFileMethods.Open Method. |
- Returns
- The result of the operation.
Implements UnifiedAutomation.UaServer.IFileMethods.
Reimplemented in UnifiedAutomation.UaServer.TrustListModel.
Opens a stream for the file referenced by FileOnDisk.
- Parameters
-
- Returns
- If FileOnDisk is null, a memory stream is created.
Reads a part of the file starting from the current file position.
The file position is advanced by the number of bytes read.
- Parameters
-
context | The context. |
model | The model. |
fileHandle | A handle returned by the Open method, indicating the access request and thus indirectly the position the file. |
length | Defines the length in byte that should be returned in data, starting from the current position of the file handle. If the end of file is reached, only all data till the end of the file are returned. If the specified length is longer than the maximum allowed message size of the communication, only those data fitting into the message size are returned. Only positive values are allowed. |
data | Contains the returned data of the file. |
- Returns
- The result of the operation.
Implements UnifiedAutomation.UaServer.IFileMethods.
void UnifiedAutomation.UaServer.FileModel.SaveHandle |
( |
OpenFileHandle |
handle | ) |
|
|
inlineprotected |
Assigns a unique id to the handle and saves the handle.
- Parameters
-
Writes a part of the file starting from the current file position.
The file position is advanced by the number of bytes written
- Parameters
-
context | The context. |
model | The file model. |
fileHandle | A handle returned by the Open method, indicating the access request and thus indirectly the position inside the file. |
data | Contains the data to be written at the position of the file. It is server-dependent whether the written data are persistently stored if the session is ended without calling the UnifiedAutomation.UaServer.IFileMethods.Close Method with the FileHandle. |
- Returns
- The result of the operation.
Implements UnifiedAutomation.UaServer.IFileMethods.
object UnifiedAutomation.UaServer.FileModel.Lock = new object() |
|
protected |
An object used to synchronize access to the file object.
IFileMethods UnifiedAutomation.UaServer.FileModel.FileMethods |
|
getset |
Gets or sets the File methods.
The File methods.
FileInfo UnifiedAutomation.UaServer.FileModel.FileOnDisk |
|
getset |
Gets or sets the disk file which can be accessed via the file object.
This should be null if a subclass implements a more complex I/O model.
int UnifiedAutomation.UaServer.FileModel.MaxFileSize |
|
getset |
Gets or sets the maximum size of the file in bytes.
string UnifiedAutomation.UaServer.FileModel.MimeType |
|
getset |
Contains the media type of the file based on RFC 2046.
uint UnifiedAutomation.UaServer.FileModel.NextFileHandle |
|
getsetprotected |
Gets or sets the next file handle to assign.
Gets or sets the NodeAccessInfo to specify user access in Open method.
ushort UnifiedAutomation.UaServer.FileModel.OpenCount |
|
getset |
Indicates the number of currently valid file handles on the file.
ulong UnifiedAutomation.UaServer.FileModel.Size |
|
getset |
Defines the size of the file in Bytes.
When a file is opened for writing the size might not be accurate.
bool UnifiedAutomation.UaServer.FileModel.UserWritable |
|
getset |
Indicates whether the file is writable, taking user access rights into account.
The Property does not take into account whether the file is currently opened for writing by another client and thus currently locked and not writable by others.
bool UnifiedAutomation.UaServer.FileModel.Writable |
|
getset |
Indicates whether the file is writable.
It does not take any user access rights into account, i.e. although the file is writable this may be restricted to a certain user/user group. The Property does not take into account whether the file is currently opened for writing by another client and thus currently locked and not writable by others.
Occurs when the file is closed.
Occurs when the file is opened.
The documentation for this class was generated from the following files:
- C:/work/uasdknet/src/UaServer/Controllers/FileModel.cs
- C:/work/uasdknet/src/UaServer/Models/UaBaseClasses.cs