示例#1
0
            public static CSharpCDI ParseCDI(byte[] val)
            {
                CDIReader r = new CDIReader(val);

                CSharpCDI cdi = new CSharpCDI();

                try
                {
                    // Read the CDIGlobal header
                    byte version = r.ReadByte();
                    if (version != CDIVERSION)
                    {
                        throw new FormatException("Got unexpected CDIGlobal version: " + version);
                    }
                    cdi.version = version;

                    byte count = r.ReadByte();
                    r.SkipPadding(4);
                    cdi.entries = new CDIItem[count];

                    // Read each CDI record
                    for (int i = 0; i < count; i++)
                    {
                        cdi.entries[i] = r.ReadItem();
                    }
                }
                catch (EndOfStreamException e)
                {
                    throw new FormatException("Unexpected end of CDI stream", e);
                }
                return(cdi);
            }
示例#2
0
 private CSharpCDI ReadCSharpCDI(ISymbolReader reader, ISymbolMethod methodSymbol)
 {
     // See if the C# CDI attribute exists
     byte[] attrVal = reader.GetSymAttribute(methodSymbol.Token, k_cSharpCDIAttrName);
     if (attrVal == null)
     {
         return(null);        // No such attribute
     }
     try
     {
         return(CDIReader.ParseCDI(attrVal));
     }
     catch (System.FormatException e)
     {
         Console.WriteLine("WARNING: Error parsing CSharp CDI for method {0}: {1}", Util.AsToken(methodSymbol.Token.GetToken()), e.Message);
         return(null);
     }
 }
示例#3
0
            public static CSharpCDI ParseCDI(byte[] val)
            {
                CDIReader r = new CDIReader(val);

                CSharpCDI cdi = new CSharpCDI();

                try
                {
                    // Read the CDIGlobal header
                    byte version = r.ReadByte();
                    if (version != CDIVERSION)
                        throw new FormatException("Got unexpected CDIGlobal version: " + version);
                    cdi.version = version;

                    byte count = r.ReadByte();
                    r.SkipPadding(4);
                    cdi.entries = new CDIItem[count];

                    // Read each CDI record
                    for (int i = 0; i < count; i++)
                    {
                        cdi.entries[i] = r.ReadItem();
                    }
                }
                catch (EndOfStreamException e)
                {
                    throw new FormatException("Unexpected end of CDI stream", e);
                }
                return cdi;
            }