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


C# FileIOPermission.Deny方法代码示例

本文整理汇总了C#中System.Security.Permissions.FileIOPermission.Deny方法的典型用法代码示例。如果您正苦于以下问题:C# FileIOPermission.Deny方法的具体用法?C# FileIOPermission.Deny怎么用?C# FileIOPermission.Deny使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Security.Permissions.FileIOPermission的用法示例。


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

示例1: Setup

 public virtual void Setup()
 {
     var sp = new FileIOPermission(PermissionState.Unrestricted);
     sp.Assert();
     string prefix;
     if (Environment.CurrentDirectory.EndsWith("target"))
     {
         prefix = "../../";
     }
     else
     {
         prefix = "../../../";
     }
     sp.Deny();
     Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US");
     BridgeSetup setup=new BridgeSetup (false){Verbose = true, Debug = true};
     setup.IgnoreJavaHome = true;
     setup.AddJVMOption("-Xmx512m");
     setup.AddClassPath(prefix + "jni4net.j/target/classes");
     setup.AddClassPath(prefix + "jni4net.tested.j/target/classes");
     setup.AddClassPath(prefix + "jni4net.test.j/target/test-classes");
     //setup.JavaHome = @"c:\Program Files (x86)\Java\ibm_sdk60";
     env = Bridge.CreateJVM(setup);
     Bridge.RegisterAssembly(typeof(TestBase).Assembly);
     Bridge.RegisterAssembly(typeof(JavaInstanceFields).Assembly);
 }
开发者ID:Mazrick,项目名称:jni4net,代码行数:26,代码来源:TestBase.cs

示例2: Main

 static void Main(string[] args)
 {
     CodeAccessPermission permission = new FileIOPermission(FileIOPermissionAccess.AllAccess,@"c:\");
      permission.Deny();
      UntrustworthyClass.Method();
      CodeAccessPermission.RevertDeny();
 }
开发者ID:alannet,项目名称:example,代码行数:7,代码来源:Class1.cs

示例3: RunInternal

        private object RunInternal(MethodOverloads methodOverloads, object[] rawParams)
        {
            // TODO: Security
            FileIOPermission phoenixLauncherFile = new FileIOPermission(FileIOPermissionAccess.AllAccess, System.IO.Path.Combine(Core.Directory, "PhoenixLauncher.xml"));
            phoenixLauncherFile.Deny();

            // First create ParameterData array
            ParameterData[] parameters = new ParameterData[rawParams.Length];
            for (int i = 0; i < rawParams.Length; i++) {
                parameters[i] = new ParameterData(rawParams[i]);
            }

            // Get valid overloads (array is never empty)
            Method[] methods = methodOverloads.FindOverloads(parameters);

            Exception exception = null;

            foreach (Method m in methods) {
                ExecutionInfo info = new ExecutionInfo(m);

                ExecutionAttribute[] execAttributes = (ExecutionAttribute[])m.MethodInfo.GetCustomAttributes(typeof(ExecutionAttribute), false);

                try {
                    // Call all Execution attributes
                    for (int i = 0; i < execAttributes.Length; i++) {
                        execAttributes[i].Starting(m);
                    }

                    // Add execution to running list
                    lock (syncRoot) {
                        if (runningExecutions.Count >= Executions.MaxExecutions) {
                            throw new RuntimeException("Executions limit exceeded.");
                        }

                        RuntimeCore.AddAssemblyObject(info, this);
                        runningExecutions.Add(info);

                        try {
                            // Raise Started event
                            executionStarted.Invoke(this, new ExecutionsChangedEventArgs(info));
                        }
                        catch (Exception e) {
                            Core.ShowMessageBoxAsync("Unhandled exception in Executions.ExecutionStarted event handler.\r\nMessage: " + e.Message, "Warning");
                        }
                    }

                    // Init thread-dependent classes
                    if (!threadInitialized) {
                        ScriptErrorException.ThreadInit();
                        WorldData.World.ThreadInit();
                        Journal.ThreadInit();
                        threadInitialized = true;
                    }

                    // Invoke
                    try {
                        return m.Invoke(parameters);
                    }
                    catch (System.Reflection.TargetInvocationException e) {
                        // Im interested only in exception thrown by code
                        throw e.InnerException;
                    }
                }
                catch (ParameterException e) {
                    exception = e;
                }
                catch (ExecutionBlockedException e) {
                    exception = e;
                }
                finally {
                    // Remove execution from running list
                    lock (syncRoot) {
                        runningExecutions.Remove(info);
                        RuntimeCore.RemoveAssemblyObject(info);

                        try {
                            // Raise Finished event
                            executionFinished.Invoke(this, new ExecutionsChangedEventArgs(info));
                        }
                        catch (Exception e) {
                            Core.ShowMessageBoxAsync("Unhandled exception in Executions.ExecutionFinished event handler.\r\nMessage: " + e.Message, "Warning");
                        }
                    }

                    // Call all Execution attributes
                    for (int i = 0; i < execAttributes.Length; i++) {
                        execAttributes[i].Finished(m);
                    }
                }
            }

            if (exception != null) {
                throw exception;
            }
            else {
                throw new InternalErrorException();
            }
        }
开发者ID:greeduomacro,项目名称:phoenix,代码行数:98,代码来源:Executions.cs

示例4: FileIOPermission

 public void FileIOPermission()
 {
   FileIOPermission f = new FileIOPermission(PermissionState.Unrestricted);
   f.Deny();
   try
   {
     IStateName2 proxy = (IStateName2)XmlRpcProxyGen.Create(typeof(IStateName2));
   }
   finally
   {
     CodeAccessPermission.RevertDeny();
   }
 }
开发者ID:wbrussell,项目名称:xmlrpcnet,代码行数:13,代码来源:proxygentest.cs

示例5: Log3

 public static void Log3(string text)
 {
     CodeAccessPermission p = new FileIOPermission(PermissionState.Unrestricted);
     p.Deny();
 }
开发者ID:dbremner,项目名称:smokey,代码行数:5,代码来源:PermitDenySecurityTest.cs


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