System.Xml.Serialization.DynamicAssemblies.Add C# (CSharp) Method

Add() static private method

static private Add ( Assembly a ) : void
a System.Reflection.Assembly
return void
        internal static void Add(Assembly a)
        {
            lock (s_nameToAssemblyMap)
            {
                if (s_assemblyToNameMap[a] != null)
                {
                    //already added
                    return;
                }
                Assembly oldAssembly = s_nameToAssemblyMap[a.FullName] as Assembly;
                string key = null;
                if (oldAssembly == null)
                {
                    key = a.FullName;
                }
                else if (oldAssembly != a)
                {
                    //more than one assembly with same name
                    key = a.FullName + ", " + s_nameToAssemblyMap.Count;
                }
                if (key != null)
                {
                    s_nameToAssemblyMap.Add(key, a);
                    s_assemblyToNameMap.Add(a, key);
                }
            }
        }
        internal static Assembly Get(string fullName)

Usage Example

Example #1
0
 internal void AddImport(Type type, Hashtable types)
 {
     if (((type != null) && !TypeScope.IsKnownType(type)) && (types[type] == null))
     {
         types[type] = type;
         Type baseType = type.BaseType;
         if (baseType != null)
         {
             this.AddImport(baseType, types);
         }
         Type declaringType = type.DeclaringType;
         if (declaringType != null)
         {
             this.AddImport(declaringType, types);
         }
         foreach (Type type4 in type.GetInterfaces())
         {
             this.AddImport(type4, types);
         }
         ConstructorInfo[] constructors = type.GetConstructors();
         for (int i = 0; i < constructors.Length; i++)
         {
             ParameterInfo[] parameters = constructors[i].GetParameters();
             for (int j = 0; j < parameters.Length; j++)
             {
                 this.AddImport(parameters[j].ParameterType, types);
             }
         }
         if (type.IsGenericType)
         {
             Type[] genericArguments = type.GetGenericArguments();
             for (int k = 0; k < genericArguments.Length; k++)
             {
                 this.AddImport(genericArguments[k], types);
             }
         }
         TempAssembly.FileIOPermission.Assert();
         Assembly a = type.Module.Assembly;
         if (DynamicAssemblies.IsTypeDynamic(type))
         {
             DynamicAssemblies.Add(a);
         }
         else
         {
             object[] customAttributes = type.GetCustomAttributes(typeof(TypeForwardedFromAttribute), false);
             if (customAttributes.Length > 0)
             {
                 TypeForwardedFromAttribute attribute = customAttributes[0] as TypeForwardedFromAttribute;
                 Assembly assembly2 = Assembly.Load(attribute.AssemblyFullName);
                 this.imports[assembly2] = assembly2.Location;
             }
             this.imports[a] = a.Location;
         }
     }
 }
All Usage Examples Of System.Xml.Serialization.DynamicAssemblies::Add