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

C# Policy类代码示例

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

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



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

示例1: Main

        static void Main(string[] args)
        {
            // create web service proxy
            // NOTE!!! When updating web reference in Visual Studio,
            // don't forget to change its base class to Microsoft.Web.Services3.WebServicesClientProtocol then
            WseSample.Service srv = new WseSample.Service();

            // create custom SOAP header and assign it to web service
            WseSample.BankAccountSettings settings = new WseSample.BankAccountSettings();
            settings.PinCode = "1111";
            srv.BankAccountSettingsValue = settings;

            // create custom policy assertion and assign it to proxy
            // for password we just use reversed username
            // it's important, because UsernameTokenManager on the service side applies the same logic
            // when looking for user password
            UsernameClientAssertion assert = new UsernameClientAssertion("admin", "nimda");

            // create policy
            Policy policy = new Policy();
            policy.Assertions.Add(assert);

            // and set it to web service
            srv.SetPolicy(policy);

            // invoke web service method
            bool valid = srv.CheckAccountStatus("123456");
            Debug.WriteLine(valid);
        }
开发者ID:lozano28,项目名称:Wsecustom,代码行数:29,代码来源:Program.cs


示例2: Main

        static void Main(string[] args)
        {
            MyMathServiceWse serviceProxy = new MyMathServiceWse();

            //UsernameToken token = new UsernameToken("zhang3", "f0f5671b9ec568d03cbe126ce135a8b3d6ce6ab2", PasswordOption.SendPlainText);
            //serviceProxy.SetClientCredential(token);

            //X509Certificate2 myServerCert = new X509Certificate2("myServer.pem.cer");
            //serviceProxy.SetServiceCredential(new X509SecurityToken(myServerCert));

            

            
            UsernameForCertificateAssertion assert = new UsernameForCertificateAssertion();
            assert.RenewExpiredSecurityContext = true;
            assert.RequireSignatureConfirmation = false;
            assert.Protection.DefaultOperation.Request.CustomSignedHeaders.Clear();
            assert.Protection.DefaultOperation.Request.EncryptBody = true;
            assert.Protection.DefaultOperation.Request.SignatureOptions = SignatureOptions.IncludeNone;
            assert.Protection.DefaultOperation.Response.EncryptBody = false;
            assert.Protection.DefaultOperation.Response.SignatureOptions = SignatureOptions.IncludeNone;

            MutualCertificate10Assertion assertion1 = new MutualCertificate10Assertion()
            {
                EstablishSecurityContext = false,
                RenewExpiredSecurityContext = true,
                RequireSignatureConfirmation = false,
                MessageProtectionOrder = MessageProtectionOrder.SignBeforeEncrypt,
                RequireDerivedKeys = false,
                TtlInSeconds = 300
            };
            //assertion1.ClientX509TokenProvider = new X509TokenProvider(StoreLocation.CurrentUser, StoreName.My, "CN=myClient,OU=R & D department,O=BJ SOS Software Tech Co.\\, Ltd,L=Beijing,ST=Beijing,C=CN", X509FindType.FindBySubjectDistinguishedName);
            assertion1.ClientX509TokenProvider = new X509TokenProvider(StoreLocation.CurrentUser, StoreName.My, "1364458997", X509FindType.FindBySerialNumber);
            assertion1.ServiceX509TokenProvider = new X509TokenProvider(StoreLocation.CurrentUser, StoreName.AddressBook, "1364458964", X509FindType.FindBySerialNumber);
            Console.Out.WriteLine(111);
            Console.Out.WriteLine(assertion1.ClientX509TokenProvider.GetToken()); 
            Console.Out.WriteLine(111);
            Console.Out.WriteLine(assertion1.ServiceX509TokenProvider.GetToken());
            Console.Out.WriteLine(222);
            //protection
            assertion1.Protection.Request.SignatureOptions = SignatureOptions.IncludeSoapBody;
            assertion1.Protection.Request.EncryptBody = true;
            assertion1.Protection.Response.SignatureOptions = SignatureOptions.IncludeSoapBody;
            assertion1.Protection.Response.EncryptBody = true;
            assertion1.Protection.Fault.SignatureOptions = SignatureOptions.IncludeSoapBody;
            assertion1.Protection.Fault.EncryptBody = false;

            Policy policy = new Policy();
            policy.Assertions.Add(assertion1);
            serviceProxy.SetPolicy(policy);

            //serviceProxy.RequestSoapContext.Addressing.Action = new Action("http://www.test.me/MyMath/add");

            addRequest req = new addRequest();
            req.x = 1;
            req.y = 2;
            addResponse resp = serviceProxy.add(req);
            Console.Out.WriteLine("resp = " + [email protected]);
             
        }
