private string GetTypeNameInCode(HashSet <string> omitNamespaces, bool includeNamespaces) { var sb = new StringBuilder(); if (!string.IsNullOrEmpty(Namespace) && (omitNamespaces == null && includeNamespaces) || omitNamespaces != null && !omitNamespaces.Contains(Namespace)) { sb.Append(Namespace).Append('.'); } if (GenericArgCounts != null) { sb.Append(string.Join(".", GetNestedClassesInCode(omitNamespaces, includeNamespaces))); } else { sb.Append(ClassName); if (IsGeneric) { sb.Append("<"); sb.Append( string.Join(", ", GenericArgs .Select(a => a.GetTypeNameInCode(omitNamespaces, includeNamespaces)) .ToArray())); sb.Append(">"); } } sb.Append(MemoryMagic); return(sb.ToString()); }
public CacheMethod(MethodInfo methodInfo, object declaringInstance, GameObject parent) : base(methodInfo, declaringInstance, parent) { GenericArgs = methodInfo.GetGenericArguments(); GenericConstraints = GenericArgs.Select(x => x.GetGenericParameterConstraints()) .Where(x => x != null) .ToArray(); m_genericArgInput = new string[GenericArgs.Length]; m_arguments = methodInfo.GetParameters(); m_argumentInput = new string[m_arguments.Length]; CreateIValue(null, methodInfo.ReturnType); }
/// <summary> /// Returns a <see cref="System.String"/> that represents this instance. /// </summary> /// <param name="full">if set to <c>true</c> includes full information /// about generic parameters and assembly properties.</param> /// <param name="includeAssembly">if set to <c>true</c> include assembly properties and generic parameters.</param> /// <returns> /// A <see cref="System.String"/> that represents this instance. /// </returns> public string ToString(bool full, bool includeAssembly) { var sb = new StringBuilder(); if (!string.IsNullOrEmpty(Namespace)) { sb.Append(Namespace).Append('.'); } if (GenericArgCounts != null) { sb.Append(string.Join("+", ClassName .Split('+') .Zip(GenericArgCounts, (n, c) => c > 0 ? String.Format("{0}`{1}", n, c) : n))); } else { sb.Append(ClassName); if (IsGeneric) { sb.Append('`').Append(GenericArgs.Count); } } if (IsGeneric) { sb.Append('['); sb.Append(String.Join(",", GenericArgs.Select(a => string.Format("[{0}]", a.ToString(full))))); sb.Append(']'); } sb.Append(MemoryMagic); if (includeAssembly && AssemblyName != null) { sb.Append(", ").Append(AssemblyName); if (full) { foreach (var property in AssemblyAttribues) { sb.Append(", ").Append(property.Key).Append('=').Append(property.Value); } } } return(sb.ToString()); }
public override void InitMember(MemberInfo member, object declaringInstance) { base.InitMember(member, declaringInstance); var mi = MemInfo as MethodInfo; GenericArgs = mi.GetGenericArguments(); GenericConstraints = GenericArgs.Select(x => x.GetGenericParameterConstraints()) .ToArray(); GenericArgInput = new string[GenericArgs.Length]; m_arguments = mi.GetParameters(); m_argumentInput = new string[m_arguments.Length]; base.Init(null, mi.ReturnType); }