当前位置: 首页>>代码示例>>C#>>正文


C# IsolatedStorageScope类代码示例

本文整理汇总了C#中IsolatedStorageScope的典型用法代码示例。如果您正苦于以下问题:C# IsolatedStorageScope类的具体用法?C# IsolatedStorageScope怎么用?C# IsolatedStorageScope使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


IsolatedStorageScope类属于命名空间,在下文中一共展示了IsolatedStorageScope类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetDataDirectory

        internal static string GetDataDirectory(IsolatedStorageScope scope)
        {
            // This is the relevant special folder for the given scope plus "IsolatedStorage".
            // It is meant to replicate the behavior of the VM ComIsolatedStorage::GetRootDir().

            string dataDirectory = null;

            if (IsMachine(scope))
            {
                dataDirectory = ApplicationData.Current.SharedLocalFolder.Path;
            }
            else
            {
                if (!IsRoaming(scope))
                {
                    dataDirectory = ApplicationData.Current.LocalFolder.Path;
                }
                else
                {
                    dataDirectory = ApplicationData.Current.RoamingFolder.Path;
                }
            }

            dataDirectory = Path.Combine(dataDirectory, IsolatedStorageDirectoryName);

            return dataDirectory;
        }
开发者ID:geoffkizer,项目名称:corefx,代码行数:27,代码来源:Helper.WinRT.cs

示例2: DomainIdentityIsSet

 public void DomainIdentityIsSet(IsolatedStorageScope scope)
 {
     TestStorage storage = new TestStorage(scope);
     Assert.NotNull(storage.AssemblyIdentity);
     Assert.NotNull(storage.DomainIdentity);
     Assert.Throws<InvalidOperationException>(() => storage.ApplicationIdentity);
 }
开发者ID:dotnet,项目名称:corefx,代码行数:7,代码来源:IdentityTests.cs

示例3: GetRootDirectory

        internal static string GetRootDirectory(IsolatedStorageScope scope)
        {
            // The full root directory is the relevant special folder from Environment.GetFolderPath() plus "IsolatedStorage"
            // and a set of random directory names if not roaming. The current identity gets tacked on after this.

            if (IsRoaming(scope))
            {
                if (string.IsNullOrEmpty(s_roamingUserRootDirectory))
                {
                    s_roamingUserRootDirectory = GetDataDirectory(scope);
                }
                return s_roamingUserRootDirectory;
            }

            if (IsMachine(scope))
            {
                if (string.IsNullOrEmpty(s_machineRootDirectory))
                {
                    s_machineRootDirectory = GetDataDirectory(scope);
                }
                return s_machineRootDirectory;
            }

            if (string.IsNullOrEmpty(s_userRootDirectory))
                s_userRootDirectory = GetDataDirectory(scope);

            return s_userRootDirectory;
        }
开发者ID:shmao,项目名称:corefx,代码行数:28,代码来源:Helper.cs

示例4: GetDataDirectory

        internal static string GetDataDirectory(IsolatedStorageScope scope)
        {
            // This is the relevant special folder for the given scope plus "IsolatedStorage".
            // It is meant to replicate the behavior of the VM ComIsolatedStorage::GetRootDir().

            // (note that Silverlight used "CoreIsolatedStorage" for a directory name and did not support machine scope)

            string dataDirectory = null;

            if (IsMachine(scope))
            {
                // SpecialFolder.CommonApplicationData -> C:\ProgramData
                dataDirectory = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);
            }
            else if (IsRoaming(scope))
            {
                // SpecialFolder.ApplicationData -> C:\Users\Joe\AppData\Roaming
                dataDirectory = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
            }
            else
            {
                // SpecialFolder.LocalApplicationData -> C:\Users\Joe\AppData\Local
                dataDirectory = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
            }

            dataDirectory = Path.Combine(dataDirectory, IsolatedStorageDirectoryName);

            return dataDirectory;
        }
开发者ID:Corillian,项目名称:corefx,代码行数:29,代码来源:Helper.Win32.Unix.cs

示例5: GetStore

    /*
    public static IsolatedStorageFile GetStore(IsolatedStorageScope scope, System.Security.Policy.Evidence domainEvidence, Type domainEvidenceType, System.Security.Policy.Evidence assemblyEvidence, Type assemblyEvidenceType)
    {
      Contract.Requires(domainEvidence != null);
      Contract.Requires(assemblyEvidence != null);

      return default(IsolatedStorageFile);
    }
     */
    public static IsolatedStorageFile GetStore(IsolatedStorageScope scope, object domainIdentity, object assemblyIdentity)
    {
      Contract.Requires(domainIdentity != null);
      Contract.Requires(assemblyIdentity != null);

      return default(IsolatedStorageFile);
    }
