public DispatchExceptionFailureEventArgs(Exception ex, IQHsm hsm, System.Reflection.MethodInfo stateMethod, IQEvent ev)
 {
     _Exception = ex;
     _Hsm = hsm;
     _StateMethod = stateMethod;
     _OriginalEvent = ev;
 }
Exemple #2
0
 public override bool Process(MethodInfo method, IMethodRemover methodRemover, IFacetHolder holder) {
     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 false;
     }
     return Process(method, holder);
 }
 public override bool ProcessParams(MethodInfo method, int paramNum, IFacetHolder holder) {
     ParameterInfo parameter = method.GetParameters()[paramNum];
     Attribute attribute = parameter.GetCustomAttributeByReflection<DescriptionAttribute>();
     if (attribute == null) {
         attribute = parameter.GetCustomAttributeByReflection<DescribedAsAttribute>();
     }
     return FacetUtils.AddFacet(Create(attribute, holder));
 }
Exemple #4
0
 public override bool ProcessParams(MethodInfo method, int paramNum, IFacetHolder holder) {
     ParameterInfo parameter = method.GetParameters()[paramNum];
     if (TypeUtils.IsString(parameter.ParameterType)) {
         var attribute = parameter.GetCustomAttributeByReflection<MultiLineAttribute>();
         return FacetUtils.AddFacet(Create(attribute, holder));
     }
     return false;
 }
        public override bool Process(MethodInfo method, IMethodRemover methodRemover, IFacetHolder holder) {
            var classAttribute = method.DeclaringType.GetCustomAttributeByReflection<AuthorizeActionAttribute>();
            var methodAttribute = method.GetCustomAttribute<AuthorizeActionAttribute>();

            if (classAttribute != null && methodAttribute != null) {
                Log.WarnFormat("Class and method level AuthorizeAttributes applied to class {0} - ignoring attribute on method {1}", method.DeclaringType.FullName, method.Name);
            }

            return Create(classAttribute ?? methodAttribute, holder);
        }
Exemple #6
0
 public Bridge()
 {
     this.lDomain = System.AppDomain.CurrentDomain;
     this.LoadTypes();
     this.lTimeout = 30000;
     lHandleEventMethod = this.GetType().GetMethod("HandleEvent");
     this.timerhotkey = new System.Timers.Timer(100);
     this.timerhotkey.Elapsed += new System.Timers.ElapsedEventHandler(TimerCheckHotKey);
     AppDomain.CurrentDomain.UnhandledException += AppDomain_UnhandledException;
     System.Windows.Forms.Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
 }
Exemple #7
0
 public override void Init(Reactor reactor)
 {
     base.Init(reactor);
     var cm = reactor.FindMethod (functionName);
     if (cm == null) {
         Debug.LogError ("Could not load function method: " + functionName);
     } else {
         component = cm.component;
         methodInfo = cm.methodInfo;
     }
 }
        // ------------------------------------------------------------------------
        //    private final MdaClass parentMdaClass;  .. see super
        //    private final String methodName; .. see super.getName
        // constructors
        // -------------------------------------------------------------------------
        public MdaMethodImpl(MdaClass parentMdaClass, int internalMethodIndex, 
		                     System.Reflection.MethodInfo method, PropertiesNode tags)
            : base(method.Name, tags, parentMdaClass)
        {
            this.internalMethodIndex = internalMethodIndex;
            this.method = method;
            this.returnType = method.ReturnType;
            if (returnType == null)
            {
                throw new System.InvalidOperationException("returnType == null for Method " + this);
            }
        }
Exemple #9
0
        private static System.Func<object, object> BuildAccessor(MethodInfo method)
        {
            ParameterExpression obj = Expression.Parameter(typeof(object), "obj");
            UnaryExpression instance = !method.IsStatic ? Expression.Convert(obj, method.DeclaringType) : null;
            Expression<System.Func<object, object>> expr = Expression.Lambda<System.Func<object, object>>(
                Expression.Convert(
                    Expression.Call(instance, method),
                    typeof(object)),
                obj);

            return expr.Compile();
        }
Exemple #10
0
        public override bool ProcessParams(MethodInfo method, int paramNum, IFacetHolder holder) {
            ParameterInfo parameter = method.GetParameters()[paramNum];
            if (TypeUtils.IsString(parameter.ParameterType)) {
                Attribute attribute = parameter.GetCustomAttributeByReflection<RegularExpressionAttribute>();
                if (attribute == null) {
                    attribute = parameter.GetCustomAttributeByReflection<RegExAttribute>();
                }

                return FacetUtils.AddFacet(Create(attribute, holder));
            }
            return false;
        }
Exemple #11
0
 public override bool ProcessParams(MethodInfo method, int paramNum, IFacetHolder holder) {
     ParameterInfo parameter = method.GetParameters()[paramNum];
     if ((parameter.ParameterType.IsPrimitive || TypeUtils.IsEnum(parameter.ParameterType))) {
         if (method.GetCustomAttribute<OptionallyAttribute>() != null) {
             Log.Warn("Ignoring Optionally annotation on primitive parameter " + paramNum + " on " + method.ReflectedType + "." +
                      method.Name);
         }
         return false;
     }
     var attribute = parameter.GetCustomAttributeByReflection<OptionallyAttribute>();
     return FacetUtils.AddFacet(Create(attribute, holder));
 }
 public ObjectBusMessageDeserializerAttribute(Type type, string funcName)
 {
     if (funcName == null)
         throw new ArgumentNullException ("funcName");
     func = type.GetMethod (funcName, System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public);
     if (func == null) {
         Console.Write ("ObjectBusMessageDeserializerAttribute is going into failsafe mode, ");
         func = type.GetMethod (funcName, System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic);
         if (func == null)
             Console.WriteLine ("failed.");
         else
             Console.WriteLine ("succeeded.");
     }
 }
		/// <summary>Construct the named stemming filter.
		/// 
		/// </summary>
		/// <param name="in">the input tokens to stem
		/// </param>
		/// <param name="name">the name of a stemmer
		/// </param>
		public SnowballFilter(TokenStream in_Renamed, System.String name) : base(in_Renamed)
		{
			try
			{
				System.Type stemClass = System.Type.GetType("SF.Snowball.Ext." + name + "Stemmer");
				stemmer = (SnowballProgram) System.Activator.CreateInstance(stemClass);
				// why doesn't the SnowballProgram class have an (abstract?) stem method?
				stemMethod = stemClass.GetMethod("Stem", (new System.Type[0] == null) ? new System.Type[0] : (System.Type[]) new System.Type[0]);
			}
			catch (System.Exception e)
			{
				throw new System.SystemException(e.ToString());
			}
		}
