public string GetInstantiation(Type type, bool interestingValue) { var genArgs = type.GetGenericArguments(); var instances = genArgs.Select(t => m_RootHandler.GetInstantiation(t, interestingValue)); return($"({string.Join(", ", instances)})"); }
public string GetInstantiation(Type type, bool interestingValue) { var dictTypes = GetDictionaryType(type); var keyTypeName = m_RootHandler.GetNameForCSharp(dictTypes.key); var valueTypeName = m_RootHandler.GetNameForCSharp(dictTypes.value); var keyTypeValue = m_RootHandler.GetInstantiation(dictTypes.key, true); var valueTypeValue = m_RootHandler.GetInstantiation(dictTypes.value, true); var invocationSuffix = interestingValue ? $"{{ {{ {keyTypeValue} , {valueTypeValue} }} }}" : "()"; m_RootHandler.GetNamespaceTracker().RecordNamespace("System.Collections.Generic"); return($"new Dictionary<{keyTypeName},{valueTypeName}>{invocationSuffix}"); }
public string GetInstantiation(Type type, bool interestingValue) { if (interestingValue) { if (!m_InterestingInstantiationCache.ContainsKey(type)) { m_InterestingInstantiationCache[type] = m_InnerTypeHandler.GetInstantiation(type, true); } return(m_InterestingInstantiationCache[type]); } if (!m_InstantiationCache.ContainsKey(type)) { m_InstantiationCache[type] = m_InnerTypeHandler.GetInstantiation(type, false); } return(m_InstantiationCache[type]); }
public string GetInstantiation(Type type, bool interestingValue) { var genArg = type.GetGenericArguments().FirstOrDefault() ?? typeof(object); var funcType = s_FuncType.MakeGenericType(genArg); if (type.IsAssignableFrom(funcType)) { return($"() => {m_RootHandler.GetInstantiation(genArg, interestingValue)}"); } return($"_ => {{ }}"); }
public string GetInstantiation(Type type, bool interestingValue) { if (type == typeof(byte[])) { if (interestingValue) { m_RootHandler.GetNamespaceTracker().RecordNamespace("System.Text"); return("Encoding.UTF8.GetBytes(\"{}\")"); } return("new byte[0]"); } if (type == typeof(Type[])) { return(interestingValue ? "new Type[] { typeof(string) }" : "Type.EmptyTypes"); } var eType = GetArrayElementType(type); return(!interestingValue ? $"new {m_RootHandler.GetNameForCSharp(eType)}[0]" : $"new {m_RootHandler.GetNameForCSharp(eType)}[] {{ {m_RootHandler.GetInstantiation(eType, true)} }}"); }
public string GetInstantiation(Type type, bool interestingValue) { return(m_InnerHandler.GetInstantiation(type, interestingValue)); }
public string GetInstantiation(Type type, bool interestingValue) { var innerType = GetNullableType(type); return($"({m_RootHandler.GetNameForCSharp(innerType)}?) {m_RootHandler.GetInstantiation(innerType, interestingValue)}"); }
public string GetInstantiation(Type type) { return(m_TypeHandler.GetInstantiation(type, false)); }