private IThriftTypeReference GetThriftTypeReference(Type csharpType, Recursiveness recursiveness) { ThriftType thriftType = GetThriftTypeFromCache(csharpType); if (thriftType == null) { if (recursiveness == Recursiveness.Forced || (recursiveness == Recursiveness.Allowed && _stack.Value.Contains(csharpType))) { // recursion: return an unresolved ThriftTypeReference _deferredTypesWorkList.Value.Push(csharpType); return(new RecursiveThriftTypeReference(this, csharpType)); } else { thriftType = _typeCache.GetOrAdd(csharpType, t => BuildThriftType(t)); } } return(new DefaultThriftTypeReference(thriftType)); }
/// <summary> /// 创建 <see cref="ThriftFieldAttribute"/> 类的新实例。 /// </summary> /// <param name="id">表示字段的顺序,在一个 struct 内应该保持唯一。</param> public ThriftFieldAttribute(ThriftIdlAnnotationAttribute[] idlAnnotations, short value = short.MinValue, bool isLegacyId = false, String name = "", Requiredness requiredness = Requiredness.UNSPECIFIED, Recursiveness isRecursive = Recursiveness.UNSPECIFIED) { this.IdlAnnotations = idlAnnotations?.ToArray(); this.Value = value; this.IsLegacyId = isLegacyId; this.IsRecursive = isRecursive; this.Requiredness = requiredness; this.Name = name; }