Exemple #14
0
 static ExecCmd()
 {
     {
     // Runtime.exec(String[] cmdArr, String[] envArr, File currDir)
     Type[] parameterTypes = new Type[] { typeof( string[] ), typeof( string[] ), typeof( FileInfo ) };
     try
     {
       execMethod = System.Diagnostics.Process.GetCurrentProcess().GetType().GetMethod( "exec", (System.Type[])parameterTypes );
     }
     catch ( System.MethodAccessException e )
     {
       execMethod = null;
     }
       }
 }
Exemple #15
0
Fichier : If.cs Projet : s76/testAI
 public override void Init(Reactor reactor)
 {
     base.Init(reactor);
     var cm = reactor.FindMethod(conditionMethod);
     if(cm == null) {
         Debug.LogError("Could not load condition method: " + conditionMethod);
     } else {
         if(cm.methodInfo.ReturnType == typeof(bool)) {
             component = cm.component;
             methodInfo = cm.methodInfo;
         } else {
             Debug.LogError("Condition method has invalid signature: " + conditionMethod);
         }
     }
 }
Exemple #16
0
 public RawProxyAttribute(Type type, string guid, string deserializeMethodName)
 {
     if (guid == null)
         throw new ArgumentNullException ("guid");
     if (deserializeMethodName == null)
         throw new ArgumentNullException ("deserializeMethodName");
     this.deserializeMethodName = deserializeMethodName;
     this.guid = Guid.Parse (guid);
     deserializeMethod = type.GetMethod (deserializeMethodName, System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public);
     attribs.AddOrUpdate (this.guid, (g) => {
         return this;
     }, (g,o) => {
         return this;
     }
     );
 }
		static GtkWorkarounds ()
		{
			if (Platform.IsMac) {
				InitMac ();
			}
			
			var flags = System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic;
			glibObjectSetProp = typeof (GLib.Object).GetMethod ("SetProperty", flags);
			glibObjectGetProp = typeof (GLib.Object).GetMethod ("GetProperty", flags);
			
			foreach (int i in new [] { 24, 22, 20, 18, 16, 14 }) {
				if (Gtk.Global.CheckVersion (2, (uint)i, 0) == null) {
					GtkMinorVersion = i;
					break;
				}
			}
		}
Exemple #18
0
    public MySocket()
    {
        //System.Net.Sockets.TcpClient client = new System.Net.Sockets.TcpClient();
        //UnityEngine.Debug.Log(client.GetType().Assembly.GetName().Name);

        //tcpClient = client;//System.Activator.CreateInstance(GetType().Assembly.FullName, "System.Net.Sockets.TcpClient");

        System.Type testType = typeof(System.Uri);
        System.Type clazz = testType.Assembly.GetType("System.Net.Sockets.TcpClient");
        tcpClient = clazz.GetConstructor(new System.Type[]{}).Invoke(null);

        //tcpClient = System.Activator.CreateInstance(testType.Assembly.FullName, "System.Net.Sockets.TcpClient");

        availableProperty = clazz.GetProperty("Available");
        connectedProperty = clazz.GetProperty("Connected");

        connectMethod = clazz.GetMethod("Connect", new System.Type[] {typeof(string), typeof(int)});
        getStreamMethod = clazz.GetMethod("GetStream");
        closeMethod = clazz.GetMethod("Close");
    }