开发者ID:freakynit,项目名称:btpka3.github.com,代码行数:60,代码来源:Program.cs


示例3: Forum

 public Forum(String name, List<User> admins, Policy policy)
 {
     if (name == null || name.Length < 1)
     {
         Console.Out.WriteLine("Error: u idiot");
     }
     else if (admins == null || admins.Count < 1)
     {
         Console.Out.WriteLine("Error: u idiot2");
     }
     else if (policy == null)
     {
         Console.Out.WriteLine("Error: u idiot3");
     }
     else
     {
         this.name = name;
         for (int i = 0; i < admins.Count; i++)
         {
             this.members.Add(admins.ElementAt(i));
             this.admins.Add(i);
         }
         subforums = new List<SubForum>();
         this.policy = policy;
     }
 }
开发者ID:javitolin,项目名称:wsep142,代码行数:26,代码来源:Forum.cs


示例4: Enqueue

 public static void Enqueue(WaitCallback callback, Policy policy)
 {
     switch(policy)
     {
         case Policy.Immediate:
             logger.Info("Immediately running callback {0}",
                 callback.Method.Name);
             ThreadPool.QueueUserWorkItem(new WaitCallback(callback));
             break;
         case Policy.Queued:
             lock (queue)
             {
                 if (cooledDown)
                 {
                     logger.Info("Immediately putting callback {0}",
                         callback.Method.Name);
                     ThreadPool.QueueUserWorkItem(
                         new WaitCallback(callback));
                 }
                 else
                 {
                     logger.Debug("Queuing callback {0} for later execution",
                         callback.Method.Name);
                     queue.Add(callback);
                 }
             }
             break;
     }
 }
开发者ID:hamishhill,项目名称:Beat-Machine,代码行数:29,代码来源:ExecutionQueue.cs


示例5: ReadJsonStringToPolicy

        public static Policy ReadJsonStringToPolicy(string jsonString)
        {
            Policy policy = new Policy();
            JsonData jPolicy = JsonMapper.ToObject(jsonString);

            if (jPolicy[JsonDocumentFields.POLICY_ID] != null && jPolicy[JsonDocumentFields.POLICY_ID].IsString)
            {
                policy.Id = (string)jPolicy[JsonDocumentFields.POLICY_ID];
            }

            JsonData jStatements = jPolicy[JsonDocumentFields.STATEMENT] as JsonData;
            if (jStatements != null && jStatements.IsArray)
            {
                foreach (JsonData jStatement in jStatements)
                {
                    Statement statement = convertStatement(jStatement);
                    if (statement != null)
                    {
                        policy.Statements.Add(statement);
                    }
                }
            }

            return policy;
        }
开发者ID:aws,项目名称:aws-sdk-net,代码行数:25,代码来源:JsonPolicyReader.cs


示例6: Configure

        public void Configure(WebServicesClientProtocol proxy)
        {
            // set proxy URL
            string serverUrl = enterpriseServerUrl.Trim();
            if (serverUrl.Length == 0)
                throw new Exception("Enterprise Server URL could not be empty");

            int idx = proxy.Url.LastIndexOf("/");

            // strip the last slash if any
            if (serverUrl[serverUrl.Length - 1] == '/')
                serverUrl = serverUrl.Substring(0, serverUrl.Length - 1);

            proxy.Url = serverUrl + proxy.Url.Substring(idx);

            // set timeout
            proxy.Timeout = 900000; //15 minutes // System.Threading.Timeout.Infinite;

            if (!String.IsNullOrEmpty(username))
            {
                // create assertion
                UsernameAssertion assert = new UsernameAssertion(username, password);

                // apply policy
                Policy policy = new Policy();
                policy.Assertions.Add(assert);

                proxy.SetPolicy(policy);
            }
        }
开发者ID:lwhitelock,项目名称:Websitepanel,代码行数:30,代码来源:EnterpriseServerProxyConfigurator.cs


示例7: TextUndoTransaction

 public TextUndoTransaction(TextUndoHistory textUndoHistory, ITextUndoTransaction parent)
 {
     _textUndoHistory = textUndoHistory;
     _state = UndoTransactionState.Open;
     _parent = parent;
     MergePolicy = new Policy();
 }
开发者ID:rride,项目名称:VsVim,代码行数:7,代码来源:TextUndoTransaction.cs


