示例#1
0
		bool CheckMethod(MethodDef cctor) {
			if (cctor == null || cctor.Body == null)
				return false;
			var localTypes = new LocalTypes(cctor);
			if (!localTypes.Exactly(ilpLocalsV1x) &&
				!localTypes.Exactly(ilpLocalsV2x))
				return false;

			var type = cctor.DeclaringType;
			var methods = GetPinvokeMethods(type, "Protect");
			if (methods.Count == 0)
				methods = GetPinvokeMethods(type, "P0");
			if (methods.Count != 2)
				return false;
			if (type.Fields.Count < 1 || type.Fields.Count > 2)
				return false;

			if (!GetDelegate(type, out invokerInstanceField, out invokerDelegate))
				return false;

			runtimeFileInfos = new List<RuntimeFileInfo>(methods.Count);
			foreach (var method in methods)
				runtimeFileInfos.Add(new RuntimeFileInfo(method));
			return true;
		}
示例#2
0
        bool CheckMethod(MethodDef cctor)
        {
            if (cctor == null || cctor.Body == null)
            {
                return(false);
            }
            var localTypes = new LocalTypes(cctor);

            if (!localTypes.Exactly(ilpLocalsV1x) &&
                !localTypes.Exactly(ilpLocalsV2x))
            {
                return(false);
            }

            var type    = cctor.DeclaringType;
            var methods = GetPinvokeMethods(type, "Protect");

            if (methods.Count == 0)
            {
                methods = GetPinvokeMethods(type, "P0");
            }
            if (methods.Count != 2)
            {
                return(false);
            }
            if (type.Fields.Count < 1 || type.Fields.Count > 2)
            {
                return(false);
            }

            if (!GetDelegate(type, out invokerInstanceField, out invokerDelegate))
            {
                return(false);
            }

            runtimeFileInfos = new List <RuntimeFileInfo>(methods.Count);
            foreach (var method in methods)
            {
                runtimeFileInfos.Add(new RuntimeFileInfo(method));
            }
            return(true);
        }