11#define META_STATIC_OVERWRITE
18using System.Reflection;
19using System.Runtime.InteropServices;
20using System.Runtime.CompilerServices;
21using System.Collections.Generic;
22using System.Threading;
30 public partial class MqFactoryC
32 public partial class MqFactoryC :
MkObjectC
35 private readonly
static ConstructorInfo ctor =
getCtor(typeof(MqFactoryC));
36 private readonly
static ThreadLocal<MqFactoryC> MK_NULL =
new ThreadLocal<MqFactoryC>(() => {
48 private static IntPtr MqFactoryC_SelfCreate (IntPtr
mkrt, IntPtr obj, IntPtr env) {
52 private static void MqFactoryC_SelfUnlink (IntPtr
mkrt, IntPtr
self, IntPtr env) {
56 internal static void SetupThreadFCT (IntPtr
mkrt) {
57 Mq.MqCsTypeUpdate(
mkrt, MqCsTypeLookupE.FCT, MqFactoryC_SelfCreate, MqFactoryC_SelfUnlink);
60 #if !META_STATIC_OVERWRITE
65 SetupThreadFCT(IntPtr.Zero);
74 Mq.MqCsTypeUpdate(IntPtr.Zero, MqCsTypeLookupE.FCT, MqFactoryC_SelfCreate, MqFactoryC_SelfUnlink);
76 if (MqFactoryC.DefaultIdent() ==
"libmqmsgque") {
81 internal MqFactoryC (IntPtr ptr) : base(ptr) {
95 private static MkErrorE FactoryCreate (
96 IntPtr
mkrt, IntPtr mqrt, IntPtr tmpl,
MqFactoryE create, IntPtr fct, out IntPtr contextP
98 contextP = IntPtr.Zero;
100 Object tmplO = MqContextC.MqContextC_ObjNewOrNull(tmpl);
101 ConstructorInfo constr =
null;
104 constr = tmplO.GetType().GetConstructor(
new Type[] {typeof(MqContextC)});
106 IntPtr data =
Mq.MqFactoryItemGetCreateData(fct);
107 constr = (ConstructorInfo)GCHandle.FromIntPtr(data).Target;
109 Object[] args =
new Object[] {tmplO};
110 contextP = ((MqContextC)(constr).Invoke(args)).hdl;
112 }
catch (Exception ex) {
117 Mq.MqSetupDup (
mkrt, contextP, tmpl);
122 private static void FactoryDelete (IntPtr
mkrt, IntPtr ctx,
bool doFactoryCleanup, IntPtr fct) {
125 if (
self != IntPtr.Zero) {
126 var selfO = GCHandle.FromIntPtr(
self).Target;
133 Mq.MqContextDelete(
mkrt, ctx);
136 private static void FactoryDataFree (IntPtr
mkrt, ref IntPtr data) {
137 GCHandle.FromIntPtr(data).Free();
141 private static void FactoryDataCopy (IntPtr
mkrt, ref IntPtr data) {
142 data = (IntPtr)GCHandle.Alloc((ConstructorInfo)GCHandle.FromIntPtr(data).Target);
150 public partial class MqFactoryC {
160 IntPtr __retVal__L =
Mq.MqFactoryHandleResolve(IntPtr.Zero, netHdl);
172 public partial class MqFactoryC {
182 IntPtr __retVal__L =
Mq.MqFactoryNext(
hdl);
188 IntPtr __retVal__L =
Mq.MqFactoryPrev(
hdl);
196 IntPtr __retVal__L =
Mq.MqFactoryInstances(IntPtr.Zero);
204 public partial class MqFactoryC {
214 IntPtr __retVal__L =
Mq.MqFactoryGetNull();
222 public partial class MqFactoryC {
232 IntPtr ident_cstr = Marshal.StringToHGlobalAnsi(ident);
233 IntPtr __retVal__L =
Mq.MqFactoryGet(IntPtr.Zero, ident_cstr);
234 Marshal.FreeHGlobal(ident_cstr);
240 IntPtr ident_cstr = Marshal.StringToHGlobalAnsi(ident);
241 IntPtr __retVal__L =
Mq.MqFactoryGetCalled(IntPtr.Zero, ident_cstr);
242 Marshal.FreeHGlobal(ident_cstr);
248 IntPtr largs_hdl =
MkBufferListC.getOBJ(
"MkBufferListC",largs);
249 IntPtr __retVal__L =
Mq.MqFactoryGetCalledL(IntPtr.Zero, largs_hdl);
257 IntPtr __retVal__L =
Mq.MqFactoryGetOriginalIdent(
hdl);
258 return Marshal.PtrToStringAnsi(__retVal__L);
265 public partial class MqFactoryC {
275 IntPtr __retVal__L =
Mq.MqFactoryDefault(
mkrt,
hdl);
281 IntPtr __retVal__L =
Mq.MqFactoryInitial(
mkrt,
hdl);
303 IntPtr __retVal__L =
Mq.MqFactoryDefaultIdent(IntPtr.Zero);
304 return Marshal.PtrToStringAnsi(__retVal__L);
309 IntPtr __retVal__L =
Mq.MqFactoryInitialIdent(IntPtr.Zero);
310 return Marshal.PtrToStringAnsi(__retVal__L);
314 public static void LogAll ([CallerMemberName]
string callfunc =
null) {
315 IntPtr callfunc_cstr = Marshal.StringToHGlobalAnsi(callfunc);
316 Mq.MqFactoryLogAll(IntPtr.Zero, callfunc_cstr);
317 Marshal.FreeHGlobal(callfunc_cstr);
334 IntPtr ident_cstr = Marshal.StringToHGlobalAnsi(ident);
335 IntPtr __retVal__L =
Mq.MqFactoryDup2(
mkrt,
hdl, ident_cstr);
336 Marshal.FreeHGlobal(ident_cstr);
337 if (__retVal__L == IntPtr.Zero) {
340 return MqFactoryC.MqFactoryC_ObjCreate(__retVal__L);
346 public MqFactoryC(Type constructor,
string ident =
null) : this(
CTOR(constructor, ident)) {}
350 if (ident ==
null) {ident = constructor.Name;}
351 if (ident ==
null) {ident = constructor.Name;}
352 IntPtr constructor_c;
355 ConstructorInfo constr = constructor.GetConstructor(
new Type[] {typeof(
MqContextC)});
356 if (constr ==
null) {
357 throw new System.Exception(
"unable to get Factory constructor");
359 constructor_c = (IntPtr) GCHandle.Alloc(constr);
361 IntPtr ident_cstr = Marshal.StringToHGlobalAnsi(ident);
362 IntPtr __retVal__L =
Mq.MqFactoryAdd(IntPtr.Zero, IntPtr.Zero, fFactoryCreate, constructor_c, fFactoryDataFree, fFactoryDataCopy, fFactoryDelete, IntPtr.Zero,
null,
null, ident_cstr);
363 Marshal.FreeHGlobal(ident_cstr);
364 if (__retVal__L == IntPtr.Zero) {
367 return MqFactoryC.MqFactoryC_ObjCreate(__retVal__L);
371 protected static IntPtr
CTOR (Type constructor,
string ident =
null) {
372 if (ident ==
null) {ident = constructor.Name;}
373 IntPtr constructor_c;
376 ConstructorInfo constr = constructor.GetConstructor(
new Type[] {typeof(
MqContextC)});
377 if (constr ==
null) {
378 throw new System.Exception(
"unable to get Factory constructor");
380 constructor_c = (IntPtr) GCHandle.Alloc(constr);
382 IntPtr ident_cstr = Marshal.StringToHGlobalAnsi(ident);
383 IntPtr __retVal__L =
Mq.MqFactoryAdd(IntPtr.Zero, IntPtr.Zero, fFactoryCreate, constructor_c, fFactoryDataFree, fFactoryDataCopy, fFactoryDelete, IntPtr.Zero,
null,
null, ident_cstr);
384 Marshal.FreeHGlobal(ident_cstr);
385 if (__retVal__L == IntPtr.Zero) {
388 return (IntPtr)__retVal__L;
421 var fct =
CTOR(typeof(T),ident);
429 return (T) base.New();
444 internal class MqFactoryCException : Exception
446 internal MqFactoryCException(
string message =
"") : base(
"MqFactoryC exception: " + message) {}
static void Check(IntPtr ctx, MkErrorE err)
static object atomObjNew(Type type, ConstructorInfo ctor, IntPtr obj)
static object atomObjCreate(Type type, ConstructorInfo ctor, IntPtr obj)
static void atomSelfUnlink(IntPtr self, IntPtr env)
static object atomSelfNull(ConstructorInfo ctor)
static ConstructorInfo getCtor(Type type)
static IntPtr atomSelfCreate(ConstructorInfo ctor, IntPtr obj, IntPtr env)
static unsafe void CsMakePersistent(IntPtr hdl)
static unsafe IntPtr CsGetSelfPtr(IntPtr hdl)
MqContextC - the class known as ctx or context is the application-handle of the application-server an...
static MqContextC MqContextC_ObjNew(IntPtr hdl)
Implements the factory-template.
static MqFactoryCT< T > Add(string ident=null)
C#: [constructor,static] MqFactoryC MqFactoryC.Add(Type constructor, string ident = null) → C-API ...
new MqFactoryCT< T > Initial()
MqFactoryC - the class known as fct or factory is used to provide an interface to create one or more ...
static MqFactoryC MqFactoryC_ObjNew(IntPtr hdl)
MkErrorE Stack([CallerMemberName]string callfunc=null,[CallerFilePath]string callfile=null,[CallerLineNumber]int callline=-1)
MkErrorC Catch(Exception exception=null,[CallerMemberName]string callfunc=null)
static MkErrorC DEFAULT()
enum MkErrorE(* MqFactoryCTorF)(MK_RT mkrt, MQ_RT mqrt, MQ_CTX const tmpl, enum MqFactoryE create, MQ_FCT const fct, MQ_CTX *ctx_out)
type of a MqFactoryC constructor
void(* MqFactoryDataFreeF)(MK_RT mkrt, MK_PTR *dataP)
prototype for a free additional factory data function
void(* MqFactoryDTorF)(MK_RT mkrt, MQ_CTX ctx, bool doFactoryCleanup, MQ_FCT const fct)
type of a MqFactoryC destructor
void(* MqFactoryDataCopyF)(MK_RT mkrt, MK_PTR *dataP)
prototype for a copy additional factory data function
new MqFactoryC Prev()
C#: MqFactoryC fct.Prev() → C-API get previous instance from linked-list of MqFactoryS type
new static MqFactoryC Instances()
C#: [static] MqFactoryC MqFactoryC.Instances() → C-API get head-instance from linked-list of MqF...
new MqFactoryC Next()
C#: MqFactoryC fct.Next() → C-API get next instance from linked-list of MqFactoryS type
new static MqFactoryC GetNull()
C#: [static] MqFactoryC MqFactoryC.GetNull() → C-API Null-Slot - return a MqFactoryC typed NULL ...
new static MqFactoryC HandleResolve(Int32 netHdl)
C#: [static] MqFactoryC MqFactoryC.HandleResolve(Int32 netHdl) → C-API Handle-Resolve-Slot - ret...
#define MqFactoryCT
class as MkTypeDefS-class-type for MqFactoryC in the Target-Programming-Language (TPL) …
static MqFactoryC GetCalled(string ident="")
C#: [static] MqFactoryC MqFactoryC.GetCalled(string ident = "") → C-API returns the MqFactoryC i...
static MqFactoryC GetCalled(MkBufferListC largs)
C#: [static] MqFactoryC MqFactoryC.GetCalled(MkBufferListC largs) → C-API returns the MqFactoryC...
static MqFactoryC Get(string ident="")
C#: [static] MqFactoryC MqFactoryC.Get(string ident = "") → C-API return the MqFactoryC
string GetOriginalIdent()
C#: string fct.GetOriginalIdent() → C-API helper function to return MqFactoryS....
static void LogAll([CallerMemberName]string callfunc=null)
C#: [static] MqFactoryC.LogAll([CallerMemberName]string callfunc = null) → C-API log all "factor...
MqFactoryC Default()
C#: MqFactoryC fct.Default() → C-API set the default-attribute to the factory …
MqFactoryC Initial()
C#: MqFactoryC fct.Initial() → C-API set the initial-attribut to fct …
MqContextC New()
C#: MqContextC fct.New() → C-API create a new MqContextC from a MqFactoryC …
static string DefaultIdent()
C#: [static] string MqFactoryC.DefaultIdent() → C-API return the factory-identifier of the defau...
static string InitialIdent()
C#: [static] string MqFactoryC.InitialIdent() → C-API return the factory-identifier of the initi...
MqFactoryC(Type constructor, string ident=null)
CONSTRUCTOR.
static MqFactoryC Add(Type constructor, string ident=null)
C#: [constructor,static] MqFactoryC MqFactoryC.Add(Type constructor, string ident = null) → C-API ...
MqFactoryC Dup2(string ident)
C#: [constructor] MqFactoryC fct.Dup2(string ident) → C-API create a duplicate of the singleton ...
static IntPtr CTOR(Type constructor, string ident=null)
C#: [constructor,static] MqFactoryC MqFactoryC.Add(Type constructor, string ident = null) → C-API ...
MqFactoryE
the factory is called to create an object for ...