/// <summary> /// Initializes the object. /// </summary> public OpcServer() { _factory = null; _server = null; _url = null; _serverName = null; _supportedLocales = null; _resourceManager = new ResourceManager("Technosoftware.DaAeHdaClient.Resources.Strings", Assembly.GetExecutingAssembly()); }
/// <summary> /// Initializes the object. /// </summary> public OpcServer() { Factory = null; Server = null; opcUrl_ = null; serverName_ = null; supportedLocales_ = null; ResourceManager = new ResourceManager("Technosoftware.DaAeHdaClient.Resources.Strings", Assembly.GetExecutingAssembly()); }
/// <summary>Establishes a physical connection to the remote server.</summary> /// <exception cref="OpcResultException" caption="OpcResultException Class">If an OPC specific error occur this exception is raised. The Result field includes then the OPC specific code.</exception> /// <param name="url">Name of the server. The usual form is http:://xxx/yyy, e.g. http://localhost//TsOpcXSampleServer/Service.asmx.</param> public virtual void Connect(string url) { OpcConnectData connectData = null; _factory = null; OpcUrl opcurl = new OpcUrl(url); Connect(opcurl, connectData); }
//------------------------------------- // Consumption helper methods. //--------------------------------- // Function to consume the new music bundle. // Exposed through MusicBundle.h. // /////////////////////////////////////////////////////////////////////////////// // Description: Deserializes the contents of a music bundle package, displays text from the Track List, Lyrics, Album Website parts. // The method then serializes the contents of the parts to files in specified output directory. /////////////////////////////////////////////////////////////////////////////// private static void ConsumeMusicBundle(string inputPackageName, // Name of music bundle. string outputDirectory // Directory into which music bundle parts are written as files. ) { // Create a new factory. var opcFactory = new IOpcFactory(); // Open a read-only stream over the input package. opcFactory.CreateStreamOnFile(inputPackageName, OPC_STREAM_IO_MODE.OPC_STREAM_IO_READ, // Read-only.
//------------------------------------- // Production helper methods. /////////////////////////////////////////////////////////////////////////////// // Description: Adds the Album Art part to the package and creates a package relationship to that has the Album Art part as its target. /////////////////////////////////////////////////////////////////////////////// private static void AddAlbumArtToBundle(IOpcFactory opcFactory, IOpcPartSet packagePartSet, // Represents the set of parts (excluding Relationships parts) in a package. IOpcRelationshipSet packageRelationshipSet, // Represents the Relationships part that stores package relationships. string inputDirectory // Directory location of the files specified in trackName and lyricsName. ) { // Add Album Art part. AddPartToBundle(opcFactory, g_albumArt, packagePartSet, g_albumArtContentType, OPC_COMPRESSION_OPTIONS.OPC_COMPRESSION_NONE, inputDirectory, out IOpcPartUri albumArtPartUri, out _); // Add a package relationship that has the Album Art part as its target. packageRelationshipSet.CreateRelationship(default, // Use auto-generated relationship ID.
/////////////////////////////////////////////////////////////////////////////// // Description: Opens a stream to the path and file name specified, and deserializes the file's content as the content of the part. /////////////////////////////////////////////////////////////////////////////// private static void WriteFileContentToPart(IOpcFactory opcFactory, string filePath, // Directory where the file is located. string fileName, // Name of file whose content will be deserialized. IOpcPart opcPart // Part into which the file content is deserialized. ) { // Get the full file name of the file. GetFullFileName(filePath, fileName, out var fullFileName); // Create a read-only stream over the file. opcFactory.CreateStreamOnFile(fullFileName, OPC_STREAM_IO_MODE.OPC_STREAM_IO_READ, default,
/// <summary> /// This must be called explicitly by clients to ensure the remote server is released. /// </summary> public virtual void Dispose() { if (_factory != null) { _factory.Dispose(); _factory = null; } if (_server != null) { try { Disconnect(); } catch (Exception e) { } _server = null; } }
/// <summary> /// Initializes the object with a factory and a default OpcUrl. /// </summary> /// <param name="factory">The OpcFactory used to connect to remote servers.</param> /// <param name="url">The network address of a remote server.</param> public OpcServer(OpcFactory factory, OpcUrl url) { if (factory == null) { throw new ArgumentNullException("factory"); } _factory = (IOpcFactory)factory.Clone(); _server = null; _url = null; _serverName = null; _supportedLocales = null; _resourceManager = new ResourceManager("Technosoftware.DaAeHdaClient.Resources.Strings", Assembly.GetExecutingAssembly()); if (url != null) { SetUrl(url); } }
/// <summary> /// This must be called explicitly by clients to ensure the remote server is released. /// </summary> public virtual void Dispose() { if (Factory != null) { Factory.Dispose(); Factory = null; } if (Server != null) { try { Disconnect(); } catch { // ignored } Server = null; } }
/// <summary> /// Contructs a server by de-serializing its OpcUrl from the stream. /// </summary> internal OpcServer(SerializationInfo info, StreamingContext context) { _serverName = info.GetString(Names.NAME); _url = (OpcUrl)info.GetValue(Names.URL, typeof(OpcUrl)); _factory = (IOpcFactory)info.GetValue(Names.FACTORY, typeof(IOpcFactory)); }
/// <summary> /// Construct a server by de-serializing its OpcUrl from the stream. /// </summary> internal OpcServer(SerializationInfo info, StreamingContext context) { serverName_ = info.GetString(Names.Name); opcUrl_ = (OpcUrl)info.GetValue(Names.Url, typeof(OpcUrl)); Factory = (IOpcFactory)info.GetValue(Names.Factory, typeof(IOpcFactory)); }
public void _Setup() => factory = new IOpcFactory();