Exemple #19
0
        public Message(MessageID msgid, string msgname, Int16 length, List<Byte> msgargtypes, System.Reflection.MethodInfo msghandler)
        {
            id = msgid;
            name = msgname;
            msglen = length;
            handler = msghandler;

            argtypes = new System.Reflection.MethodInfo[msgargtypes.Count];
            for(int i=0; i<msgargtypes.Count; i++)
            {
                argtypes[i] = StreamRWBinder.bindReader(msgargtypes[i]);
                if(argtypes[i] == null)
                {
                    Dbg.ERROR_MSG("Message::Message(): bindReader(" + msgargtypes[i] + ") is error!");
                }
            }

            // Dbg.DEBUG_MSG(string.Format("Message::Message(): ({0}/{1}/{2})!",
            //	msgname, msgid, msglen));
        }
        public override bool Process(MethodInfo actionMethod, IMethodRemover methodRemover, IFacetHolder action) {
            string capitalizedName = NameUtils.CapitalizeName(actionMethod.Name);

            Type type = actionMethod.DeclaringType;
            var facets = new List<IFacet>();
            INakedObjectSpecification onType = Reflector.LoadSpecification(type);
            INakedObjectSpecification returnSpec = Reflector.LoadSpecification(actionMethod.ReturnType);

            RemoveMethod(methodRemover, actionMethod);
            facets.Add(new ActionInvocationFacetViaMethod(actionMethod, onType, returnSpec, action));

            MethodType methodType = actionMethod.IsStatic ? MethodType.Class : MethodType.Object;
            Type[] paramTypes = actionMethod.GetParameters().Select(p => p.ParameterType).ToArray();
            FindAndRemoveValidMethod(facets, methodRemover, type, methodType, capitalizedName, paramTypes, action);

            DefaultNamedFacet(facets, capitalizedName, action); // must be called after the checkForXxxPrefix methods

            AddHideForSessionFacetNone(facets, action);
            AddDisableForSessionFacetNone(facets, action);
            FindDefaultHideMethod(facets, methodRemover, type, methodType, "ActionDefault", paramTypes, action);
            FindAndRemoveHideMethod(facets, methodRemover, type, methodType, capitalizedName, paramTypes, action);
            FindDefaultDisableMethod(facets, methodRemover, type, methodType, "ActionDefault", paramTypes, action);
            FindAndRemoveDisableMethod(facets, methodRemover, type, methodType, capitalizedName, paramTypes, action);

            if (action is DotNetNakedObjectActionPeer) {
                var nakedObjectActionPeer = (DotNetNakedObjectActionPeer) action;
                // Process the action's parameters names, descriptions and optional
                // an alternative design would be to have another facet factory processing just ActionParameter, and have it remove these
                // supporting methods.  However, the FacetFactory API doesn't allow for methods of the class to be removed while processing
                // action parameters, only while processing Methods (ie actions)
                INakedObjectActionParamPeer[] actionParameters = nakedObjectActionPeer.Parameters;
                string[] paramNames = actionMethod.GetParameters().Select(p => p.Name).ToArray();

                FindAndRemoveParametersAutoCompleteMethod(methodRemover, type, capitalizedName, paramTypes, actionParameters);
                FindAndRemoveParametersChoicesMethod(methodRemover, type, capitalizedName, paramTypes, paramNames, actionParameters);
                FindAndRemoveParametersDefaultsMethod(methodRemover, type, capitalizedName, paramTypes, paramNames, actionParameters);
                FindAndRemoveParametersValidateMethod(methodRemover, type, capitalizedName, paramTypes, paramNames, actionParameters);
            }
            return FacetUtils.AddFacets(facets);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="StyleCopXmlRunner" /> class.
        /// <remarks>
        /// Attach to the OutputGenerated event to get an indication once any violations are encountered.
        /// Only 1 event will be triggered on the first violation
        /// </remarks>
        /// </summary>
        /// <param name="settings">Settings file</param>
        /// <param name="outputFileName">Output file</param>
        /// <param name="addInPaths">Add-in paths to use</param>
        public StyleCopXmlRunner(string settings, string outputFileName, ICollection<string> addInPaths)
        {
            Param.Ignore(settings);
            Param.Ignore(outputFileName);
            Param.Ignore(addInPaths);

            this.settingsPath = settings;
            if (this.outputFile == null)
            {
                this.outputFile = "StyleCopViolations.xml";
            }
            else
            {
                this.outputFile = outputFileName;
            }

            this.Core = new StyleCopCore(null, null);
            this.CaptureViolations = false;
            this.Core.Initialize(addInPaths, true);
            this.Core.WriteResultsCache = false;
            this.method = typeof(StyleCopRunner).GetMethod("CreateSafeSectionName", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic);
        }
Exemple #22
0
        public Message(MessageID msgid, string msgname, Int16 length, sbyte argstype, List<Byte> msgargtypes, System.Reflection.MethodInfo msghandler)
        {
            id = msgid;
            name = msgname;
            msglen = length;
            handler = msghandler;
            argsType = argstype;

            // 对该消息的所有参数绑定反序列化方法,改方法能够将二进制流转化为参数需要的值
            // 在服务端下发消息数据时会用到
            argtypes = new KBEDATATYPE_BASE[msgargtypes.Count];
            for(int i=0; i<msgargtypes.Count; i++)
            {
                if(!EntityDef.id2datatypes.TryGetValue(msgargtypes[i], out argtypes[i]))
                {
                    Dbg.ERROR_MSG("Message::Message(): argtype(" + msgargtypes[i] + ") is not found!");
                }
            }

            // Dbg.DEBUG_MSG(string.Format("Message::Message(): ({0}/{1}/{2})!",
            //	msgname, msgid, msglen));
        }
        public void DisplayMethodProperties(System.Reflection.MethodInfo Method)
        {
            ThisMethod = Method;

            // Show the method name

            Label2.Text = ThisMethod.Name;

            // Show the calling convention

            Label4.Text = "0x" + ThisMethod.CallingConvention.ToString("x") +
                " = " + ThisMethod.CallingConvention.ToString();

            // Show the method's standard attributes

            Label6.Text = "0x" + ThisMethod.Attributes.ToString("x") +
                " = " + ThisMethod.Attributes.ToString();

            // Show the return type

            Label8.Text = ThisMethod.ReturnType.FullName;

            // Show the parameters

            foreach (System.Reflection.ParameterInfo parm in ThisMethod.GetParameters())
            {
                //ListBox1.Items.Add(parm.Name + " as " + parm.ParameterType.FullName);
                ListBox1.Items.Add(parm.ParameterType);//changed because I need the type later
            }

            // Show the custom attributes

            foreach (object attr in ThisMethod.GetCustomAttributes(true))
            {
                ListBox2.Items.Add(attr);
            }
        }
Exemple #24
0
        public int s_size; /* search string */

        #endregion Fields

        #region Constructors

        public Among(System.String s, int substring_i, int result, System.String methodname, SnowballProgram methodobject)
        {
            this.s_size = s.Length;
            this.s = s;
            this.substring_i = substring_i;
            this.result = result;
            this.methodobject = methodobject;
            if (methodname.Length == 0)
            {
                this.method = null;
            }
            else
            {
                try
                {
                    this.method = methodobject.GetType().GetMethod(methodname, System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.DeclaredOnly, null, new System.Type[0], null);
                }
                catch (System.MethodAccessException e)
                {
                    // FIXME - debug message
                    this.method = null;
                }
            }
        }
Exemple #25
0
 public JsPropertySetDefinition(string name, System.Reflection.MethodInfo setterMethod)
     : base(name, setterMethod)
 {
 }
 /// <summary>
 /// Determines whether the action name is valid in the specified controller context.
 /// </summary>
 /// <param name="controllerContext">The controller context.</param>
 /// <param name="actionName">The name of the action.</param>
 /// <param name="methodInfo">Information about the action method.</param>
 /// <returns>true if the action name is valid in the specified controller context; otherwise, false.</returns>
 public override bool IsValidName(ControllerContext controllerContext, string actionName, System.Reflection.MethodInfo methodInfo)
 {
     if (Name == "action" && actionName != Argument)
     {
         return(false);
     }
     foreach (var formKey in controllerContext.RequestContext.HttpContext.Request.Form.Keys)
     {
         if (formKey is string && ((string)formKey).StartsWith(Name + ":"))
         {
             return(false);
         }
     }
     return(true);
 }
Exemple #27
0
 public void SetTeardownMethod(System.Reflection.MethodInfo met)
 {
     this.teardownMethod = met;
 }
 public override bool IsValidForRequest(ControllerContext controllerContext, System.Reflection.MethodInfo methodInfo)
 {
     return(controllerContext.RequestContext.HttpContext.Request.IsAjaxRequest());
 }
Exemple #29
0
        //internal static Dictionary<ParamTypes, System.Reflection.MethodInfo> _ConvertMethods = new Dictionary<ParamTypes, System.Reflection.MethodInfo>();
        // I decide not to use cache for converters. Instead, use the method below when you want to convert obj by implicit or explicit operators.
        public static object ConvertTypeEx(this object obj, Type type)
        {
            if (type == null)
            {
                return(null);
            }
            if (obj == null)
            {
                return(null);
            }
            var rv = ConvertType(obj, type);

            if (rv != null)
            {
                return(rv);
            }

            System.Reflection.MethodInfo mi = null;
            LinkedList <KeyValuePair <Type, object> > types = new LinkedList <KeyValuePair <Type, object> >();

            types.AddLast(new KeyValuePair <Type, object>(type, obj));
            types.AddLast(new KeyValuePair <Type, object>(obj.GetType(), obj));
            while (obj is IExpando)
            {
                obj = ((IExpando)obj).Core;
                if (obj != null)
                {
                    types.AddLast(new KeyValuePair <Type, object>(obj.GetType(), obj));
                }
            }
            if (obj is BaseDynamic)
            {
                obj = ((BaseDynamic)obj).Binding;
                if (obj != null)
                {
                    types.AddLast(new KeyValuePair <Type, object>(obj.GetType(), obj));
                }
            }

            foreach (var kvp in types)
            {
                mi = null;
                try
                {
                    mi = kvp.Key.GetMethods().First(mic =>
                    {
                        if (mic.IsStatic && mic.ReturnType == type && mic.Name == "op_Implicit")
                        {
                            var pars = mic.GetParameters();
                            if (pars != null && pars.Length == 1 && pars[0].ParameterType == kvp.Value.GetType())
                            {
                                return(true);
                            }
                        }
                        return(false);
                    });
                }
                catch { }
                if (mi != null)
                {
                    try
                    {
                        var args = ObjectPool.GetParamsFromPool(1);
                        args[0] = kvp.Value;
                        var rv2 = mi.Invoke(null, args);
                        ObjectPool.ReturnParamsToPool(args);
                        return(rv2);
                    }
                    catch { }
                    return(null);
                }
                mi = null;
                try
                {
                    mi = kvp.Key.GetMethods().First(mic =>
                    {
                        if (mic.IsStatic && mic.ReturnType == type && mic.Name == "op_Explicit")
                        {
                            var pars = mic.GetParameters();
                            if (pars != null && pars.Length == 1 && pars[0].ParameterType == kvp.Value.GetType())
                            {
                                return(true);
                            }
                        }
                        return(false);
                    });
                }
                catch { }
                if (mi != null)
                {
                    try
                    {
                        var args = ObjectPool.GetParamsFromPool(1);
                        args[0] = kvp.Value;
                        var rv2 = mi.Invoke(null, args);
                        ObjectPool.ReturnParamsToPool(args);
                        return(rv2);
                    }
                    catch { }
                    return(null);
                }
            }
            return(null);
        }
Exemple #30
0
 public TestCaseMethod(TestCaseInstance owner, System.Reflection.MethodInfo met)
 {
     this.owner = owner;
     this.met   = met;
 }
 public bool ShouldInterceptMethod(Type type, System.Reflection.MethodInfo methodInfo)
 {
     return(true);
 }
Exemple #32
0
 public virtual void EmitCall(System.Reflection.Emit.OpCode opcode, System.Reflection.MethodInfo methodInfo, System.Type[]?optionalParameterTypes)
 {
 }
        public virtual void runTest()
        {
            MethodProvider mp = new MethodProvider();

            try {
            // Test boolean primitive.
            System.Object[] booleanParams = new System.Object[]{true};
            type = "boolean";
            method = RuntimeSingleton.Introspector.getMethod(typeof(MethodProvider), type + "Method", booleanParams);
            result = (System.String) method.Invoke(mp, (System.Object[]) booleanParams);

            if (!result.Equals(type))
            failures.add(type + "Method could not be found!");

            // Test byte primitive.
            System.Object[] byteParams = new System.Object[]{System.Byte.Parse("1")};
            type = "byte";
            method = RuntimeSingleton.Introspector.getMethod(typeof(MethodProvider), type + "Method", byteParams);
            result = (System.String) method.Invoke(mp, (System.Object[]) byteParams);

            if (!result.Equals(type))
            failures.add(type + "Method could not be found!");

            // Test char primitive.
            System.Object[] characterParams = new System.Object[]{'a'};
            type = "character";
            method = RuntimeSingleton.Introspector.getMethod(typeof(MethodProvider), type + "Method", characterParams);
            result = (System.String) method.Invoke(mp, (System.Object[]) characterParams);

            if (!result.Equals(type))
            failures.add(type + "Method could not be found!");

            // Test double primitive.
            System.Object[] doubleParams = new System.Object[]{(double) 1};
            type = "double";
            method = RuntimeSingleton.Introspector.getMethod(typeof(MethodProvider), type + "Method", doubleParams);
            result = (System.String) method.Invoke(mp, (System.Object[]) doubleParams);

            if (!result.Equals(type))
            failures.add(type + "Method could not be found!");

            // Test float primitive.
            System.Object[] floatParams = new System.Object[]{(float) 1};
            type = "float";
            method = RuntimeSingleton.Introspector.getMethod(typeof(MethodProvider), type + "Method", floatParams);
            result = (System.String) method.Invoke(mp, (System.Object[]) floatParams);

            if (!result.Equals(type))
            failures.add(type + "Method could not be found!");

            // Test integer primitive.
            System.Object[] integerParams = new System.Object[]{(int) 1};
            type = "integer";
            method = RuntimeSingleton.Introspector.getMethod(typeof(MethodProvider), type + "Method", integerParams);
            result = (System.String) method.Invoke(mp, (System.Object[]) integerParams);

            if (!result.Equals(type))
            failures.add(type + "Method could not be found!");

            // Test long primitive.
            System.Object[] longParams = new System.Object[]{(long) 1};
            type = "long";
            method = RuntimeSingleton.Introspector.getMethod(typeof(MethodProvider), type + "Method", longParams);
            result = (System.String) method.Invoke(mp, (System.Object[]) longParams);

            if (!result.Equals(type))
            failures.add(type + "Method could not be found!");

            // Test short primitive.
            System.Object[] shortParams = new System.Object[]{(short) 1};
            type = "short";
            method = RuntimeSingleton.Introspector.getMethod(typeof(MethodProvider), type + "Method", shortParams);
            result = (System.String) method.Invoke(mp, (System.Object[]) shortParams);

            if (!result.Equals(type))
            failures.add(type + "Method could not be found!");

            // Test untouchable

            System.Object[] params_Renamed = new System.Object[]{};

            method = RuntimeSingleton.Introspector.getMethod(typeof(MethodProvider), "untouchable", params_Renamed);

            if (method != null)
            failures.add(type + "able to access a private-access method.");

            // Test really untouchable

            method = RuntimeSingleton.Introspector.getMethod(typeof(MethodProvider), "reallyuntouchable", params_Renamed);

            if (method != null)
            failures.add(type + "able to access a default-access method.");

            // There were any failures then show all the
            // errors that occured.

            int totalFailures = failures.size();
            if (totalFailures > 0) {
            System.Text.StringBuilder sb = new System.Text.StringBuilder("\nIntrospection Errors:\n");
            for (int i = 0; i < totalFailures; i++)
            sb.Append((System.String) failures.get(i)).Append("\n");

            fail(sb.ToString());
            }
            } catch (System.Exception e) {
            fail(e.ToString());
            }
        }
		private void RegisterStartupScript(Type type, string key, string script, bool addScriptTags)
		{
			if (HasMsAjax)
			{
				if (mtdRegisterStartupScript == null)
					mtdRegisterStartupScript = typScriptManager.GetMethod("RegisterStartupScript", new Type[5] { typeof(Control), typeof(Type), typeof(string), typeof(string), typeof(bool) });
				mtdRegisterStartupScript.Invoke(null, new object[5] { this, type, key, script, addScriptTags });
			}
			else
				Page.ClientScript.RegisterStartupScript(type, key, script, addScriptTags);
		}
		private void RegisterOnSubmitStatement(Type type, string key, string script)
		{
			if (HasMsAjax)
			{
				if (mtdRegisterOnSubmitStatement == null)
					mtdRegisterOnSubmitStatement = typScriptManager.GetMethod("RegisterOnSubmitStatement", new Type[4] { typeof(Control), typeof(Type), typeof(string), typeof(string) });
				mtdRegisterOnSubmitStatement.Invoke(null, new object[4] { this, type, key, script });
			}
			else
				Page.ClientScript.RegisterOnSubmitStatement(type, key, script);
		}
Exemple #36
0
 internal static Delegate CreateDelegate(Type delegateType, System.Reflection.MethodInfo method)
 {
     return(Delegate.CreateDelegate(delegateType, method));
 }
        public override bool IsValidName(ControllerContext controllerContext, string actionName, System.Reflection.MethodInfo methodInfo)
        {
            if (actionName.Equals(methodInfo.Name, StringComparison.InvariantCultureIgnoreCase))
            {
                return(true);
            }
            if (!actionName.Equals("ApplicationStaffAdmin", StringComparison.InvariantCultureIgnoreCase))
            {
                return(false);
            }

            var request = controllerContext.RequestContext.HttpContext.Request;

            foreach (string item in request.Form.Keys)
            {
                if (item.StartsWith(Prefix + methodInfo.Name))
                {
                    return(true);
                }
            }
            return(request[Prefix + methodInfo.Name] != null && !controllerContext.IsChildAction);
        }
 public override bool IsValidForRequest(ControllerContext controllerContext, System.Reflection.MethodInfo methodInfo)
 {
     return(DBMode.Service != null && DBMode.Service.DatabaseMode != DatabaseMode.ReadOnly);
 }
Exemple #39
0
 public SetupOptions(int priority, Mod mod, System.Reflection.MethodInfo mi)
 {
     this.priority = priority;
     this.mod      = mod;
     this.mi       = mi;
 }
Exemple #40
0
 private static bool TrySetBusy(this object state)
 {
     return((bool)(_trySetBusy ?? (_trySetBusy = state.GetType().GetMethod("TrySetBusy", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public))).Invoke(state, null));
 }
Exemple #41
0
 public virtual void Emit(System.Reflection.Emit.OpCode opcode, System.Reflection.MethodInfo meth)
 {
 }
Exemple #42
0
 /// <summary>
 /// Force Unity To Write Project File
 /// </summary>
 /// <remarks>
 /// Reflection!
 /// </remarks>
 public static void SyncSolution()
 {
     System.Type T = System.Type.GetType("UnityEditor.SyncVS,UnityEditor");
     System.Reflection.MethodInfo SyncSolution = T.GetMethod("SyncSolution", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static);
     SyncSolution.Invoke(null, null);
 }
        private void edit_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            System.Reflection.MethodInfo methodInfo = e.ClickedItem.Tag as System.Reflection.MethodInfo;
            if (methodInfo == null)
            {
                return;
            }

            Control control = null;

            if (sender is ContextMenuStrip)
            {
                control = (sender as ContextMenuStrip).SourceControl;
            }

            if (control == null)
            {
                if (this.rtbCustomUI.Focused)
                {
                    control = this.rtbCustomUI;
                }
                else if (this.rtbCallbacks != null && this.rtbCallbacks.Focused)
                {
                    control = this.rtbCallbacks;
                }
            }

            if (control != null && control is RichTextBox)
            {
                //RedoUndo
                if (methodInfo.Name.Equals("Undo"))
                {
                    RichTextBox rtb = control as RichTextBox;
                    int         index;
                    string      rtf = _commands.RemoveCommand(out index, true);
                    while (rtf.Equals(rtb.Rtf))
                    {
                        rtf = _commands.RemoveCommand(out index, false);
                        if (rtf == null)
                        {
                            break;
                        }
                    }
                    if (rtf != null)
                    {
                        rtb.Rtf = rtf;
                    }
                    rtb.SelectionStart = index;
                }
                else if (methodInfo.Name.Equals("Redo"))
                {
                    RichTextBox rtb = control as RichTextBox;
                    int         index;
                    string      rtf = _commands.RedoCommand(out index);
                    if (rtf != null)
                    {
                        while (rtf.Equals(rtb.Rtf))
                        {
                            rtf = _commands.RedoCommand(out index);

                            if (rtf == null)
                            {
                                break;
                            }
                        }
                        rtb.Rtf            = rtf;
                        rtb.SelectionStart = index;
                    }
                }
                else
                {
                    methodInfo.Invoke(control, null);
                }

                return;
            }

            Debug.Assert(false, "Fail to invoke " + methodInfo.Name);
        }
