Example #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);
        }
        /*
         * Implementation which allows customization of the SymbolBinder to use.
         * searchPath is a simicolon-delimited list of paths on which to search for pathModule.
         * If searchPath is null, pathModule must be a full path to the assembly.
         */
        internal static ISymbolReader GetReaderForFile(SymbolFormat symFormat, string pathModule, string searchPath)
        {
            // Create the appropriate symbol binder
            SymbolBinder binder;
            if (symFormat == SymbolFormat.PDB)
            {
                binder = new SymbolBinder();
            }
            else
            {
                throw new ArgumentException("Invalid format", "symFormat");
            }

            // Create the Metadata dispenser.
            object objDispenser;
            NativeMethods.CoCreateInstance(ref dispenserClassID, null, 1, ref dispenserIID, out objDispenser);

            // Now open an Importer on the given filename. We'll end up passing this importer straight
            // through to the Binder.
            object objImporter;
            IMetaDataDispenserPrivate dispenser = (IMetaDataDispenserPrivate)objDispenser;
            dispenser.OpenScope(pathModule, OPEN_READ, ref importerIID, out objImporter);

            IntPtr importerPtr = IntPtr.Zero;
            ISymbolReader reader;
            try
            {
                // This will manually AddRef the underlying object, so we need to be very careful to Release it.
                importerPtr = Marshal.GetComInterfaceForObject(objImporter, typeof(IMetadataImportPrivateComVisible));

                reader = binder.GetReader(importerPtr, pathModule, searchPath);
            }
            finally
            {
                if (importerPtr != IntPtr.Zero)
                {
                    Marshal.Release(importerPtr);
                }
            }
            return reader;
        }
Example #3
0
        public string ToString(string valueFormat, KinematicViscosityUnit unit, SymbolFormat symbolFormat, IFormatProvider formatProvider)
        {
            var quantityFormat = FormatCache <KinematicViscosityUnit> .GetOrCreate(valueFormat, unit, symbolFormat);

            return(this.ToString(quantityFormat, formatProvider));
        }
Example #4
0
        private static void XMLToPdb(string asmPath, string inputXml, SymbolFormat symFormat)
        {
            Console.WriteLine("Reading XML file: {0}", inputXml);
            Console.WriteLine("Writing a {0} symbol file and updating assembly: {1}", symFormat, asmPath);

            // Use XML serialization to read in the symbol data
            XmlReaderSettings settings = new XmlReaderSettings();
            settings.ConformanceLevel = ConformanceLevel.Document;
            XmlSerializer ser = new XmlSerializer(typeof(SymbolData));
            SymbolData symData;
            using (XmlReader reader = XmlReader.Create(inputXml, settings))
            {
                symData = (SymbolData)ser.Deserialize(reader);
            }

            // Emit PDB
            SymbolDataWriter writer = new SymbolDataWriter(asmPath, symFormat);
            writer.WritePdb(symData);
        }
Example #5
0
        public string ToString(string valueFormat, SpeedUnit unit, SymbolFormat symbolFormat)
        {
            var quantityFormat = FormatCache <SpeedUnit> .GetOrCreate(valueFormat, unit, symbolFormat);

            return(this.ToString(quantityFormat, null));
        }
 protected static string CreateSuffix(SymbolFormat format, ElectricChargeUnit unit)
 {
     return default(ElectricCharge).ToString(unit, format).Trim('0');
 }
        public string ToString(SpecificVolumeUnit unit, SymbolFormat symbolFormat)
        {
            var quantityFormat = FormatCache <SpecificVolumeUnit> .GetOrCreate(null, unit, symbolFormat);

            return(this.ToString(quantityFormat, null));
        }
