public BasicNodeAddress(string rootUri, string path) : this(StringUriUtils.GetScheme(rootUri), rootUri, path, false) { }
private static string GetFileName(TypeDescriptorProvider typeDescriptorProvider, string cacheDirectory, string serializedConfiguration, out string fullhash) { var sha1 = SHA1.Create(); var modelAssembly = typeDescriptorProvider.DataAccessModelType.Assembly; var uniquelyReferencedAssemblies = new HashSet <Assembly> { typeof(DataAccessModel).Assembly, modelAssembly }; foreach (var type in typeDescriptorProvider.GetTypeDescriptors()) { var current = type.Type; while (current != null) { uniquelyReferencedAssemblies.Add(current.Assembly); current = current.BaseType; } } var bytes = Encoding.UTF8.GetBytes(serializedConfiguration); sha1.TransformBlock(bytes, 0, bytes.Length, null, 0); foreach (var assembly in uniquelyReferencedAssemblies.OrderBy(c => c.FullName)) { bytes = Encoding.UTF8.GetBytes(assembly.FullName); sha1.TransformBlock(bytes, 0, bytes.Length, null, 0); bytes = Encoding.UTF8.GetBytes(assembly.GetName().Version.ToString()); sha1.TransformBlock(bytes, 0, bytes.Length, null, 0); var path = StringUriUtils.GetScheme(assembly.CodeBase) == "file" ? new Uri(assembly.CodeBase).LocalPath : assembly.Location; if (path != null) { if (assembly.GetName().GetPublicKeyToken().Length == 0) { var fileInfo = new FileInfo(path); bytes = BitConverter.GetBytes(fileInfo.Length); sha1.TransformBlock(bytes, 0, bytes.Length, null, 0); bytes = BitConverter.GetBytes(fileInfo.LastWriteTimeUtc.Ticks); sha1.TransformBlock(bytes, 0, bytes.Length, null, 0); } } } sha1.TransformFinalBlock(bytes, 0, 0); var fileName = modelAssembly.Location == null?modelAssembly.GetName().Name : Path.GetFileNameWithoutExtension(modelAssembly.Location); cacheDirectory = cacheDirectory?.Trim(); var codebaseUri = new Uri(modelAssembly.CodeBase); var modelName = typeDescriptorProvider.DataAccessModelType.Name; if (modelAssembly.GetExportedTypes().Any(c => c.Name == modelName && c != typeDescriptorProvider.DataAccessModelType)) { modelName = typeDescriptorProvider.DataAccessModelType.FullName.Replace(".", "_"); } fullhash = TextConversion.ToHexString(sha1.Hash); fileName = $"{fileName}.{modelName}.Generated.dll"; cacheDirectory = !string.IsNullOrEmpty(cacheDirectory) ? cacheDirectory : !codebaseUri.IsFile ? Environment.CurrentDirectory : Path.GetDirectoryName(codebaseUri.LocalPath); return(Path.Combine(cacheDirectory, fileName)); }