开发者ID:asvishnyakov,项目名称:CodeContracts,代码行数:16,代码来源:System.IO.IsolatedStorage.IsolatedStorageFile.cs

示例6: GetRootDirectory

        /// <summary>
        /// The full root directory is the relevant special folder from Environment.GetFolderPath() plus "IsolatedStorage"
        /// and a set of random directory names if not roaming.
        /// 
        /// Examples:
        /// 
        ///     User: @"C:\Users\jerem\AppData\Local\IsolatedStorage\10v31ho4.bo2\eeolfu22.f2w\"
        ///     User|Roaming: @"C:\Users\jerem\AppData\Roaming\IsolatedStorage\"
        ///     Machine: @"C:\ProgramData\IsolatedStorage\nin03cyc.wr0\o3j0urs3.0sn\"
        /// 
        /// Identity for the current store gets tacked on after this.
        /// </summary>
        internal static string GetRootDirectory(IsolatedStorageScope scope)
        {
            if (IsRoaming(scope))
            {
                if (string.IsNullOrEmpty(s_roamingUserRootDirectory))
                {
                    s_roamingUserRootDirectory = GetDataDirectory(scope);
                }
                return s_roamingUserRootDirectory;
            }

            if (IsMachine(scope))
            {
                if (string.IsNullOrEmpty(s_machineRootDirectory))
                {
                    s_machineRootDirectory = GetRandomDirectory(GetDataDirectory(scope), scope);
                }
                return s_machineRootDirectory;
            }

            if (string.IsNullOrEmpty(s_userRootDirectory))
                s_userRootDirectory = GetRandomDirectory(GetDataDirectory(scope), scope);

            return s_userRootDirectory;
        }
开发者ID:Corillian,项目名称:corefx,代码行数:37,代码来源:Helper.cs

示例7: GetRandomDirectory

        internal static string GetRandomDirectory(string rootDirectory, IsolatedStorageScope scope)
        {
            string randomDirectory = GetExistingRandomDirectory(rootDirectory);
            if (string.IsNullOrEmpty(randomDirectory))
            {
                using (Mutex m = CreateMutexNotOwned(rootDirectory))
                {
                    if (!m.WaitOne())
                    {
                        throw new IsolatedStorageException(SR.IsolatedStorage_Init);
                    }

                    try
                    {
                        randomDirectory = GetExistingRandomDirectory(rootDirectory);
                        if (string.IsNullOrEmpty(randomDirectory))
                        {
                            // Someone else hasn't created the directory before we took the lock
                            randomDirectory = Path.Combine(rootDirectory, Path.GetRandomFileName(), Path.GetRandomFileName());
                            CreateDirectory(randomDirectory, scope);
                        }
                    }
                    finally
                    {
                        m.ReleaseMutex();
                    }
                }
            }

            return randomDirectory;
        }
开发者ID:Corillian,项目名称:corefx,代码行数:31,代码来源:Helper.cs

示例8: IsolatedStorageSettings

 public IsolatedStorageSettings(
     bool useIsolatedStore,
     IsolatedStorageScope isolationScope
     )
 {
     UseIsolatedStore = useIsolatedStore;
     _isolationScope = isolationScope;
 }
开发者ID:alienwaredream,项目名称:toolsdotnet,代码行数:8,代码来源:IsolatedStorageSettings.cs