Example #8
0
        /// <summary>
        /// Converts the quantity value of this instance to its equivalent string representation.
        /// </summary>
        /// <param name="valueFormat">The format to use for the scalar value. Valid formats are formats valid for formatting <see cref="double"/></param>
        /// <param name="unit">The unit to use in the conversion</param>
        /// <param name="symbolFormat">Specifies the symbol format to use when creating the string representation.</param>///
        /// <param name="formatProvider">Specifies the <see cref="IFormatProvider"/> to use when creating the string representation.</param>
        /// <returns>The string representation of the value of this instance.</returns>
        public string ToString(string valueFormat, AngleUnit unit, SymbolFormat symbolFormat, IFormatProvider formatProvider)
        {
            var quantityFormat = FormatCache <AngleUnit> .GetOrCreate(valueFormat, unit, symbolFormat);

            return(ToString(quantityFormat, formatProvider));
        }
 protected static string CreateSuffix(SymbolFormat format, MagneticFluxUnit unit)
 {
     return default(MagneticFlux).ToString(unit, format).Trim('0');
 }
Example #10
0
 /// <summary>
 /// Initialize the Pdb to Xml converter. Actual conversion happens in ReadPdbAndWriteToXml.
 /// Passing a filename also makes it easy for us to use reflection to get some information
 /// (such as enumeration)
 /// </summary>
 public SymbolDataReader(string assemblyPath, SymbolFormat symFormat, bool expandAttributes)
 {
     m_assemblyPath     = assemblyPath;
     m_symFormat        = symFormat;
     m_expandAttributes = expandAttributes;
 }
 protected static string CreateSuffix(SymbolFormat format, LengthUnit unit)
 {
     return default(Length).ToString(unit, format).Trim('0');
 }
 protected static string CreateSuffix(SymbolFormat format, LuminousIntensityUnit unit)
 {
     return default(LuminousIntensity).ToString(unit, format).Trim('0');
 }
 protected static string CreateSuffix(SymbolFormat format, KinematicViscosityUnit unit)
 {
     return default(KinematicViscosity).ToString(unit, format).Trim('0');
 }
 protected static string CreateSuffix(SymbolFormat format, InductanceUnit unit)
 {
     return default(Inductance).ToString(unit, format).Trim('0');
 }
 protected static string CreateSuffix(SymbolFormat format, FrequencyUnit unit)
 {
     return default(Frequency).ToString(unit, format).Trim('0');
 }
Example #16
0
        /// <summary>
        /// Converts the quantity value of this instance to its equivalent string representation.
        /// </summary>
        /// <param name="unit">The unit to use in the conversion</param>
        /// <param name="symbolFormat">Specifies the symbol format to use when creting the string representation.</param>
        /// <param name="formatProvider">Specifies the <see cref="IFormatProvider"/> to use when creting the string representation.</param>
        /// <returns>The string representation of the value of this instance.</returns>
        public string ToString(ForcePerUnitlessUnit unit, SymbolFormat symbolFormat, IFormatProvider formatProvider)
        {
            var quantityFormat = FormatCache <ForcePerUnitlessUnit> .GetOrCreate(null, unit, symbolFormat);

            return(ToString(quantityFormat, formatProvider));
        }
 protected static string CreateSuffix(SymbolFormat format, MomentumUnit unit)
 {
     return default(Momentum).ToString(unit, format).Trim('0');
 }
Example #18
0
        /// <summary>
        /// Converts the quantity value of this instance to its equivalent string representation.
        /// </summary>
        /// <param name="unit">The unit to use in the conversion</param>
        /// <param name="symbolFormat">Specifies the symbol format to use when creting the string representation.</param>
        /// <param name="formatProvider">Specifies the <see cref="IFormatProvider"/> to use when creting the string representation.</param>
        /// <returns>The string representation of the value of this instance.</returns>
        public string ToString(CatalyticActivityUnit unit, SymbolFormat symbolFormat, IFormatProvider formatProvider)
        {
            var quantityFormat = FormatCache <CatalyticActivityUnit> .GetOrCreate(null, unit, symbolFormat);

            return(ToString(quantityFormat, formatProvider));
        }
 protected static string CreateSuffix(SymbolFormat format, SolidAngleUnit unit)
 {
     return default(SolidAngle).ToString(unit, format).Trim('0');
 }
        /// <summary>
        /// Converts the quantity value of this instance to its equivalent string representation.
        /// </summary>
        /// <param name="unit">The unit to use in the conversion</param>
        /// <param name="symbolFormat">Specifies the symbol format to use when creting the string representation.</param>
        /// <returns>The string representation of the value of this instance.</returns>
        public string ToString(AmountOfSubstanceUnit unit, SymbolFormat symbolFormat)
        {
            var quantityFormat = FormatCache <AmountOfSubstanceUnit> .GetOrCreate(null, unit, symbolFormat);

            return(this.ToString(quantityFormat, null));
        }
 protected static string CreateSuffix(SymbolFormat format, SpecificVolumeUnit unit)
 {
     return default(SpecificVolume).ToString(unit, format).Trim('0');
 }
        public string ToString(AreaDensityUnit unit, SymbolFormat symbolFormat)
        {
            var quantityFormat = FormatCache <AreaDensityUnit> .GetOrCreate(null, unit, symbolFormat);

            return(this.ToString(quantityFormat, null));
        }
 protected static string CreateSuffix(SymbolFormat format, TorqueUnit unit)
 {
     return default(Torque).ToString(unit, format).Trim('0');
 }
