1 //
2 // Author:
3 //   Jb Evain (jbevain@gmail.com)
4 //
5 // Copyright (c) 2008 - 2015 Jb Evain
6 // Copyright (c) 2008 - 2011 Novell, Inc.
7 //
8 // Licensed under the MIT/X11 license.
9 //
10 
11 namespace Mono.Cecil {
12 
13 	public interface IMarshalInfoProvider : IMetadataTokenProvider {
14 
15 		bool HasMarshalInfo { get; }
16 		MarshalInfo MarshalInfo { get; set; }
17 	}
18 
19 	static partial class Mixin {
20 
GetHasMarshalInfo( this IMarshalInfoProvider self, ModuleDefinition module)21 		public static bool GetHasMarshalInfo (
22 			this IMarshalInfoProvider self,
23 			ModuleDefinition module)
24 		{
25 			return module.HasImage () && module.Read (self, (provider, reader) => reader.HasMarshalInfo (provider));
26 		}
27 
GetMarshalInfo( this IMarshalInfoProvider self, ref MarshalInfo variable, ModuleDefinition module)28 		public static MarshalInfo GetMarshalInfo (
29 			this IMarshalInfoProvider self,
30 			ref MarshalInfo variable,
31 			ModuleDefinition module)
32 		{
33 			return module.HasImage ()
34 				? module.Read (ref variable, self, (provider, reader) => reader.ReadMarshalInfo (provider))
35 				: null;
36 		}
37 	}
38 }
39