/// <summary> /// Resolves implementation of a single-generic-argument interface on this type. /// </summary> /// <param name="fullNamePrefix">Interface name to search for (eg. "System.Collections.Generic.IList")</param> /// <param name="implementation">Result found implementation.</param> /// <param name="itemType">The only generic argument of <paramref name="implementation"/></param> /// <returns>True if found, false otherwise.</returns> public static bool ResolveGenericInterfaceImplementation(this DebugType type, string fullNamePrefix, out DebugType implementation, out DebugType itemType) { if (type == null) { throw new ArgumentNullException("type"); } implementation = null; itemType = null; implementation = type.GetGenericInterface(fullNamePrefix); if (implementation != null) { if (implementation.GetGenericArguments().Length == 1) { itemType = (DebugType)implementation.GetGenericArguments()[0]; return(true); } } return(false); }
public static IndexerExpression AppendIndexer(this Expression expression, params int[] indices) { IndexerExpression indexerExpr = new IndexerExpression(Parenthesize(expression), new List <Expression>()); foreach (int index in indices) { indexerExpr.Indexes.Add(new PrimitiveExpression(index)); } DebugType staticType = expression.GetStaticType(); if (staticType != null && staticType.IsArray) { indexerExpr.SetStaticType((DebugType)staticType.GetElementType()); } if (staticType != null && staticType.FullNameWithoutGenericArguments == typeof(List <>).FullName) { indexerExpr.SetStaticType((DebugType)staticType.GetGenericArguments()[0]); } return(indexerExpr); }
public static Eval AsyncNewObjectNoConstructor(DebugType debugType) { return(new Eval( debugType.AppDomain, "New object: " + debugType.FullName, delegate(Eval eval) { eval.CorEval2.NewParameterizedObjectNoConstructor(debugType.CorType.GetClass(), (uint)debugType.GetGenericArguments().Length, debugType.GenericArgumentsAsCorDebugType); } )); }