• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Policy.Evidence类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: CreateDomainHelper

 protected static AppDomain CreateDomainHelper(string friendlyName, Evidence securityInfo, AppDomainSetup appDomainInfo)
 {
     if (friendlyName == null)
     {
         throw new ArgumentNullException(Environment.GetResourceString("ArgumentNull_String"));
     }
     if (securityInfo != null)
     {
         new SecurityPermission(SecurityPermissionFlag.ControlEvidence).Demand();
         AppDomain.CheckDomainCreationEvidence(appDomainInfo, securityInfo);
     }
     if (appDomainInfo == null)
     {
         appDomainInfo = new AppDomainSetup();
     }
     if ((appDomainInfo.AppDomainManagerAssembly == null) || (appDomainInfo.AppDomainManagerType == null))
     {
         string str;
         string str2;
         AppDomain.CurrentDomain.GetAppDomainManagerType(out str, out str2);
         if (appDomainInfo.AppDomainManagerAssembly == null)
         {
             appDomainInfo.AppDomainManagerAssembly = str;
         }
         if (appDomainInfo.AppDomainManagerType == null)
         {
             appDomainInfo.AppDomainManagerType = str2;
         }
     }
     return AppDomain.nCreateDomain(friendlyName, appDomainInfo, securityInfo, (securityInfo == null) ? AppDomain.CurrentDomain.InternalEvidence : null, AppDomain.CurrentDomain.GetSecurityDescriptor());
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:31,代码来源:AppDomainManager.cs


示例2: BuildChildDomain

 /// <summary>
 /// Creates a new child domain and copies the evidence from a parent domain.
 /// </summary>
 /// <param name="parentDomain">The parent domain.</param>
 /// <returns>The new child domain.</returns>
 /// <remarks>
 /// Grabs the <paramref name="parentDomain"/> evidence and uses it to construct the new
 /// <see cref="AppDomain"/> because in a ClickOnce execution environment, creating an
 /// <see cref="AppDomain"/> will by default pick up the partial trust environment of 
 /// the AppLaunch.exe, which was the root executable. The AppLaunch.exe does a 
 /// create domain and applies the evidence from the ClickOnce manifests to 
 /// create the domain that the application is actually executing in. This will 
 /// need to be Full Trust for Composite Application Library applications.
 /// </remarks>
 protected virtual AppDomain BuildChildDomain(AppDomain parentDomain)
 {
     Evidence evidence = new Evidence(parentDomain.Evidence);
     AppDomainSetup setup = parentDomain.SetupInformation;
     var domain = AppDomain.CreateDomain("DiscoveryRegion", evidence, setup);
     return domain;
 }
开发者ID:christal1980,项目名称:wingsoa,代码行数:21,代码来源:DirectoryModuleCatalog.cs


示例3: BuildChildDomain

 /// <summary>
 /// Creates a new AppDomain based on the parent AppDomains 
 /// Evidence and AppDomainSetup
 /// </summary>
 /// <param name="parentDomain">The parent AppDomain</param>
 /// <returns>A newly created AppDomain</returns>
 private AppDomain BuildChildDomain(AppDomain parentDomain)
 {
     Evidence evidence = new Evidence(parentDomain.Evidence);
     AppDomainSetup setup = parentDomain.SetupInformation;
     return AppDomain.CreateDomain("DiscoveryRegion",
         evidence, setup);
 }
开发者ID:ssickles,项目名称:archive,代码行数:13,代码来源:SeperateAppDomainAssemblyLoader.cs


示例4: Start

        /// <summary>
        /// Starts this instance.
        /// </summary>
        /// <exception cref="System.InvalidOperationException">Job already started.</exception>
        public static void Start()
        {
            if (_job != null)
                throw new InvalidOperationException("Job already started.");

            var evidence = new Evidence(AppDomain.CurrentDomain.Evidence);
            var setup = new AppDomainSetup
            {
                ApplicationBase = AppDomain.CurrentDomain.SetupInformation.ApplicationBase,
                ShadowCopyFiles = "false"
            };

            _appDomain = AppDomain.CreateDomain("eSync-" + Guid.NewGuid(), evidence, setup);
            try
            {
                var assembly = _appDomain.Load(typeof(SyncServiceJob).Assembly.GetName());
                var jobTypeName = typeof(SyncServiceJob).FullName;

                _job = (IJob)_appDomain.CreateInstanceAndUnwrap(assembly.FullName, jobTypeName);
                _job.Start();
            }
            catch
            {
                _job = null;
                AppDomain.Unload(_appDomain);
                _appDomain = null;

                throw;
            }
        }
开发者ID:mparsin,项目名称:Elements,代码行数:34,代码来源:ESyncJob.cs


示例5: RemoteDebugger

        public RemoteDebugger()
        {
            // Create a new debugger session
            mSessionId = Guid.NewGuid().ToString();

            Evidence evidence = new Evidence(AppDomain.CurrentDomain.Evidence);
            AppDomainSetup appDomainSetup = AppDomain.CurrentDomain.SetupInformation;

            mAppDomain = AppDomain.CreateDomain(String.Format("Debugger-{0}", mSessionId), evidence, appDomainSetup);

            /*
            Type assemblyLoaderType = typeof(AssemblyLoader);
            AssemblyLoader loader = mAppDomain.CreateInstanceAndUnwrap(assemblyLoaderType.Assembly.GetName().Name, assemblyLoaderType.FullName) as AssemblyLoader;

            foreach (String assemblyPath in Directory.GetFiles(DebuggerConfig.ApplicationPath, "Tridion*.dll"))
            {
                loader.LoadAssembly(assemblyPath);
            }
            */
            Type debuggerHostType = typeof(DebugEngineServer);

            mDebuggerHost = mAppDomain.CreateInstanceAndUnwrap(
                debuggerHostType.Assembly.GetName().Name,
                debuggerHostType.FullName,
                true,
                BindingFlags.Default,
                null,
                new Object[] { mSessionId },
                null,
                null) as DebugEngineServer;
        }
开发者ID:mvlasenko,项目名称:TridionVSRazorExtension,代码行数:31,代码来源:RemoteDebugger.cs


示例6: Check

		public void Check ()
		{
			ApplicationDirectoryMembershipCondition ad = new ApplicationDirectoryMembershipCondition ();
			Evidence e = null;
			Assert.IsFalse (ad.Check (e), "Check (null)");
			e = new Evidence ();
			Assert.IsFalse (ad.Check (e), "Check (empty)");
			e.AddHost (new Zone (SecurityZone.MyComputer));
			Assert.IsFalse (ad.Check (e), "Check (zone)");

			string codebase = Assembly.GetExecutingAssembly ().CodeBase;
			Url u = new Url (codebase);
			ApplicationDirectory adir = new ApplicationDirectory (codebase);

			e.AddHost (u);
			Assert.IsFalse (ad.Check (e), "Check (url-host)"); // not enough
			e.AddAssembly (adir);
			Assert.IsFalse (ad.Check (e), "Check (url-host+adir-assembly)");

			e = new Evidence ();
			e.AddHost (adir);
			Assert.IsFalse (ad.Check (e), "Check (adir-host)"); // not enough
			e.AddAssembly (u);
			Assert.IsFalse (ad.Check (e), "Check (url-assembly+adir-host)");

			e = new Evidence ();
			e.AddHost (u);
			e.AddHost (adir);
			Assert.IsTrue (ad.Check (e), "Check (url+adir host)"); // both!!
		}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:30,代码来源:ApplicationDirectoryMembershipConditionTest.cs


示例7: BaseVsaEngine

	// Constructor.
	internal BaseVsaEngine(String language, String version, bool supportDebug)
			{
				applicationPath = String.Empty;
				assemblyVersion = version;
				compiledRootNamespace = null;
				engineMoniker = String.Empty;
				engineName = String.Empty;
				engineSite = null;
				errorLocale = CultureInfo.CurrentCulture.LCID;
				executionEvidence = null;
				failedCompilation = false;
				genDebugInfo = false;
				haveCompiledState = false;
				isClosed = false;
				isDebugInfoSupported = supportDebug;
				isEngineCompiled = false;
				isEngineDirty = false;
				isEngineInitialized = false;
				isEngineRunning = false;
				loadedAssembly = null;
				rootNamespace = String.Empty;
				scriptLanguage = language;
				startupClass = null;
				startupInstance = null;
				vsaItems = null;
			}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:27,代码来源:BaseVsaEngine.cs


示例8: BaseVsaEngine

 internal BaseVsaEngine(string language, string version, bool supportDebug)
 {
     this.scriptLanguage = language;
     this.assemblyVersion = version;
     this.isDebugInfoSupported = supportDebug;
     this.executionEvidence = null;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:7,代码来源:BaseVsaEngine.cs


示例9: SandboxCreator

        public static AppDomain SandboxCreator()
        {
            CheckMono();
            #if RAZOR4
            Assert.Ignore("IsolatedRazorEngineServiceTestFixture is not tested with razor 4 as it is not signed!");
            #endif

            #if MONO
            // Mono has no AddHostEvidence or GetHostEvidence.
            // We do not run the tests anyway.
            return null;
            #else
            Evidence ev = new Evidence();
            ev.AddHostEvidence(new Zone(SecurityZone.Internet));
            PermissionSet permSet = SecurityManager.GetStandardSandbox(ev);
            // We have to load ourself with full trust
            StrongName razorEngineAssembly = typeof(RazorEngineService).Assembly.Evidence.GetHostEvidence<StrongName>();
            // We have to load Razor with full trust (so all methods are SecurityCritical)
            // This is because we apply AllowPartiallyTrustedCallers to RazorEngine, because
            // We need the untrusted (transparent) code to be able to inherit TemplateBase.
            // Because in the normal environment/appdomain we run as full trust and the Razor assembly has no security attributes
            // it will be completely SecurityCritical.
            // This means we have to mark a lot of our members SecurityCritical (which is fine).
            // However in the sandbox domain we have partial trust and because razor has no Security attributes that means the
            // code will be transparent (this is where we get a lot of exceptions, because we now have different security attributes)
            // To work around this we give Razor full trust in the sandbox as well.
            StrongName razorAssembly = typeof(RazorTemplateEngine).Assembly.Evidence.GetHostEvidence<StrongName>();
            // We trust ourself as well
            StrongName testAssembly = typeof(IsolatedRazorEngineServiceTestFixture).Assembly.Evidence.GetHostEvidence<StrongName>();
            AppDomainSetup adSetup = new AppDomainSetup();
            adSetup.ApplicationBase = AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
            AppDomain newDomain = AppDomain.CreateDomain("Sandbox", null, adSetup, permSet, razorEngineAssembly, razorAssembly, testAssembly);
            return newDomain;
            #endif
        }
开发者ID:rmeshksar,项目名称:RazorEngine,代码行数:35,代码来源:IsolatedRazorEngineServiceTestFixture.cs


示例10: Arrange

        protected override void Arrange()
        {
            base.Arrange();

            var fullyTrustedAssemblies = this.GetFullyTrustedAssemblies().ToArray();
            var unsignedAssemblies = fullyTrustedAssemblies.Where(sn => sn.PublicKey.ToString() == "");
            if (unsignedAssemblies.Any())
            {
                Assert.Inconclusive("Full trust assemblies must be signed. This test will be ignored. Unsigned assemblies: " + unsignedAssemblies.Aggregate("", (a, sn) => a + sn.Name + " "));
            }

            var evidence = new Evidence();
            evidence.AddHostEvidence(new Zone(SecurityZone.Intranet));
            var set = SecurityManager.GetStandardSandbox(evidence);
            this.AddPermissions(set);
            this.appDomain =
                AppDomain.CreateDomain(
                    "partial trust",
                    null,
                    AppDomain.CurrentDomain.SetupInformation,
                    set,
                    fullyTrustedAssemblies);

            this.loggerProxy = ((LoggerProxy)this.appDomain.CreateInstanceAndUnwrap(typeof(LoggerProxy).Assembly.FullName, typeof(LoggerProxy).FullName));
            this.loggerProxy.Setup();
        }
开发者ID:HondaBey,项目名称:EnterpriseLibrary6,代码行数:26,代码来源:TracerTransparencyFixture.cs


示例11: compile

 private Result compile(Input input)
 {
     Compiler compiler;
     Result r;
     System.AppDomain unitDomain = null;
     try
     {
         Evidence evidence = new Evidence(AppDomain.CurrentDomain.Evidence);
         AppDomainSetup setup = AppDomain.CurrentDomain.SetupInformation;
         unitDomain = AppDomain.CreateDomain("uTestDomain", evidence, setup);
         Type type = typeof(Compiler);
         compiler = (Compiler)unitDomain.CreateInstanceFrom(
                 type.Assembly.Location,
                 type.FullName).Unwrap();
         foreach (string s in GetAssemblies(Assembly.GetExecutingAssembly()))
         {
             compiler.LoadAssembly(s);
         }
         r = compiler.Compile(input);
     }
     finally
     {
         if (unitDomain != null) System.AppDomain.Unload(unitDomain);
     }
     return r;
 }
开发者ID:gkudel,项目名称:Testility,代码行数:26,代码来源:CompilerProxy.cs


示例12: CreatePermissionSet

        /*!*/
        private static PermissionSet CreatePermissionSet()
        {
            #if CLR2
            string name = "Internet";
            bool foundName = false;
            PermissionSet setIntersection = new PermissionSet(PermissionState.Unrestricted);

            // iterate over each policy level
            IEnumerator e = SecurityManager.PolicyHierarchy();
            while (e.MoveNext()) {
                PolicyLevel level = (PolicyLevel)e.Current;
                PermissionSet levelSet = level.GetNamedPermissionSet(name);
                if (levelSet != null) {
                    foundName = true;
                    setIntersection = setIntersection.Intersect(levelSet);
                }
            }

            if (setIntersection == null || !foundName) {
                setIntersection = new PermissionSet(PermissionState.None);
            } else {
                setIntersection = new NamedPermissionSet(name, setIntersection);
            }

            return setIntersection;
            #else
            // this functionality is not available on Mono (AddHostEvidence is undefined), use dynamic to resolve it at runtime
            dynamic e = new Evidence();
            e.AddHostEvidence(new Zone(SecurityZone.Internet));
            return SecurityManager.GetStandardSandbox((Evidence)e);
            #endif
        }
开发者ID:TerabyteX,项目名称:main,代码行数:33,代码来源:PartialTrustDriver.cs


示例13: Main

		static void Main(string[] args)
		{
			// Create the permission set to grant to other assemblies. 
			// In this case we are granting the permissions found in the LocalIntranet zone.
			PermissionSet permissionSet = GetNamedPermissionSet("LocalIntranet");
			if (permissionSet == null)
				return;
			AppDomainSetup appDomainSetup = new AppDomainSetup();
			// Identify the folder to use for the sandbox.
			Directory.CreateDirectory("C:\\Sandbox");
			appDomainSetup.ApplicationBase = "C:\\Sandbox";
			// Copy the application to be executed to the sandbox.
			File.Copy(@"..\..\..\NewConsoleApp\Bin\Debug\NewConsoleApp.exe",
				"C:\\sandbox\\NewConsoleApp.exe", true);
			File.Copy(@"..\..\..\NewConsoleApp\Bin\Debug\NewConsoleApp.pdb",
				"C:\\sandbox\\NewConsoleApp.pdb", true);

			Evidence hostEvidence = new Evidence();

			// Create the sandboxed domain.
			AppDomain sandbox = AppDomain.CreateDomain(
				"Sandboxed Domain",
				hostEvidence,
				appDomainSetup,
				permissionSet,
				GetStrongName(Assembly.GetExecutingAssembly()));
			sandbox.ExecuteAssemblyByName("NewConsoleApp");
		}
开发者ID:oblivious,项目名称:Oblivious,代码行数:28,代码来源:Program.cs


示例14: Load

        public static LoadedAssembly Load(String assemblyFilePath)
        {
            string currentExecutingAssemblyPath = Assembly.GetExecutingAssembly().Location;

            if (currentExecutingAssemblyPath.StartsWith("File:"))
                currentExecutingAssemblyPath = currentExecutingAssemblyPath.Substring(9).Replace("/", "\\");
            else if (string.IsNullOrWhiteSpace(currentExecutingAssemblyPath))
                currentExecutingAssemblyPath = Assembly.GetExecutingAssembly().CodeBase.Substring(9).Replace("/", "\\");

            string newAppDomainFolderPath = currentExecutingAssemblyPath.Substring(0, currentExecutingAssemblyPath.LastIndexOf("\\"));
            string tempAppDomainName = Guid.NewGuid().ToString();
            var appDomainSecurity = new Evidence(AppDomain.CurrentDomain.Evidence);

            AppDomain appDomain = AppDomain.CreateDomain(
                friendlyName: tempAppDomainName,
                securityInfo: appDomainSecurity,
                appBasePath: newAppDomainFolderPath,
                appRelativeSearchPath: null,
                shadowCopyFiles: true);

            FileLoader fileLoader = (FileLoader)appDomain.CreateInstanceAndUnwrap(
                Assembly.GetExecutingAssembly().FullName, typeof(FileLoader).FullName);

            Assembly assembly = fileLoader.LoadAssembly(assemblyFilePath);

            return new LoadedAssembly { Module = assembly, Domain = appDomain };
        }
开发者ID:Exclr8,项目名称:CloudCore,代码行数:27,代码来源:AssemblyLoader.cs


示例15: CreateDomain

        /// <summary>
        /// Construct an application domain for running a test package
        /// </summary>
        /// <param name="package">The TestPackage to be run</param>
        public AppDomain CreateDomain( TestPackage package )
        {
            AppDomainSetup setup = CreateAppDomainSetup(package);

            string domainName = "test-domain-" + package.Name;
            // Setup the Evidence
            Evidence evidence = new Evidence(AppDomain.CurrentDomain.Evidence);
            if (evidence.Count == 0)
            {
                Zone zone = new Zone(SecurityZone.MyComputer);
                evidence.AddHost(zone);
                Assembly assembly = Assembly.GetExecutingAssembly();
                Url url = new Url(assembly.CodeBase);
                evidence.AddHost(url);
                Hash hash = new Hash(assembly);
                evidence.AddHost(hash);
            }

            log.Info("Creating AppDomain " + domainName);

            AppDomain runnerDomain = AppDomain.CreateDomain(domainName, evidence, setup);

            // Set PrincipalPolicy for the domain if called for in the settings
            if (_settingsService != null && _settingsService.GetSetting("Options.TestLoader.SetPrincipalPolicy", false))
            {
                runnerDomain.SetPrincipalPolicy(_settingsService.GetSetting(
                    "Options.TestLoader.PrincipalPolicy", 
                    PrincipalPolicy.UnauthenticatedPrincipal));
            }

            return runnerDomain;
        }
开发者ID:alfeg,项目名称:nunit,代码行数:36,代码来源:DomainManager.cs


示例16: GenerateEvidence

 public EvidenceBase GenerateEvidence(Type evidenceType)
 {
     if (!this.m_targetDomain.IsDefaultAppDomain())
     {
         return AppDomain.GetDefaultDomain().GetHostEvidence(evidenceType);
     }
     if (this.m_entryPointEvidence == null)
     {
         Assembly entryAssembly = Assembly.GetEntryAssembly();
         RuntimeAssembly assembly2 = entryAssembly as RuntimeAssembly;
         if (assembly2 != null)
         {
             this.m_entryPointEvidence = assembly2.EvidenceNoDemand.Clone();
         }
         else if (entryAssembly != null)
         {
             this.m_entryPointEvidence = entryAssembly.Evidence;
         }
     }
     if (this.m_entryPointEvidence == null)
     {
         return null;
     }
     return this.m_entryPointEvidence.GetHostEvidence(evidenceType);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:25,代码来源:AppDomainEvidenceFactory.cs


示例17: DetermineApplicationTrust

		public virtual ApplicationTrust DetermineApplicationTrust (Evidence applicationEvidence, Evidence activatorEvidence, TrustManagerContext context)
		{
			if (applicationEvidence == null)
				throw new ArgumentNullException ("applicationEvidence");

			ActivationArguments aa = null;
			foreach (object o in applicationEvidence) {
				aa = (o as ActivationArguments);
				if (aa != null)
					break;
			}

			if (aa == null) {
				string msg = Locale.GetText ("No {0} found in {1}.");
				throw new ArgumentException (string.Format (msg, "ActivationArguments", "Evidence"), "applicationEvidence");
			}
			if (aa.ActivationContext == null) {
				string msg = Locale.GetText ("No {0} found in {1}.");
				throw new ArgumentException (string.Format (msg, "ActivationContext", "ActivationArguments"), "applicationEvidence");
			}

			// FIXME: this part is still untested (requires manifest support)
			if (ApplicationSecurityManager.DetermineApplicationTrust (aa.ActivationContext, context)) {
				if (aa.ApplicationIdentity == null)
					return new ApplicationTrust ();
				else
					return new ApplicationTrust (aa.ApplicationIdentity);
			}
			return null;
		}
开发者ID:runefs,项目名称:Marvin,代码行数:30,代码来源:HostSecurityManager.cs


示例18: URLString

        bool IReportMatchMembershipCondition.Check(Evidence evidence, out object usedEvidence)
        {
            usedEvidence = null;

            if (evidence == null)
                return false;

            ApplicationDirectory dir = evidence.GetHostEvidence<ApplicationDirectory>();
            Url url = evidence.GetHostEvidence<Url>();

            if (dir != null && url != null)
            {
                // We need to add a wildcard at the end because IsSubsetOf keys off of it.
                String appDir = dir.Directory;
                
                if (appDir != null && appDir.Length > 1)
                {
                    if (appDir[appDir.Length-1] == '/')
                        appDir += "*";
                    else
                        appDir += "/*";
                    
                    URLString appDirString = new URLString(appDir);
                    if (url.GetURLString().IsSubsetOf(appDirString))
                    {
                        usedEvidence = dir;
                        return true;
                    }
                }
            }
            
            return false;
        }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:33,代码来源:ApplicationDirectoryMembershipCondition.cs


示例19: CreateInstanceHelper

		protected static ObjectHandle CreateInstanceHelper (AppDomainSetup adSetup)
		{
			if (adSetup == null)
				throw new ArgumentNullException ("adSetup");

			if (adSetup.ActivationArguments == null) {
				string msg = Locale.GetText ("{0} is missing it's {1} property");
				throw new ArgumentException (String.Format (msg, "AppDomainSetup", "ActivationArguments"), "adSetup");
			}

			HostSecurityManager hsm = null;
			if (AppDomain.CurrentDomain.DomainManager != null)
				hsm = AppDomain.CurrentDomain.DomainManager.HostSecurityManager;
			else
				hsm = new HostSecurityManager (); // default

			Evidence applicationEvidence = new Evidence ();
			applicationEvidence.AddHost (adSetup.ActivationArguments);
			TrustManagerContext context = new TrustManagerContext ();
			ApplicationTrust trust = hsm.DetermineApplicationTrust (applicationEvidence, null, context);
			if (!trust.IsApplicationTrustedToRun) {
				string msg = Locale.GetText ("Current policy doesn't allow execution of addin.");
				throw new PolicyException (msg);
			}

			// FIXME: we're missing the information from the manifest
			AppDomain ad = AppDomain.CreateDomain ("friendlyName", null, adSetup);
			return ad.CreateInstance ("assemblyName", "typeName", null);
		}
开发者ID:runefs,项目名称:Marvin,代码行数:29,代码来源:ApplicationActivator.cs


示例20: Check

		// Methods
		public bool Check (Evidence evidence)
		{
			if (evidence == null)
				return false;

			string codebase = Assembly.GetCallingAssembly ().CodeBase;
			Uri local = new Uri (codebase);
			Url ucode = new Url (codebase);

			// *both* ApplicationDirectory and Url must be in *Host* evidences
			bool adir = false;
			bool url = false;
			IEnumerator e = evidence.GetHostEnumerator ();
			while (e.MoveNext ()) {
				object o = e.Current;

				if (!adir && (o is ApplicationDirectory)) {
					ApplicationDirectory ad = (o as ApplicationDirectory);
					string s = ad.Directory;
					adir = (String.Compare (s, 0, local.ToString (), 0, s.Length, true, CultureInfo.InvariantCulture) == 0);
				}
				else if (!url && (o is Url)) {
					url = ucode.Equals (o);
				}

				// got both ?
				if (adir && url)
					return true;
			}
			return false;
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:32,代码来源:ApplicationDirectoryMembershipCondition.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Policy.PolicyLevel类代码示例发布时间:2022-05-26
下一篇:
C# Policy.ApplicationTrust类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap