2 using System
.Collections
.Generic
;
3 using System
.ComponentModel
.Composition
.Hosting
;
6 using System
.Threading
;
7 using System
.ComponentModel
.Composition
.Primitives
;
9 namespace Microsoft
.Internal
11 internal class ContractServices
13 public static T Cast
<T
>(object o
)
18 public static bool TryCast(Type contractType
, object value, out object result
)
25 if (contractType
.IsInstanceOfType(value))
31 // We couldn't cast see if a delegate works for us.
32 if (typeof(Delegate
).IsAssignableFrom(contractType
))
34 ExportedDelegate exportedDelegate
= value as ExportedDelegate
;
35 if (exportedDelegate
!= null)
37 result
= exportedDelegate
.CreateDelegate(contractType
);
38 return (result
!= null);