Example #24
0
        /// <summary>
        /// Converts the quantity value of this instance to its equivalent string representation.
        /// </summary>
        /// <param name="valueFormat">The format to use for the scalar value. Valid formats are formats valid for formatting <see cref="double"/></param>
        /// <param name="unit">The unit to use in the conversion</param>
        /// <param name="symbolFormat">Specifies the symbol format to use when creting the string representation.</param>
        /// <returns>The string representation of the value of this instance.</returns>
        public string ToString(string valueFormat, InductanceUnit unit, SymbolFormat symbolFormat)
        {
            var quantityFormat = FormatCache <InductanceUnit> .GetOrCreate(valueFormat, unit, symbolFormat);

            return(ToString(quantityFormat, null));
        }
 protected static string CreateSuffix(SymbolFormat format, UnitlessUnit unit)
 {
     return default(Unitless).ToString(unit, format).Trim('0');
 }
        /// <summary>
        /// Converts the quantity value of this instance to its equivalent string representation.
        /// </summary>
        /// <param name="unit">The unit to use in the conversion</param>
        /// <param name="symbolFormat">Specifies the symbol format to use when creting the string representation.</param>
        /// <returns>The string representation of the value of this instance.</returns>
        public string ToString(ElectricChargeUnit unit, SymbolFormat symbolFormat)
        {
            var quantityFormat = FormatCache <ElectricChargeUnit> .GetOrCreate(null, unit, symbolFormat);

            return(this.ToString(quantityFormat, null));
        }
 protected static string CreateSuffix(SymbolFormat format, VolumetricFlowUnit unit)
 {
     return default(VolumetricFlow).ToString(unit, format).Trim('0');
 }
 protected static string CreateSuffix(SymbolFormat format, CatalyticActivityUnit unit)
 {
     return default(CatalyticActivity).ToString(unit, format).Trim('0');
 }
 protected static string CreateSuffix(SymbolFormat format, WavenumberUnit unit)
 {
     return default(Wavenumber).ToString(unit, format).Trim('0');
 }
        public string ToString(string valueFormat, MolarHeatCapacityUnit unit, SymbolFormat symbolFormat, IFormatProvider formatProvider)
        {
            var quantityFormat = FormatCache <MolarHeatCapacityUnit> .GetOrCreate(valueFormat, unit, symbolFormat);

            return(this.ToString(quantityFormat, formatProvider));
        }
 protected override string CreateSuffix(SymbolFormat format)
 {
     return CreateSuffix(format, this.Unit);
 }
Example #32
0
        private static void PdbToXML(string asmPath, string outputXml, SymbolFormat symFormat, bool expandAttrs)
        {
            Console.WriteLine("Reading the {0} symbol file for assembly: {1}", symFormat, asmPath);
            Console.WriteLine("Writing XML file: {0}", outputXml);

            try
            {
                // Read the PDB into a SymbolData object
                SymbolDataReader reader = new SymbolDataReader(asmPath, symFormat, expandAttrs);
                SymbolData symData = reader.ReadSymbols();

                if (symData != null)
                {
                    // Use XML serialization to write out the symbol data
                    XmlWriterSettings settings = new XmlWriterSettings();
                    settings.ConformanceLevel = ConformanceLevel.Document;
                    settings.Indent = true;
                    XmlSerializer ser = new XmlSerializer(typeof(SymbolData));
                    using (XmlWriter writer = XmlWriter.Create(outputXml, settings))
                    {
                        ser.Serialize(writer, symData);
                    }
                }
            }
            catch (ReflectionTypeLoadException ex)
            {
                foreach(var e in ex.LoaderExceptions)
                {
                    Console.WriteLine(e.Message);
                }
                throw;
            }
        }
 protected static string CreateSuffix(SymbolFormat format, AccelerationUnit unit)
 {
     return default(Acceleration).ToString(unit, format).Trim('0');
 }
