예제 #1
0
        public static UnsafeObjectRef Create(IObjectRef objectRef)
        {
            Validate.IsNotNull <IObjectRef>(objectRef, "objectRef");
            UnsafeObjectRef?nullable = TryCreate(objectRef);

            if (!nullable.HasValue)
            {
                ExceptionUtil.ThrowObjectDisposedException(objectRef.GetType().FullName);
            }
            return(nullable.Value);
        }
예제 #2
0
        public static IObjectRef CreateRef(this IObjectRef objectRef, Type interfaceType)
        {
            IObjectRef ref2;
            bool?      nullable = objectRef.TryCreateRef(interfaceType, out ref2);

            if (!nullable.HasValue)
            {
                throw new ObjectDisposedException(objectRef.GetType().FullName);
            }
            if (!nullable.Value)
            {
                throw new InterfaceNotSupportedException(interfaceType);
            }
            return(ref2);
        }