internal RecordableCommand(Environment environment, IEnvironmentService service, Guid id, IRecordType type, string name, string description, bool isAvailable, bool isSynchronous) : base(environment, service, id, type, name, description, isAvailable) { IsSynchronous = isSynchronous; }
public RecordType(string name, IRecordType baseRecordType = null) { Name = name; if (baseRecordType != null) { InitializeBaseType(baseRecordType); } }
/// <summary> /// Sets the BaseRecordType-Property and copies all the fields from the base type /// </summary> /// <param name="baseRecordType"></param> private void InitializeBaseType(IRecordType baseRecordType) { BaseRecordType = baseRecordType; foreach (var field in baseRecordType.Fields) { AddFieldWithParentType(field.Name, field.Type, baseRecordType, field.DefaultValue); } }
public void Inheritance_Works_If_Base_Is_Defined_After_Child_Type() { _Client.Run(_Code, _IncludeCode); IRecordType type = (from r in _SyneryMemory.RecordTypes where r.Value.FullName == "One.Cheese" select r.Value).FirstOrDefault(); Assert.AreEqual("One.Meal", type.BaseRecordType.FullName); }
public static IRecordType GetRecordType() { if (_RecordType != null) { return(_RecordType); } _RecordType = new RecordType(RECORD_TYPE_NAME); _RecordType.AddField("IsHandled", TypeHelper.BOOL_TYPE, new TypedValue(TypeHelper.BOOL_TYPE, false)); return(_RecordType); }
public void HandleSyneryEvent(Antlr4.Runtime.ParserRuleContext context, IValue eventValue) { if (eventValue.Value is ExecutionExceptionRecord) { // if it is an #.ExecutionException or a derived type // set the information about the context the exception has occurred ((ExecutionExceptionRecord)eventValue.Value).Line = context.Start.Line; ((ExecutionExceptionRecord)eventValue.Value).CharPosition = context.Start.Column; } // try to get the event record from the given value IRecord eventRecord = TryToGetEventRecordFromValue(context, eventValue); // get the event record type from the given value IRecordType eventRecordType = eventRecord.RecordType; // check whether it is an exception bool isException = eventRecordType.IsType(ExceptionRecord.RECORD_TYPE_NAME); // search for a HANDLE-block that handles the emitted/thrown event IEnumerable <IHandleBlockData> listOfHandleBlocks = GetHandleBlocks(eventRecord, eventRecordType.FullName); if (isException == true && listOfHandleBlocks.Count() == 0) { // no handle block found for the given exception // throw a real exception string message = "Unhandled Exception. Data:"; foreach (var field in eventRecord.Data) { message += String.Format("{0}{0}{1}={2}", Environment.NewLine, field.Key, (field.Value.Value ?? "NULL")); } throw new InterfaceBoosterException(message); } else { bool isFirst = true; foreach (var handleBlock in listOfHandleBlocks) { EventHelper.InterpretHandleBlock(this, handleBlock, eventValue); // mark the event as handled after the first handle block is executed if (isFirst) { isFirst = false; eventRecord.SetFieldValue("IsHandled", new TypedValue(TypeHelper.BOOL_TYPE, true)); } } } }
public static new IRecordType GetRecordType() { if (_RecordType != null) { return(_RecordType); } _RecordType = new RecordType(RECORD_TYPE_NAME, EventRecord.GetRecordType()); _RecordType.AddField("Message", TypeHelper.STRING_TYPE); return(_RecordType); }
public static new IRecordType GetRecordType() { if (_RecordType != null) { return(_RecordType); } _RecordType = new RecordType(RECORD_TYPE_NAME, ExceptionRecord.GetRecordType()); _RecordType.AddField("Line", TypeHelper.INT_TYPE); _RecordType.AddField("CharPosition", TypeHelper.INT_TYPE); return(_RecordType); }
public static new IRecordType GetRecordType() { if (_RecordType != null) { return(_RecordType); } _RecordType = new RecordType(RECORD_TYPE_NAME, ExecutionExceptionRecord.GetRecordType()); _RecordType.AddField("DataCommandType", TypeHelper.STRING_TYPE); _RecordType.AddField("FullPath", TypeHelper.STRING_TYPE); return(_RecordType); }
public static new IRecordType GetRecordType() { if (_RecordType != null) { return(_RecordType); } _RecordType = new RecordType(RECORD_TYPE_NAME, ExecutionExceptionRecord.GetRecordType()); _RecordType.AddField("FullIdentifier", TypeHelper.STRING_TYPE); _RecordType.AddField("LibraryPluginIdentifier", TypeHelper.STRING_TYPE); return(_RecordType); }
public static new IRecordType GetRecordType() { if (_RecordType != null) { return(_RecordType); } _RecordType = new RecordType(RECORD_TYPE_NAME, ExecutionExceptionRecord.GetRecordType()); _RecordType.AddField("ConnectionPath", TypeHelper.STRING_TYPE); _RecordType.AddField("PluginInstanceReferenceIdentifier", TypeHelper.STRING_TYPE); return(_RecordType); }
public void Loading_All_Fields_Works_Over_Multiple_Levels_And_Code_Files() { _Client.Run(_Code, _IncludeCode); IRecordType type = (from r in _SyneryMemory.RecordTypes where r.Value.FullName == "WhiteWine" select r.Value).FirstOrDefault(); Assert.AreEqual(4, type.Fields.Count); Assert.AreEqual(true, type.Fields.Select(f => f.Name).Contains("Year")); Assert.AreEqual(true, type.Fields.Select(f => f.Name).Contains("CountryOfOrigin")); Assert.AreEqual(true, type.Fields.Select(f => f.Name).Contains("Liter")); Assert.AreEqual(true, type.Fields.Select(f => f.Name).Contains("Weight")); }
/// <summary> /// Checks whether the record type <paramref name="checkTypeName"/> is derived from or equals to the given /// <paramref name="baseTypeName"/> record type. /// </summary> /// <param name="memory">The current memory state. Is needed to access the list of record types.</param> /// <param name="checkTypeName">the full name of the type that should be checked</param> /// <param name="baseTypeName">the full name of the potential base type</param> /// <returns>true = type is derived from or equal to the base type</returns> public static bool IsDerivedType(ISyneryMemory memory, string checkTypeName, string baseTypeName) { if (checkTypeName == baseTypeName) { return(true); } IRecordType checkType = (from t in memory.RecordTypes.Values where t.Name == checkTypeName select t).FirstOrDefault(); if (checkType == null) { throw new SyneryException(String.Format("Record type wiht name='{0}' not found", baseTypeName)); } return(checkType.IsType(baseTypeName)); }
private IRecord GetRecordFromTableRow(IRecordType recordType, object[] row, ISchema schema) { IRecord record = new Record(recordType); foreach (var field in recordType.Fields) { var column = schema.GetField(field.Name); if (column != null && column.Type == field.Type.UnterlyingDotNetType) { int fieldPosition = schema.GetFieldPosition(field.Name); IValue value = new TypedValue(field.Type, row[fieldPosition]); record.SetFieldValue(field.Name, value); } } return(record); }
/// <summary> /// Creates a field using the given parameters and adds it to the list of fields /// </summary> /// <param name="name"></param> /// <param name="type"></param> /// <param name="parentType"></param> /// <param name="defaultValue"></param> /// <returns></returns> private IRecordTypeField AddFieldWithParentType(string name, SyneryType type, IRecordType parentType, IValue defaultValue = null) { IRecordTypeField field = new RecordTypeField(parentType) { Name = name, Type = type, DefaultValue = defaultValue, }; _Fields.Add(field); return(field); }
public RecordTypeField(IRecordType recordType) { RecordType = recordType; }
private void ExtractRecordTypes(string code, IDictionary <string, string> includeCode = null) { int endlessLoopPreventionCounter = 0; IList <RecordTypeDelcarationContainer> listOfDeclrartionContainer = GetRecordTypeContexts(code, includeCode); // assure that there is a dictionary if (Memory.RecordTypes == null) { Memory.RecordTypes = new Dictionary <SyneryType, IRecordType>(); } // extract all RecordTypes without a base type var listOfDeclarationsWithoutBaseType = (from d in listOfDeclrartionContainer where d.BaseRecordFullName == null select d).ToList(); foreach (var item in listOfDeclarationsWithoutBaseType) { IRecordType recordType = Controller .Interpret <SyneryParser.RecordTypeDeclarationContext, IRecordType, RecordTypeDelcarationContainer>(item.RecordTypeDeclarationContext, item); SyneryType syneryType = new SyneryType(typeof(IRecord), recordType.FullName); // set the alias of the included code file if (item.CodeFileAlias != null) { recordType.CodeFileAlias = item.CodeFileAlias; } Memory.RecordTypes.Add(syneryType, recordType); listOfDeclrartionContainer.Remove(item); } // loop threw the list of RecordTypes with a base type // assure that a RecordType only is loaded if the base type already is available while (listOfDeclrartionContainer.Count != 0) { var listOfAvailableTypes = Memory.RecordTypes.Select(r => r.Value.FullName); var listOfDeclarationsWithAvailableBaseTypes = (from d in listOfDeclrartionContainer where listOfAvailableTypes.Contains(d.BaseRecordFullName) select d).ToList(); // extract all RecordTypes for which the base type already is available foreach (var item in listOfDeclarationsWithAvailableBaseTypes) { IRecordType recordType = Controller .Interpret <SyneryParser.RecordTypeDeclarationContext, IRecordType, RecordTypeDelcarationContainer>(item.RecordTypeDeclarationContext, item); SyneryType syneryType = new SyneryType(typeof(IRecord), recordType.FullName); // set the alias of the included code file if (item.CodeFileAlias != null) { recordType.CodeFileAlias = item.CodeFileAlias; } Memory.RecordTypes.Add(syneryType, recordType); listOfDeclrartionContainer.Remove(item); } // prevent an endless loop: // if the counter reaches the 1000-mark the loop is stopped by throwing an exception endlessLoopPreventionCounter++; if (endlessLoopPreventionCounter > 1000) { // throw an exception that contains the name(s) of the left declarations that couldn't be resolved throw new SyneryException(String.Format( "The base type for the following record types couldn't be resolved: {0}", String.Join(", ", listOfDeclrartionContainer.Select(d => String.Format("'{0} : {1}'", d.FullName, d.BaseRecordFullName))))); } } }
private static KeyValuePair <SyneryType, IRecordType> GetRecordTypeSignature(IRecordType recordType) { SyneryType syneryType = new SyneryType(typeof(IRecord), recordType.Name); return(new KeyValuePair <SyneryType, IRecordType>(syneryType, recordType)); }
/// <summary> /// A record is an object composition that can take an indefinite number of fields. /// A field can take a primitive value or another record type. /// </summary> /// <param name="recordType"></param> public Record(IRecordType recordType) { _Data = new Dictionary <string, IValue>(); RecordType = recordType; }