Exemple #1
0
 public override void Execute( MethodInfo aMethod, ILOpCode aOpCode )
 {
     DoNullReferenceCheck(Assembler, DebugEnabled, 0);
     XS.Pop(XSRegisters.EAX);
     new CPUx86.Push { DestinationReg = CPUx86.RegistersEnum.EAX, DestinationIsIndirect = true, DestinationDisplacement = 4 };
     XS.Push(XSRegisters.EAX, isIndirect: true);
 }
 public MemberInfo[] GetTestedMethods()
   {
   Type type = typeof(Convert);
   ArrayList list = new ArrayList();
   list.Add(type.GetMethod("ToBoolean", new Type[]{typeof(Byte)}));
   list.Add(type.GetMethod("ToBoolean", new Type[]{typeof(SByte)}));
   list.Add(type.GetMethod("ToBoolean", new Type[]{typeof(Int16)}));
   list.Add(type.GetMethod("ToBoolean", new Type[]{typeof(Int32)}));
   list.Add(type.GetMethod("ToBoolean", new Type[]{typeof(Int64)}));
   list.Add(type.GetMethod("ToBoolean", new Type[]{typeof(UInt16)}));
   list.Add(type.GetMethod("ToBoolean", new Type[]{typeof(UInt32)}));
   list.Add(type.GetMethod("ToBoolean", new Type[]{typeof(UInt64)}));
   list.Add(type.GetMethod("ToBoolean", new Type[]{typeof(String), typeof(IFormatProvider)}));
   list.Add(type.GetMethod("ToBoolean", new Type[]{typeof(String)}));
   list.Add(type.GetMethod("ToBoolean", new Type[]{typeof(Boolean)}));
   list.Add(type.GetMethod("ToBoolean", new Type[]{typeof(Char)}));
   list.Add(type.GetMethod("ToBoolean", new Type[]{typeof(Object)}));
   list.Add(type.GetMethod("ToBoolean", new Type[]{typeof(Object), typeof(IFormatProvider)}));
   list.Add(type.GetMethod("ToBoolean", new Type[]{typeof(Single)}));
   list.Add(type.GetMethod("ToBoolean", new Type[]{typeof(Double)}));
   list.Add(type.GetMethod("ToBoolean", new Type[]{typeof(DateTime)}));
   list.Add(type.GetMethod("ToBoolean", new Type[]{typeof(Decimal)}));
   MethodInfo[] methods = new MethodInfo[list.Count];
   list.CopyTo(methods, 0);
   return methods;
   }
Exemple #3
0
		public override void Execute(MethodInfo aMethod, ILOpCode aOpCode) {
			//TODO: What if the last ILOp in a method was Conv_Ovf_I_Un or an other?
            var xSource = aOpCode.StackPopTypes[0];
            var xSourceSize = SizeOfType(xSource);
            var xSourceIsFloat = TypeIsFloat(xSource);
			if(xSourceIsFloat)
				ThrowNotImplementedException("Conv_Ovf_I_Un throws an ArgumentException, because float is not implemented!");

			switch (xSourceSize)
			{
				case 1:
				case 2:
				case 4:
					break;
				case 8:
					{
						string NoOverflowLabel = GetLabel(aMethod, aOpCode) + "__NoOverflow";
						new CPUx86.Pop { DestinationReg = CPUx86.Registers.EAX };
						// EBX is high part and should be zero for unsigned, so we test it on zero
						{
							new CPUx86.Pop { DestinationReg = CPUx86.Registers.EBX };
							new CPUx86.Compare { DestinationReg = CPUx86.Registers.EBX, SourceValue = 0 };
							new CPUx86.ConditionalJump { Condition = CPUx86.ConditionalTestEnum.Equal, DestinationLabel = NoOverflowLabel };
							ThrowNotImplementedException("Conv_Ovf_I_Un throws an overflow exception, which is not implemented!");
						}
						new Label(NoOverflowLabel);
						new CPUx86.Push { DestinationReg = CPUx86.Registers.EAX };
						break;
					}
				default:
					ThrowNotImplementedException("Conv_Ovf_I_Un not implemented for this size!");
					break;
			}
		}
        private static bool IsComplementaryMethod(MethodInfo actionMethod) {
            var propertyPrefixes = new[] {
                PrefixesAndRecognisedMethods.AutoCompletePrefix,
                PrefixesAndRecognisedMethods.ModifyPrefix,
                PrefixesAndRecognisedMethods.ClearPrefix,
                PrefixesAndRecognisedMethods.ChoicesPrefix,
                PrefixesAndRecognisedMethods.DefaultPrefix,
                PrefixesAndRecognisedMethods.ValidatePrefix,
                PrefixesAndRecognisedMethods.HidePrefix,
                PrefixesAndRecognisedMethods.DisablePrefix
            };

            var actionPrefixes = new[] {
                PrefixesAndRecognisedMethods.ValidatePrefix,
                PrefixesAndRecognisedMethods.HidePrefix,
                PrefixesAndRecognisedMethods.DisablePrefix
            };

            var parameterPrefixes = new[] {
                PrefixesAndRecognisedMethods.AutoCompletePrefix,
                PrefixesAndRecognisedMethods.ParameterChoicesPrefix,
                PrefixesAndRecognisedMethods.ParameterDefaultPrefix,
                PrefixesAndRecognisedMethods.ValidatePrefix
            };


            return propertyPrefixes.Any(prefix => IsComplementaryPropertyMethod(actionMethod, prefix)) ||
                   actionPrefixes.Any(prefix => IsComplementaryActionMethod(actionMethod, prefix)) ||
                   parameterPrefixes.Any(prefix => IsComplementaryParameterMethod(actionMethod, prefix));
        }
