public Invokable(SSMethodInfo methodInfo, Runner runner, BaseMethodDeclarationSyntax declaration) { this.Type = InvokeType.Interpret; this.MethodInfo = methodInfo; this.Runner = runner; this.InterpretMethod = declaration; }
private static T Create <T>(InvokeType invokeType, object invoker_object) { if (invoker_object == null) { throw new Exception("MethodProxy.Create object == null"); } object proxy = Create <T, MethodProxy>(); var p = Cast(proxy); p._type = typeof(T); p._invokeType = invokeType; switch (invokeType) { case InvokeType.Proxy: p._invokerProxy = (IInvokerProxy)invoker_object; break; case InvokeType.ProxyFunc: p.GetIInvokerProxyFunc = (Func <IInvokerProxy>)invoker_object; break; case InvokeType.Object: p._invokeObject = invoker_object; break; default: throw new Exception("InvokeProxy.Create unknown type"); } return((T)proxy); }
public List <CommandPluginHandler> GetActions(InvokeType invoke_type) { if (invoke_type == InvokeType.Before) { return(this.beforeActions); } return(this.afterActions); }
public EvalInvoke(string target, string result, string memberName, InvokeType invokeType, params string[] args) { this.target = target; this.result = result; this.memberName = memberName; this.invokeType = invokeType; this.args = new List <string>(args); }
public EvalInvoke(string target, string result, string memberName, InvokeType invokeType, List <string> args) { this.target = target; this.result = result; this.memberName = memberName; this.invokeType = invokeType; this.args = args; }
public ImageButton(Vector2 position, Resize resize, Request[] requests, Rectangle window, char?hotkey, bool resetIndices, params Texture2D[] images) { this.Position = position; this.resize = resize; this.Actions = new Action[0]; this.Requests = requests; this.Window = window; this.hotkey = hotkey; this.ResetIndices = resetIndices; this.Images = images; this.invokeType = InvokeType.Request; }
public ExecInvoke(string trigger, string next, string target, string result, string memberName, InvokeType invokeType, params string[] args) { this.trigger = trigger; this.next = next; this.target = target; this.result = result; this.memberName = memberName; this.invokeType = invokeType; this.args = new List <string>(args); }
private void Invoke() { this.timer.Interval = this.random.Next(this.settings.MinInterval, this.settings.MaxInterval); DateTime wrongDeltaTime; lock (this) { this.sensorId++; if (this.sensorId >= this.settings.SensorAmount) { this.sensorId = 0; } wrongDeltaTime = this.time.AddSeconds(this.settings.MaxRealInterval * 2); this.time = this.time.AddMilliseconds(this.random.Next(this.settings.MinRealInterval, this.settings.MaxRealInterval)); } IDictionary <InvokeType, int> weights = this.GetWeights(this.settings); int totalWeight = weights.Select(w => w.Value).Sum(); int weight = this.random.Next(0, totalWeight); InvokeType invokeType = this.GetInvokeType(weights, weight); switch (invokeType) { case InvokeType.Success: this.TimingTriggered?.Invoke(this.sensorId, this.time); break; case InvokeType.DoNotTrigger: break; case InvokeType.WrongSensor: this.TimingTriggered?.Invoke(-1, this.time); break; case InvokeType.WrongDeltaTime: this.TimingTriggered?.Invoke(this.sensorId, wrongDeltaTime); break; case InvokeType.MultipleSensors: this.TimingTriggered?.Invoke(this.sensorId, this.time); this.TimingTriggered?.Invoke(this.sensorId, this.time); break; default: throw new CaseNotImplementedException <InvokeType>(invokeType); } }
private static void Invoke(Page page, Control sender, InvokeType invokeType, params object[] _parmas) { if (page == null) { throw new ApplicationException("未指定页面"); } string pagePluginKey = PagePluginFactory.GetPagePluginKey(page); List <EventCallHandlerItem> eventCallHandlerItemList = handlerContext.GetEventCallHandlerItemList(pagePluginKey, sender.ID); if ((eventCallHandlerItemList != null) && (eventCallHandlerItemList.Count > 0)) { foreach (EventCallHandlerItem item in eventCallHandlerItemList) { if (item.InvokeInfo.InvokeType == invokeType) { item.EventCallHandler.Invoke(page, sender, _parmas); } } } }
/// <summary> /// Stops all Invoke routines of a determined type /// </summary> /// <param name="stopperScript"></param> /// <param name="type"></param> public static void StopInvoke(MonoBehaviour stopperScript, InvokeType type) { switch (type) { case InvokeType.Invoke: InvokeRoutine.StopAll(stopperScript); break; case InvokeType.InvokeRepeating: InvokeRepeatingRoutine.StopAll(stopperScript); break; case InvokeType.All: StopInvoke(stopperScript, InvokeType.Invoke); StopInvoke(stopperScript, InvokeType.InvokeRepeating); break; default: break; } }
/// <summary> /// Возвращает подходящий сервис для исполнения. /// </summary> /// <param name="invoked_data">Исполняемые данные.</param> /// <param name="invoke_type">Тип исполнения.</param> /// <returns>Серис исполнения.</returns> public IInvokeService GetInvokeService(DataInvoke invoked_data, InvokeType invoke_type = InvokeType.Manual) { switch (invoke_type) { case InvokeType.Manual: switch (invoked_data.InvokeType) { case InvokeType.Remote: return(_remoteInvokeService); case InvokeType.Local: return(_serviceDictionary[invoked_data.Method.MethodType]); } break; case InvokeType.Remote: return(_remoteInvokeService); case InvokeType.Local: return(_serviceDictionary[invoked_data.Method.MethodType]); } throw new Exception(string.Format("InvokeServiceFactory.GetInvokeService -> Тип {0} недопустим.", invoked_data.InvokeType)); }
public void SetActiveState(int invokeType) { active = (InvokeType)invokeType; }
public InvokeHelper(Object instance, MethodInfo methodInfo, InvokeType invokeType) { classInstance = instance; method = methodInfo; type = invokeType; }
public InvokeAttribute(InvokeType invokeType) { Type = invokeType; }
/// <summary> /// Initializes a new instance of the <see cref="HandlerEntry" /> class. /// Initialisiert eine neue Instanz der <see cref="HandlerEntry" /> Klasse. /// Initializes a new instance of the <see cref="HandlerEntry" /> class. /// </summary> /// <param name="methodInfo"> /// The method info. /// </param> /// <param name="target"> /// The target. /// </param> public HandlerEntry(MethodBase methodInfo, object target) { Contract.Requires<ArgumentNullException>(methodInfo != null, "methodInfo"); Contract.Requires<ArgumentNullException>(target != null, "target"); _type = (InvokeType) methodInfo.GetParameters().Length; _delegate = new WeakDelegate(methodInfo, target); }
/// <summary> /// Supports Serialization of NPC, Items & Projectiles. /// It also supports multiple formats by specifing the Method. /// </summary> /// <param name="type"></param> /// <param name="ignoreFields"></param> /// <param name="SetDefaults"></param> /// <param name="invokeType"></param> /// <param name="input"></param> public static Dictionary<Int32, String> Serialize( Type type, string[] ignoreFields, MethodInfo SetDefaults, InvokeType invokeType = InvokeType.ITEM_NPC, string[] inputs = null, int MaxObjects = 1000, bool NPCOverride = false) { var FilePath = (invokeType == InvokeType.ITEM_NPC_BY_NAME) ? type.Name + "sByName.xml" : type.Name + "s.xml"; if (File.Exists(FilePath)) File.Delete(FilePath); DiffSerializer serializer = new DiffSerializer(type, ignoreFields); FileStream fs = new FileStream(FilePath, FileMode.OpenOrCreate); XmlWriterSettings ws = new XmlWriterSettings(); ws.Indent = true; XmlDictionaryWriter.Create(fs, ws); XmlDictionaryWriter writer = XmlDictionaryWriter.CreateTextWriter(fs); writer.WriteStartElement("ArrayOf" + type.Name); var returnData = new Dictionary<Int32, String>(); int count = 0; for (int i = 0; i < MaxObjects; i++) { object obj = Activator.CreateInstance(type); try { if(invokeType == InvokeType.ITEM_NPC) SetDefaults.Invoke(obj, new object[] { i, null }); else if (invokeType == InvokeType.ITEM_NPC_BY_NAME) SetDefaults.Invoke(obj, new object[] { inputs[i] }); else SetDefaults.Invoke(obj, new object[] { i }); } catch //(Exception e) //Usually catches player data which is not set { //Console.WriteLine("[Error] {0}", e.Message); } FieldInfo info = type.GetField("Name"); string value = String.Empty; try { value = (String)info.GetValue(obj); } catch (NullReferenceException) { //Close writer.WriteString("\n"); writer.WriteEndElement(); writer.Close(); fs.Close(); Console.WriteLine("Please restart this application, The Assemblies need refreshing."); Console.ReadKey(true); Environment.Exit(0); } if (!String.IsNullOrWhiteSpace(value)) { Console.WriteLine("Processing `{0}`...", value); serializer.WriteObject(writer, obj); count++; if (obj is Terraria.NPC) { var npc = obj as Terraria.NPC; if(!returnData.ContainsKey(npc.type)) returnData.Add(npc.type, value); } else returnData.Add(count, value); } Thread.Sleep(5); } writer.WriteString("\n"); writer.WriteEndElement(); writer.Close(); fs.Close(); Console.WriteLine("Found {0} {1}s.", count, type.Name); return returnData; }
public Invokable(Runner runner, Func <HybInstance[], HybInstance> func) { this.Runner = runner; this.Type = InvokeType.FuncInvoke; this.FuncMethod = func; }
public void SetActiveState(InvokeType invokeType) { active = invokeType; }
private void HandleInvoke(InvokeType type,string msg) { switch (type) { case InvokeType.Close: this.Close(); break; case InvokeType.ShowNotice: { NoticeForm frm = new NoticeForm(); frm.NoticeInfo = msg; frm.Show(); //ShowWindow(frm.Handle, 4); //frm.Notice(); break; } case InvokeType.ShowError: { notifyIcon.BalloonTipText = msg; notifyIcon.ShowBalloonTip(1); break; } default: break; } }
public static object InvokePropertyOrMethod(string className, string methodName, object[] parameters, InvokeType invokeType) { var perm = new ReflectionPermission( PermissionState.Unrestricted); perm.Assert(); Type type; bool isGetProperty; object[] newargs; object instance; BindingFlags defaultFlags; object resultObject; //if (ActionManager.IsInvokeTypeStatic(invokeType)) //{ // if (String.IsNullOrEmpty(className)) // { // throw new ArgumentException( // "className cannot be null or empty for static invocations", // "className"); // } // type = ReflectionUtils.FindType(className); // if (type == null) // { // throw new InvalidOperationException("FindType fails"); // } //} //else //{ if (parameters == null || parameters.Length == 0) { throw new ArgumentException( "parameters cannot be null or empty for instance invocations", nameof(parameters)); } if (parameters[0] == null) { throw new ArgumentException( "parameters cannot have a null first element for instance invocations", nameof(parameters)); } type = parameters[0].GetType(); //} Debug.Assert(type != null); defaultFlags = BindingFlags.ExactBinding | BindingFlags.Public; newargs = null; instance = null; switch (invokeType) { case InvokeType.StaticMethod: defaultFlags |= BindingFlags.InvokeMethod; defaultFlags |= BindingFlags.Static; break; case InvokeType.InstanceMethod: defaultFlags |= BindingFlags.InvokeMethod; defaultFlags |= BindingFlags.Instance; instance = ExtractFirstParameterAsInstance(parameters, ref newargs); parameters = newargs; break; case InvokeType.GetStaticProperty: defaultFlags |= BindingFlags.GetProperty; defaultFlags |= BindingFlags.Static; break; case InvokeType.SetStaticProperty: defaultFlags |= BindingFlags.SetProperty; defaultFlags |= BindingFlags.Static; break; case InvokeType.GetInstanceProperty: defaultFlags |= BindingFlags.GetProperty; defaultFlags |= BindingFlags.Instance; instance = ExtractFirstParameterAsInstance(parameters, ref newargs); parameters = newargs; break; case InvokeType.SetInstanceProperty: defaultFlags |= BindingFlags.SetProperty; defaultFlags |= BindingFlags.Instance; instance = ExtractFirstParameterAsInstance(parameters, ref newargs); parameters = newargs; break; case InvokeType.GetStaticField: defaultFlags |= BindingFlags.GetField; defaultFlags |= BindingFlags.Static; break; case InvokeType.SetStaticField: defaultFlags |= BindingFlags.SetField; defaultFlags |= BindingFlags.Static; break; case InvokeType.GetInstanceField: defaultFlags |= BindingFlags.GetField; defaultFlags |= BindingFlags.Instance; instance = ExtractFirstParameterAsInstance(parameters, ref newargs); parameters = newargs; break; case InvokeType.SetInstanceField: defaultFlags |= BindingFlags.SetField; defaultFlags |= BindingFlags.Instance; instance = ExtractFirstParameterAsInstance(parameters, ref newargs); parameters = newargs; break; } try { resultObject = type.InvokeMember( methodName, defaultFlags, null, instance, parameters); } catch (MissingMethodException e) { isGetProperty = invokeType == InvokeType.GetInstanceProperty || invokeType == InvokeType.GetStaticProperty; if (parameters.Length > 0 && isGetProperty) { } throw e; } catch (AmbiguousMatchException e) { throw e; } return(resultObject); }
public Invokable(MethodInfo method) { this.Type = InvokeType.ReflectionInvoke; this.CompiledMethod = method; }
public static object InvokePropertyOrMethod(string className, string methodName, object[] parameters, InvokeType invokeType) { System.Security.Permissions.ReflectionPermission perm = new System.Security.Permissions.ReflectionPermission( System.Security.Permissions.PermissionState.Unrestricted); perm.Assert(); Type type; bool isGetProperty; object[] newargs; object instance; BindingFlags defaultFlags; object resultObject; //if (ActionManager.IsInvokeTypeStatic(invokeType)) //{ // if (String.IsNullOrEmpty(className)) // { // throw new ArgumentException( // "className cannot be null or empty for static invocations", // "className"); // } // type = ReflectionUtils.FindType(className); // if (type == null) // { // throw new InvalidOperationException("FindType fails"); // } //} //else //{ if (parameters == null || parameters.Length == 0) { throw new ArgumentException( "parameters cannot be null or empty for instance invocations", "parameters"); } if (parameters[0] == null) { throw new ArgumentException( "parameters cannot have a null first element for instance invocations", "parameters"); } type = parameters[0].GetType(); //} System.Diagnostics.Debug.Assert(type != null); defaultFlags = BindingFlags.ExactBinding | BindingFlags.Public; newargs = null; instance = null; switch (invokeType) { case InvokeType.StaticMethod: defaultFlags |= BindingFlags.InvokeMethod; defaultFlags |= BindingFlags.Static; break; case InvokeType.InstanceMethod: defaultFlags |= BindingFlags.InvokeMethod; defaultFlags |= BindingFlags.Instance; instance = ExtractFirstParameterAsInstance(parameters, ref newargs); parameters = newargs; break; case InvokeType.GetStaticProperty: defaultFlags |= BindingFlags.GetProperty; defaultFlags |= BindingFlags.Static; break; case InvokeType.SetStaticProperty: defaultFlags |= BindingFlags.SetProperty; defaultFlags |= BindingFlags.Static; break; case InvokeType.GetInstanceProperty: defaultFlags |= BindingFlags.GetProperty; defaultFlags |= BindingFlags.Instance; instance = ExtractFirstParameterAsInstance(parameters, ref newargs); parameters = newargs; break; case InvokeType.SetInstanceProperty: defaultFlags |= BindingFlags.SetProperty; defaultFlags |= BindingFlags.Instance; instance = ExtractFirstParameterAsInstance(parameters, ref newargs); parameters = newargs; break; case InvokeType.GetStaticField: defaultFlags |= BindingFlags.GetField; defaultFlags |= BindingFlags.Static; break; case InvokeType.SetStaticField: defaultFlags |= BindingFlags.SetField; defaultFlags |= BindingFlags.Static; break; case InvokeType.GetInstanceField: defaultFlags |= BindingFlags.GetField; defaultFlags |= BindingFlags.Instance; instance = ExtractFirstParameterAsInstance(parameters, ref newargs); parameters = newargs; break; case InvokeType.SetInstanceField: defaultFlags |= BindingFlags.SetField; defaultFlags |= BindingFlags.Instance; instance = ExtractFirstParameterAsInstance(parameters, ref newargs); parameters = newargs; break; } try { resultObject = type.InvokeMember( methodName, defaultFlags, null, instance, parameters); } catch (MissingMethodException e) { isGetProperty = invokeType == InvokeType.GetInstanceProperty || invokeType == InvokeType.GetStaticProperty; if (parameters.Length > 0 && isGetProperty) { } throw; } catch (AmbiguousMatchException e) { throw; } return resultObject; }
/// <summary> /// Supports Serialization of NPC, Items & Projectiles. /// It also supports multiple formats by specifing the Method. /// </summary> /// <param name="type"></param> /// <param name="ignoreFields"></param> /// <param name="SetDefaults"></param> /// <param name="invokeType"></param> /// <param name="input"></param> public static Dictionary <Int32, String> Serialize(Type type, string[] ignoreFields, MethodInfo SetDefaults, InvokeType invokeType = InvokeType.ITEM_NPC, string[] inputs = null, int MaxObjects = 1000) { var FilePath = (invokeType == InvokeType.ITEM_NPC_BY_NAME) ? type.Name + "sByName.xml" : type.Name + "s.xml"; if (File.Exists(FilePath)) { File.Delete(FilePath); } DiffSerializer serializer = new DiffSerializer(type, ignoreFields); FileStream fs = new FileStream(FilePath, FileMode.OpenOrCreate); XmlWriterSettings ws = new XmlWriterSettings(); ws.Indent = true; XmlDictionaryWriter.Create(fs, ws); XmlDictionaryWriter writer = XmlDictionaryWriter.CreateTextWriter(fs); writer.WriteStartElement("ArrayOf" + type.Name); var returnData = new Dictionary <Int32, String>(); int count = 0; for (int i = 0; i < MaxObjects; i++) { object obj = Activator.CreateInstance(type); try { if (invokeType == InvokeType.ITEM_NPC) { SetDefaults.Invoke(obj, new object[] { i, null }); } else if (invokeType == InvokeType.ITEM_NPC_BY_NAME) { SetDefaults.Invoke(obj, new object[] { inputs[i] }); } else { SetDefaults.Invoke(obj, new object[] { i }); } } catch //(Exception e) //Usually catches player data which is not set { //Console.WriteLine("[Error] {0}", e.Message); } FieldInfo info = type.GetField("Name"); string value = String.Empty; try { value = (String)info.GetValue(obj); } catch (NullReferenceException) { //Close writer.WriteString("\n"); writer.WriteEndElement(); writer.Close(); fs.Close(); Console.WriteLine("Please restart this application, The Assemblies need refreshing."); Console.ReadKey(true); Environment.Exit(0); } if (!String.IsNullOrWhiteSpace(value)) { Console.WriteLine("Processing `{0}`...", value); serializer.WriteObject(writer, obj); count++; returnData.Add(count, value); } Thread.Sleep(5); } writer.WriteString("\n"); writer.WriteEndElement(); writer.Close(); fs.Close(); Console.WriteLine("Found {0} {1}s.", count, type.Name); return(returnData); }
public InvokeAttribute() { Type = InvokeType.MultiCast; }
public ComplexMessageContent(string brief, ComplexMessageType complexType, InvokeType invokeType) : this(brief, complexType) { _invokeType = invokeType; }
/// <summary> /// Initializes a new instance of the <see cref="HandlerEntry" /> class. /// Initialisiert eine neue Instanz der <see cref="HandlerEntry" /> Klasse. /// Initializes a new instance of the <see cref="HandlerEntry" /> class. /// </summary> /// <param name="dDelegate"> /// The d delegate. /// </param> public HandlerEntry(Delegate dDelegate) { Contract.Requires<ArgumentNullException>(dDelegate != null, "dDelegate"); _type = (InvokeType) dDelegate.Method.GetParameters().Length; _delegate = new WeakDelegate(dDelegate); }