select new DirectoryRecord
{
DisplayName = container.Name,
- Uri=new Uri(client.StorageUrl,container.Name),
+ Uri=new Uri(client.StorageUrl,String.Format(@"{0}/{1}",Account.AccountName, container.Name)),
Directories = (from dir in client.ListObjects(_monitor.UserName, container.Name)
where dir.Content_Type == DirectoryType
select dir).ToTree()
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
+ <Compile Include="CollectionExtensionsTest.cs" />
<Compile Include="EnumerableExtensionsTest.cs" />
<Compile Include="ExtensionTests.cs" />
<Compile Include="FileSystemWatcherAdapterTest.cs" />
//If the uri is below the root, it should match the root's segments one by one\r
//If there is any root segment that doesn't match its corresponding target segment,\r
//the target is not below the root\r
+ //DON'T FORGET that Uri segments include the slashes. Must remove them to ensure proper checks\r
var mismatch = rootSegments\r
- .Where((t, i) => !String.Equals(targetSegments[i], t))\r
+ .Where((t, i) => !String.Equals(targetSegments[i].TrimEnd('/'), t.TrimEnd('/')))\r
.Any();\r
return !mismatch;\r
}\r
throw new ArgumentNullException("target");\r
Contract.EndContractBlock();\r
\r
+ if (target.Equals(root))\r
+ return true;\r
return\r
//If the target is directly below the root, it will have exactly \r
//one segment more than the root \r
throw new ArgumentNullException("rootPath");\r
Contract.EndContractBlock();\r
\r
-\r
+ if (targetPath==rootPath)\r
+ return true;\r
var targetSegments = targetPath.Split('\\');\r
var rootSegments = rootPath.Split('\\');\r
\r
private readonly AsyncManualResetEvent _syncEvent = new AsyncManualResetEvent();\r
\r
private readonly ConcurrentDictionary<string, DateTime> _lastSeen = new ConcurrentDictionary<string, DateTime>();\r
- private readonly ConcurrentDictionary<string, AccountInfo> _accounts = new ConcurrentDictionary<string,AccountInfo>();\r
+ private readonly ConcurrentDictionary<Uri, AccountInfo> _accounts = new ConcurrentDictionary<Uri,AccountInfo>();\r
\r
\r
/// <summary>\r
public void AddAccount(AccountInfo accountInfo)\r
{\r
//Avoid adding a duplicate accountInfo\r
- _accounts.TryAdd(accountInfo.UserName, accountInfo);\r
+ _accounts.TryAdd(accountInfo.AccountKey, accountInfo);\r
}\r
\r
public void RemoveAccount(AccountInfo accountInfo)\r
{\r
AccountInfo account;\r
- _accounts.TryRemove(accountInfo.UserName,out account);\r
+ _accounts.TryRemove(accountInfo.AccountKey, out account);\r
SnapshotDifferencer differencer;\r
- _differencer.Differencers.TryRemove(accountInfo.UserName, out differencer);\r
+ _differencer.Differencers.TryRemove(accountInfo.AccountKey, out differencer);\r
}\r
}\r
}\r
* -----------------------------------------------------------------------\r
*/\r
#endregion\r
+\r
+using System;\r
using System.Collections.Concurrent;\r
using System.Diagnostics.Contracts;\r
using Pithos.Interfaces;\r
\r
public class AccountsDifferencer\r
{\r
- readonly ConcurrentDictionary<string, SnapshotDifferencer> _differencers = new ConcurrentDictionary<string, SnapshotDifferencer>();\r
+ readonly ConcurrentDictionary<Uri, SnapshotDifferencer> _differencers = new ConcurrentDictionary<Uri, SnapshotDifferencer>();\r
\r
- public ConcurrentDictionary<string, SnapshotDifferencer> Differencers { get { return _differencers; } }\r
+ public ConcurrentDictionary<Uri, SnapshotDifferencer> Differencers { get { return _differencers; } }\r
\r
public SnapshotDifferencer PostSnapshot(AccountInfo accountInfo, List<ObjectInfo> cleanRemotes)\r
{\r
SnapshotDifferencer differencer;\r
- if (!_differencers.TryGetValue(accountInfo.UserName, out differencer))\r
+ if (!_differencers.TryGetValue(accountInfo.AccountKey, out differencer))\r
{\r
differencer = new SnapshotDifferencer();\r
- _differencers[accountInfo.UserName] = differencer;\r
+ _differencers[accountInfo.AccountKey] = differencer;\r
}\r
differencer.Post(cleanRemotes);\r
return differencer;\r
var permissionString= (string) reader.Value;
+ var permissions = ParsePermissions(permissionString);
+
+ return permissions;
+ }
+
+ public static Dictionary<string, string> ParsePermissions(string permissionString)
+ {
var permissions = (from permisson in permissionString.Split(';')
let parsed = permisson.Split('=')
from account in parsed[1].Split(',')
- select new { account, Permission = parsed[0] })
- .ToDictionary(perm=>perm.account,perm=>perm.Permission);
-
+ select new {account, Permission = parsed[0]})
+ .Distinct().ToDictionary(perm => perm.account, perm => perm.Permission);
return permissions;
}
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Pithos.Client.WPF.Test", "Pithos.Client.WPF.Test\Pithos.Client.WPF.Test.csproj", "{7B5BFE77-FC4D-43B3-84A0-9CB457238951}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Pithos.Interfaces.Test", "Pithos.Interfaces.Test\Pithos.Interfaces.Test.csproj", "{881F7260-CA40-40FD-AEEC-860B346DC2DC}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug All|Any CPU = Debug All|Any CPU
{7B5BFE77-FC4D-43B3-84A0-9CB457238951}.Test|Mixed Platforms.Build.0 = Release|Any CPU
{7B5BFE77-FC4D-43B3-84A0-9CB457238951}.Test|x64.ActiveCfg = Release|Any CPU
{7B5BFE77-FC4D-43B3-84A0-9CB457238951}.Test|x86.ActiveCfg = Release|Any CPU
+ {881F7260-CA40-40FD-AEEC-860B346DC2DC}.Debug All|Any CPU.ActiveCfg = Debug|Any CPU
+ {881F7260-CA40-40FD-AEEC-860B346DC2DC}.Debug All|Any CPU.Build.0 = Debug|Any CPU
+ {881F7260-CA40-40FD-AEEC-860B346DC2DC}.Debug All|Mixed Platforms.ActiveCfg = Debug|Any CPU
+ {881F7260-CA40-40FD-AEEC-860B346DC2DC}.Debug All|Mixed Platforms.Build.0 = Debug|Any CPU
+ {881F7260-CA40-40FD-AEEC-860B346DC2DC}.Debug All|x64.ActiveCfg = Debug|Any CPU
+ {881F7260-CA40-40FD-AEEC-860B346DC2DC}.Debug All|x86.ActiveCfg = Debug|Any CPU
+ {881F7260-CA40-40FD-AEEC-860B346DC2DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {881F7260-CA40-40FD-AEEC-860B346DC2DC}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {881F7260-CA40-40FD-AEEC-860B346DC2DC}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+ {881F7260-CA40-40FD-AEEC-860B346DC2DC}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+ {881F7260-CA40-40FD-AEEC-860B346DC2DC}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {881F7260-CA40-40FD-AEEC-860B346DC2DC}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {881F7260-CA40-40FD-AEEC-860B346DC2DC}.Premium Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {881F7260-CA40-40FD-AEEC-860B346DC2DC}.Premium Debug|Any CPU.Build.0 = Debug|Any CPU
+ {881F7260-CA40-40FD-AEEC-860B346DC2DC}.Premium Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+ {881F7260-CA40-40FD-AEEC-860B346DC2DC}.Premium Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+ {881F7260-CA40-40FD-AEEC-860B346DC2DC}.Premium Debug|x64.ActiveCfg = Debug|Any CPU
+ {881F7260-CA40-40FD-AEEC-860B346DC2DC}.Premium Debug|x86.ActiveCfg = Debug|Any CPU
+ {881F7260-CA40-40FD-AEEC-860B346DC2DC}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {881F7260-CA40-40FD-AEEC-860B346DC2DC}.Release|Any CPU.Build.0 = Release|Any CPU
+ {881F7260-CA40-40FD-AEEC-860B346DC2DC}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+ {881F7260-CA40-40FD-AEEC-860B346DC2DC}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+ {881F7260-CA40-40FD-AEEC-860B346DC2DC}.Release|x64.ActiveCfg = Release|Any CPU
+ {881F7260-CA40-40FD-AEEC-860B346DC2DC}.Release|x86.ActiveCfg = Release|Any CPU
+ {881F7260-CA40-40FD-AEEC-860B346DC2DC}.Test|Any CPU.ActiveCfg = Release|Any CPU
+ {881F7260-CA40-40FD-AEEC-860B346DC2DC}.Test|Any CPU.Build.0 = Release|Any CPU
+ {881F7260-CA40-40FD-AEEC-860B346DC2DC}.Test|Mixed Platforms.ActiveCfg = Release|Any CPU
+ {881F7260-CA40-40FD-AEEC-860B346DC2DC}.Test|Mixed Platforms.Build.0 = Release|Any CPU
+ {881F7260-CA40-40FD-AEEC-860B346DC2DC}.Test|x64.ActiveCfg = Release|Any CPU
+ {881F7260-CA40-40FD-AEEC-860B346DC2DC}.Test|x86.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
{E027200B-C26A-4877-BFD9-1A18CF5DF2F4} = {B5DD7C4D-D396-4C55-A8D5-DCFE865AA095}
{F9AF3E97-BCB7-46B7-8014-7FC858AEE9BA} = {B5DD7C4D-D396-4C55-A8D5-DCFE865AA095}
{7B5BFE77-FC4D-43B3-84A0-9CB457238951} = {B5DD7C4D-D396-4C55-A8D5-DCFE865AA095}
+ {881F7260-CA40-40FD-AEEC-860B346DC2DC} = {B5DD7C4D-D396-4C55-A8D5-DCFE865AA095}
EndGlobalSection
EndGlobal