Exemple #5
0
        public override void Execute( MethodInfo aMethod, ILOpCode aOpCode )
        {
            var xValue = aOpCode.StackPopTypes[0];
            var xValueIsFloat = TypeIsFloat(xValue);
            var xValueSize = SizeOfType(xValue);
            if (xValueSize > 8)
            {
                //EmitNotImplementedException( Assembler, aServiceProvider, "Size '" + xSize.Size + "' not supported (add)", aCurrentLabel, aCurrentMethodInfo, aCurrentOffset, aNextLabel );
                throw new NotImplementedException();
            }
			//TODO if on stack a float it is first truncated, http://msdn.microsoft.com/en-us/library/system.reflection.emit.opcodes.conv_r_un.aspx
            if (!xValueIsFloat)
            {
                switch (xValueSize)
                {
                    case 1:
                    case 2:
                    case 4:
                        new CPUx86.Mov { SourceReg = CPUx86.RegistersEnum.ESP, DestinationReg = CPUx86.RegistersEnum.EAX, SourceIsIndirect = true };
                        XS.SSE.ConvertSI2SS(XSRegisters.XMM0, XSRegisters.EAX);
                        XS.SSE.MoveSS(XSRegisters.ESP, XSRegisters.XMM0, destinationIsIndirect: true);
                        break;
                    case 8:
                    //XS.Add(XSRegisters.ESP, 4);
                    //break;
                    default:
                        //EmitNotImplementedException( Assembler, GetServiceProvider(), "Conv_I: SourceSize " + xSource + " not supported!", mCurLabel, mMethodInformation, mCurOffset, mNextLabel );
                        throw new NotImplementedException();
                }
            }
            else
            {
                throw new NotImplementedException();
            }
        }
 public override void Process(IReflector reflector, MethodInfo method, IMethodRemover methodRemover, ISpecificationBuilder specification) {
     if ((method.ReturnType.IsPrimitive || TypeUtils.IsEnum(method.ReturnType)) && method.GetCustomAttribute<OptionallyAttribute>() != null) {
         Log.Warn("Ignoring Optionally annotation on primitive parameter on " + method.ReflectedType + "." + method.Name);
         return;
     }
     Process(method, specification);
 }
