public void Matches_Drive() { var rule = new AttributeRule(); var drive = new DriveObject(@"C:", null); var result = rule.Matches(drive, null); }
/// <summary> /// Print the attribute /// /// </summary> /// <param name="item"></param> /// <returns></returns> private TreeViewItem PrintAttribute(AttributeRule item) { TreeViewItem attributeItem = new TreeViewItem(); attributeItem.Header = "Attribute - " + item.attributeName; if (item.cardinality != "") { attributeItem.Items.Add("Cardinality: " + item.cardinality); } List <EntityRule> allEntityRules = item.getEntityRules(); if (allEntityRules.Any()) { TreeViewItem entityRulesItems = new TreeViewItem(); entityRulesItems.Header = "EntityRules"; foreach (var item1 in allEntityRules) { TreeViewItem treeViewItem1 = new TreeViewItem(); treeViewItem1 = PrintEntityRule(item1); entityRulesItems.Items.Add(treeViewItem1); } attributeItem.Items.Add(entityRulesItems); } return(attributeItem); }
public void SimpleRuleSolver_solves_AttributeRule() { var mventry = new MockMventry(); mventry["uid"].Value = "espenaske"; mventry["givenName"].Value = "per"; var attributeRule = new AttributeRule() { IsPresent = true, Attribute = "uid", RequiredValue = "espenaske" }; var attributeRule2 = new AttributeRule() { Attribute = "givenName", RequiredValue = "per" }; var provRule = new ProvisionRule(); provRule.AttributeRules = new[] { attributeRule, attributeRule2 }; var ruleSolver = new SimpleRuleSolver(provRule); bool solved = ruleSolver.PassesRule(mventry); Assert.IsTrue(solved); }
private void getEntityRules2(AttributeRule attributeRule) { foreach (EntityRule er in attributeRule.getEntityRules()) { ChosenEntities.Add(er.entityName); foreach (AttributeRule ar in er.getAttributeRules()) { getEntityRules2(ar); } } }
private void FindEntityRules(AttributeRule AttRule) { //Console.WriteLine("AttributeName: {0}, EntityRules count: {1}", AttRule.attributeName, AttRule.getEntityRules().Count); List <EntityRule> listEnRules = AttRule.getEntityRules(); foreach (EntityRule en in listEnRules) { //Console.WriteLine("EntityName={0}", en.entityName); ChosenEntities.Add(en.entityName); FindAttributeRules(en); } }
public void Matches_File_False() { var fileSystem = new MockFileSystem(); fileSystem.RegisterFile(@"C:\file"); var rule = new AttributeRule(FileAttributes.Hidden); var file = new FileObject(@"C:\file", fileSystem); var result = rule.Matches(file, null); Assert.AreEqual(false, result); }
public void Matches_Directory_Directory() { var fileSystem = new MockFileSystem(); fileSystem.RegisterDirectory(@"C:\dir"); var rule = new AttributeRule(FileAttributes.Directory); var directory = new DirectoryObject(@"C:\dir", fileSystem); var result = rule.Matches(directory, null); Assert.AreEqual(true, result); }
public void Matches_File_True() { var fileSystem = new MockFileSystem(); fileSystem.RegisterFile(@"C:\file", FileAttributes.Archive); var rule = new AttributeRule(FileAttributes.Archive); var file = new FileObject(@"C:\file", fileSystem); var result = rule.Matches(file, null); Assert.AreEqual(true, result); }
public IQueryable <xAttribute> GetAttributes([FromODataUri] AttributeRule valueRule) { var qry = base.DbContext.Attributes.Where(x => x.Rules == valueRule); return(qry.AsQueryable()); }
private static Templates DisplayTemplates(XmlNode node, ConceptTemplate conceptTemplate, Templates templates, bool subTemplates, bool rules, AttributeRule attributeRule, EntityRule entityRule) { //Print the node type, node name and node value of the node if (node.Name == "ConceptTemplate") { conceptTemplate = new ConceptTemplate(); if (node.Attributes != null) { XmlAttributeCollection attrs = node.Attributes; foreach (XmlAttribute attr in attrs) { switch (attr.Name) { case "uuid": conceptTemplate.setUUID(attr.Value); break; case "name": conceptTemplate.name = attr.Value; break; case "code": conceptTemplate.code = attr.Value; break; case "status": break; case "applicableSchema": conceptTemplate.applicableSchema = attr.Value; break; case "applicableEntity": conceptTemplate.applicableEntity = attr.Value; break; } } } templates.addConceptTemplate(conceptTemplate.getUUID(), conceptTemplate); } else if (node.Name == "Definition") { foreach (XmlNode childNode in node.ChildNodes) { Definition definition = new Definition(); definition.setBody(childNode.InnerText); conceptTemplate.addDefinition(definition); } } else if (node.Name == "SubTemplates") { templates = new Templates(); conceptTemplate.addTemplates(templates); } else if (node.Name == "Rules") { rules = true; } else if (node.Name == "AttributeRule") { attributeRule = new AttributeRule(); if (node.Attributes != null) { XmlAttributeCollection attrs = node.Attributes; foreach (XmlAttribute attr in attrs) { if (attr.Name == "AttributeName") { attributeRule.attributeName = attr.Value; } else if (attr.Name == "Cardinality") { attributeRule.cardinality = attr.Value; } } } if (rules == true) { conceptTemplate.addAttributeRule(attributeRule); } else { entityRule.addAttributeRule(attributeRule); } } else if (node.Name == "EntityRule") { rules = false; entityRule = new EntityRule(); string attributeName = attributeRule.attributeName; if (!String.IsNullOrEmpty(attributeName)) { if (node.Attributes != null) { XmlAttributeCollection attrs = node.Attributes; foreach (XmlAttribute attr in attrs) { if (attr.Name == "EntityName") { entityRule.entityName = attr.Value; } else if (attr.Name == "Cardinality") { entityRule.cardinality = attr.Value; } } } attributeRule.addEntityRule(entityRule); } } else { Console.WriteLine("Type = [" + node.NodeType + "] Name = " + node.Name); } //Print attributes of the node if (node.Attributes != null) { XmlAttributeCollection attrs = node.Attributes; foreach (XmlAttribute attr in attrs) { Console.WriteLine("Attribute Name = " + attr.Name + "; Attribute Value = " + attr.Value); } } //Print individual children of the node, gets only direct children of the node XmlNodeList children = node.ChildNodes; foreach (XmlNode child in children) { DisplayTemplates(child, conceptTemplate, templates, subTemplates, rules, attributeRule, entityRule); } return(templates); }