internal RemoteRunspacePoolInternal(Guid instanceId, string name, bool isDisconnected, ConnectCommandInfo[] connectCommands, RunspaceConnectionInfo connectionInfo, PSHost host, TypeTable typeTable) : base(1, 1) { this.applicationPrivateDataReceived = new ManualResetEvent(false); this.friendlyName = string.Empty; if (connectCommands == null) { throw PSTraceSource.NewArgumentNullException("ConnectCommandInfo[]"); } if (connectionInfo == null) { throw PSTraceSource.NewArgumentNullException("WSManConnectionInfo"); } if (connectionInfo is WSManConnectionInfo) { this.connectionInfo = ((WSManConnectionInfo)connectionInfo).Copy(); } base.instanceId = instanceId; base.minPoolSz = -1; base.maxPoolSz = -1; PSEtwLog.LogOperationalVerbose(PSEventId.RunspacePoolConstructor, PSOpcode.Constructor, PSTask.CreateRunspace, PSKeyword.UseAlwaysOperational, new object[] { instanceId.ToString(), this.minPoolSz.ToString(CultureInfo.InvariantCulture), this.maxPoolSz.ToString(CultureInfo.InvariantCulture) }); this.connectCommands = connectCommands; this.Name = name; base.host = host; this.dispatchTable = new DispatchTable <object>(); this.SetRunspacePoolState(new RunspacePoolStateInfo(RunspacePoolState.Disconnected, null)); this.CreateDSHandler(typeTable); this.availableForConnection = isDisconnected; }
public virtual ActionResult DeleteDispatch(List <int> items) { try { string resultado = string.Empty; using (TransactionScope trs = new TransactionScope(TransactionScopeOption.Required)) { foreach (var item in items) { DispatchTable entidad = new DispatchTable(); entidad.DispatchID = item; resultado = Dispatch.DeleteDispatch(entidad); if (resultado.Trim().Length > 0) { trs.Dispose(); return(Json(new { result = false, message = resultado })); } } trs.Complete(); } return(Json(new { result = true, message = "" })); } catch (Exception ex) { var exception = EntityExceptionHelper.GetAndLogNetStepsException(ex, NetSteps.Data.Entities.Constants.NetStepsExceptionType.NetStepsApplicationException); return(JsonError(exception.PublicMessage)); } }
/// <summary> /// Constructor which creates a RunspacePool using the /// supplied <paramref name="connectionInfo"/>, <paramref name="minRunspaces"/> /// and <paramref name="maxRunspaces"/> /// </summary> /// <param name="maxRunspaces"> /// The maximum number of Runspaces that can exist in this pool. /// Should be greater than or equal to 1. /// </param> /// <param name="minRunspaces"> /// The minimum number of Runspaces that can exist in this pool. /// Should be greater than or equal to 1. /// </param> /// <param name="typeTable"> /// The TypeTable to use while deserializing/serializing remote objects. /// TypeTable has the following information used by serializer: /// 1. SerializationMethod /// 2. SerializationDepth /// 3. SpecificSerializationProperties /// TypeTable has the following information used by deserializer: /// 1. TargetTypeForDeserialization /// 2. TypeConverter /// </param> /// <param name="host">Host associated with this runspacepool</param> /// <param name="applicationArguments"> /// Application arguments the server can see in <see cref="System.Management.Automation.Remoting.PSSenderInfo.ApplicationArguments"/> /// </param> /// <param name="connectionInfo">The RunspaceConnectionInfo object /// which identifies this runspace pools connection to the server /// </param> /// <param name="name">Session name.</param> /// <exception cref="ArgumentException"> /// Maximum runspaces is less than 1. /// Minimum runspaces is less than 1. /// </exception> /// <exception cref="ArgumentException"> /// ConnectionInfo specified is null /// </exception> internal RemoteRunspacePoolInternal(int minRunspaces, int maxRunspaces, TypeTable typeTable, PSHost host, PSPrimitiveDictionary applicationArguments, RunspaceConnectionInfo connectionInfo, string name = null) : base(minRunspaces, maxRunspaces) { if (connectionInfo == null) { throw PSTraceSource.NewArgumentNullException("WSManConnectionInfo"); } PSEtwLog.LogOperationalVerbose(PSEventId.RunspacePoolConstructor, PSOpcode.Constructor, PSTask.CreateRunspace, PSKeyword.UseAlwaysOperational, instanceId.ToString(), minPoolSz.ToString(CultureInfo.InvariantCulture), maxPoolSz.ToString(CultureInfo.InvariantCulture)); _connectionInfo = connectionInfo.InternalCopy(); this.host = host; ApplicationArguments = applicationArguments; AvailableForConnection = false; DispatchTable = new DispatchTable<object>(); _runningPowerShells = new System.Collections.Concurrent.ConcurrentStack<PowerShell>(); if (!string.IsNullOrEmpty(name)) { this.Name = name; } CreateDSHandler(typeTable); }
internal RemoteRunspacePoolInternal(Guid instanceId, string name, bool isDisconnected, ConnectCommandInfo[] connectCommands, RunspaceConnectionInfo connectionInfo, PSHost host, TypeTable typeTable) : base(1, 1) { this.applicationPrivateDataReceived = new ManualResetEvent(false); this.friendlyName = string.Empty; if (connectCommands == null) { throw PSTraceSource.NewArgumentNullException("ConnectCommandInfo[]"); } if (connectionInfo == null) { throw PSTraceSource.NewArgumentNullException("WSManConnectionInfo"); } if (connectionInfo is WSManConnectionInfo) { this.connectionInfo = ((WSManConnectionInfo) connectionInfo).Copy(); } base.instanceId = instanceId; base.minPoolSz = -1; base.maxPoolSz = -1; PSEtwLog.LogOperationalVerbose(PSEventId.RunspacePoolConstructor, PSOpcode.Constructor, PSTask.CreateRunspace, PSKeyword.UseAlwaysOperational, new object[] { instanceId.ToString(), this.minPoolSz.ToString(CultureInfo.InvariantCulture), this.maxPoolSz.ToString(CultureInfo.InvariantCulture) }); this.connectCommands = connectCommands; this.Name = name; base.host = host; this.dispatchTable = new DispatchTable<object>(); this.SetRunspacePoolState(new RunspacePoolStateInfo(RunspacePoolState.Disconnected, null)); this.CreateDSHandler(typeTable); this.availableForConnection = isDisconnected; }
internal RemoteRunspacePoolInternal(int minRunspaces, int maxRunspaces, TypeTable typeTable, PSHost host, PSPrimitiveDictionary applicationArguments, RunspaceConnectionInfo connectionInfo, string name = null) : base(minRunspaces, maxRunspaces) { this.applicationPrivateDataReceived = new ManualResetEvent(false); this.friendlyName = string.Empty; if (connectionInfo == null) { throw PSTraceSource.NewArgumentNullException("WSManConnectionInfo"); } PSEtwLog.LogOperationalVerbose(PSEventId.RunspacePoolConstructor, PSOpcode.Constructor, PSTask.CreateRunspace, PSKeyword.UseAlwaysOperational, new object[] { this.instanceId.ToString(), this.minPoolSz.ToString(CultureInfo.InvariantCulture), this.maxPoolSz.ToString(CultureInfo.InvariantCulture) }); if (connectionInfo is WSManConnectionInfo) { this.connectionInfo = ((WSManConnectionInfo)connectionInfo).Copy(); } else if (connectionInfo is NewProcessConnectionInfo) { this.connectionInfo = ((NewProcessConnectionInfo)connectionInfo).Copy(); } base.host = host; this.applicationArguments = applicationArguments; this.availableForConnection = false; this.dispatchTable = new DispatchTable <object>(); if (!string.IsNullOrEmpty(name)) { this.Name = name; } this.CreateDSHandler(typeTable); }
public void Add_Is_Ignored_If_Entry_Exists(bool is32BitPlatform) { DispatchTable tbl = new DispatchTable(4, is32BitPlatform); tbl.Add(a4, m1); tbl.Add(a4, m2); Assert.AreEqual(1, tbl.Size); Assert.AreSame(m1, tbl.Match(a4)); }
public void Can_Match_Method_With_4_Args(bool is32BitPlatform) { DispatchTable tbl = new DispatchTable(4, is32BitPlatform); tbl.Add(a4, m1); tbl.Add(a4_2, m2); Assert.AreSame(m1, tbl.Match(a4)); Assert.AreSame(m2, tbl.Match(a4_2)); }
public void Can_Match_Method_With_4_Args(bool is32BitPlatform) { DispatchTable tbl = new DispatchTable(4, is32BitPlatform); tbl.Add(a4, m1); tbl.Add(a4_2, m2); Assert.AreSame(m1, tbl.Match(a4)); Assert.AreSame(m2, tbl.Match(a4_2)); }
public static void dllEntry(ReturnInfo RetInfo, DispatchTable SyscallTable, IntPtr Unknown) { SDK.QAGameInit(SyscallTable); SDK.PRINT(Colors.Red + "[QAGame] Hello Quake Live!\n"); IntPtr _uix86 = Kernel32.LoadLibrary("cliq3\\orig\\_qagamex86.dll"); dllEntryFunc _dllEntry = Kernel32.GetProcAddress<dllEntryFunc>(_uix86, "dllEntry"); _dllEntry(RetInfo, SyscallTable, Unknown); }
public void Can_Match_Method_With_1_Arg(bool is32BitPlatform) { DispatchTable tbl = new DispatchTable(1, is32BitPlatform); tbl.Add(a1, m1); tbl.Add(a2, m2); Assert.AreSame(m1, tbl.Match(a1)); Assert.AreSame(m2, tbl.Match(a2)); }
public void Add_Is_Ignored_If_Entry_Exists(bool is32BitPlatform) { DispatchTable tbl = new DispatchTable(4, is32BitPlatform); tbl.Add(a4, m1); tbl.Add(a4, m2); Assert.AreEqual(1, tbl.Size); Assert.AreSame(m1, tbl.Match(a4)); }
public void Can_Match_Method_With_1_Arg(bool is32BitPlatform) { DispatchTable tbl = new DispatchTable(1, is32BitPlatform); tbl.Add(a1, m1); tbl.Add(a2, m2); Assert.AreSame(m1, tbl.Match(a1)); Assert.AreSame(m2, tbl.Match(a2)); }
static void Main(string[] args) { DispatchTable t = new DispatchTable( delegate() { Console.WriteLine(1); }, delegate() { Console.WriteLine(2); }, delegate() { Console.WriteLine(3); } ); t.Execute(0x04); t.Execute(0x02); t.Execute(0x01); t.Execute(0x0F); }
public virtual ActionResult Edit(int?dispatchID) { try { TempData["sDispatch"] = from x in PaymentsMethodsExtensions.typedispatchDisplay() orderby x.Key select new SelectListItem() { Text = x.Value, Value = x.Key }; DispatchTable dispatch = new DispatchTable(); dispatch = Dispatch.DispatchById(Convert.ToInt32(dispatchID)); dispatch.ProductsQuery = DispatchItems.DispatchItemsByDispatchID(Convert.ToInt32(dispatchID)); DispatchModel model = new DispatchModel(dispatch); return(View(model)); } catch (Exception ex) { var exception = EntityExceptionHelper.GetAndLogNetStepsException(ex, NetSteps.Data.Entities.Constants.NetStepsExceptionType.NetStepsApplicationException); throw exception; } }
internal RemoteRunspacePoolInternal(int minRunspaces, int maxRunspaces, TypeTable typeTable, PSHost host, PSPrimitiveDictionary applicationArguments, RunspaceConnectionInfo connectionInfo, string name = null) : base(minRunspaces, maxRunspaces) { this.applicationPrivateDataReceived = new ManualResetEvent(false); this.friendlyName = string.Empty; if (connectionInfo == null) { throw PSTraceSource.NewArgumentNullException("WSManConnectionInfo"); } PSEtwLog.LogOperationalVerbose(PSEventId.RunspacePoolConstructor, PSOpcode.Constructor, PSTask.CreateRunspace, PSKeyword.UseAlwaysOperational, new object[] { this.instanceId.ToString(), this.minPoolSz.ToString(CultureInfo.InvariantCulture), this.maxPoolSz.ToString(CultureInfo.InvariantCulture) }); if (connectionInfo is WSManConnectionInfo) { this.connectionInfo = ((WSManConnectionInfo) connectionInfo).Copy(); } else if (connectionInfo is NewProcessConnectionInfo) { this.connectionInfo = ((NewProcessConnectionInfo) connectionInfo).Copy(); } base.host = host; this.applicationArguments = applicationArguments; this.availableForConnection = false; this.dispatchTable = new DispatchTable<object>(); if (!string.IsNullOrEmpty(name)) { this.Name = name; } this.CreateDSHandler(typeTable); }
public virtual ActionResult Save(DispatchTable dispatch) { int resultado = 0; try { if (dispatch.DispatchID > 0) { using (TransactionScope tran = new TransactionScope(TransactionScopeOption.Required)) { resultado = Dispatch.UpdateDispatch(dispatch); if (resultado < 1) { tran.Dispose(); return(Json(new { result = false, message = "No se grabó correctamente en la tabla Dispatch" })); } int retora = DispatchItems.DeleteDispatchItemsbyID(dispatch.DispatchID); foreach (var product in dispatch.Products.Where(x => x.ProductID != 0)) { product.DispatchID = dispatch.DispatchID; if (DispatchItems.InsertDispatchItems(product) < 1) { tran.Dispose(); return(Json(new { result = false, message = "No se grabó correctamente en la tabla Dispatch" })); } } resultado = 1; tran.Complete(); } } else { using (TransactionScope tran = new TransactionScope(TransactionScopeOption.Required)) { int dispatchID = 0; dispatchID = Dispatch.InsertDispatch(dispatch); if (dispatchID < 1) { tran.Dispose(); return(Json(new { result = false, message = "No se grabó correctamente en la tabla Dispatch" })); } foreach (var product in dispatch.Products.Where(x => x.ProductID != 0)) { product.DispatchID = dispatchID; if (DispatchItems.InsertDispatchItems(product) < 1) { tran.Dispose(); return(Json(new { result = false, message = "No se grabó correctamente en la tabla Dispatch" })); } } resultado = 1; tran.Complete(); } } } catch (Exception ex) { var exception = EntityExceptionHelper.GetAndLogNetStepsException(ex, NetSteps.Data.Entities.Constants.NetStepsExceptionType.NetStepsApplicationException); //tran.Dispose(); //throw exception; return(Json(new { result = false, message = ex.Message })); } return(Json(new { result = (resultado == 0 ? false : true), message = "" })); }
/// <summary> /// Create a runspacepool object in the disconnected state. /// </summary> /// <param name="instanceId">Identifies remote session to connect.</param> /// <param name="name">Friendly name for runspace pool.</param> /// <param name="isDisconnected">Indicates whether the runspacepool is disconnected.</param> /// <param name="connectCommands">Array of commands associated with this runspace pool.</param> /// <param name="connectionInfo">Connection information for remote server.</param> /// <param name="host">PSHost object.</param> /// <param name="typeTable">TypeTable for object serialization/deserialization.</param> internal RemoteRunspacePoolInternal(Guid instanceId, string name, bool isDisconnected, ConnectCommandInfo[] connectCommands, RunspaceConnectionInfo connectionInfo, PSHost host, TypeTable typeTable) : base(1, 1) { if (instanceId == null) { throw PSTraceSource.NewArgumentNullException("RunspacePool Guid"); } if (connectCommands == null) { throw PSTraceSource.NewArgumentNullException("ConnectCommandInfo[]"); } if (connectionInfo == null) { throw PSTraceSource.NewArgumentNullException("WSManConnectionInfo"); } if (connectionInfo is WSManConnectionInfo) { _connectionInfo = connectionInfo.InternalCopy(); } else { Dbg.Assert(false, "ConnectionInfo must be WSManConnectionInfo"); } // Create the runspace pool object to have the same instanceId as the remote session. this.instanceId = instanceId; // This indicates that this is a disconnected remote runspace pool and min/max values // are currently unknown. These values will be updated once the object is connected. this.minPoolSz = -1; this.maxPoolSz = -1; PSEtwLog.LogOperationalVerbose(PSEventId.RunspacePoolConstructor, PSOpcode.Constructor, PSTask.CreateRunspace, PSKeyword.UseAlwaysOperational, instanceId.ToString(), minPoolSz.ToString(CultureInfo.InvariantCulture), maxPoolSz.ToString(CultureInfo.InvariantCulture)); ConnectCommands = connectCommands; this.Name = name; this.host = host; DispatchTable = new DispatchTable<object>(); _runningPowerShells = new System.Collections.Concurrent.ConcurrentStack<PowerShell>(); // Create this object in the disconnected state. SetRunspacePoolState(new RunspacePoolStateInfo(RunspacePoolState.Disconnected, null)); CreateDSHandler(typeTable); AvailableForConnection = isDisconnected; }
private void Create() { var methods = GetMethods(); var declaringMethodNames = new HashSet<string>(methods.Select(_ => _.Name)); var dispatchTable = new DispatchTable<MethodDef>(declaringMethodNames.Count); var propertyDispatchTable = new DispatchTable<PropertyDef>(); foreach (var method in methods) { string declaringName = method.Name; string scriptingName = ConvertIdentifier(declaringName); string scriptingPropertyName = null; if (declaringName != scriptingName && declaringMethodNames.Contains(scriptingName)) { throw ExceptionBuilder.TypeAlreadyReservesMember(this.Type, scriptingName, declaringName); } var property = method.GetDeclaringTypeProperty(); if (property != null) { var declaringPropertyName = property.Name; scriptingPropertyName = ConvertIdentifier(declaringPropertyName); if (declaringPropertyName != scriptingPropertyName && declaringMethodNames.Contains(scriptingPropertyName)) { throw ExceptionBuilder.TypeAlreadyReservesMember(this.Type, scriptingPropertyName, declaringPropertyName); } } // method attributes var methodAttributes = method.IsStatic ? MethodDefAttributes.Static : MethodDefAttributes.None; if (property != null) { methodAttributes |= MethodDefAttributes.Hidden; if (method.IsGetterLikeSignature()) { methodAttributes |= MethodDefAttributes.Getter; } else if (method.IsSetterLikeSignature()) { methodAttributes |= MethodDefAttributes.Setter; } } // put method info into a dispatch table // note: property accessors can't be overloaded var scriptableMethodInfo = dispatchTable.GetOrDefault(scriptingName); if (scriptableMethodInfo == null) { scriptableMethodInfo = new MethodDef(scriptingName, methodAttributes); dispatchTable.Add(scriptableMethodInfo); } scriptableMethodInfo.Add(method); // put property info into a property dispatch table if (property != null) { var scriptablePropertyInfo = propertyDispatchTable.GetOrDefault(scriptingPropertyName); if (scriptablePropertyInfo == null) { scriptablePropertyInfo = new PropertyDef(scriptingPropertyName); propertyDispatchTable.Add(scriptablePropertyInfo); } scriptablePropertyInfo.Add(scriptableMethodInfo); } } dispatchTable.Optimize(); propertyDispatchTable.Optimize(); // TODO: prevent dispatch tables from modifying this.dispatchTable = dispatchTable; this.propertyDispatchTable = propertyDispatchTable; }
/// <summary> /// If instance == null -> then object reference will be got from object's userdata. /// Otherwise userdata ignored. /// </summary> public ScriptableObjectV8Accessor(ScriptableObjectBinder binder, object instance) { this.instance = instance; this.dispatchTable = binder.PropertyDispatchTable; }