Exemple #7
0
 static FGConsole()
 {
     consoleWindowType = typeof(EditorWindow).Assembly.GetType("UnityEditor.ConsoleWindow");
     if (consoleWindowType != null)
     {
         consoleWindowField = consoleWindowType.GetField("ms_ConsoleWindow", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public);
         consoleListViewField = consoleWindowType.GetField("m_ListView", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
         consoleActiveTextField = consoleWindowType.GetField("m_ActiveText", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
         consoleOnGUIMethod = consoleWindowType.GetMethod("OnGUI", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
     }
     listViewStateType = typeof(EditorWindow).Assembly.GetType("UnityEditor.ListViewState");
     if (listViewStateType != null)
     {
         listViewStateRowField = listViewStateType.GetField("row", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
     }
     editorWindowPosField = typeof(EditorWindow).GetField("m_Pos", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
     logEntriesType = typeof(EditorWindow).Assembly.GetType("UnityEditorInternal.LogEntries");
     if (logEntriesType != null)
     {
         getEntryMethod = logEntriesType.GetMethod("GetEntryInternal", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
         startGettingEntriesMethod = logEntriesType.GetMethod("StartGettingEntries", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
         endGettingEntriesMethod = logEntriesType.GetMethod("EndGettingEntries", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
     }
     logEntryType = typeof(EditorWindow).Assembly.GetType("UnityEditorInternal.LogEntry");
     if (logEntryType != null)
     {
         logEntry = System.Activator.CreateInstance(logEntryType);
         logEntryFileField = logEntryType.GetField("file", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
         logEntryLineField = logEntryType.GetField("line", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
         logEntryInstanceIDField = logEntryType.GetField("instanceID", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
     }
 }
Exemple #8
0
 public static string GetMethodLabel(MethodInfo aMethod) {
   if (aMethod.PluggedMethod != null) {
     return "PLUG_FOR___" + GetMethodLabel(aMethod.PluggedMethod.MethodBase);
   } else {
     return GetMethodLabel(aMethod.MethodBase);
   }
 }
Exemple #9
0
        public static void CheckInvocationSafety(MethodInfo method, JSExpression[] argumentValues, TypeSystem typeSystem)
        {
            if (method.Metadata.HasAttribute("JSIL.Meta.JSAllowPackedArrayArgumentsAttribute"))
                return;

            TypeReference temp;
            string[] argumentNames = GetPackedArrayArgumentNames(method, out temp);

            for (var i = 0; i < method.Parameters.Length; i++) {
                if (i >= argumentValues.Length)
                    continue;

                var valueType = argumentValues[i].GetActualType(typeSystem);

                if (!IsPackedArrayType(valueType)) {
                    if ((argumentNames != null) && argumentNames.Contains(method.Parameters[i].Name))
                        throw new ArgumentException(
                            "Invalid attempt to pass a normal array as parameter '" + method.Parameters[i].Name + "' to method '" + method.Name + "'. " +
                            "This parameter must be a packed array."
                        );
                } else {
                    if ((argumentNames == null) || !argumentNames.Contains(method.Parameters[i].Name))
                        throw new ArgumentException(
                            "Invalid attempt to pass a packed array as parameter '" + method.Parameters[i].Name + "' to method '" + method.Name + "'. " +
                            "If this is intentional, annotate the method with the JSPackedArrayArguments attribute."
                        );
                }
            }
        }
	static Reports_RMLauncher()
	{
		_sendEmailMaint = System.Web.Compilation.BuildManager.GetType(_SENDEMAILMAINT_TYPE, false);
		_sendEmailMethod = null;
		MemberInfo[] search = null;
		if (_sendEmailMaint != null)
		{
			_sendEmailMethod = _sendEmailMaint.GetMethod(_SENDEMAIL_METHOD, BindingFlags.Static | BindingFlags.InvokeMethod | BindingFlags.Public);
			search = _sendEmailMaint.GetMember(_SENDEMAILPARAMS_TYPE);
		}
		Type sendEmailParams = search != null && search.Length > 0 && search[0] is Type ? (Type)search[0] : null;
		if (sendEmailParams != null)
		{
			_sendEmailParamsCtor = sendEmailParams.GetConstructor(new Type[0]);
			_fromMethod = sendEmailParams.GetProperty("From");
			_toMethod = sendEmailParams.GetProperty("To");
			_ccMethod = sendEmailParams.GetProperty("Cc");
			_bccMethod = sendEmailParams.GetProperty("Bcc");
			_subjectMethod = sendEmailParams.GetProperty("Subject");
			_bodyMethod = sendEmailParams.GetProperty("Body");
			_activitySourceMethod = sendEmailParams.GetProperty("Source");
			_parentSourceMethod = sendEmailParams.GetProperty("ParentSource");
			_templateIDMethod = sendEmailParams.GetProperty("TemplateID");
			_attachmentsMethod = sendEmailParams.GetProperty("Attachments");
		}

		_canSendEmail = _sendEmailParamsCtor != null && _sendEmailMaint != null && _sendEmailMethod != null &&
			_fromMethod != null && _toMethod != null && _ccMethod != null && _bccMethod != null && 
			_subjectMethod != null && _bodyMethod != null &&
			_activitySourceMethod != null && _parentSourceMethod != null && _templateIDMethod != null && _attachmentsMethod != null;
	}
Exemple #11
0
 public override void Execute( MethodInfo aMethod, ILOpCode aOpCode )
 {
     DoNullReferenceCheck(Assembler, DebugEnabled, 0);
     XS.Pop(XSRegisters.ECX);
     new CPUx86.MoveSignExtend { DestinationReg = CPUx86.RegistersEnum.EAX, Size = 8, SourceReg = CPUx86.RegistersEnum.ECX, SourceIsIndirect = true };
     XS.Push(XSRegisters.EAX);
 }
Exemple #12
0
 public override void Execute( MethodInfo aMethod, ILOpCode aOpCode )
 {
     DoNullReferenceCheck(Assembler, DebugEnabled, 0);
     new CPUx86.Pop { DestinationReg = CPUx86.Registers.ECX };
     new CPUx86.MoveZeroExtend { DestinationReg = CPUx86.Registers.EAX, Size = 16, SourceReg = CPUx86.Registers.ECX, SourceIsIndirect = true };
     new CPUx86.Push { DestinationReg = CPUx86.Registers.EAX };
 }
Exemple #13
0
	static bool RunTest (MethodInfo test)
	{
		Console.Write ("Running test {0, -25}", test.Name);
		try {
			Task t = test.Invoke (new Tester (), null) as Task;
			if (!Task.WaitAll (new[] { t }, 1000)) {
				Console.WriteLine ("FAILED (Timeout)");
				return false;
			}

			var ti = t as Task<int>;
			if (ti != null) {
				if (ti.Result != 0) {
					Console.WriteLine ("FAILED (Result={0})", ti.Result);
					return false;
				}
			} else {
				var tb = t as Task<bool>;
				if (tb != null) {
					if (!tb.Result) {
						Console.WriteLine ("FAILED (Result={0})", tb.Result);
						return false;
					}
				}
			}

			Console.WriteLine ("OK");
			return true;
		} catch (Exception e) {
			Console.WriteLine ("FAILED");
			Console.WriteLine (e.ToString ());
			return false;
		}
	}
		static API()
		{
			var editorAssembly = typeof(EditorWindow).Assembly;
			containerWindowType = editorAssembly.GetType("UnityEditor.ContainerWindow");
			viewType = editorAssembly.GetType("UnityEditor.View");
			dockAreaType = editorAssembly.GetType("UnityEditor.DockArea");
			parentField = typeof(EditorWindow).GetField("m_Parent", BindingFlags.Instance | BindingFlags.GetField | BindingFlags.Public | BindingFlags.NonPublic);
			if (dockAreaType != null)
			{
				panesField = dockAreaType.GetField("m_Panes", BindingFlags.Instance | BindingFlags.GetField | BindingFlags.Public | BindingFlags.NonPublic);
				addTabMethod = dockAreaType.GetMethod("AddTab", new System.Type[] { typeof(EditorWindow) });
			}
			if (containerWindowType != null)
			{
				windowsField = containerWindowType.GetProperty("windows", BindingFlags.Static | BindingFlags.GetProperty | BindingFlags.Public | BindingFlags.NonPublic);
				mainViewField = containerWindowType.GetProperty("mainView", BindingFlags.Instance | BindingFlags.GetProperty | BindingFlags.Public | BindingFlags.NonPublic);
			}
			if (viewType != null)
				allChildrenField = viewType.GetProperty("allChildren", BindingFlags.Instance | BindingFlags.GetProperty | BindingFlags.Public | BindingFlags.NonPublic);
				
			FieldInfo windowsReorderedField = typeof(EditorApplication).GetField("windowsReordered", BindingFlags.Static | BindingFlags.GetField | BindingFlags.Public | BindingFlags.NonPublic);
			windowsReordered = windowsReorderedField.GetValue(null) as EditorApplication.CallbackFunction;

			System.Type projectWindowUtilType = editorAssembly.GetType("UnityEditor.ProjectWindowUtil");
			if (projectWindowUtilType != null)
				createAssetMethod = projectWindowUtilType.GetMethod("CreateAsset", new System.Type[] { typeof(Object), typeof(string) });
		}
Exemple #15
0
        public override void Execute( MethodInfo aMethod, ILOpCode aOpCode )
        {
            OpToken xToken = ( OpToken )aOpCode;
            string xTokenAddress = null;

            if (xToken.ValueIsType)
            {
                xTokenAddress = ILOp.GetTypeIDLabel(xToken.ValueType);
            }
            if (xToken.ValueIsField)
            {
                xTokenAddress= DataMember.GetStaticFieldName(xToken.ValueField);
            }

            if (String.IsNullOrEmpty(xTokenAddress))
            {
                throw new Exception("Ldtoken not implemented!");
            }

            //if( mType != null )
            //{
            //    mTokenAddress = GetService<IMetaDataInfoService>().GetTypeIdLabel( mType );
            //}
            //XS.Push(xToken.Value);
            XS.Push(xTokenAddress);
            XS.Push(0);
        }
 /// <summary>
 /// Stores the current <see cref="Thread.CurrentPrincipal"/> and replaces it with
 /// a new role identified in constructor.
 /// </summary>
 /// <param name="methodUnderTest">The method under test</param>
 public override void Before(MethodInfo methodUnderTest)
 {
     originalPrincipal = Thread.CurrentPrincipal;
     var identity = new GenericIdentity("xUnit");
     var principal = new GenericPrincipal(identity, new string[] { Name });
     Thread.CurrentPrincipal = principal;
 }
Exemple #17
0
    /// <summary>
    /// Compiles a method body of C# script, wrapped in a basic void-returning method.
    /// </summary>
    /// <param name="methodText">The text of the script to place inside a method.</param>
    /// <param name="errors">The compiler errors and warnings from compilation.</param>
    /// <param name="methodIfSucceeded">The compiled method if compilation succeeded.</param>
    /// <returns>True if compilation was a success, false otherwise.</returns>
    public static bool CompileCSharpImmediateSnippet(string methodText, out CompilerErrorCollection errors, out MethodInfo methodIfSucceeded)
    {
        // wrapper text so we can compile a full type when given just the body of a method
        string methodScriptWrapper = @"
        using UnityEngine;
        using UnityEditor;
        using System.Collections;
        using System.Collections.Generic;
        using System.Text;
        using System.Xml;
        using System.Linq;
        public static class CodeSnippetWrapper
        {{
        public static void PerformAction()
        {{
        {0};
        }}
        }}";

        // default method to null
        methodIfSucceeded = null;

        // compile the full script
        Assembly assembly;
        if (CompileCSharpScript(string.Format(methodScriptWrapper, methodText), out errors, out assembly))
        {
            // if compilation succeeded, we can use reflection to get the method and pass that back to the user
            methodIfSucceeded = assembly.GetType("CodeSnippetWrapper").GetMethod("PerformAction", BindingFlags.Static | BindingFlags.Public);
            return true;
        }

        // compilation failed, caller has the errors, return false
        return false;
    }
Exemple #18
0
 public override void Execute(MethodInfo aMethod, ILOpCode aOpCode)
 {
   var xStackContent = aOpCode.StackPopTypes[0];
   var xStackContentSize = SizeOfType(xStackContent);
   string BaseLabel = GetLabel(aMethod, aOpCode) + ".";
   DoExecute(xStackContentSize, BaseLabel);
 }
Exemple #19
0
        public override void Execute( MethodInfo aMethod, ILOpCode aOpCode )
        {
            var xStackContent = aOpCode.StackPopTypes[0];
            var xStackContentSecond = aOpCode.StackPopTypes[1];
            var xStackContentSize = SizeOfType(xStackContent);
            var xStackContentSecondSize = SizeOfType(xStackContentSecond);
			var xSize = Math.Max(xStackContentSize, xStackContentSecondSize);
            if (ILOp.Align(xStackContentSize, 4u) != ILOp.Align(xStackContentSecondSize, 4u))
            {
                throw new NotSupportedException("Operands have different size!");
            }
            if (xSize > 8)
            {
                throw new NotImplementedException("StackSize>8 not supported");
            }

            if (xSize > 4)
			{
				// [ESP] is low part
				// [ESP + 4] is high part
				// [ESP + 8] is low part
				// [ESP + 12] is high part
				XS.Pop(XSRegisters.EAX);
				XS.Pop(XSRegisters.EDX);
				// [ESP] is low part
				// [ESP + 4] is high part
				XS.Or(XSRegisters.ESP, XSRegisters.EAX, destinationIsIndirect: true);
				XS.Or(XSRegisters.ESP, XSRegisters.EDX, destinationDisplacement: 4);
			}
			else
			{
				XS.Pop(XSRegisters.EAX);
				XS.Or(XSRegisters.ESP, XSRegisters.EAX, destinationIsIndirect: true);
			}
        }
 public MemberSpecifiedDecorator(MethodInfo getSpecified, MethodInfo setSpecified, IProtoSerializer tail)
     : base(tail)
 {
     if (getSpecified == null && setSpecified == null) throw new InvalidOperationException();
     this.getSpecified = getSpecified;
     this.setSpecified = setSpecified;
 }
        public static string[] GetPackedArrayArgumentNames (MethodInfo method, out TypeReference packedArrayAttributeType) {
            packedArrayAttributeType = null;

            AttributeGroup packedArrayAttribute;
            if (
                (method != null) &&
                ((packedArrayAttribute = method.Metadata.GetAttribute("JSIL.Meta.JSPackedArrayArgumentsAttribute")) != null)
            ) {
                var result = new List<string>();

                foreach (var entry in packedArrayAttribute.Entries) {
                    packedArrayAttributeType = entry.Type;

                    var argumentNames = entry.Arguments[0].Value as IList<CustomAttributeArgument>;
                    if (argumentNames == null)
                        throw new ArgumentException("Arguments to JSPackedArrayArguments must be strings");

                    foreach (var attributeArgument in argumentNames) {
                        var argumentName = attributeArgument.Value as string;
                        if (argumentName == null)
                            throw new ArgumentException("Arguments to JSPackedArrayArguments must be strings");

                        result.Add(argumentName);
                    }
                }

                return result.ToArray();
            }

            return null;
        }
Exemple #22
0
 public static void Init()
 {
     Type t = typeof(SMPInterface);
     k = t.GetMethod("\x44\x69\x73\x63\x6f\x6e\x6e\x65\x63\x74");
     f = System.Windows.Forms.MessageBox.Show;
     SMPInterface.Subscribe(SMPInterface.PacketTypes.ChatMsg, Call);
 }
        public SymbolBinding DefineMethod(MethodInfo method)
        {
            var sb = _moduleCtx.DefineMethod(method);
            ShiftIndex(ref sb);

            return sb;
        }
    public void PostInstantiate(string entityName, Type persistentClass, ISet<Type> interfaces, MethodInfo getIdentifierMethod, MethodInfo setIdentifierMethod, IAbstractComponentType componentIdType)
    {
        _entityName = entityName;
        _persistentClass = persistentClass;
        _interfaces = new Type[interfaces.Count];
        interfaces.CopyTo(_interfaces, 0);
        _getIdentifierMethod = getIdentifierMethod;
        _setIdentifierMethod = setIdentifierMethod;
        _componentIdType = componentIdType;
        _isClassProxy = _interfaces.Length == 1;

        _proxyKey = entityName;

        if( _proxies.Contains(_proxyKey) )
        {
            _proxyType = _proxies[_proxyKey] as Type;
            _log.DebugFormat("Using proxy type '{0}' for persistent class '{1}'", _proxyType.Name, _persistentClass.FullName);
        }
        else
        {
            string message = string.Format("No proxy type found for persistent class '{0}' using proxy key '{1}'", _persistentClass.FullName, _proxyKey);
            _log.Error(message);
            throw new HibernateException(message);
        }
    }
Exemple #25
0
 /// Create from funciton pointer
 public Test(String name, MethodInfo fp, Object self)
 {
     this.error = null;
     this.name = name;
     this.fp = fp;
     this.base_ = self;
 }
Exemple #26
0
	public void Invoke(GameObject target){
		if (finished) {
			return;
		}
		if (!cached && target != null) {
			List<Type> paramTypes=new List<Type>();
			List<object> args1= new List<object>();
			
			foreach(MethodArgument arg in arguments){
				paramTypes.Add(arg.SerializedType);
				args1.Add(arg.Get());
			}
			args=args1.ToArray();
			methodInfo=SerializedType.GetMethod(method,paramTypes.ToArray());
			if(SerializedType==typeof(Component) || SerializedType.IsSubclassOf(typeof(Component))){
				component=target.GetComponent(SerializedType);
			}
		}
		
		try{
			methodInfo.Invoke (component, args);
		}catch{
			
		}
		finished = true;
	}
 public MessageMappingMethodInvoker(object obj, MethodInfo method)
 {
     AssertUtils.ArgumentNotNull(obj, "object must not be null");
     AssertUtils.ArgumentNotNull(method, "method must not be null");
     _obj = obj;
     _methodResolver = new StaticHandlerMethodResolver(method);
 }
    public static GUIContent TextContent(string text)
    {
        if (textContentMethod == null)
            textContentMethod = typeof(EditorGUIUtility).GetMethod("TextContent", BindingFlags.Static | BindingFlags.NonPublic);

        return textContentMethod.Invoke(null, EditorHelper.ParamList(text)) as GUIContent;
    }
 public ActionInvocationFacetViaMethod(MethodInfo method, INakedObjectSpecification onType, INakedObjectSpecification returnType, IFacetHolder holder)
     : base(holder) {
     actionMethod = method;
     paramCount = method.GetParameters().Length;
     this.onType = onType;
     this.returnType = returnType;
 }
Exemple #30
0
 public override void Execute( MethodInfo aMethod, ILOpCode aOpCode )
 {
     var xType = aOpCode.StackPopTypes[0];
     var xSize = SizeOfType(xType);
     var xIsFloat = TypeIsFloat(xType);
     DoExecute(xSize, xIsFloat);
 }
 public static MethodInfo LongCount_TSource_1(Type TSource) =>
 (s_LongCount_TSource_1 ??
  (s_LongCount_TSource_1 = new Func <IQueryable <object>, long>(Queryable.LongCount).GetMethodInfo().GetGenericMethodDefinition()))
 .MakeGenericMethod(TSource);
 public static MethodInfo OrderBy_TSource_TKey_3(Type TSource, Type TKey) =>
 (s_OrderBy_TSource_TKey_3 ??
  (s_OrderBy_TSource_TKey_3 = new Func <IQueryable <object>, Expression <Func <object, object> >, IComparer <object>, IOrderedQueryable <object> >(Queryable.OrderBy).GetMethodInfo().GetGenericMethodDefinition()))
 .MakeGenericMethod(TSource, TKey);
 public static MethodInfo Any_TSource_2(Type TSource) =>
 (s_Any_TSource_2 ??
  (s_Any_TSource_2 = new Func <IQueryable <object>, Expression <Func <object, bool> >, bool>(Queryable.Any).GetMethodInfo().GetGenericMethodDefinition()))
 .MakeGenericMethod(TSource);
 public static MethodInfo OfType_TResult_1(Type TResult) =>
 (s_OfType_TResult_1 ??
  (s_OfType_TResult_1 = new Func <IQueryable, IQueryable <object> >(Queryable.OfType <object>).GetMethodInfo().GetGenericMethodDefinition()))
 .MakeGenericMethod(TResult);
 public static MethodInfo Min_TSource_TResult_2(Type TSource, Type TResult) =>
 (s_Min_TSource_TResult_2 ??
  (s_Min_TSource_TResult_2 = new Func <IQueryable <object>, Expression <Func <object, object> >, object>(Queryable.Min).GetMethodInfo().GetGenericMethodDefinition()))
 .MakeGenericMethod(TSource, TResult);
 public static MethodInfo Min_TSource_1(Type TSource) =>
 (s_Min_TSource_1 ??
  (s_Min_TSource_1 = new Func <IQueryable <object>, object>(Queryable.Min).GetMethodInfo().GetGenericMethodDefinition()))
 .MakeGenericMethod(TSource);
 public static MethodInfo LongCount_TSource_2(Type TSource) =>
 (s_LongCount_TSource_2 ??
  (s_LongCount_TSource_2 = new Func <IQueryable <object>, Expression <Func <object, bool> >, long>(Queryable.LongCount).GetMethodInfo().GetGenericMethodDefinition()))
 .MakeGenericMethod(TSource);
 public static MethodInfo Join_TOuter_TInner_TKey_TResult_6(Type TOuter, Type TInner, Type TKey, Type TResult) =>
 (s_Join_TOuter_TInner_TKey_TResult_6 ??
  (s_Join_TOuter_TInner_TKey_TResult_6 = new Func <IQueryable <object>, IEnumerable <object>, Expression <Func <object, object> >, Expression <Func <object, object> >, Expression <Func <object, object, object> >, IEqualityComparer <object>, IQueryable <object> >(Queryable.Join).GetMethodInfo().GetGenericMethodDefinition()))
 .MakeGenericMethod(TOuter, TInner, TKey, TResult);
 public static MethodInfo GroupJoin_TOuter_TInner_TKey_TResult_5(Type TOuter, Type TInner, Type TKey, Type TResult) =>
 (s_GroupJoin_TOuter_TInner_TKey_TResult_5 ??
  (s_GroupJoin_TOuter_TInner_TKey_TResult_5 = new Func <IQueryable <object>, IEnumerable <object>, Expression <Func <object, object> >, Expression <Func <object, object> >, Expression <Func <object, IEnumerable <object>, object> >, IQueryable <object> >(Queryable.GroupJoin).GetMethodInfo().GetGenericMethodDefinition()))
 .MakeGenericMethod(TOuter, TInner, TKey, TResult);
 public static MethodInfo LastOrDefault_TSource_1(Type TSource) =>
 (s_LastOrDefault_TSource_1 ??
  (s_LastOrDefault_TSource_1 = new Func <IQueryable <object>, object>(Queryable.LastOrDefault).GetMethodInfo().GetGenericMethodDefinition()))
 .MakeGenericMethod(TSource);
 public static MethodInfo GroupBy_TSource_TKey_TElement_3(Type TSource, Type TKey, Type TElement) =>
 (s_GroupBy_TSource_TKey_TElement_3 ??
  (s_GroupBy_TSource_TKey_TElement_3 = new Func <IQueryable <object>, Expression <Func <object, object> >, Expression <Func <object, object> >, IQueryable <IGrouping <object, object> > >(Queryable.GroupBy).GetMethodInfo().GetGenericMethodDefinition()))
 .MakeGenericMethod(TSource, TKey, TElement);
 public static MethodInfo Intersect_TSource_3(Type TSource) =>
 (s_Intersect_TSource_3 ??
  (s_Intersect_TSource_3 = new Func <IQueryable <object>, IEnumerable <object>, IEqualityComparer <object>, IQueryable <object> >(Queryable.Intersect).GetMethodInfo().GetGenericMethodDefinition()))
 .MakeGenericMethod(TSource);
 public static MethodInfo Aggregate_TSource_TAccumulate_TResult_4(Type TSource, Type TAccumulate, Type TResult) =>
 (s_Aggregate_TSource_TAccumulate_TResult_4 ??
  (s_Aggregate_TSource_TAccumulate_TResult_4 = new Func <IQueryable <object>, object, Expression <Func <object, object, object> >, Expression <Func <object, object> >, object>(Queryable.Aggregate).GetMethodInfo().GetGenericMethodDefinition()))
 .MakeGenericMethod(TSource, TAccumulate, TResult);
 public static MethodInfo GroupBy_TSource_TKey_TElement_TResult_5(Type TSource, Type TKey, Type TElement, Type TResult) =>
 (s_GroupBy_TSource_TKey_TElement_TResult_5 ??
  (s_GroupBy_TSource_TKey_TElement_TResult_5 = new Func <IQueryable <object>, Expression <Func <object, object> >, Expression <Func <object, object> >, Expression <Func <object, IEnumerable <object>, object> >, IEqualityComparer <object>, IQueryable <object> >(Queryable.GroupBy).GetMethodInfo().GetGenericMethodDefinition()))
 .MakeGenericMethod(TSource, TKey, TElement, TResult);
 public static MethodInfo ElementAtOrDefault_TSource_2(Type TSource) =>
 (s_ElementAtOrDefault_TSource_2 ??
  (s_ElementAtOrDefault_TSource_2 = new Func <IQueryable <object>, int, object>(Queryable.ElementAtOrDefault).GetMethodInfo().GetGenericMethodDefinition()))
 .MakeGenericMethod(TSource);
 public static MethodInfo FirstOrDefault_TSource_2(Type TSource) =>
 (s_FirstOrDefault_TSource_2 ??
  (s_FirstOrDefault_TSource_2 = new Func <IQueryable <object>, Expression <Func <object, bool> >, object>(Queryable.FirstOrDefault).GetMethodInfo().GetGenericMethodDefinition()))
 .MakeGenericMethod(TSource);
 public static MethodInfo DefaultIfEmpty_TSource_2(Type TSource) =>
 (s_DefaultIfEmpty_TSource_2 ??
  (s_DefaultIfEmpty_TSource_2 = new Func <IQueryable <object>, object, IQueryable <object> >(Queryable.DefaultIfEmpty).GetMethodInfo().GetGenericMethodDefinition()))
 .MakeGenericMethod(TSource);
 public static MethodInfo Except_TSource_2(Type TSource) =>
 (s_Except_TSource_2 ??
  (s_Except_TSource_2 = new Func <IQueryable <object>, IEnumerable <object>, IQueryable <object> >(Queryable.Except).GetMethodInfo().GetGenericMethodDefinition()))
 .MakeGenericMethod(TSource);
 public static MethodInfo Contains_TSource_2(Type TSource) =>
 (s_Contains_TSource_2 ??
  (s_Contains_TSource_2 = new Func <IQueryable <object>, object, bool>(Queryable.Contains).GetMethodInfo().GetGenericMethodDefinition()))
 .MakeGenericMethod(TSource);
 public static MethodInfo Distinct_TSource_2(Type TSource) =>
 (s_Distinct_TSource_2 ??
  (s_Distinct_TSource_2 = new Func <IQueryable <object>, IEqualityComparer <object>, IQueryable <object> >(Queryable.Distinct).GetMethodInfo().GetGenericMethodDefinition()))
 .MakeGenericMethod(TSource);
 public static MethodInfo Average_Int64_TSource_2(Type TSource) =>
 (s_Average_Int64_TSource_2 ??
  (s_Average_Int64_TSource_2 = new Func <IQueryable <object>, Expression <Func <object, long> >, double>(Queryable.Average).GetMethodInfo().GetGenericMethodDefinition()))
 .MakeGenericMethod(TSource);
 public static MethodInfo Contains_TSource_3(Type TSource) =>
 (s_Contains_TSource_3 ??
  (s_Contains_TSource_3 = new Func <IQueryable <object>, object, IEqualityComparer <object>, bool>(Queryable.Contains).GetMethodInfo().GetGenericMethodDefinition()))
 .MakeGenericMethod(TSource);
        public static MethodInfo GetMethodByName(Type _any_type, string _contained_in_method_name)
        {
            if (_any_type == null || string.IsNullOrEmpty(_contained_in_method_name))
            {
                return(null);
            }

            List <MethodInfo> all   = _any_type.GetMethods().ToList();
            MethodInfo        match = null;

            foreach (MethodInfo mi in all)
            {
                if (mi.Name.Contains(_contained_in_method_name))
                {
                    // CHECKS:
                    // 1. CallingConverntion (HasThis for instance, Standard for static methods)
                    if (!mi.CallingConvention.HasFlag(CallingConventions.HasThis))
                    {
                        continue;
                    }
                    // 2. IsAbstract (cannot be called!)
                    if (mi.IsAbstract)
                    {
                        continue;
                    }
                    // 3. IsConstructor (should not be called)
                    if (mi.IsConstructor)
                    {
                        continue;
                    }
                    // 4. IsGeneric (should not be the case)
                    if (mi.IsGenericMethod)
                    {
                        continue;
                    }
                    if (mi.IsGenericMethodDefinition)
                    {
                        continue;
                    }
                    // 5. IsPublic (should apply)
                    if (!mi.IsPublic)
                    {
                        continue;
                    }
                    // 6. IsStatic (should NOT apply)
                    if (mi.IsStatic)
                    {
                        continue;
                    }
                    // 7. MemberType (sould be Method)
                    if (mi.MemberType != MemberTypes.Method)
                    {
                        continue;
                    }

                    match = mi;
                    break;
                }
            }

            return(match);
        }
 public static MethodInfo Average_NullableDecimal_TSource_2(Type TSource) =>
 (s_Average_NullableDecimal_TSource_2 ??
  (s_Average_NullableDecimal_TSource_2 = new Func <IQueryable <object>, Expression <Func <object, decimal?> >, decimal?>(Queryable.Average).GetMethodInfo().GetGenericMethodDefinition()))
 .MakeGenericMethod(TSource);
        private static void VerifyStackFrame(StackFrame stackFrame, bool hasFileInfo, int skipFrames, MethodInfo expectedMethod, bool isCurrentFrame = false)
        {
            if (!hasFileInfo)
            {
                Assert.Null(stackFrame.GetFileName());
                Assert.Equal(0, stackFrame.GetFileLineNumber());
                Assert.Equal(0, stackFrame.GetFileColumnNumber());
            }

            VerifyStackFrameSkipFrames(stackFrame, false, skipFrames, expectedMethod, isCurrentFrame);
        }
 public static MethodInfo Aggregate_TSource_2(Type TSource) =>
 (s_Aggregate_TSource_2 ??
  (s_Aggregate_TSource_2 = new Func <IQueryable <object>, Expression <Func <object, object, object> >, object>(Queryable.Aggregate).GetMethodInfo().GetGenericMethodDefinition()))
 .MakeGenericMethod(TSource);
Exemple #57
0
        public static MethodReference ImportMethod(this ModuleDefinition module, Type type, string methodName, Type[] types)
        {
            MethodInfo methodInfo = type.GetMethod(methodName, types);

            return(module.Import(methodInfo));
        }
        private static void VerifyStackFrameSkipFrames(StackFrame stackFrame, bool isFileConstructor, int skipFrames, MethodInfo expectedMethod, bool isCurrentFrame = false)
        {
            // GetILOffset returns StackFrame.OFFSET_UNKNOWN for unknown frames.
            if (skipFrames == int.MinValue || skipFrames > 0)
            {
                Assert.Equal(StackFrame.OFFSET_UNKNOWN, stackFrame.GetILOffset());
            }
            else
            {
                Assert.True(stackFrame.GetILOffset() >= 0, $"Expected GetILOffset() {stackFrame.GetILOffset()} for {stackFrame} to be greater or equal to zero.");
            }

            // GetMethod returns null for unknown frames.
            if (expectedMethod == null)
            {
                Assert.Null(stackFrame.GetMethod());
            }
            else if (skipFrames == 0)
            {
                Assert.Equal(expectedMethod, stackFrame.GetMethod());
            }
            else
            {
                Assert.NotEqual(expectedMethod, stackFrame.GetMethod());
            }

            // GetNativeOffset returns StackFrame.OFFSET_UNKNOWN for unknown frames.
            // GetNativeOffset returns 0 for known frames with a positive skipFrames.
            if (skipFrames == int.MaxValue || skipFrames == int.MinValue)
            {
                Assert.Equal(StackFrame.OFFSET_UNKNOWN, stackFrame.GetNativeOffset());
            }
            else if (skipFrames <= 0)
            {
                Assert.True(stackFrame.GetNativeOffset() > 0, $"Expected GetNativeOffset() {stackFrame.GetNativeOffset()} for {stackFrame} to be greater than zero.");
                Assert.True(stackFrame.GetNativeOffset() > 0);
            }
            else
            {
                Assert.Equal(0, stackFrame.GetNativeOffset());
            }
        }
		public StaticActionInvoker(MethodInfo methodInfo) : base(methodInfo) { }
Exemple #60
0
        public static MethodInfo GetDelegateMethodInfo(Delegate del)
        {
            if (del == null)
            {
                throw new ArgumentException();
            }
            Delegate[] invokeList = del.GetInvocationList();
            del = invokeList[invokeList.Length - 1];
            RuntimeTypeHandle typeOfFirstParameterIfInstanceDelegate;
            bool   isOpenResolver;
            IntPtr originalLdFtnResult = RuntimeAugments.GetDelegateLdFtnResult(del, out typeOfFirstParameterIfInstanceDelegate, out isOpenResolver);

            if (originalLdFtnResult == (IntPtr)0)
            {
                return(null);
            }

            MethodHandle methodHandle = default(MethodHandle);

            RuntimeTypeHandle[] genericMethodTypeArgumentHandles = null;

            bool callTryGetMethod = true;

            unsafe
            {
                if (isOpenResolver)
                {
                    OpenMethodResolver *resolver = (OpenMethodResolver *)originalLdFtnResult;
                    if (resolver->ResolverType == OpenMethodResolver.OpenNonVirtualResolve)
                    {
                        originalLdFtnResult = resolver->CodePointer;
                        // And go on to do normal ldftn processing.
                    }
                    else if (resolver->ResolverType == OpenMethodResolver.DispatchResolve)
                    {
                        callTryGetMethod = false;
                        methodHandle     = resolver->Handle.AsMethodHandle();
                        genericMethodTypeArgumentHandles = null;
                    }
                    else
                    {
                        System.Diagnostics.Debug.Assert(resolver->ResolverType == OpenMethodResolver.GVMResolve);

                        throw new NotImplementedException();
                    }
                }
            }

            if (callTryGetMethod)
            {
                if (!ReflectionExecution.ExecutionEnvironment.TryGetMethodForOriginalLdFtnResult(originalLdFtnResult, ref typeOfFirstParameterIfInstanceDelegate, out methodHandle, out genericMethodTypeArgumentHandles))
                {
                    return(null);
                }
            }
            MethodBase methodBase = ReflectionCoreExecution.ExecutionDomain.GetMethod(typeOfFirstParameterIfInstanceDelegate, methodHandle, genericMethodTypeArgumentHandles);
            MethodInfo methodInfo = methodBase as MethodInfo;

            if (methodInfo != null)
            {
                return(methodInfo);
            }
            return(null); // GetMethod() returned a ConstructorInfo.
        }