Esempio n. 1
0
        /// <summary>
        /// Reads PhpBytes from file using the PhpStream.
        /// </summary>
        /// <param name="filename"></param>
        /// <returns></returns>
        internal static PhpBytes ReadPhpBytes(string filename)
        {
            PhpBytes bytes;

            using (PhpStream stream = PhpStream.Open(filename, "rb", StreamOpenOptions.Empty, StreamContext.Default))
            {
                if (stream == null)
                {
                    return(null);
                }

                try
                {
                    bytes = PhpStream.AsBinary(stream.ReadContents());
                    if (bytes == null || bytes.IsEmpty())
                    {
                        return(null);
                    }
                }
                catch
                {
                    return(null);
                }
            }

            return(bytes);
        }
Esempio n. 2
0
 internal StringDataSource(object source)
 {
     this.m_src = new MemoryStream(PhpStream.AsBinary(source).ReadonlyData);
 }