Exemple #44
0
        static void SolveIteration(int iteration, GH_Component component, List <object[]> input, List <object[]> output, System.Reflection.MethodInfo method)
        {
            var da = new GhPyDataAccess(component, input[iteration]);

            method.Invoke(component, new object[] { da });
            object[] solve_results = da.Output;
            if (solve_results != null)
            {
                for (int j = 0; j < solve_results.Length; j++)
                {
                    output[j][iteration] = solve_results[j];
                }
            }
        }
Exemple #45
0
        public override bool IsValidForRequest(System.Web.Mvc.ControllerContext controllerContext, System.Reflection.MethodInfo methodInfo)
        {
            var isValideForRequest = base.IsValidForRequest(controllerContext, methodInfo);

            //if(isValideForRequest && !HttpContext.Current.Items.Contains(UrlRewriter.UrlRewriterCurrentRouteKey))
            //    throw new HttpException(404, "HTTP/1.1 404 Not Found");

            //return isValideForRequest;

            return(isValideForRequest && HttpContext.Current.Items.Contains(UrlRewriterHttpModule.UrlRewriterCurrentRouteKey));
        }
Exemple #46
0
 static public void Emit(this MethodBody body, OpCode instruction, MethodInfo method)
 {
     body.Add(Instruction.Create(instruction, body.Method.DeclaringType.Module.Import(method)));
 }