示例8: Page_Init

 protected void Page_Init(object sender, EventArgs e)
 {
     ctx = new AriClinicContext("AriClinicContext");
     // security control, it must be a user logged
     if (Session["User"] == null)
         Response.Redirect("Default.aspx");
     else
     {
         user = CntAriCli.GetUser((Session["User"] as User).UserId, ctx);
         Process proc = (from p in ctx.Processes
                         where p.Code == "policy"
                         select p).FirstOrDefault<Process>();
         per = CntAriCli.GetPermission(user.UserGroup, proc, ctx);
         btnAccept.Visible = per.Modify;
     }
     // 
     if (Request.QueryString["CustomerId"] != null)
     {
         patientId = Int32.Parse(Request.QueryString["CustomerId"]);
         pat = CntAriCli.GetCustomer(patientId, ctx);
         txtCustomer.Text = pat.FullName;
     }
     // 
     if (Request.QueryString["PolicyId"] != null)
     {
         policyId = Int32.Parse(Request.QueryString["PolicyId"]);
         pol = CntAriCli.GetPolicy(policyId, ctx);
         LoadData(pol);
     }
     else
     {
         LoadTypeCombo(null);
         LoadInsuranceCombo(null);
     }
 }
开发者ID:ragare62,项目名称:AriClinic,代码行数:35,代码来源:PolicyForm.aspx.cs


示例9: AddAssertion

		public void AddAssertion(PolicyAssertion assertion)
		{
			if (_securityPolicy == null)
				_securityPolicy = new Policy();

			_securityPolicy.Assertions.Add(assertion);
		}
开发者ID:jordan49,项目名称:websitepanel,代码行数:7,代码来源:ProxyConfigurator.cs


示例10: Executing_the_asynchronous_policies_using_the_synchronous_execute_should_throw_an_invalid_operation_exception

        public void Executing_the_asynchronous_policies_using_the_synchronous_execute_should_throw_an_invalid_operation_exception(Policy asyncPolicy, string description)
        {
            Action action = () => asyncPolicy.Execute(() => { });

            action.ShouldThrow<InvalidOperationException>()
                .WithMessage("Please use the synchronous Retry, RetryForever, WaitAndRetry or CircuitBreaker methods when calling the synchronous Execute method.");
        }
开发者ID:christopherbahr,项目名称:Polly,代码行数:7,代码来源:PolicySpecs.cs


示例11: PolicyDomainModel

 public PolicyDomainModel(Policy policyEntity)
 {
   Id = policyEntity.Id;
   Number = policyEntity.Number;
   SerialNumber = policyEntity.SerialNumber;
   DeviceName = policyEntity.DeviceName;
 }
开发者ID:pcarswell,项目名称:cscc-claims-system-prototype,代码行数:7,代码来源:PolicyDomainModel.cs


示例12: writePolicy

        private void writePolicy(Policy policy, JsonWriter generator)
        {
            generator.WriteObjectStart();

            writePropertyValue(generator, JsonDocumentFields.VERSION, policy.Version);

            if (policy.Id != null)
            {
                writePropertyValue(generator, JsonDocumentFields.POLICY_ID, policy.Id);
            }

            generator.WritePropertyName(JsonDocumentFields.STATEMENT);
            generator.WriteArrayStart();
            foreach (Statement statement in policy.Statements)
            {
                generator.WriteObjectStart();
                if (statement.Id != null)
                {
                    writePropertyValue(generator, JsonDocumentFields.STATEMENT_ID, statement.Id);
                }
                writePropertyValue(generator, JsonDocumentFields.STATEMENT_EFFECT, statement.Effect.ToString());

                writePrincipals(statement, generator);
                writeActions(statement, generator);
                writeResources(statement, generator);
                writeConditions(statement, generator);

                generator.WriteObjectEnd();
            }
            generator.WriteArrayEnd();

            generator.WriteObjectEnd();
        }
开发者ID:friism,项目名称:AWS-SDK-for-.NET,代码行数:33,代码来源:JsonPolicyWriter.cs


示例13: AsyncExists

 public AsyncExists(AsyncCluster cluster, Policy policy, Key key, ExistsListener listener)
     : base(cluster)
 {
     this.policy = policy;
     this.listener = listener;
     this.key = key;
     this.partition = new Partition(key);
 }
开发者ID:Caldas,项目名称:aerospike-client-csharp,代码行数:8,代码来源:AsyncExists.cs


示例14: Init

        /// <summary>
        /// 对某个WS进行初始化
        /// </summary>
        /// <param name="ws"></param>
        /// <param name="username"></param>
        /// <param name="password"></param>
        public static void Init(WebServicesClientProtocol ws, string username, string password)
        {
            AppContext.UserName = username;
            AppContext.Password = password;

            Policy policy = new Policy();
            policy.Assertions.Add(new MyAssertion());
            ws.SetPolicy(policy);
        }
