internal void CreateDelegateType() { if (this.HasBody || m_formalParameters.Count > 0 || this.ReturnType.Equals(TypeReference.TypeVoid)) { m_delegateType = ProcedureDelegateManager.CreateOrGetDelegateType( this.ReturnType, this.CreateFormalParametersData()); } else { m_delegateType = null; } m_parametersInternal = new List <IdentifierInfo>(); if (m_delegateType != null) { m_parametersInternal.Add(new IdentifierInfo("callcontext", "callcontext", IdentifierType.Parameter, (TypeReference)m_delegateType, m_callContextParameter)); foreach (var p in m_formalParameters) { var runtimePar = Expression.Parameter(p.Type.Type, p.Name); m_parametersInternal.Add(new IdentifierInfo(p.Name, p.Name, IdentifierType.Parameter, p.Type, runtimePar)); } m_referenceType = typeof(IProcedureReference <>).MakeGenericType(m_delegateType); var refObjectType = typeof(Reference <>).MakeGenericType(m_delegateType); m_reference = (IProcedureReference)Activator.CreateInstance(refObjectType, this); m_dataType = new TypeReference(m_referenceType, this); } else { m_referenceType = null; m_reference = new ReferenceBase(this); m_dataType = new TypeReference(typeof(IProcedureReference), this); } }
public static bool ProcedureReferenceIs(IScriptCallContext context, IProcedureReference procedure, int fileID, int procedureID, bool isNot) { var type = GetProcedure(context, fileID, procedureID); if (Object.ReferenceEquals(procedure, type)) { return(!isNot); } return(false); }
public static IProcedureReference GetProcedure(IScriptCallContext context, int fileID, int procedureID) { IProcedureReference procedure = null; if (fileID < 0) { procedure = ((ScriptFile)context.Self.ParentFile).GetProcedure(procedureID); if (procedure == null) { if (context != null) { context.ReportError(String.Format("INTERNAL ERROR: Could not find procedure with id = {0}.", procedureID)); } else { throw new NotImplementedException(); } } } else { ScriptFile file = context.LoadedFiles.ListFiles <ScriptFile>().FirstOrDefault(f => f.UniqueID == fileID); if (file == null) { if (context != null) { context.ReportError(String.Format("INTERNAL ERROR: Could not find script file with id = {0}.", fileID)); } else { throw new NotImplementedException(); } } else { procedure = file.GetProcedure(procedureID); if (procedure == null) { if (context != null) { context.ReportError(String.Format("INTERNAL ERROR: Could not find procedure with id = {0}.", procedureID)); } else { throw new NotImplementedException(); } } } } return(procedure); }
public static object DynamicFunctionCall( this IProcedureReference procedure, IScriptCallContext context, object[] sequencialFirstArguments, ArgumentList namedArguments, object[] sequencialLastArguments) { if (procedure == null) { throw new ArgumentNullException("procedure"); } if ((procedure.ProcedureData.Flags & ProcedureFlags.IsFunction) == ProcedureFlags.None) { throw new ArgumentException("The procedure is not marked as being a function."); } throw new NotImplementedException(); }
public static object DynamicProcedureCall( this IProcedureReference procedure, IScriptCallContext context, PropertyBlock propertyBlock, object[] sequencialFirstArguments, ArgumentList namedArguments, object[] sequencialLastArguments) { if (procedure == null) { throw new ArgumentNullException("procedure"); } IScriptCallContext subContext = null; try { subContext = context.EnterNewScriptContext(procedure, Logging.ContextLogOption.Normal, true); var methodInfo = ((FileProcedure)procedure.ProcedureData).DelegateType.GetMethod("Invoke"); var arguments = new List <object>(); int i = 0; foreach (var p in methodInfo.GetParameters()) { if (i == 0) { arguments.Add(subContext); } i++; } Delegate runtimeProcedure = ((FileProcedure)procedure.ProcedureData).RuntimeProcedure; return(runtimeProcedure.DynamicInvoke(arguments.ToArray())); } catch (Exception ex) { context.ReportError("Exception in dynamic procedure call.", exception: ex); return(null); } finally { subContext.InternalDispose(); } }
public bool GetNext() { if (m_testCases == null) { m_testCases = new List <ITestListEntryTestCase>(); GetTestCases(m_list, m_testCases); } if (m_index < (m_testCases.Count - 1)) { m_index++; m_currentProcedure = m_testCases[m_index].ProcedureReference; m_currentProcedureArguments = m_testCases[m_index].Arguments; return(true); } else { return(false); } }
public IScriptCallContext EnterNewScriptContext(IProcedureReference procedure, ContextLogOption procedureLoggingOption, bool isDynamicCall) { throw new NotImplementedException(); }
public static IProcedureReference <T> GetPartnerReferenceFromProcedureReference <T>( IScriptCallContext context, IProcedureReference procedure, string partnerName) { return(GetPartnerReference <T>(context, procedure.ProcedureData, partnerName)); }
public static IProcedureReference <T> CastToSpecificProcedureType <T>(IScriptCallContext context, IProcedureReference reference) { if (reference is IProcedureReference <T> ) { return((IProcedureReference <T>)reference); } else { context.ReportError("The procedure reference is not the expected type. Type: " + reference.GetType().Name); return(null); } }
public IScriptCallContext EnterNewScriptContext(IProcedureReference procedure, ContextLogOption callerLoggingOption, bool isDynamicCall) { return(this.EnterNewScriptContext(procedure.ProcedureData, callerLoggingOption, isDynamicCall)); }
//public object CallProcedure(IProcedureReference procedure, LoggerRoot logger, ContextLogOption callerLoggingOption, IExecutionScopeStatusUpdate statusUpdate, params object[] arguments) //{ // this.Setup(logger, callerLoggingOption, statusUpdate); // return this.DoCallProcedure(procedure.ProcedureInfo, arguments); //} public object CallProcedure(IProcedureReference procedure, params object[] arguments) { return(this.DoCallProcedure(procedure.ProcedureData, arguments)); }
public static object CallDebug(this IProcedureReference procedure, params object[] args) { return(DoDynamicInvoke(procedure.ProcedureData, true, args)); }
public EntryTestCase(FileTestList home, string referenceName, IProcedureReference procedure) : base(home, TestListEntryType.TestCase, referenceName) { m_procedure = procedure; }
public void AddTestCase(string name, IProcedureReference procedure) { m_entries.Add(new EntryTestCase(this, name, procedure)); }