Exemple #47
0
        /// <summary>
        /// Converts a VtValue holding a VtArray of T to a C#-native array type, using (slow) late binding.
        /// </summary>
        object ToCsDynamicConvertHelper(pxr.VtValue vtValue, Type vtArrayType, System.Reflection.MethodInfo valToVtArray, System.Reflection.MethodInfo vtToCsArray)
        {
            // Intentionally not tracking size here, since USD will resize the array for us.
            object vtArrayObject = UsdIo.ArrayAllocator.MallocHandle(vtArrayType);

            // Convert value to VtArray<T> and convert that to the target C# array type.

            // For example:
            //   class UsdCs {
            //     public static void VtValueToVtTokenArray(VtValue value, VtTokenArray output);
            valToVtArray.Invoke(null, new object[] { vtValue, vtArrayObject });

            // For example:
            //   class IntrinsicTypeConverter {
            //     static public string[] FromVtArray(VtTokenArray input);
            object csArray = vtToCsArray.Invoke(null, new object[] { vtArrayObject });

            // Free the handle back to the allocator.
            UsdIo.ArrayAllocator.FreeHandle(vtArrayType, vtArrayObject);

            // Return the C# array.
            return(csArray);
        }
Exemple #48
0
 public AssemblyEn(object ptarget, System.Reflection.MethodInfo pmethodInfo)
 {
     this.target     = ptarget;
     this.methodInfo = pmethodInfo;
 }