开发者ID:reckcn,项目名称:DevLib.Comm,代码行数:15,代码来源:WebServiceIniter.cs


示例15: ExsistingPolicy

        public bool ExsistingPolicy(Policy toCheck)
        {
            var currentList = GetAll();

            foreach (var c in currentList)
            {
                if (c.Title == toCheck.Title)
                    return true;
            }

            return false;
        }
开发者ID:paul-bargerstock,项目名称:Examples,代码行数:12,代码来源:PoliciesDatabase.cs


示例16: GetDeferredProxy

        public WSCommerceIntegrationServiceImplService GetDeferredProxy()
        {
            var proxy = new WSCommerceIntegrationServiceImplService();

            proxy.Url = "https://tbk.orangepeople.cl/WSWebpayTransaction/cxf/WSCommerceIntegrationService";

            Policy policy = new Policy();
            CustomPolicyAssertion customPolicy = new CustomPolicyAssertion(this.IssuerCertificateName, this.TransbankCertificateName);
            policy.Assertions.Add(customPolicy);
            proxy.SetPolicy(policy);
            proxy.Timeout = 60000;
            proxy.UseDefaultCredentials = false;

            return proxy;
        }
开发者ID:jpvillaseca,项目名称:DNN-Modules-3G,代码行数:15,代码来源:DeferredWrapper.cs


示例17: Add

        /// <summary>
        /// 向缓存中添加一项。
        /// </summary>
        /// <param name="key"></param>
        /// <param name="value"></param>
        /// <param name="policy">缓存使用的策略(一般是过期策略)</param>
        /// <param name="region"></param>
        /// <returns></returns>
        public bool Add(string key, object value, Policy policy, string region = null)
        {
            if (value == null) return false;
            ChangeChecker checker = null;
            if (policy != null)
            {
                checker = policy.Checker;
            }

            return this.AddCore(region, key, new StoredValue()
            {
                Value = value,
                Checker = checker
            });
        }
开发者ID:569550384,项目名称:Rafy,代码行数:23,代码来源:CacheProvider.cs


示例18: Delete

        public void Delete(Policy delPolicy)
        {
            var currentList = GetAll();
            currentList.RemoveAll(c => c.Title == delPolicy.Title);

            File.Delete(_filepath);

            using (var writer = File.CreateText(_filepath))
            {
                foreach (var c in currentList)
                {
                    writer.WriteLine("{0}^{1}^{2}^{3}", c.Id, c.Category, c.Title, c.Content);
                }
            }
        }
开发者ID:paul-bargerstock,项目名称:Examples,代码行数:15,代码来源:PoliciesDatabase.cs


示例19: RunHardCodePolicy

        public XmlDocument RunHardCodePolicy(XmlDocument request)
        {
            //load request into typed document
            TypedXmlDocument txd = new TypedXmlDocument("AdaptivIntegration.BizTalkSample.SampleSchema", request);

            //load BRE policy from the BTS Rules Engine DB
            Policy policy = new Policy("AdaptivIntegration.BizTalkSample.Policy");

            //Execute the policy
            policy.Execute(txd);

            //load up modified document as response
            XmlDocument response = new XmlDocument();
            response.LoadXml(txd.Document.OuterXml);

            return response;
        }
开发者ID:nikolaiblackie,项目名称:Adaptiv.MuleDotNetSamples.DotNet,代码行数:17,代码来源:SampleBreCall.cs


示例20: ToPolicy

        public Policy ToPolicy()
        {

            
            
            var policy = new Policy {ReportOnlyMode = ReportOnly, ReportUri = ReportUri};
            policy.AddDirective(AllowedSources.AsDirective("default-src"));
            policy.AddDirective(AllowedFontSources.AsDirective("font-src"));
            policy.AddDirective(AllowedFrameAncestors.AsDirective("frame-ancestors"));
            policy.AddDirective(AllowedFrameSources.AsDirective("frame-src"));
            policy.AddDirective(AllowedImageSources.AsDirective("img-src"));
            policy.AddDirective(AllowedMediaSources.AsDirective("media-src"));
            policy.AddDirective(AllowedObjectSources.AsDirective("object-src"));
            policy.AddDirective(AllowedStyleSources.AsDirective("style-src"));
            policy.AddDirective(AllowedConnectSources.AsAliasedDirective("connect-src", "xhr-src"));
            policy.AddDirective(AllowedScriptSources.AsDirective("script-src"));
            return policy;
        }
开发者ID:eoftedal,项目名称:ContentSecurityPolicy.Net,代码行数:18,代码来源:ContentSecurityPolicySection.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# PolicyContainer类代码示例发布时间:2022-05-24
下一篇:
C# PokerHandsChecker类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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