Exemplo n.º 1
0
        public void Do()
        {
            var assembly = globalDataList.GatheredAssemblies[assemblyIndex];
            var type     = assembly.GetType(typeName);

            if (null != genericTypeIndexs)
            {
                Type[] args = new Type[genericTypeIndexs.Count];

                for (int i = 0; i < genericTypeIndexs.Count; i++)
                {
                    int typeIndex = (int)genericTypeIndexs[i];

                    if (typeIndex >= 0)
                    {
                        args[i] = globalDataList.GatheredTypes[typeIndex];
                    }
                    else
                    {
                        args[i] = GetBaseType.GetBaseTypeByIndex(typeIndex);
                    }
                }

                type = type.MakeGenericType(args);
            }

            globalDataList.GatheredTypes.Add(type);
        }
Exemplo n.º 2
0
        public void Do()
        {
            List <Type> paramTypeList = new List <Type>();

            if (null != paramList)
            {
                foreach (var obj in paramList)
                {
                    int index = (int)obj;

                    if (null == paramTypeList)
                    {
                        paramTypeList = new List <Type>();
                    }

                    if (index >= 0)
                    {
                        paramTypeList.Add(globalDataList.GatheredTypes[index]);
                    }
                    else
                    {
                        paramTypeList.Add(GetBaseType.GetBaseTypeByIndex(index));
                    }
                }
            }

            Func <MethodInfo, bool> isMatch = m =>
            {
                if (m.Name != methodName)
                {
                    return(false);
                }
                var p = m.GetParameters();
                if (p.Length != paramTypeList.Count)
                {
                    return(false);
                }
                for (var i = 0; i < p.Length; i++)
                {
                    if (p[i].ParameterType != paramTypeList[i])
                    {
                        return(false);
                    }
                }
                return(true);
            };

            var type   = globalDataList.GatheredTypes[typeIndex];
            var method = type.GetRuntimeMethods().FirstOrDefault(isMatch);

            if (null == method)
            {
                throw new Exception($"Can't get method {methodName} with {paramTypeList.Count} params");
            }
            globalDataList.GatheredMethods.Add(method);
        }
Exemplo n.º 3
0
        public void Do()
        {
            var   type  = typeIndex < 0 ? GetBaseType.GetBaseTypeByIndex(typeIndex) : globalDataList.GatheredTypes[typeIndex];
            IList array = Array.CreateInstance(type, null == items ? 0 : items.Count);

            if (null != items)
            {
                for (int i = 0; i < items.Count; i++)
                {
                    if (items[i] is Instance instance)
                    {
                        array[i] = globalDataList.GatheredInstances[instance.Index];
                    }
                    else
                    {
                        array[i] = items[i];
                    }
                }
            }

            globalDataList.GatheredInstances.Add(array);
        }