Code inspections
This commit is contained in:
+63
-63
@@ -33,43 +33,43 @@ namespace ASCOM.Meade.net
|
||||
#region Access to ole32.dll functions for class factories
|
||||
|
||||
// Define two common GUID objects for public usage.
|
||||
public static Guid IID_IUnknown = new Guid("{00000000-0000-0000-C000-000000000046}");
|
||||
public static Guid IID_IDispatch = new Guid("{00020400-0000-0000-C000-000000000046}");
|
||||
public static Guid IidIUnknown = new Guid("{00000000-0000-0000-C000-000000000046}");
|
||||
public static Guid IidIDispatch = new Guid("{00020400-0000-0000-C000-000000000046}");
|
||||
|
||||
[Flags]
|
||||
enum CLSCTX : uint
|
||||
enum Clsctx : uint
|
||||
{
|
||||
CLSCTX_INPROC_SERVER = 0x1,
|
||||
CLSCTX_INPROC_HANDLER = 0x2,
|
||||
CLSCTX_LOCAL_SERVER = 0x4,
|
||||
CLSCTX_INPROC_SERVER16 = 0x8,
|
||||
CLSCTX_REMOTE_SERVER = 0x10,
|
||||
CLSCTX_INPROC_HANDLER16 = 0x20,
|
||||
CLSCTX_RESERVED1 = 0x40,
|
||||
CLSCTX_RESERVED2 = 0x80,
|
||||
CLSCTX_RESERVED3 = 0x100,
|
||||
CLSCTX_RESERVED4 = 0x200,
|
||||
CLSCTX_NO_CODE_DOWNLOAD = 0x400,
|
||||
CLSCTX_RESERVED5 = 0x800,
|
||||
CLSCTX_NO_CUSTOM_MARSHAL = 0x1000,
|
||||
CLSCTX_ENABLE_CODE_DOWNLOAD = 0x2000,
|
||||
CLSCTX_NO_FAILURE_LOG = 0x4000,
|
||||
CLSCTX_DISABLE_AAA = 0x8000,
|
||||
CLSCTX_ENABLE_AAA = 0x10000,
|
||||
CLSCTX_FROM_DEFAULT_CONTEXT = 0x20000,
|
||||
CLSCTX_INPROC = CLSCTX_INPROC_SERVER | CLSCTX_INPROC_HANDLER,
|
||||
CLSCTX_SERVER = CLSCTX_INPROC_SERVER | CLSCTX_LOCAL_SERVER | CLSCTX_REMOTE_SERVER,
|
||||
CLSCTX_ALL = CLSCTX_SERVER | CLSCTX_INPROC_HANDLER
|
||||
ClsctxInprocServer = 0x1,
|
||||
ClsctxInprocHandler = 0x2,
|
||||
ClsctxLocalServer = 0x4,
|
||||
ClsctxInprocServer16 = 0x8,
|
||||
ClsctxRemoteServer = 0x10,
|
||||
ClsctxInprocHandler16 = 0x20,
|
||||
ClsctxReserved1 = 0x40,
|
||||
ClsctxReserved2 = 0x80,
|
||||
ClsctxReserved3 = 0x100,
|
||||
ClsctxReserved4 = 0x200,
|
||||
ClsctxNoCodeDownload = 0x400,
|
||||
ClsctxReserved5 = 0x800,
|
||||
ClsctxNoCustomMarshal = 0x1000,
|
||||
ClsctxEnableCodeDownload = 0x2000,
|
||||
ClsctxNoFailureLog = 0x4000,
|
||||
ClsctxDisableAaa = 0x8000,
|
||||
ClsctxEnableAaa = 0x10000,
|
||||
ClsctxFromDefaultContext = 0x20000,
|
||||
ClsctxInproc = ClsctxInprocServer | ClsctxInprocHandler,
|
||||
ClsctxServer = ClsctxInprocServer | ClsctxLocalServer | ClsctxRemoteServer,
|
||||
ClsctxAll = ClsctxServer | ClsctxInprocHandler
|
||||
}
|
||||
|
||||
[Flags]
|
||||
enum REGCLS : uint
|
||||
enum Regcls : uint
|
||||
{
|
||||
REGCLS_SINGLEUSE = 0,
|
||||
REGCLS_MULTIPLEUSE = 1,
|
||||
REGCLS_MULTI_SEPARATE = 2,
|
||||
REGCLS_SUSPENDED = 4,
|
||||
REGCLS_SURROGATE = 8
|
||||
RegclsSingleuse = 0,
|
||||
RegclsMultipleuse = 1,
|
||||
RegclsMultiSeparate = 2,
|
||||
RegclsSuspended = 4,
|
||||
RegclsSurrogate = 8
|
||||
}
|
||||
//
|
||||
// CoRegisterClassObject() is used to register a Class Factory
|
||||
@@ -109,30 +109,30 @@ namespace ASCOM.Meade.net
|
||||
|
||||
#region Constructor and Private ClassFactory Data
|
||||
|
||||
protected readonly Type m_ClassType;
|
||||
protected Guid m_ClassId;
|
||||
protected readonly ArrayList m_InterfaceTypes;
|
||||
protected uint m_ClassContext;
|
||||
protected uint m_Flags;
|
||||
protected UInt32 m_locked = 0;
|
||||
protected uint m_Cookie;
|
||||
protected string m_progid;
|
||||
protected readonly Type MClassType;
|
||||
protected Guid MClassId;
|
||||
protected readonly ArrayList MInterfaceTypes;
|
||||
protected uint MClassContext;
|
||||
protected uint MFlags;
|
||||
protected UInt32 MLocked = 0;
|
||||
protected uint MCookie;
|
||||
protected string MProgid;
|
||||
|
||||
public ClassFactory(Type type)
|
||||
{
|
||||
if (type == null)
|
||||
throw new ArgumentNullException("type");
|
||||
m_ClassType = type;
|
||||
MClassType = type;
|
||||
|
||||
//PWGS Get the ProgID from the MetaData
|
||||
m_progid = Marshal.GenerateProgIdForType(type);
|
||||
m_ClassId = Marshal.GenerateGuidForType(type); // Should be nailed down by [Guid(...)]
|
||||
m_ClassContext = (uint)CLSCTX.CLSCTX_LOCAL_SERVER; // Default
|
||||
m_Flags = (uint)REGCLS.REGCLS_MULTIPLEUSE | // Default
|
||||
(uint)REGCLS.REGCLS_SUSPENDED;
|
||||
m_InterfaceTypes = new ArrayList();
|
||||
MProgid = Marshal.GenerateProgIdForType(type);
|
||||
MClassId = Marshal.GenerateGuidForType(type); // Should be nailed down by [Guid(...)]
|
||||
MClassContext = (uint)Clsctx.ClsctxLocalServer; // Default
|
||||
MFlags = (uint)Regcls.RegclsMultipleuse | // Default
|
||||
(uint)Regcls.RegclsSuspended;
|
||||
MInterfaceTypes = new ArrayList();
|
||||
foreach (Type T in type.GetInterfaces()) // Save all of the implemented interfaces
|
||||
m_InterfaceTypes.Add(T);
|
||||
MInterfaceTypes.Add(T);
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -140,20 +140,20 @@ namespace ASCOM.Meade.net
|
||||
#region Common ClassFactory Methods
|
||||
public uint ClassContext
|
||||
{
|
||||
get => m_ClassContext;
|
||||
set => m_ClassContext = value;
|
||||
get => MClassContext;
|
||||
set => MClassContext = value;
|
||||
}
|
||||
|
||||
public Guid ClassId
|
||||
{
|
||||
get => m_ClassId;
|
||||
set => m_ClassId = value;
|
||||
get => MClassId;
|
||||
set => MClassId = value;
|
||||
}
|
||||
|
||||
public uint Flags
|
||||
{
|
||||
get => m_Flags;
|
||||
set => m_Flags = value;
|
||||
get => MFlags;
|
||||
set => MFlags = value;
|
||||
}
|
||||
|
||||
public bool RegisterClassObject()
|
||||
@@ -161,18 +161,18 @@ namespace ASCOM.Meade.net
|
||||
// Register the class factory
|
||||
int i = CoRegisterClassObject
|
||||
(
|
||||
ref m_ClassId,
|
||||
ref MClassId,
|
||||
this,
|
||||
m_ClassContext,
|
||||
m_Flags,
|
||||
out m_Cookie
|
||||
MClassContext,
|
||||
MFlags,
|
||||
out MCookie
|
||||
);
|
||||
return (i == 0);
|
||||
}
|
||||
|
||||
public bool RevokeClassObject()
|
||||
{
|
||||
int i = CoRevokeClassObject(m_Cookie);
|
||||
int i = CoRevokeClassObject(MCookie);
|
||||
return (i == 0);
|
||||
}
|
||||
|
||||
@@ -201,25 +201,25 @@ namespace ASCOM.Meade.net
|
||||
//
|
||||
// Handle specific requests for implemented interfaces
|
||||
//
|
||||
foreach (Type iType in m_InterfaceTypes)
|
||||
foreach (Type iType in MInterfaceTypes)
|
||||
{
|
||||
if (riid == Marshal.GenerateGuidForType(iType))
|
||||
{
|
||||
ppvObject = Marshal.GetComInterfaceForObject(Activator.CreateInstance(m_ClassType), iType);
|
||||
ppvObject = Marshal.GetComInterfaceForObject(Activator.CreateInstance(MClassType), iType);
|
||||
return;
|
||||
}
|
||||
}
|
||||
//
|
||||
// Handle requests for IDispatch or IUnknown on the class
|
||||
//
|
||||
if (riid == IID_IDispatch)
|
||||
if (riid == IidIDispatch)
|
||||
{
|
||||
ppvObject = Marshal.GetIDispatchForObject(Activator.CreateInstance(m_ClassType));
|
||||
ppvObject = Marshal.GetIDispatchForObject(Activator.CreateInstance(MClassType));
|
||||
return;
|
||||
}
|
||||
else if (riid == IID_IUnknown)
|
||||
else if (riid == IidIUnknown)
|
||||
{
|
||||
ppvObject = Marshal.GetIUnknownForObject(Activator.CreateInstance(m_ClassType));
|
||||
ppvObject = Marshal.GetIUnknownForObject(Activator.CreateInstance(MClassType));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user