Ejemplo n.º 1
0
            public FileContentCache(string path, DateTime lastWriteTimeUtc, bool isXml = false)
            {
                var content = FileSystemHelpers.ReadAllText(path);
                var xml     = isXml ? XDocument.Parse(content) : null;

                _path              = path;
                _lastWriteTimeUtc  = lastWriteTimeUtc;
                _lastAccessTimeUtc = DateTime.UtcNow;
                _content           = content;
                _xml = xml;
            }
Ejemplo n.º 2
0
        private static bool TryGetAspNet5Sdk(string rootPath, out AspNet5Sdk aspNetSdk)
        {
            aspNetSdk = null;
            var globalJson = Path.Combine(rootPath, "global.json");

            if (FileSystemHelpers.FileExists(globalJson))
            {
                var parsedGlobalJson = JObject.Parse(FileSystemHelpers.ReadAllText(globalJson));
                if (parsedGlobalJson["sdk"] != null)
                {
                    aspNetSdk = parsedGlobalJson["sdk"].ToObject <AspNet5Sdk>();
                    if (string.IsNullOrEmpty(aspNetSdk.Architecture))
                    {
                        aspNetSdk.Architecture = GetDefaultAspNet5RuntimeArchitecture();
                    }
                    return(true);
                }
            }
            return(false);
        }
Ejemplo n.º 3
0
        private static bool TryGetAspNet5Sdk(string rootPath, IFileFinder fileFinder, out AspNet5Sdk aspNetSdk)
        {
            aspNetSdk = null;
            var globalJsonFiles = fileFinder.ListFiles(rootPath, SearchOption.AllDirectories, new[] { "*global.json" })
                                  .Where(path => Path.GetFileName(path).Equals("global.json", StringComparison.OrdinalIgnoreCase))
                                  .ToList();

            if (globalJsonFiles.Count == 1 && FileSystemHelpers.FileExists(globalJsonFiles.First()))
            {
                var parsedGlobalJson = JObject.Parse(FileSystemHelpers.ReadAllText(globalJsonFiles.First()));
                if (parsedGlobalJson["sdk"] != null)
                {
                    aspNetSdk = parsedGlobalJson["sdk"].ToObject <AspNet5Sdk>();
                    if (string.IsNullOrEmpty(aspNetSdk.Architecture))
                    {
                        aspNetSdk.Architecture = GetDefaultAspNet5RuntimeArchitecture();
                    }
                    return(true);
                }
            }
            return(false);
        }