public TSLField(ITSLType type, string name, bool optional, IEnumerable <TSLAttribute> attributes = null) { Type = type; Name = name; Optional = optional; Attributes = (attributes?.ToImmutableArray()).GetValueOrDefault(); }
public ListType(ITSLType elementType) { ElementType = elementType; Name = $"List<{elementType.Name}>"; ClrTypeName = $"List<{elementType.ClrTypeName}>"; GetRandomValue = GetRandomListValue; }
public TSLProtocol(string name, TSLProtocolType type, ITSLType requestType, ITSLType responseType) { Name = name; Type = type; RequestType = requestType; ResponseType = responseType; }
public ArrayType(ITSLType elementType, int[] dimensions) { ElementType = elementType; Dimensions = dimensions.ToImmutableArray(); if (elementType.DynamicLengthed) { throw new ArgumentOutOfRangeException(nameof(elementType), "Element type can't be dynamic lengthed!"); } Name = $"{elementType.Name}[{string.Join(", ", dimensions)}]"; ClrTypeName = $"{elementType.Name}[{string.Join(",", dimensions.Select(d => ""))}]"; GetRandomValue = random => GetRandomArrayValue(random); }
public static Func <TSLGeneratorContext, ITSLType> GenerateNonNullType(TSLGeneratorCombinator <ITSLType> generator) { return(context => { ITSLType ret = null; for (int i = 0; i < GeneralSettings.NonNullRetries; ++i) { ret = generator.DefaultGenerate(context); if (ret != null) { return ret; } } throw new Exception("Too many retries before getting a non null type!"); }); }