Exemple #1
0
        private void ReadEmbedded()
        {
            var assembly     = Assembly.GetExecutingAssembly();
            var resourceName = GetType().Namespace + ".Template.Resource.rc";

            using (var stream = assembly.GetManifestResourceStream(resourceName))
                using (var reader = new StreamReader(stream, Encoding.Unicode))
                {
                    _fileContent = reader.ReadToEnd();
                }
            const string defaultResourceHeaderFileName = "resource{0}.h";

            var resourceHeaderFileName = Path.Combine(Path.GetDirectoryName(FileName), string.Format(defaultResourceHeaderFileName, string.Empty));

            if (File.Exists(resourceHeaderFileName))
            {
                int index = 0;
                while (true)
                {
                    index++;
                    resourceHeaderFileName = Path.Combine(Path.GetDirectoryName(FileName), string.Format(defaultResourceHeaderFileName, index));
                    if (File.Exists(resourceHeaderFileName))
                    {
                        continue;
                    }
                    _fileContent = _fileContent.Replace(string.Format(defaultResourceHeaderFileName, string.Empty), string.Format(defaultResourceHeaderFileName, index));
                    break;
                }
            }
            _resourceHeaderFile = new ResourceHeaderFile(resourceHeaderFileName, this, true);
        }
Exemple #2
0
        private void FindHeaderFile()
        {
            var basePath = Path.GetDirectoryName(FileName);
            var regEx    = new Regex(@"#include +""(.*)""");
            var matches  = regEx.Matches(_fileContent);

            foreach (Match match in matches)
            {
                var headerFile = Path.Combine(basePath, match.Groups[1].Value);
                if (!File.Exists(headerFile))
                {
                    continue;
                }
                var resourceHeaderFile = new ResourceHeaderFile(headerFile, this);
                if (!resourceHeaderFile.IsValid())
                {
                    continue;
                }
                _resourceHeaderFile = resourceHeaderFile;
                return;
            }
        }