Пример #1
0
 private PE.Row TypeDefOrRefRowFromQualifiedTypeName(DllSaveContext ctxt, QualifiedTypeName name)
 {
     if (name.Assembly.Equals(ctxt.AssemblyName))
     {
         var assemblyDef = default(AssemblyDef);
         var typeDef     = default(TypeDef);
         if (!name.PrimTryResolve(rootEnv.Global, out assemblyDef, out typeDef))
         {
             throw new InvalidOperationException("no such type");
         }
         return(TypeDefRowFromTypeDef(ctxt, typeDef));
     }
     else
     {
         var row      = default(PE.TypeRefRow);
         var resScope = default(PE.Row);
         if (name.Type.IsNested)
         {
             resScope = TypeDefOrRefRowFromQualifiedTypeName(ctxt, name.Outer());
         }
         else
         {
             resScope = AssemblyNameToAssemblyRefRow(ctxt, name.Assembly);
         }
         if (!ctxt.QualifiedTypeNameToRowCache.TryGetValue(name, out row))
         {
             row = new PE.TypeRefRow
             {
                 ResolutionScope = { Value = resScope },
                 TypeName        = { Value = name.Type.Types[name.Type.Types.Count - 1] },
                 TypeNamespace   = { Value = name.Type.Namespace }
             };
             ctxt.QualifiedTypeNameToRowCache.Add(name, row);
         }
         return(row);
     }
 }
Пример #2
0
 private PE.Row TypeDefOrRefRowFromQualifiedTypeName(DllSaveContext ctxt, QualifiedTypeName name)
 {
     if (name.Assembly.Equals(ctxt.AssemblyName))
     {
         var assemblyDef = default(AssemblyDef);
         var typeDef = default(TypeDef);
         if (!name.PrimTryResolve(rootEnv.Global, out assemblyDef, out typeDef))
             throw new InvalidOperationException("no such type");
         return TypeDefRowFromTypeDef(ctxt, typeDef);
     }
     else
     {
         var row = default(PE.TypeRefRow);
         var resScope = default(PE.Row);
         if (name.Type.IsNested)
             resScope = TypeDefOrRefRowFromQualifiedTypeName(ctxt, name.Outer());
         else
             resScope = AssemblyNameToAssemblyRefRow(ctxt, name.Assembly);
         if (!ctxt.QualifiedTypeNameToRowCache.TryGetValue(name, out row))
         {
             row = new PE.TypeRefRow
                   {
                       ResolutionScope = { Value = resScope },
                       TypeName = { Value = name.Type.Types[name.Type.Types.Count - 1] },
                       TypeNamespace = { Value = name.Type.Namespace }
                   };
             ctxt.QualifiedTypeNameToRowCache.Add(name, row);
         }
         return row;
     }
 }