コード例 #1
0
 public TSLField(ITSLType type, string name, bool optional, IEnumerable <TSLAttribute> attributes = null)
 {
     Type       = type;
     Name       = name;
     Optional   = optional;
     Attributes = (attributes?.ToImmutableArray()).GetValueOrDefault();
 }
コード例 #2
0
 public ListType(ITSLType elementType)
 {
     ElementType    = elementType;
     Name           = $"List<{elementType.Name}>";
     ClrTypeName    = $"List<{elementType.ClrTypeName}>";
     GetRandomValue = GetRandomListValue;
 }
コード例 #3
0
 public TSLProtocol(string name, TSLProtocolType type, ITSLType requestType, ITSLType responseType)
 {
     Name         = name;
     Type         = type;
     RequestType  = requestType;
     ResponseType = responseType;
 }
コード例 #4
0
        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);
        }
コード例 #5
0
 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!");
     });
 }