public static VCSolutionOptions Read(string InputFileName)
        {
            IOleStorage Storage = null;

            StgOpenStorage(InputFileName, null, STGM.Direct | STGM.Read | STGM.ShareExclusive, IntPtr.Zero, 0, out Storage);
            try
            {
                IOleEnumSTATSTG Enumerator = null;
                Storage.EnumElements(0, IntPtr.Zero, 0, out Enumerator);
                try
                {
                    uint      Fetched;
                    STATSTG[] Stats = new STATSTG[200];
                    Enumerator.Next((uint)Stats.Length, Stats, out Fetched);

                    VCSolutionOptions Options = new VCSolutionOptions();
                    foreach (STATSTG Stat in Stats)
                    {
                        if (Stat.pwcsName == "SolutionConfiguration")
                        {
                            IOleStream OleStream;
                            Storage.OpenStream(Stat.pwcsName, IntPtr.Zero, STGM.Read | STGM.ShareExclusive, 0, out OleStream);
                            try
                            {
                                uint   SizeRead;
                                byte[] Buffer = new byte[Stat.cbSize];
                                OleStream.Read(Buffer, (uint)Stat.cbSize, out SizeRead);

                                using (MemoryStream InputStream = new MemoryStream(Buffer, false))
                                {
                                    BinaryReader Reader = new BinaryReader(InputStream, Encoding.Unicode);
                                    while (InputStream.Position < InputStream.Length)
                                    {
                                        Options.SolutionConfiguration.Add(VCBinarySetting.Read(Reader));
                                    }
                                }
                            }
                            finally
                            {
                                Marshal.ReleaseComObject(OleStream);
                            }
                        }
                    }
                    return(Options);
                }
                finally
                {
                    Marshal.ReleaseComObject(Enumerator);
                }
            }
            finally
            {
                Marshal.ReleaseComObject(Storage);
            }
        }
示例#2
0
 public IEnumerable <VCBinarySetting> GetConfiguration()
 {
     byte[] Data;
     if (TryGetSection("SolutionConfiguration", out Data))
     {
         using (MemoryStream InputStream = new MemoryStream(Data, false))
         {
             BinaryReader Reader = new BinaryReader(InputStream, Encoding.Unicode);
             while (InputStream.Position < InputStream.Length)
             {
                 yield return(VCBinarySetting.Read(Reader));
             }
         }
     }
 }
示例#3
0
        public static VCBinarySetting Read(BinaryReader Reader)
        {
            VCBinarySetting Setting = new VCBinarySetting();

            // Read the key
            Setting.Name = new string(Reader.ReadChars(Reader.ReadInt32())).TrimEnd('\0');

            // Read an equals sign
            if (Reader.ReadChar() != '=')
            {
                throw new InvalidDataException("Expected equals symbol");
            }

            // Read the value
            Setting.Type = (ValueType)Reader.ReadUInt16();
            if (Setting.Type == ValueType.Bool)
            {
                Setting.BoolValue = (Reader.ReadUInt32() != 0);
            }
            else if (Setting.Type == ValueType.String)
            {
                Setting.StringValue = new string(Reader.ReadChars(Reader.ReadInt32()));
            }
            else
            {
                throw new InvalidDataException("Unknown value type");
            }

            // Read a semicolon
            if (Reader.ReadChar() != ';')
            {
                throw new InvalidDataException("Expected semicolon");
            }

            return(Setting);
        }
示例#4
0
		public static VCBinarySetting Read(BinaryReader Reader)
		{
			VCBinarySetting Setting = new VCBinarySetting();

			// Read the key
			Setting.Name = new string(Reader.ReadChars(Reader.ReadInt32())).TrimEnd('\0');

			// Read an equals sign
			if (Reader.ReadChar() != '=')
			{
				throw new InvalidDataException("Expected equals symbol");
			}

			// Read the value
			Setting.Type = (ValueType)Reader.ReadUInt16();
			if (Setting.Type == ValueType.Bool)
			{
				Setting.BoolValue = (Reader.ReadUInt32() != 0);
			}
			else if (Setting.Type == ValueType.String)
			{
				Setting.StringValue = new string(Reader.ReadChars(Reader.ReadInt32()));
			}
			else
			{
				throw new InvalidDataException("Unknown value type");
			}

			// Read a semicolon
			if (Reader.ReadChar() != ';')
			{
				throw new InvalidDataException("Expected semicolon");
			}

			return Setting;
		}