public IValue RunWithResult(SyneryParser.LibraryPluginFunctionCallContext context)
        {
            string libraryPluginIdentifier;
            string functionIdentifier;
            string fullIdentifier = context.libraryPluginFunctionCallIdentifier().ExternalLibraryIdentifier().GetText();

            // split the identifier

            bool success = FunctionHelper.FragmentLibraryPluginIdentifier(fullIdentifier, out libraryPluginIdentifier, out functionIdentifier);

            if (success == false)
            {
                throw new SyneryInterpretationException(context.libraryPluginFunctionCallIdentifier(), "Wasn't able to fragment the library plugin function identifier. It doesn't have the expected format.");
            }

            // validate the identifier

            if (String.IsNullOrEmpty(libraryPluginIdentifier))
            {
                throw new SyneryInterpretationException(context, "The library plugin identifier is empty.");
            }
            if (String.IsNullOrEmpty(functionIdentifier))
            {
                throw new SyneryInterpretationException(context, "The function identifier is empty.");
            }

            // get the parameters

            IList <IValue> listOfParameters = FunctionHelper.GetListOfParameterValues(Controller, context.expressionList());

            Type[]   listOfParameterTypes  = listOfParameters.Select(p => p.Type.UnterlyingDotNetType).ToArray();
            object[] listOfParameterValues = listOfParameters.Select(p => p.Value).ToArray();

            // find the function declaration

            IStaticExtensionFunctionData functionDeclaration = Memory.LibraryPluginManager.GetStaticFunctionDataBySignature(libraryPluginIdentifier, functionIdentifier, listOfParameterTypes);

            object result = null;

            try
            {
                // execute the function

                result = Memory.LibraryPluginManager.CallStaticFunctionWithPrimitiveReturn(functionDeclaration, listOfParameterValues);
            }
            catch (Exception ex)
            {
                // create a Synery exception that can be caught by the Synery developer

                LibraryPluginExceptionRecord syneryException = new LibraryPluginExceptionRecord();
                syneryException.Message                 = ExceptionHelper.GetNestedExceptionMessages(ex);
                syneryException.FullIdentifier          = fullIdentifier;
                syneryException.LibraryPluginIdentifier = libraryPluginIdentifier;

                Controller.HandleSyneryEvent(context, syneryException.GetAsSyneryValue());
            }

            return(new TypedValue(TypeHelper.GetSyneryType(functionDeclaration.ReturnType), result));
        }
        public void Run(SyneryParser.LibraryPluginVariableStatementContext context)
        {
            if (context.libraryPluginVariableAssignment() != null)
            {
                string libraryPluginIdentifier;
                string variableIdentifier;
                string fullIdentifier = context.libraryPluginVariableAssignment().ExternalLibraryIdentifier().GetText();

                // split the identifier

                bool success = FunctionHelper.FragmentLibraryPluginIdentifier(fullIdentifier, out libraryPluginIdentifier, out variableIdentifier);

                if (success == false)
                {
                    throw new SyneryInterpretationException(context, "Wasn't able to fragment the library plugin variable identifier. It doesn't have the expected format.");
                }

                // validate the identifier

                if (String.IsNullOrEmpty(libraryPluginIdentifier))
                {
                    throw new SyneryInterpretationException(context, "The library plugin identifier is empty.");
                }
                if (String.IsNullOrEmpty(variableIdentifier))
                {
                    throw new SyneryInterpretationException(context, "The variable identifier is empty.");
                }

                // find the variable declaration
                IStaticExtensionVariableData variableData = Memory.LibraryPluginManager.GetStaticVariableDataByIdentifier(libraryPluginIdentifier, variableIdentifier);

                // interpret the set-value

                IValue value = Controller.Interpret <SyneryParser.ExpressionContext, IValue>(context.libraryPluginVariableAssignment().variableInitializer().expression());

                try
                {
                    //  set the value

                    Memory.LibraryPluginManager.SetStaticVariableWithPrimitiveReturn(variableData, value);
                }
                catch (Exception ex)
                {
                    // create a Synery exception that can be caught by the Synery developer

                    LibraryPluginExceptionRecord syneryException = new LibraryPluginExceptionRecord();
                    syneryException.Message                 = ExceptionHelper.GetNestedExceptionMessages(ex);
                    syneryException.FullIdentifier          = fullIdentifier;
                    syneryException.LibraryPluginIdentifier = libraryPluginIdentifier;

                    Controller.HandleSyneryEvent(context, syneryException.GetAsSyneryValue());
                }
            }
        }
        private IValue GetLibraryPluginVariableValue(SyneryParser.LibraryPluginVariableReferenceContext context)
        {
            string libraryPluginIdentifier;
            string variableIdentifier;
            string fullIdentifier = context.ExternalLibraryIdentifier().GetText();

            // split the identifier

            bool success = FunctionHelper.FragmentLibraryPluginIdentifier(fullIdentifier, out libraryPluginIdentifier, out variableIdentifier);

            if (success == false)
            {
                throw new SyneryInterpretationException(context, "Wasn't able to fragment the library plugin variable identifier. It doesn't have the expected format.");
            }

            // validate the identifier

            if (String.IsNullOrEmpty(libraryPluginIdentifier))
            {
                throw new SyneryInterpretationException(context, "The library plugin identifier is empty.");
            }
            if (String.IsNullOrEmpty(variableIdentifier))
            {
                throw new SyneryInterpretationException(context, "The variable identifier is empty.");
            }

            // find the variable declaration
            IStaticExtensionVariableData variableData = Memory.LibraryPluginManager.GetStaticVariableDataByIdentifier(libraryPluginIdentifier, variableIdentifier);

            object result = null;

            try
            {
                // get the value

                result = Memory.LibraryPluginManager.GetStaticVariableWithPrimitiveReturn(variableData);
            }
            catch (Exception ex)
            {
                // create a Synery exception that can be caught by the Synery developer

                LibraryPluginExceptionRecord syneryException = new LibraryPluginExceptionRecord();
                syneryException.Message                 = ExceptionHelper.GetNestedExceptionMessages(ex);
                syneryException.FullIdentifier          = fullIdentifier;
                syneryException.LibraryPluginIdentifier = libraryPluginIdentifier;

                Controller.HandleSyneryEvent(context, syneryException.GetAsSyneryValue());
            }

            return(new TypedValue(TypeHelper.GetSyneryType(variableData.Type), result));
        }
        /// <summary>
        /// Get a dictionary with all the system record types provided by Interface Booster.
        /// </summary>
        /// <returns></returns>
        public static IDictionary <SyneryType, IRecordType> GetSystemRecordTypes()
        {
            IDictionary <SyneryType, IRecordType> listOfRecordTypes = new Dictionary <SyneryType, IRecordType>();

            // get the signatures of the default system record types

            listOfRecordTypes.Add(GetRecordTypeSignature(EventRecord.GetRecordType()));
            listOfRecordTypes.Add(GetRecordTypeSignature(ExceptionRecord.GetRecordType()));
            listOfRecordTypes.Add(GetRecordTypeSignature(ExecutionExceptionRecord.GetRecordType()));
            listOfRecordTypes.Add(GetRecordTypeSignature(LibraryPluginExceptionRecord.GetRecordType()));
            listOfRecordTypes.Add(GetRecordTypeSignature(ProviderPluginConnectionExceptionRecord.GetRecordType()));
            listOfRecordTypes.Add(GetRecordTypeSignature(ProviderPluginDataExchangeExceptionRecord.GetRecordType()));

            return(listOfRecordTypes);
        }