IsDomain() static private method

static private IsDomain ( IsolatedStorageScope scope ) : bool
scope IsolatedStorageScope
return bool
Example #1
0
        public override void Remove()
        {
            // Deletes the current IsoFile's directory and the identity folder if possible.
            // (e.g. @"C:\Users\jerem\AppData\Local\IsolatedStorage\10v31ho4.bo2\eeolfu22.f2w\Url.qgeirsoc3cznuklvq5xlalurh1m0unxl\AssemFiles\")

            // This matches .NET Framework logic. We want to try and clean as well as possible without being more aggressive with the identity folders.
            // (e.g. Url.qgeirsoc3cznuklvq5xlalurh1m0unxl, etc.) We don't want to inadvertently yank folders for a different scope under the same
            // identity (at least no more so than NetFX).

            try
            {
                Directory.Delete(RootDirectory, recursive: true);
            }
            catch
            {
                throw new IsolatedStorageException(SR.IsolatedStorage_DeleteDirectories);
            }

            Close();

            string?parentDirectory = Path.GetDirectoryName(RootDirectory.TrimEnd(Path.DirectorySeparatorChar));

            Debug.Assert(parentDirectory != null);

            if (ContainsUnknownFiles(parentDirectory))
            {
                return;
            }

            try
            {
                Directory.Delete(parentDirectory, recursive: true);
            }
            catch
            {
                return;
            }

            // Domain paths are doubly nested
            // @"C:\Users\jerem\AppData\Local\IsolatedStorage\10v31ho4.bo2\eeolfu22.f2w\Url.qgeirsoc3cznuklvq5xlalurh1m0unxl\Url.qgeirsoc3cznuklvq5xlalurh1m0unxl\Files\"
            if (Helper.IsDomain(Scope))
            {
                parentDirectory = Path.GetDirectoryName(parentDirectory);
                Debug.Assert(parentDirectory != null);

                if (ContainsUnknownFiles(parentDirectory))
                {
                    return;
                }

                try
                {
                    Directory.Delete(parentDirectory, recursive: true);
                }
                catch
                {
                    return;
                }
            }
        }
Example #2
0
        // Data file notes
        // ===============

        // "identity.dat" is the serialized identity object, such as StrongName or Url. It is used to
        // enumerate stores, which we currently do not support.
        //
        // private const string IDFile = "identity.dat";

        // "info.dat" is used to track disk space usage (against quota). The accounting file for Silverlight
        // stores is "appInfo.dat". .NET Core is always in full trust so we can safely ignore these.
        //
        // private const string InfoFile = "info.dat";
        // private const string AppInfoFile = "appInfo.dat";

        internal IsolatedStorageFile(IsolatedStorageScope scope)
        {
            // Evidence isn't currently available: https://github.com/dotnet/runtime/issues/18208
            // public static IsolatedStorageFile GetStore(IsolatedStorageScope scope, Evidence domainEvidence, Type domainEvidenceType, Evidence assemblyEvidence, Type assemblyEvidenceType) { return default(IsolatedStorageFile); }

            // InitStore will set up the IdentityHash
            InitStore(scope, null, null);

            StringBuilder sb = new StringBuilder(Helper.GetRootDirectory(scope));

            sb.Append(SeparatorExternal);
            sb.Append(IdentityHash);
            sb.Append(SeparatorExternal);

            if (Helper.IsApplication(scope))
            {
                sb.Append(s_appFiles);
            }
            else if (Helper.IsDomain(scope))
            {
                sb.Append(s_files);
            }
            else
            {
                sb.Append(s_assemFiles);
            }
            sb.Append(SeparatorExternal);

            _rootDirectory = sb.ToString();
            Helper.CreateDirectory(_rootDirectory, scope);
        }
Example #3
0
        // https://github.com/dotnet/corefx/issues/10935
        // Evidence isn't currently available
        // public static IsolatedStorageFile GetStore(IsolatedStorageScope scope, Evidence domainEvidence, Type domainEvidenceType, Evidence assemblyEvidence, Type assemblyEvidenceType) { return default(IsolatedStorageFile); }

        private void Initialize(IsolatedStorageScope scope)
        {
            // InitStore will set up the IdentityHash
            InitStore(scope, null, null);

            StringBuilder sb = new StringBuilder(Helper.GetRootDirectory(scope));

            sb.Append(SeparatorExternal);
            sb.Append(IdentityHash);
            sb.Append(SeparatorExternal);

            if (Helper.IsApplication(scope))
            {
                sb.Append(s_appFiles);
            }
            else if (Helper.IsDomain(scope))
            {
                sb.Append(s_files);
            }
            else
            {
                sb.Append(s_assemFiles);
            }
            sb.Append(SeparatorExternal);

            _rootDirectory = sb.ToString();
            Helper.CreateDirectory(_rootDirectory, scope);
        }
Example #4
0
        protected void InitStore(IsolatedStorageScope scope, Type domainEvidenceType, Type assemblyEvidenceType)
        {
            VerifyScope(scope);
            Scope = scope;

            object identity;
            string hash;

            Helper.GetDefaultIdentityAndHash(out identity, out hash, SeparatorInternal);

            if (Helper.IsApplication(scope))
            {
                _applicationIdentity = identity;
            }
            else
            {
                if (Helper.IsDomain(scope))
                {
                    _domainIdentity = identity;
                    hash            = $"{hash}{SeparatorExternal}{hash}";
                }

                _assemblyIdentity = identity;
            }

            IdentityHash = hash;
        }
Example #5
0
        private bool IsMatchingScopeDirectory(string directory)
        {
            string directoryName = Path.GetFileName(directory);

            return
                ((Helper.IsApplication(Scope) && string.Equals(directoryName, s_appFiles, StringComparison.Ordinal)) ||
                 (Helper.IsAssembly(Scope) && string.Equals(directoryName, s_assemFiles, StringComparison.Ordinal)) ||
                 (Helper.IsDomain(Scope) && string.Equals(directoryName, s_files, StringComparison.Ordinal)));
        }
Example #6
0
        protected void InitStore(IsolatedStorageScope scope, Type?domainEvidenceType, Type?assemblyEvidenceType)
        {
            VerifyScope(scope);
            Scope = scope;

            Helper.GetDefaultIdentityAndHash(out object identity, out string hash, SeparatorInternal);

            if (Helper.IsApplication(scope))
            {
                _applicationIdentity = identity;
            }
            else
            {
                if (Helper.IsDomain(scope))
                {
                    _domainIdentity = identity;
                    hash            = string.Create(null, stackalloc char[128], $"{hash}{SeparatorExternal}{hash}");
                }

                _assemblyIdentity = identity;
            }

            IdentityHash = hash;
        }