Exemple #1
0
        protected virtual List <Assembly> LoadDynamicAssemblies()
        {
            var ret = new List <Assembly>();

            Options.DynamicAssemblies?.ForEach(da =>
            {
                var a = Assembly.LoadFile(da);
                DynamicAssemblies.Add(a);
            });
            return(ret);
        }
Exemple #2
0
        // SxS: This method does not take any resource name and does not expose any resources to the caller.
        // It's OK to suppress the SxS warning.
        internal void AddImport(Type type, Hashtable types)
        {
            if (type == null)
            {
                return;
            }
            if (TypeScope.IsKnownType(type))
            {
                return;
            }
            if (types[type] != null)
            {
                return;
            }
            types[type] = type;
            Type baseType = type.BaseType;

            if (baseType != null)
            {
                AddImport(baseType, types);
            }

            Type declaringType = type.DeclaringType;

            if (declaringType != null)
            {
                AddImport(declaringType, types);
            }

            foreach (Type intf in type.GetInterfaces())
            {
                AddImport(intf, types);
            }

            ConstructorInfo[] ctors = type.GetConstructors();
            for (int i = 0; i < ctors.Length; i++)
            {
                ParameterInfo[] parms = ctors[i].GetParameters();
                for (int j = 0; j < parms.Length; j++)
                {
                    AddImport(parms[j].ParameterType, types);
                }
            }

            if (type.IsGenericType)
            {
                Type[] arguments = type.GetGenericArguments();
                for (int i = 0; i < arguments.Length; i++)
                {
                    AddImport(arguments[i], types);
                }
            }

            Module   module   = type.Module;
            Assembly assembly = module.Assembly;

            if (DynamicAssemblies.IsTypeDynamic(type))
            {
                DynamicAssemblies.Add(assembly);
                return;
            }

            object[] typeForwardedFromAttribute = type.GetCustomAttributes(typeof(TypeForwardedFromAttribute), false);
            if (typeForwardedFromAttribute.Length > 0)
            {
                TypeForwardedFromAttribute originalAssemblyInfo = typeForwardedFromAttribute[0] as TypeForwardedFromAttribute;
                Assembly originalAssembly = Assembly.Load(new AssemblyName(originalAssemblyInfo.AssemblyFullName));
                //_imports[originalAssembly] = originalAssembly.Location;
            }
            //_imports[assembly] = assembly.Location;
        }