System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.GetTypeInformation C# (CSharp) Method

GetTypeInformation() static private method

static private GetTypeInformation ( Type type ) : TypeInformation
type System.Type
return TypeInformation
        internal static TypeInformation GetTypeInformation(Type type)
        {
            lock (s_typeNameCache)
            {
                TypeInformation typeInformation;
                if (!s_typeNameCache.TryGetValue(type, out typeInformation))
                {
                    bool hasTypeForwardedFrom;
                    string assemblyName = FormatterServices.GetClrAssemblyName(type, out hasTypeForwardedFrom);
                    typeInformation = new TypeInformation(FormatterServices.GetClrTypeFullName(type), assemblyName, hasTypeForwardedFrom);
                    s_typeNameCache.Add(type, typeInformation);
                }
                return typeInformation;
            }
        }
    }

Usage Example

コード例 #1
0
 private static void CheckTypeForwardedTo(Assembly sourceAssembly, Assembly destAssembly, Type resolvedType)
 {
     if ((!FormatterServices.UnsafeTypeForwardersIsEnabled() && (sourceAssembly != destAssembly)) && !destAssembly.PermissionSet.IsSubsetOf(sourceAssembly.PermissionSet))
     {
         TypeInformation typeInformation = BinaryFormatter.GetTypeInformation(resolvedType);
         if (!typeInformation.HasTypeForwardedFrom)
         {
             SecurityException exception2 = new SecurityException {
                 Demanded = sourceAssembly.PermissionSet
             };
             throw exception2;
         }
         Assembly assembly = null;
         try
         {
             assembly = Assembly.Load(typeInformation.AssemblyString);
         }
         catch
         {
         }
         if (assembly != sourceAssembly)
         {
             SecurityException exception = new SecurityException {
                 Demanded = sourceAssembly.PermissionSet
             };
             throw exception;
         }
     }
 }
All Usage Examples Of System.Runtime.Serialization.Formatters.Binary.BinaryFormatter::GetTypeInformation