static string ParseAndConvertGenericArgsString(string genericArgs) { if (GenericArgsToTagCache.TryGetValue(genericArgs, out var CachedResult)) { return(CachedResult); } StringBuilder Result = new StringBuilder(); int start = 0, idx, stack = 0; bool inside = false; for (idx = 0; idx < genericArgs.Length; ++idx) { if (inside) { switch (genericArgs[idx]) { case '[': ++stack; break; case ']': --stack; if (stack == 0) { var typeName = genericArgs.Substring(start, idx - start - 1); var type = Type.GetType(typeName); if (Result.Length > 0) { Result.Append(','); } Result.Append(BondSerializationUtil.GetTypeIdentifierString(type)); inside = false; } break; } } else { if (genericArgs[idx] == '[') { inside = true; stack = 1; start = idx + 1; } } } GenericArgsToTagCache.TryAdd(genericArgs, Result.ToString()); TagToGenericArgsCache.TryAdd(Result.ToString(), genericArgs); return(Result.ToString()); }
// TODO: It would be AWESOME if we could just store this class directly, but // unfortunately, Bond's type aliases allow only primitive types to be aliased. // We should check to see if we can add support for custom types in Bond's source, // but for now, we're forced to do a double serialization here. public static ArraySegment <byte> ToByteArray(IGenericSerializable Serializable) { if (Serializable == null) { return(default(ArraySegment <byte>)); } var Type = Serializable.GetType(); var Result = new SerializationGenericReference(0) { Type = BondSerializationUtil.GetTypeIdentifierString(Type), Data = BondSerializer.Serialize(Serializable) }; return(BondSerializer.Serialize(Result)); }
public string GetTypeString(string OrleansTypeString, Type Type) { return(BondSerializationUtil.GetTypeIdentifierString(Type)); }