// The static constructor prepares static readonly fields static zmq() { // (0) Initialize Library handle (try libsodium.* before libzmq.*) try { NativeLibSodium = Platform.LoadUnmanagedLibrary(SodiumLibraryName); } catch (System.IO.FileNotFoundException) { } // (0) Initialize Library handle NativeLib = Platform.LoadUnmanagedLibrary(LibraryName); // (1) Initialize Platform information Platform.SetupImplementation(typeof(zmq)); // Set once LibVersion to libversion() int major, minor, patch; version(out major, out minor, out patch); Version = new Version(major, minor, patch); // Trigger static constructor var noSym = ZSymbol.None; if (major >= 4) { // Current Version 4 // Use default delegate settings from field initializers. // "Compatability" is done by "disabling" old methods, or "redirecting" to new methods, // so the developer is forced to work against the latest API if (minor == 0) { sizeof_zmq_msg_t = sizeof_zmq_msg_t_v3; } } else // if (major >= 3) { // TODO: Backwards compatability for v3 throw VersionNotSupported(null, ">= 4"); } // else { } }
// The static constructor prepares static readonly fields static zmq() { // (0) Initialize Library handle (try libsodium.* before libzmq.*) try { NativeLibSodium = Platform.LoadUnmanagedLibrary(SodiumLibraryName); } catch (System.IO.FileNotFoundException) { } // (0) Initialize Library handle NativeLib = Platform.LoadUnmanagedLibrary(LibraryName); // (1) Initialize Platform information Platform.SetupImplementation(typeof(zmq)); // Set once LibVersion to libversion() int major, minor, patch; version(out major, out minor, out patch); LibraryVersion = new Version(major, minor, patch); // Trigger static constructor var noSym = ZSymbol.None; if (major >= 4) { // Current Version 4 // Use default delegate settings from field initializers. // "Compatibility" is done by "disabling" old methods, or "redirecting" to new methods, // so the developer is forced to work against the latest API if (minor == 0) { sizeof_zmq_msg_t = sizeof_zmq_msg_t_v3; } } else if (major >= 3) { // Backwards compatibility for v3 sizeof_zmq_msg_t = sizeof_zmq_msg_t_v3; zmq.ctx_shutdown = (ctxPtr) => { throw VersionNotSupported("zmq_ctx_shutdown", "v4"); }; zmq.msg_gets = (msgPtr, propertyPtr) => { throw VersionNotSupported("zmq_msg_gets", "v4"); }; zmq.has = (capabilityPtr) => { throw VersionNotSupported("zmq_has", "v4"); }; zmq.proxy_steerable = (frontendPtr, backendPtr, capturePtr, controlPtr) => { throw VersionNotSupported("zmq_proxy_steerable", "v4"); }; zmq.curve_keypair = (z85_public_key, z85_secret_key) => { throw VersionNotSupported("zmq_curve_keypair", "v4"); }; zmq.z85_encode = (dest, data, size) => { throw VersionNotSupported("zmq_z85_encode", "v4"); }; zmq.z85_decode = (dest, data) => { throw VersionNotSupported("zmq_z85_decode", "v4"); }; if (!Platform.Is__Internal) { zmq.ctx_term = zmq.zmq_term; } else { zmq.ctx_term = zmq.zmq_term__Internal; } } else { throw VersionNotSupported(null, ">= v3"); } }