Exemple #49
0
 public BindingInvoker(System.Reflection.MethodInfo mi, object[] parms)
 {
     this.mi    = mi;
     this.parms = parms;
 }
        /// <summary>
        /// Determines whether the action name is valid in the specified controller context.
        /// </summary>
        /// <param name="controllerContext">The controller context.</param>
        /// <param name="actionName">The name of the action.</param>
        /// <param name="methodInfo">Information about the action method.</param>
        /// <returns>true if the action name is valid in the specified controller context; otherwise, false.</returns>
        public override bool IsValidName(ControllerContext controllerContext, string actionName, System.Reflection.MethodInfo methodInfo)
        {
            var value = controllerContext.Controller.ValueProvider.GetValue(string.Format("{0}:{1}", Name, Argument));

            if (value != null)
            {
                controllerContext.Controller.ControllerContext.RouteData.Values[Name] = Argument;
                return(true);
            }

            return(false);
        }
Exemple #51
0
        /// <summary>Generates a generic object at runtime (typically delegates).</summary>
        /// <typeparam name="T">The type of the generic object to create.</typeparam>
        /// <param name="code">The object to generate.</param>
        /// <param name="method">The name of the method to generate the object in.</param>
        /// <param name="_class">The name of the class to generate the object in.</param>
        /// <param name="_namespace">The name of the namespace to generate the object in.</param>
        /// <param name="name_spaces">The required namespaces.</param>
        /// <param name="_unsafe">Is unsafe code allowed?</param>
        /// <param name="references">The required assembly references.</param>
        /// <returns>The generated object.</returns>
        internal static T Compile <T>(
            string code, string method, string _class, string _namespace, bool _unsafe, string[] name_spaces, string[] references)
        {
            if (code == null)
            {
                throw new System.ArgumentNullException("code");
            }
            if (method == null)
            {
                throw new System.ArgumentNullException("method");
            }
            if (_class == null)
            {
                throw new System.ArgumentNullException("_class");
            }
            if (_namespace == null)
            {
                throw new System.ArgumentNullException("_namespace");
            }

            string full_code = string.Empty;

            if (name_spaces != null)
            {
                for (int i = 0; i < name_spaces.Length; i++)
                {
                    full_code += "using " + name_spaces[i] + ";";
                }
            }

            full_code += "namespace " + _namespace + " {";
            full_code += "public class " + _class + " {";
            full_code += "public static object " + method + "() { return " + code + "; } } }";

            System.CodeDom.Compiler.CompilerParameters parameters =
                new System.CodeDom.Compiler.CompilerParameters();

            if (references != null)
            {
                foreach (string reference in references)
                {
                    parameters.ReferencedAssemblies.Add(reference);
                }
            }

            parameters.GenerateInMemory = true;

            if (_unsafe)
            {
                parameters.CompilerOptions = "/optimize /unsafe";
            }

            System.CodeDom.Compiler.CompilerResults results =
                new Microsoft.CSharp.CSharpCodeProvider().CompileAssemblyFromSource(parameters, full_code);

            if (results.Errors.HasErrors)
            {
                string error = string.Empty;

                foreach (System.CodeDom.Compiler.CompilerError compiler_error in results.Errors)
                {
                    error += compiler_error.ErrorText.ToString() + "\n";
                }

                throw new System.FormatException(error);
            }

            System.Reflection.MethodInfo generate =
                results.CompiledAssembly.GetType(_namespace + "." + _class).GetMethod(method);

            return((T)generate.Invoke(null, null));
        }
Exemple #52
0
 public void SetSetupMethod(System.Reflection.MethodInfo met)
 {
     this.setupMethod = met;
 }
