Ejemplo n.º 1
0
        // Writer access with custom-specified format
        public static ISymbolWriter2 GetWriterForFile(SymbolFormat format, string pathModule, ref object emitter)
        {
            SymbolWriter writer;
            if (format == SymbolFormat.PDB)
                writer = new SymbolWriter();
            else if (format == SymbolFormat.ILDB)
                writer = new IldbSymbolWriter();
            else
                throw new ArgumentException("Invalid format", "format");

            return InitializeWriterForFile(writer, pathModule, ref emitter);
        }
Ejemplo n.º 2
0
        // Writer access with custom-specified format
        public static ISymbolWriter2 GetWriterForFile(SymbolFormat format, string pathModule, ref object emitter)
        {
            SymbolWriter writer;

            if (format == SymbolFormat.PDB)
            {
                writer = new SymbolWriter();
            }
            else if (format == SymbolFormat.ILDB)
            {
                writer = new IldbSymbolWriter();
            }
            else
            {
                throw new ArgumentException("Invalid format", "format");
            }

            return(InitializeWriterForFile(writer, pathModule, ref emitter));
        }
Ejemplo n.º 3
0
        // Initialization routine that allows a customized writer object to be supplied
        private static ISymbolWriter2 InitializeWriterForFile(SymbolWriter writer, string pathModule, ref object emitter)
        {
            // If no emitter is provided, make one and return it.
            if (emitter == null)
            {
                // First get a dispenser
                object objDispenser;
                NativeMethods.CoCreateInstance(ref dispenserClassID, null, 1, ref dispenserIID, out objDispenser);
                Debug.Assert(objDispenser != null, "Dispenser is null.");

                // Now get an emitter
                IMetaDataDispenserPrivate dispenser = (IMetaDataDispenserPrivate)objDispenser;
                dispenser.OpenScope(pathModule, OPEN_WRITE, ref emitterIID, out emitter);
            }
            Debug.Assert(emitter != null, "Emitter is null.");

            // An emitter was provided, just use that one.
            writer.Initialize(emitter, pathModule, false);
            return writer;
        }
Ejemplo n.º 4
0
        // Initialization routine that allows a customized writer object to be supplied
        private static ISymbolWriter2 InitializeWriterForFile(SymbolWriter writer, string pathModule, ref object emitter)
        {
            // If no emitter is provided, make one and return it.
            if (emitter == null)
            {
                // First get a dispenser
                object objDispenser;
                NativeMethods.CoCreateInstance(ref dispenserClassID, null, 1, ref dispenserIID, out objDispenser);
                Debug.Assert(objDispenser != null, "Dispenser is null.");

                // Now get an emitter
                IMetaDataDispenserPrivate dispenser = (IMetaDataDispenserPrivate)objDispenser;
                dispenser.OpenScope(pathModule, OPEN_WRITE, ref emitterIID, out emitter);
            }
            Debug.Assert(emitter != null, "Emitter is null.");

            // An emitter was provided, just use that one.
            writer.Initialize(emitter, pathModule, false);
            return(writer);
        }