IsComObject() static private method

static private IsComObject ( object obj ) : bool
obj object
return bool
コード例 #1
0
ファイル: ComObject.cs プロジェクト: tralivali1234/dlr
        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);
            }
        }
コード例 #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));
 }
コード例 #3
0
ファイル: ComObject.cs プロジェクト: todor-dk/IronSmalltalk
 internal ComObject(object rcw)
 {
     Debug.Assert(ComObject.IsComObject(rcw));
     _rcw = rcw;
 }