Exemple #53
0
 static IReceiverEntryContractToViewAddInAdapter()
 {
     s_MessageReceivedEventAddFire = typeof(IReceiverEntryContractToViewAddInAdapter).GetMethod("Fire_MessageReceived", ((System.Reflection.BindingFlags)(36)));
 }
        static HDLightUI()
        {
            Inspector = CED.Group(
                CED.AdvancedFoldoutGroup(s_Styles.generalHeader, Expandable.General, k_ExpandedState,
                                         (serialized, owner) => GetAdvanced(Advanceable.General, serialized, owner),
                                         (serialized, owner) => SwitchAdvanced(Advanceable.General, serialized, owner),
                                         DrawGeneralContent,
                                         DrawGeneralAdvancedContent
                                         ),
                CED.AdvancedFoldoutGroup(s_Styles.shapeHeader, Expandable.Shape, k_ExpandedState,
                                         (serialized, owner) => GetAdvanced(Advanceable.Shape, serialized, owner),
                                         (serialized, owner) => SwitchAdvanced(Advanceable.Shape, serialized, owner),
                                         DrawShapeContent,
                                         DrawShapeAdvancedContent
                                         ),
                CED.AdvancedFoldoutGroup(s_Styles.emissionHeader, Expandable.Emission, k_ExpandedState,
                                         (serialized, owner) => GetAdvanced(Advanceable.Emission, serialized, owner),
                                         (serialized, owner) => SwitchAdvanced(Advanceable.Emission, serialized, owner),
                                         DrawEmissionContent,
                                         DrawEmissionAdvancedContent
                                         ),
                CED.FoldoutGroup(s_Styles.volumetricHeader, Expandable.Volumetric, k_ExpandedState, DrawVolumetric),
                CED.Conditional((serialized, owner) => serialized.editorLightShape != LightShape.Rectangle && serialized.editorLightShape != LightShape.Tube,
                                CED.AdvancedFoldoutGroup(s_Styles.shadowHeader, Expandable.Shadows, k_ExpandedState,
                                                         (serialized, owner) => GetAdvanced(Advanceable.Shadow, serialized, owner),
                                                         (serialized, owner) => SwitchAdvanced(Advanceable.Shadow, serialized, owner),
                                                         CED.Group(
                                                             CED.FoldoutGroup(s_Styles.shadowMapSubHeader, Expandable.ShadowMap, k_ExpandedState, FoldoutOption.SubFoldout | FoldoutOption.Indent | FoldoutOption.NoSpaceAtEnd, DrawShadowMapContent),
                                                             CED.Conditional((serialized, owner) => GetAdvanced(Advanceable.Shadow, serialized, owner) && k_ExpandedState[Expandable.ShadowMap],
                                                                             CED.Group(GroupOption.Indent, DrawShadowMapAdvancedContent)),
                                                             CED.space,
                                                             // Very High setting
                                                             CED.Conditional((serialized, owner) => HasShadowQualitySettingsUI(HDShadowQuality.VeryHigh, serialized, owner),
                                                                             CED.FoldoutGroup(s_Styles.veryHighShadowQualitySubHeader, Expandable.ShadowQuality, k_ExpandedState, FoldoutOption.SubFoldout | FoldoutOption.Indent, DrawVeryHighShadowSettingsContent)),
                                                             // High setting
                                                             CED.Conditional((serialized, owner) => HasShadowQualitySettingsUI(HDShadowQuality.High, serialized, owner),
                                                                             CED.FoldoutGroup(s_Styles.highShadowQualitySubHeader, Expandable.ShadowQuality, k_ExpandedState, FoldoutOption.SubFoldout | FoldoutOption.Indent, DrawHighShadowSettingsContent)),
                                                             CED.Conditional((serialized, owner) => HasShadowQualitySettingsUI(HDShadowQuality.Medium, serialized, owner),
                                                                             CED.FoldoutGroup(s_Styles.mediumShadowQualitySubHeader, Expandable.ShadowQuality, k_ExpandedState, FoldoutOption.SubFoldout | FoldoutOption.Indent, DrawMediumShadowSettingsContent)),
                                                             CED.Conditional((serialized, owner) => HasShadowQualitySettingsUI(HDShadowQuality.Low, serialized, owner),
                                                                             CED.FoldoutGroup(s_Styles.lowShadowQualitySubHeader, Expandable.ShadowQuality, k_ExpandedState, FoldoutOption.SubFoldout | FoldoutOption.Indent, DrawLowShadowSettingsContent)),
                                                             CED.FoldoutGroup(s_Styles.contactShadowsSubHeader, Expandable.ContactShadow, k_ExpandedState, FoldoutOption.SubFoldout | FoldoutOption.Indent | FoldoutOption.NoSpaceAtEnd, DrawContactShadowsContent),
                                                             CED.Conditional((serialized, owner) => serialized.settings.isBakedOrMixed || serialized.settings.isCompletelyBaked,
                                                                             CED.space,
                                                                             CED.FoldoutGroup(s_Styles.bakedShadowsSubHeader, Expandable.BakedShadow, k_ExpandedState, FoldoutOption.SubFoldout | FoldoutOption.Indent | FoldoutOption.NoSpaceAtEnd, DrawBakedShadowsContent))
                                                             ),
                                                         CED.noop //will only add parameter in first sub header
                                                         )
                                )
                );

            //quicker than standard reflection as it is compiled
            var paramLabel    = Expression.Parameter(typeof(GUIContent), "label");
            var paramProperty = Expression.Parameter(typeof(SerializedProperty), "property");
            var paramSettings = Expression.Parameter(typeof(LightEditor.Settings), "settings");

            System.Reflection.MethodInfo sliderWithTextureInfo = typeof(EditorGUILayout)
                                                                 .GetMethod(
                "SliderWithTexture",
                System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static,
                null,
                System.Reflection.CallingConventions.Any,
                new[] { typeof(GUIContent), typeof(SerializedProperty), typeof(float), typeof(float), typeof(float), typeof(Texture2D), typeof(GUILayoutOption[]) },
                null);
            var sliderWithTextureCall = Expression.Call(
                sliderWithTextureInfo,
                paramLabel,
                paramProperty,
                Expression.Constant((float)typeof(LightEditor.Settings).GetField("kMinKelvin", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic).GetRawConstantValue()),
                Expression.Constant((float)typeof(LightEditor.Settings).GetField("kMaxKelvin", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic).GetRawConstantValue()),
                Expression.Constant((float)typeof(LightEditor.Settings).GetField("kSliderPower", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic).GetRawConstantValue()),
                Expression.Field(paramSettings, typeof(LightEditor.Settings).GetField("m_KelvinGradientTexture", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance)),
                Expression.Constant(null, typeof(GUILayoutOption[])));
            var lambda = Expression.Lambda <Action <GUIContent, SerializedProperty, LightEditor.Settings> >(sliderWithTextureCall, paramLabel, paramProperty, paramSettings);

            SliderWithTexture = lambda.Compile();
        }
		private void RegisterClientScriptInclude(Type type, string key, string url)
		{
			if (HasMsAjax)
			{
				if (mtdRegisterClientScriptInclude == null)
					mtdRegisterClientScriptInclude = typScriptManager.GetMethod("RegisterClientScriptInclude", new Type[4] { typeof(Control), typeof(Type), typeof(string), typeof(string) });
				mtdRegisterClientScriptInclude.Invoke(null, new object[4] { this, type, key, url });
			}
			else
				Page.ClientScript.RegisterClientScriptInclude(type, key, url);
		}
Exemple #56
0
 /// <inheritdoc/>
 public virtual Object Invoke(Object composite, System.Reflection.MethodInfo method, Object[] args)
 {
     return(null);
 }
Exemple #57
0
 internal static SerializationErrorCallback CreateSerializationErrorCallback(MethodInfo callbackMethodInfo)
 {
     return (o, context, econtext) => callbackMethodInfo.Invoke(o, new object[] { context, econtext });
 }
