/// <summary> /// The copy. /// </summary> /// <returns> /// The <see cref="EhMethodInfo"/>. /// </returns> public EhMethodInfo Copy() { var result = new EhMethodInfo(); result.AssemblyFullPath = this.AssemblyFullPath; result.ClassName = this.AssemblyFullPath; //result.CustomAttributes = this.CustomAttributes; result.MemberType = this.MemberType; result.MethodDisplayName = this.MethodDisplayName; result.MethodFullName = this.MethodFullName; result.MethodName = this.MethodName; result.Namespace = this.Namespace; result.ParameterInfo = this.ParameterInfo.Copy(); return(result); }
/// <summary> /// The get methods infos. /// </summary> /// <param name="directoryName"> /// The directory name. /// </param> /// <param name="assemblyFileName"> /// The assembly file name. /// </param> /// <returns> /// The <see cref="EhMethodInfo"/>. /// </returns> internal EhMethodInfoCollection GetTestScriptInformationMethodsInfos(string directoryName, string assemblyFileName) { var methodInfos = new EhMethodInfoCollection(); var directory = new DirectoryInfo(directoryName); ResolveEventHandler resolveEventHandler = (s, e) => { return(this.OnReflectionOnlyResolve(e, directory)); }; AppDomain.CurrentDomain.ReflectionOnlyAssemblyResolve += resolveEventHandler; Assembly reflectionOnlyAssembly = AppDomain.CurrentDomain.ReflectionOnlyGetAssemblies().First(); foreach (Type type in reflectionOnlyAssembly.GetTypes()) { try { ObjectHandle oh = Activator.CreateInstanceFrom(assemblyFileName, type.ToString()); object o = oh.Unwrap(); Type to = o.GetType(); foreach (var methodInfo in to.GetMethods()) { var customAttributes = methodInfo.GetCustomAttributes(false); if (customAttributes.Length > 0) { foreach (var customAttribut in customAttributes) { if (customAttribut is TestScriptInformation) { var ehMethodInfo = new EhMethodInfo(); ehMethodInfo.ParameterInfo = this.GetParameterInfos(methodInfo); ehMethodInfo.CustomAttributGuid = (customAttribut as TestScriptInformation).Guid; ehMethodInfo.CustomAttributTestDefinition = (customAttribut as TestScriptInformation).TestDefinition.ToString(); ehMethodInfo.CustomAttributTestScript = (customAttribut as TestScriptInformation).TestScript; ehMethodInfo.MethodFullName = methodInfo.DeclaringType.FullName; // ehMethodInfo.AssemblyFullPath = methodInfo.DeclaringType.Assembly.Location; ehMethodInfo.AssemblyFullPath = assemblyFileName; ehMethodInfo.MethodName = methodInfo.Name; ehMethodInfo.MethodDisplayName = this.GetDisplayName(methodInfo); ehMethodInfo.Namespace = methodInfo.DeclaringType.Namespace; ehMethodInfo.ClassName = methodInfo.ReflectedType.Name; ehMethodInfo.MemberType = methodInfo.MemberType.ToString(); methodInfos.Add(ehMethodInfo); } } } } } catch (Exception ex) { Log.ErrorEx(this, ex, MethodBase.GetCurrentMethod().Name); string test = string.Empty; } } AppDomain.CurrentDomain.ReflectionOnlyAssemblyResolve -= resolveEventHandler; return(methodInfos); }