RelativityFileShareBase
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
namespace Relativity.Transfer
{
public abstract class RelativityFileShareBase : FileStorageBase
{
private static readonly IDnsService = new DnsService();
private readonly ConcurrentDictionary<string, List<Uri>> = new ConcurrentDictionary<string, List<Uri>>();
private Uri ;
private Uri ;
public int { get; set; }
public string { get; set; }
public AsperaCredential { get; set; }
public ResourceServerType { get; set; }
internal IDnsService { get; set; }
protected static IFileSystemService { get; } = ServiceObjectLocator.GetService<IFileSystemService>();
protected RelativityFileShareBase()
{
ArtifactId = 0;
AsperaCredential = null;
base.CloudInstance = false;
base.Credential = null;
DocRoot = null;
base.Error = null;
base.Name = null;
base.Number = 0;
ResourceServerType = null;
base.TenantId = null;
DnsService = DnsServiceInstance;
}
public bool (string path)
{
if (string.IsNullOrEmpty(path))
throw new ArgumentNullException("path");
if (serverPathUri == (Uri)null) {
string uriString = FileSystemService.AddTrailingBackSlash(Url).ToUpperInvariant();
if (!Uri.TryCreate(uriString, UriKind.RelativeOrAbsolute, out serverPathUri))
serverPathUri = null;
}
if (Uri.TryCreate(PathHelper.ToWindowsPath(FileSystemService.TrimTrailingSlash(path)).ToUpperInvariant(), UriKind.RelativeOrAbsolute, out Uri result)) {
if (!(serverPathUri != (Uri)null) || !IsBaseOfHelper(serverPathUri, result)) {
if (serverDocRootUri == (Uri)null && !string.IsNullOrEmpty(DocRoot)) {
string uriString2 = FileSystemService.AddTrailingBackSlash(PathHelper.ToWindowsPath(DocRoot).ToUpperInvariant());
if (!Uri.TryCreate(uriString2, UriKind.RelativeOrAbsolute, out serverDocRootUri))
serverDocRootUri = null;
}
return serverDocRootUri != (Uri)null && IsBaseOfHelper(serverDocRootUri, result);
}
return true;
}
return false;
}
protected void ()
{
if (!base.CloudInstance) {
base.Number = 0;
base.TenantId = null;
} else {
string[] array = new string[2] {
base.Name,
Url
};
foreach (string name in array) {
try {
if (base.Number == 0)
base.Number = ResourceServerNameFormatter.GetCloudFileShareNumber(name);
} catch (ArgumentException) {
base.Number = 0;
}
try {
if (string.IsNullOrEmpty(base.TenantId))
base.TenantId = ResourceServerNameFormatter.GetCloudTenantId(name);
} catch (ArgumentException) {
base.TenantId = string.Empty;
}
}
}
}
private bool (Uri testServerPathUri, Uri pathUri)
{
if (!(pathUri == (Uri)null) && pathUri.IsAbsoluteUri && testServerPathUri.IsAbsoluteUri) {
bool flag;
try {
flag = (testServerPathUri.Equals((object)pathUri) || testServerPathUri.IsBaseOf(pathUri));
} catch (ArgumentException) {
flag = false;
}
if (!flag && base.CloudInstance)
flag = CheckCloudFileShareAttributes(testServerPathUri, pathUri);
if (!flag)
flag = CheckDnsAliases(testServerPathUri, pathUri);
return flag;
}
return false;
}
private bool (Uri testServerPathUri, Uri pathUri)
{
bool result = false;
try {
int cloudFileShareNumber = ResourceServerNameFormatter.GetCloudFileShareNumber(pathUri.LocalPath);
if (cloudFileShareNumber == base.Number) {
string components = testServerPathUri.GetComponents(UriComponents.Path, UriFormat.Unescaped);
string components2 = pathUri.GetComponents(UriComponents.Path, UriFormat.Unescaped);
UriBuilder uriBuilder = new UriBuilder {
Host = "\\\\files",
Path = components,
Scheme = "file"
};
UriBuilder uriBuilder2 = new UriBuilder {
Host = "\\\\files",
Path = components2,
Scheme = "file"
};
result = (uriBuilder.Uri.Equals((object)uriBuilder2.Uri) || uriBuilder.Uri.IsBaseOf(uriBuilder2.Uri));
}
} catch (ArgumentException) {
result = false;
} catch (InvalidOperationException) {
result = false;
}
return result;
}
private bool (Uri serverPath, Uri path)
{
if (DnsService != null) {
string key = serverPath.LocalPath.ToUpperInvariant();
if (!serverAliasedPaths.TryGetValue(key, out List<Uri> value)) {
value = GetAliasedUriPaths(serverPath);
serverAliasedPaths.TryAdd(key, value);
}
if (value != null) {
List<Uri> aliasedUriPaths = GetAliasedUriPaths(path);
foreach (Uri item in value) {
foreach (Uri item2 in aliasedUriPaths) {
if (item.Equals((object)item2) || item.IsBaseOf(item2))
return true;
}
}
return false;
}
return false;
}
return false;
}
private List<Uri> (Uri path)
{
IList<string> aliases = DnsService.GetAliases(path.Host);
List<Uri> list = new List<Uri> {
path
};
if (aliases != null && aliases.Count > 0) {
string components = path.GetComponents(UriComponents.Path, UriFormat.Unescaped);
if (!string.IsNullOrEmpty(components))
list.AddRange(from alias in aliases
where string.Compare(alias, path.Host, StringComparison.OrdinalIgnoreCase) != 0
select new UriBuilder {
Host = alias.ToUpperInvariant(),
Path = components,
Scheme = "file"
} into builder
select builder.Uri);
}
return list;
}
}
}