Exemple #58
0
        private void DrawNodes()
        {
            Event e = Event.current;

            if (e.type == EventType.Layout)
            {
                selectionCache = new List <UnityEngine.Object>(Selection.objects);
            }

            System.Reflection.MethodInfo onValidate = null;
            if (Selection.activeObject != null && Selection.activeObject is XNode.Node)
            {
                onValidate = Selection.activeObject.GetType().GetMethod("OnValidate");
                if (onValidate != null)
                {
                    EditorGUI.BeginChangeCheck();
                }
            }

            BeginZoomed();

            Vector2 mousePos = Event.current.mousePosition;

            if (e.type != EventType.Layout)
            {
                hoveredNode = null;
                hoveredPort = null;
            }

            List <UnityEngine.Object> preSelection = preBoxSelection != null ? new List <UnityEngine.Object>(preBoxSelection) : new List <UnityEngine.Object>();

            // Selection box stuff
            Vector2 boxStartPos = GridToWindowPositionNoClipped(dragBoxStart);
            Vector2 boxSize     = mousePos - boxStartPos;

            if (boxSize.x < 0)
            {
                boxStartPos.x += boxSize.x; boxSize.x = Mathf.Abs(boxSize.x);
            }
            if (boxSize.y < 0)
            {
                boxStartPos.y += boxSize.y; boxSize.y = Mathf.Abs(boxSize.y);
            }
            Rect selectionBox = new Rect(boxStartPos, boxSize);

            //Save guiColor so we can revert it
            Color guiColor = GUI.color;

            if (e.type == EventType.Layout)
            {
                culledNodes = new List <XNode.Node>();
            }
            for (int n = 0; n < graph.nodes.Count; n++)
            {
                // Skip null nodes. The user could be in the process of renaming scripts, so removing them at this point is not advisable.
                if (graph.nodes[n] == null)
                {
                    continue;
                }
                if (n >= graph.nodes.Count)
                {
                    return;
                }
                XNode.Node node = graph.nodes[n];

                // Culling
                if (e.type == EventType.Layout)
                {
                    // Cull unselected nodes outside view
                    if (!Selection.Contains(node) && ShouldBeCulled(node))
                    {
                        culledNodes.Add(node);
                        continue;
                    }
                }
                else if (culledNodes.Contains(node))
                {
                    continue;
                }

                if (e.type == EventType.Repaint)
                {
                    _portConnectionPoints = _portConnectionPoints.Where(x => x.Key.node != node).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
                }

                NodeEditor nodeEditor = NodeEditor.GetEditor(node, this);

                NodeEditor.portPositions.Clear();

                //Get node position
                Vector2 nodePos = GridToWindowPositionNoClipped(node.position);

                GUILayout.BeginArea(new Rect(nodePos, new Vector2(nodeEditor.GetWidth(), 4000)));

                bool selected = selectionCache.Contains(graph.nodes[n]);

                if (selected)
                {
                    GUIStyle style          = new GUIStyle(nodeEditor.GetBodyStyle());
                    GUIStyle highlightStyle = new GUIStyle(NodeEditorResources.styles.nodeHighlight);
                    highlightStyle.padding = style.padding;
                    style.padding          = new RectOffset();
                    GUI.color = nodeEditor.GetTint();
                    GUILayout.BeginVertical(style);
                    GUI.color = NodeEditorPreferences.GetSettings().highlightColor;
                    GUILayout.BeginVertical(new GUIStyle(highlightStyle));
                }
                else
                {
                    GUIStyle style = new GUIStyle(nodeEditor.GetBodyStyle());
                    GUI.color = nodeEditor.GetTint();
                    GUILayout.BeginVertical(style);
                }

                GUI.color = guiColor;
                EditorGUI.BeginChangeCheck();

                //Draw node contents
                nodeEditor.OnHeaderGUI();
                nodeEditor.OnBodyGUI();

                //If user changed a value, notify other scripts through onUpdateNode
                if (EditorGUI.EndChangeCheck())
                {
                    if (NodeEditor.onUpdateNode != null)
                    {
                        NodeEditor.onUpdateNode(node);
                    }
                    EditorUtility.SetDirty(node);
                    nodeEditor.serializedObject.ApplyModifiedProperties();
                }

                GUILayout.EndVertical();

                //Cache data about the node for next frame
                if (e.type == EventType.Repaint)
                {
                    Vector2 size = GUILayoutUtility.GetLastRect().size;
                    if (nodeSizes.ContainsKey(node))
                    {
                        nodeSizes[node] = size;
                    }
                    else
                    {
                        nodeSizes.Add(node, size);
                    }

                    foreach (var kvp in NodeEditor.portPositions)
                    {
                        Vector2 portHandlePos = kvp.Value;
                        portHandlePos += node.position;
                        Rect rect = new Rect(portHandlePos.x - 8, portHandlePos.y - 8, 16, 16);
                        portConnectionPoints[kvp.Key] = rect;
                    }
                }

                if (selected)
                {
                    GUILayout.EndVertical();
                }

                if (e.type != EventType.Layout)
                {
                    //Check if we are hovering this node
                    Vector2 nodeSize   = GUILayoutUtility.GetLastRect().size;
                    Rect    windowRect = new Rect(nodePos, nodeSize);
                    if (windowRect.Contains(mousePos))
                    {
                        hoveredNode = node;
                    }

                    //If dragging a selection box, add nodes inside to selection
                    if (currentActivity == NodeActivity.DragGrid)
                    {
                        if (windowRect.Overlaps(selectionBox))
                        {
                            preSelection.Add(node);
                        }
                    }

                    //Check if we are hovering any of this nodes ports
                    //Check input ports
                    foreach (XNode.NodePort input in node.Inputs)
                    {
                        //Check if port rect is available
                        if (!portConnectionPoints.ContainsKey(input))
                        {
                            continue;
                        }
                        Rect r = GridToWindowRectNoClipped(portConnectionPoints[input]);
                        if (r.Contains(mousePos))
                        {
                            hoveredPort = input;
                        }
                    }
                    //Check all output ports
                    foreach (XNode.NodePort output in node.Outputs)
                    {
                        //Check if port rect is available
                        if (!portConnectionPoints.ContainsKey(output))
                        {
                            continue;
                        }
                        Rect r = GridToWindowRectNoClipped(portConnectionPoints[output]);
                        if (r.Contains(mousePos))
                        {
                            hoveredPort = output;
                        }
                    }
                }

                GUILayout.EndArea();
            }

            if (e.type != EventType.Layout && currentActivity == NodeActivity.DragGrid)
            {
                Selection.objects = preSelection.ToArray();
            }
            EndZoomed();

            //If a change in is detected in the selected node, call OnValidate method.
            //This is done through reflection because OnValidate is only relevant in editor,
            //and thus, the code should not be included in build.
            if (onValidate != null && EditorGUI.EndChangeCheck())
            {
                onValidate.Invoke(Selection.activeObject, null);
            }
        }
        private void FindResourceNameEncodingMethod()
        {
            System.Reflection.Assembly a = AssemblyUtils.LoadAssemblyFile(_assembly.MainModule.FullyQualifiedName);
            Type[] types = a.GetTypes();
            if (types != null)
            {
                for (int i = 0; i < types.Length; i++)
                {
                    Type type = types[i];
                    if (IsBaseType("System.Resources.ResourceManager", type))
                    {
                        System.Reflection.MethodInfo[] methods = type.GetMethods(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static);
                        if (methods != null)
                        {
                            for (int j = 0; j < methods.Length; j++)
                            {
                                System.Reflection.MethodInfo method = methods[j];
                                if (method.ReturnType.FullName == "System.String")
                                {
                                    System.Reflection.ParameterInfo[] parameters = method.GetParameters();
                                    if (parameters != null && parameters.Length == 1 && parameters[0].ParameterType.FullName == "System.String")
                                    {
                                        _encodingMethod = method;
                                        break;
                                    }
                                }
                            }
                        }
                        if (_encodingMethod != null)
                            break;
                    }
                }
            }

        }
 protected abstract object Invoke(System.Reflection.MethodInfo targetMethod, object[] args);