Example #34
0
        /// <summary>
        /// Converts the quantity value of this instance to its equivalent string representation.
        /// </summary>
        /// <param name="valueFormat">The format to use for the scalar value. Valid formats are formats valid for formatting <see cref="double"/></param>
        /// <param name="unit">The unit to use in the conversion</param>
        /// <param name="symbolFormat">Specifies the symbol format to use when creting the string representation.</param>
        /// <returns>The string representation of the value of this instance.</returns>
        public string ToString(string valueFormat, ForcePerUnitlessUnit unit, SymbolFormat symbolFormat)
        {
            var quantityFormat = FormatCache <ForcePerUnitlessUnit> .GetOrCreate(valueFormat, unit, symbolFormat);

            return(ToString(quantityFormat, null));
        }
        public string ToString(string valueFormat, AngularAccelerationUnit unit, SymbolFormat symbolFormat)
        {
            var quantityFormat = FormatCache <AngularAccelerationUnit> .GetOrCreate(valueFormat, unit, symbolFormat);

            return(this.ToString(quantityFormat, null));
        }
Example #36
0
        /// <summary>
        /// Converts the quantity value of this instance to its equivalent string representation.
        /// </summary>
        /// <param name="valueFormat">The format to use for the scalar value. Valid formats are formats valid for formatting <see cref="double"/></param>
        /// <param name="unit">The unit to use in the conversion</param>
        /// <param name="symbolFormat">Specifies the symbol format to use when creting the string representation.</param>
        /// <returns>The string representation of the value of this instance.</returns>
        public string ToString(string valueFormat, CatalyticActivityUnit unit, SymbolFormat symbolFormat)
        {
            var quantityFormat = FormatCache <CatalyticActivityUnit> .GetOrCreate(valueFormat, unit, symbolFormat);

            return(ToString(quantityFormat, null));
        }
Example #37
0
        /// <summary>
        /// Converts the quantity value of this instance to its equivalent string representation.
        /// </summary>
        /// <param name="unit">The unit to use in the conversion</param>
        /// <param name="symbolFormat">Specifies the symbol format to use when creting the string representation.</param>
        /// <param name="formatProvider">Specifies the <see cref="IFormatProvider"/> to use when creting the string representation.</param>
        /// <returns>The string representation of the value of this instance.</returns>
        public string ToString(MagneticFluxUnit unit, SymbolFormat symbolFormat, IFormatProvider formatProvider)
        {
            var quantityFormat = FormatCache <MagneticFluxUnit> .GetOrCreate(null, unit, symbolFormat);

            return(ToString(quantityFormat, formatProvider));
        }
        /// <summary>
        /// Converts the quantity value of this instance to its equivalent string representation.
        /// </summary>
        /// <param name="unit">The unit to use in the conversion</param>
        /// <param name="symbolFormat">Specifies the symbol format to use when creting the string representation.</param>
        /// <returns>The string representation of the value of this instance.</returns>
        public string ToString(ElectricalConductanceUnit unit, SymbolFormat symbolFormat)
        {
            var quantityFormat = FormatCache <ElectricalConductanceUnit> .GetOrCreate(null, unit, symbolFormat);

            return(ToString(quantityFormat, null));
        }