示例9: IsolatedStorageFileEnumerator

 internal IsolatedStorageFileEnumerator(IsolatedStorageScope scope)
 {
     this.m_Scope = scope;
     this.m_fiop = IsolatedStorageFile.GetGlobalFileIOPerm(scope);
     this.m_rootDir = IsolatedStorageFile.GetRootDir(scope);
     this.m_fileEnum = new TwoLevelFileEnumerator(this.m_rootDir);
     this.Reset();
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:8,代码来源:IsolatedStorageFileEnumerator.cs

示例10: GetRandomDirectory

 public void GetRandomDirectory(IsolatedStorageScope scope)
 {
     using (var temp = new TempDirectory())
     {
         string randomDir = Helper.GetRandomDirectory(temp.Path, scope);
         Assert.True(Directory.Exists(randomDir));
     }
 }
开发者ID:kouvel,项目名称:corefx,代码行数:8,代码来源:HelperTests.cs

示例11: IsolatedStorageFileEnumerator

		public IsolatedStorageFileEnumerator (IsolatedStorageScope scope, string root)
		{
			_scope = scope;
			// skip application-isolated storages
			if (Directory.Exists (root))
				_storages = Directory.GetDirectories (root, "d.*");
			_pos = -1;
		}
开发者ID:jack-pappas,项目名称:mono,代码行数:8,代码来源:IsolatedStorageFileEnumerator.cs

示例12: IsolatedStorageFile

	// Constructor.
	internal IsolatedStorageFile(IsolatedStorageScope scope,
								 String baseDirectory)
			{
				InitStore(scope, null, null);
				this.baseDirectory = baseDirectory;
				this.refCount = 1;
				this.closed = false;
			}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:9,代码来源:IsolatedStorageFile.cs

示例13: GetEnumerator

		private void GetEnumerator (IsolatedStorageScope scope)
		{
			IEnumerator e = IsolatedStorageFile.GetEnumerator (scope);
			int n = 0;
			while (e.MoveNext ())
			{
				IsolatedStorageFile isf = (IsolatedStorageFile)e.Current;
				CheckEnumerated (++n, scope, isf);
			}
		}
开发者ID:nkuln,项目名称:mono,代码行数:10,代码来源:IsolatedStorageFileTest.cs

示例14: CreateDirectory

        internal static void CreateDirectory(string path, IsolatedStorageScope scope)
        {
            if (Directory.Exists(path))
                return;

            DirectoryInfo info = Directory.CreateDirectory(path);

            if (IsMachine(scope) && RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                // Need to emulate COMIsolatedStorage::CreateDirectoryWithDacl(), which gives the following rights:
                //
                //  World / Everyone (S-1-1-0 / SECURITY_WORLD_RID) -> (FILE_GENERIC_WRITE | FILE_GENERIC_READ) & (~WRITE_DAC)
                //  Creator Owner (S-1-3-0 / SECURITY_CREATOR_OWNER_RID) -> FILE_ALL_ACCESS
                //  Local Admins (S-1-5-32 / SECURITY_BUILTIN_DOMAIN_RID & DOMAIN_ALIAS_RID_ADMINS) -> FILE_ALL_ACCESS
                // 
                // When looking at rights through the GUI it looks like this:
                //
                //  "Everyone" -> Read, Write
                //  "Administrators" -> Full control
                //  "CREATOR OWNER" -> Full control
                //
                // With rights applying to "This folder, subfolders, and files". No inheritance from the parent folder.
                //
                // Note that trying to reset the rules for CREATOR OWNER leaves the current directory with the actual creator's SID.
                // (But applies CREATOR OWNER as expected for items and subdirectories.) Setting up front when creating the directory
                // doesn't exhibit this behavior, but as we can't currently do that we'll take the rough equivalent for now.

                DirectorySecurity security = new DirectorySecurity();

                // Don't inherit the existing rules
                security.SetAccessRuleProtection(isProtected: true, preserveInheritance: false);
                security.AddAccessRule(new FileSystemAccessRule(
                    identity: new SecurityIdentifier(WellKnownSidType.WorldSid, null),
                    fileSystemRights: FileSystemRights.Read | FileSystemRights.Write,
                    inheritanceFlags: InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit,
                    propagationFlags: PropagationFlags.None,
                    type: AccessControlType.Allow));

                security.AddAccessRule(new FileSystemAccessRule(
                    identity: new SecurityIdentifier(WellKnownSidType.BuiltinAdministratorsSid, null),
                    fileSystemRights: FileSystemRights.FullControl,
                    inheritanceFlags: InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit,
                    propagationFlags: PropagationFlags.None,
                    type: AccessControlType.Allow));

                security.AddAccessRule(new FileSystemAccessRule(
                    identity: new SecurityIdentifier(WellKnownSidType.CreatorOwnerSid, null),
                    fileSystemRights: FileSystemRights.FullControl,
                    inheritanceFlags: InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit,
                    propagationFlags: PropagationFlags.None,
                    type: AccessControlType.Allow));

                info.SetAccessControl(security);
            }
        }
开发者ID:kouvel,项目名称:corefx,代码行数:55,代码来源:Helper.Win32.Unix.cs

示例15: InitStore_InvalidScopes

 public void InitStore_InvalidScopes(IsolatedStorageScope scope)
 {
     try
     {
         s_verifyScopeMethod.Invoke(null, new object[] { scope });
     }
     catch (TargetInvocationException e)
     {
         Assert.IsType<ArgumentException>(e.InnerException);
     }
 }
开发者ID:Corillian,项目名称:corefx,代码行数:11,代码来源:GetStoreTests.cs


注:本文中的IsolatedStorageScope类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。