IsComObject() static private method

static private IsComObject ( object obj ) : bool
obj object
return bool
Exemplo n.º 1
0
        public static ComObject ObjectToComObject(object rcw)
        {
            Debug.Assert(ComObject.IsComObject(rcw));

            // Marshal.Get/SetComObjectData has a LinkDemand for UnmanagedCode which will turn into
            // a full demand. We could avoid this by making this method SecurityCritical
            object data = Marshal.GetComObjectData(rcw, _ComObjectInfoKey);

            if (data != null)
            {
                return((ComObject)data);
            }

            lock (_ComObjectInfoKey) {
                data = Marshal.GetComObjectData(rcw, _ComObjectInfoKey);
                if (data != null)
                {
                    return((ComObject)data);
                }

                ComObject comObjectInfo = CreateComObject(rcw);
                if (!Marshal.SetComObjectData(rcw, _ComObjectInfoKey, comObjectInfo))
                {
                    throw Error.SetComObjectDataFailed();
                }

                return(comObjectInfo);
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Determines if an object is a COM object.
 /// </summary>
 /// <param name="value">The object to test.</param>
 /// <returns>true if the object is a COM object, false otherwise.</returns>
 public static bool IsComObject(object value)
 {
     return(ComObject.IsComObject(value));
 }
Exemplo n.º 3
0
 internal ComObject(object rcw)
 {
     Debug.Assert(ComObject.IsComObject(rcw));
     _rcw = rcw;
 }