Example #39
0
        /// <summary>
        /// Converts the quantity value of this instance to its equivalent string representation.
        /// </summary>
        /// <param name="valueFormat">The format to use for the scalar value. Valid formats are formats valid for formatting <see cref="double"/></param>
        /// <param name="unit">The unit to use in the conversion</param>
        /// <param name="symbolFormat">Specifies the symbol format to use when creting the string representation.</param>
        /// <returns>The string representation of the value of this instance.</returns>
        public string ToString(string valueFormat, MagneticFluxUnit unit, SymbolFormat symbolFormat)
        {
            var quantityFormat = FormatCache <MagneticFluxUnit> .GetOrCreate(valueFormat, unit, symbolFormat);

            return(ToString(quantityFormat, null));
        }
        /// <summary>
        /// Converts the quantity value of this instance to its equivalent string representation.
        /// </summary>
        /// <param name="valueFormat">The format to use for the scalar value. Valid formats are formats valid for formatting <see cref="double"/></param>
        /// <param name="unit">The unit to use in the conversion</param>
        /// <param name="symbolFormat">Specifies the symbol format to use when creating the string representation.</param>
        /// <param name="formatProvider">Specifies the <see cref="IFormatProvider"/> to use when creating the string representation.</param>
        /// <returns>The string representation of the value of this instance.</returns>
        public string ToString(string valueFormat, AmountOfSubstanceUnit unit, SymbolFormat symbolFormat, IFormatProvider formatProvider)
        {
            var quantityFormat = FormatCache <AmountOfSubstanceUnit> .GetOrCreate(valueFormat, unit, symbolFormat);

            return(this.ToString(quantityFormat, formatProvider));
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="Gu.Units.Wpf.UnitFormatConverterExtension"/> class.
 /// </summary>
 /// <param name="format"><see cref="Gu.Units.SymbolFormat"/>.</param>
 public UnitFormatConverterExtension(SymbolFormat format)
 {
     this.Format = format;
 }
        public string ToString(string valueFormat, SpecificVolumeUnit unit, SymbolFormat symbolFormat, IFormatProvider formatProvider)
        {
            var quantityFormat = FormatCache <SpecificVolumeUnit> .GetOrCreate(valueFormat, unit, symbolFormat);

            return(this.ToString(quantityFormat, formatProvider));
        }
 internal ValueAndUnitFormatKey(string?valueFormat, TUnit unit, SymbolFormat symbolFormat)
 {
     this.ValueFormat  = valueFormat;
     this.Unit         = unit;
     this.SymbolFormat = symbolFormat;
 }
Example #44
0
        /// <summary>
        /// Converts the quantity value of this instance to its equivalent string representation.
        /// </summary>
        /// <param name="unit">The unit to use in the conversion</param>
        /// <param name="symbolFormat">Specifies the symbol format to use when creting the string representation.</param>
        /// <returns>The string representation of the value of this instance.</returns>
        public string ToString(AngleUnit unit, SymbolFormat symbolFormat)
        {
            var quantityFormat = FormatCache <AngleUnit> .GetOrCreate(null, unit, symbolFormat);

            return(ToString(quantityFormat, null));
        }
        internal static QuantityFormat <TUnit> GetOrCreate(string?valueFormat, TUnit unit, SymbolFormat symbolFormat)
        {
            var key = new ValueAndUnitFormatKey(valueFormat, unit, symbolFormat);

            return(Cache.GetOrAdd(key, _ => CreateFromValueFormatAndUnit(key)));
        }
Example #46
0
        /// <summary>
        /// Converts the quantity value of this instance to its equivalent string representation.
        /// </summary>
        /// <param name="unit">The unit to use in the conversion</param>
        /// <param name="symbolFormat">Specifies the symbol format to use when creting the string representation.</param>
        /// <param name="formatProvider">Specifies the <see cref="IFormatProvider"/> to use when creting the string representation.</param>
        /// <returns>The string representation of the value of this instance.</returns>
        public string ToString(InductanceUnit unit, SymbolFormat symbolFormat, IFormatProvider formatProvider)
        {
            var quantityFormat = FormatCache <InductanceUnit> .GetOrCreate(null, unit, symbolFormat);

            return(ToString(quantityFormat, formatProvider));
        }
Example #47
0
        public string ToString(LengthPerUnitlessUnit unit, SymbolFormat symbolFormat)
        {
            var quantityFormat = FormatCache <LengthPerUnitlessUnit> .GetOrCreate(null, unit, symbolFormat);

            return(this.ToString(quantityFormat, null));
        }
Example #48
0
        public string ToString(SpeedUnit unit, SymbolFormat symbolFormat, IFormatProvider formatProvider)
        {
            var quantityFormat = FormatCache <SpeedUnit> .GetOrCreate(null, unit, symbolFormat);

            return(this.ToString(quantityFormat, formatProvider));
        }
 protected abstract string CreateSuffix(SymbolFormat symbolFormat);
Example #50
0
        /// <summary>
        /// Converts the quantity value of this instance to its equivalent string representation.
        /// </summary>
        /// <param name="valueFormat">The format to use for the scalar value. Valid formats are formats valid for formatting <see cref="double"/></param>
        /// <param name="unit">The unit to use in the conversion</param>
        /// <param name="symbolFormat">Specifies the symbol format to use when creating the string representation.</param>
        /// <param name="formatProvider">Specifies the <see cref="IFormatProvider"/> to use when creating the string representation.</param>
        /// <returns>The string representation of the value of this instance.</returns>
        public string ToString(string valueFormat, ElectricalConductanceUnit unit, SymbolFormat symbolFormat, IFormatProvider formatProvider)
        {
            var quantityFormat = FormatCache <ElectricalConductanceUnit> .GetOrCreate(valueFormat, unit, symbolFormat);

            return(this.ToString(quantityFormat, formatProvider));
        }
Example #51
0
 /// <summary>
 /// Initialize the Pdb to Xml converter. Actual conversion happens in ReadPdbAndWriteToXml.
 /// Passing a filename also makes it easy for us to use reflection to get some information 
 /// (such as enumeration)
 /// </summary>
 public SymbolDataReader(string assemblyPath, SymbolFormat symFormat, bool expandAttributes)
 {
     _assemblyPath = assemblyPath;
     _symFormat = symFormat;
     _expandAttributes = expandAttributes;
 }
Example #52
0
 public SymbolDataWriter(string asmPath, SymbolFormat symFormat)
 {
     m_outputAssembly = asmPath;
     m_symFormat = symFormat;
 }
 protected static string CreateSuffix(SymbolFormat format, CurrentUnit unit)
 {
     return default(Current).ToString(unit, format).Trim('0');
 }
 public static void SetSymbolFormat(this UIElement element, SymbolFormat value)
 {
     element.SetValue(SymbolFormatProperty, value);
 }
Example #55
0
        /// <summary>
        /// Converts the quantity value of this instance to its equivalent string representation.
        /// </summary>
        /// <param name="unit">The unit to use in the conversion</param>
        /// <param name="symbolFormat">Specifies the symbol format to use when creting the string representation.</param>
        /// <returns>The string representation of the value of this instance.</returns>
        public string ToString(LuminousFluxUnit unit, SymbolFormat symbolFormat)
        {
            var quantityFormat = FormatCache <LuminousFluxUnit> .GetOrCreate(null, unit, symbolFormat);

            return(this.ToString(quantityFormat, null));
        }
Example #56
0
        /// <summary>
        /// Converts the quantity value of this instance to its equivalent string representation.
        /// </summary>
        /// <param name="valueFormat">The format to use for the scalar value. Valid formats are formats valid for formatting <see cref="double"/></param>
        /// <param name="unit">The unit to use in the conversion</param>
        /// <param name="symbolFormat">Specifies the symbol format to use when creating the string representation.</param>
        /// <param name="formatProvider">Specifies the <see cref="IFormatProvider"/> to use when creating the string representation.</param>
        /// <returns>The string representation of the value of this instance.</returns>
        public string ToString(string valueFormat, LuminousFluxUnit unit, SymbolFormat symbolFormat, IFormatProvider formatProvider)
        {
            var quantityFormat = FormatCache <LuminousFluxUnit> .GetOrCreate(valueFormat, unit, symbolFormat);

            return(this.ToString(quantityFormat, formatProvider));
        }
 protected static string CreateSuffix(SymbolFormat format, AngularSpeedUnit unit)
 {
     return default(AngularSpeed).ToString(unit, format).Trim('0');
 }