コード例 #1
0
        public async Task <IEnumerable <PolicyTemplate> > GetLatestAsync()
        {
            var policyFiles = GetAllPolicyFiles();


            var policyTasks = policyFiles.Select(async filePath =>
            {
                {
                    var policyDocument = await ReadFileAsync(filePath);
                    var policyName     = Path.GetFileNameWithoutExtension(filePath);

                    var policy = new PolicyTemplate(
                        policyName,
                        policyDocument
                        );

                    return(policy);
                }
            }).ToArray();

            var policies = await Task.WhenAll(policyTasks);


            return(policies);
        }
コード例 #2
0
        private bool IsThereAToastAction(string policyFile)
        {
            PolicyTemplate template = new PolicyTemplate();
            template.Load(policyFile);

            List<IPolicy> policies = template.Policies;

            bool bToast = false;
            foreach (IPolicy policy in policies)
            {
                foreach (IPolicyChannel channel in policy.Channels)
                {
                    if (channel.Type == ChannelType.ActiveContent)
                    {
                        SortedList<int, IAction> internalActions = template[policy.Name.Value, ChannelType.ActiveContent, Routing.Internal];
                        SortedList<int, IAction> externalActions = template[policy.Name.Value, ChannelType.ActiveContent, Routing.External];

                        if (internalActions.Count > 1)
                        {
                            IAction internalToastAction = ActiveContentPolicy.GetToastAction(internalActions);
                            if (internalToastAction != null)
                                return true;
                        }

                        if (externalActions.Count > 1)
                        {
                            IAction externalToastAction = ActiveContentPolicy.GetToastAction(externalActions);
                            if (externalToastAction != null)
                                return true;
                        }
                     }
                }
            }
            return bToast;
        }
コード例 #3
0
        public void Properties_Will_Be_Set()
        {
            // Arrange
            var name           = "foo";
            var document       = "baaa";
            var policyTemplate = new PolicyTemplate(name, document);

            // Act
            var policy = Policy.Create(policyTemplate);

            // Assert
            Assert.Equal(name, policy.Name);
            Assert.Equal(document, policy.Document);
        }
コード例 #4
0
        public void CapabilityName_Will_Be_Replaced_In_Document()
        {
            // Arrange
            var name           = "foo";
            var document       = "foo capabilityName";
            var policyTemplate = new PolicyTemplate(name, document);
            var capabilityName = new CapabilityName("baaa");

            Func <PolicyTemplate, string> policyTemplateFormatter = (template) =>
            {
                return(template.Document.Replace("capabilityName", capabilityName.ToString().ToLower()));
            };

            // Act
            var policy = Policy.Create(policyTemplate, policyTemplateFormatter);

            // Assert
            var expectedDocument = "foo baaa";

            Assert.Equal(expectedDocument, policy.Document);
        }
コード例 #5
0
		public CleanPolicyForTests(PolicyTemplate template, Dictionary<RiskRating, List<string>> riskRatings, bool forceBinaryCleanEnabled)
			: base(template, riskRatings)
		{
			m_forceBinaryCleanEnabled = forceBinaryCleanEnabled;
		}
コード例 #6
0
 public MockActiveContentPolicy(PolicyTemplate template)
     : base(template)
 {
 }