public override IDeepCopyable CopyTo(IDeepCopyable other) { var dest = other as Provenance; if (dest != null) { base.CopyTo(dest); if (Target != null) { dest.Target = new List <Hl7.Fhir.Model.ResourceReference>(Target.DeepCopy()); } if (Period != null) { dest.Period = (Hl7.Fhir.Model.Period)Period.DeepCopy(); } if (RecordedElement != null) { dest.RecordedElement = (Hl7.Fhir.Model.Instant)RecordedElement.DeepCopy(); } if (Reason != null) { dest.Reason = new List <Hl7.Fhir.Model.CodeableConcept>(Reason.DeepCopy()); } if (Activity != null) { dest.Activity = (Hl7.Fhir.Model.CodeableConcept)Activity.DeepCopy(); } if (Location != null) { dest.Location = (Hl7.Fhir.Model.ResourceReference)Location.DeepCopy(); } if (PolicyElement != null) { dest.PolicyElement = new List <Hl7.Fhir.Model.FhirUri>(PolicyElement.DeepCopy()); } if (Agent != null) { dest.Agent = new List <Hl7.Fhir.Model.Provenance.AgentComponent>(Agent.DeepCopy()); } if (Entity != null) { dest.Entity = new List <Hl7.Fhir.Model.Provenance.EntityComponent>(Entity.DeepCopy()); } if (Signature != null) { dest.Signature = new List <Hl7.Fhir.Model.Signature>(Signature.DeepCopy()); } return(dest); } else { throw new ArgumentException("Can only copy to an object of the same type", "other"); } }
private static void CreateConfigWithCallHandlers(ContainerElement c) { var interceptionElement = new InterceptionElement(); var policy = new PolicyElement() { Name = "PolicyOne" }; policy.MatchingRules.Add(new MatchingRuleElement() { Name = "All", TypeName = "AlwaysMatchingRule" }); policy.CallHandlers.Add(new CallHandlerElement() { Name = "NamedRule" }); policy.CallHandlers.Add(new CallHandlerElement() { Name = "NameAndType", TypeName = "DoMoreRule" }); policy.CallHandlers.Add(new CallHandlerElement() { Name = "HandlerWithLifetime", TypeName = "DoSomethingRule", Lifetime = new LifetimeElement() { TypeName = "singleton" } }); var handlerWithMembers = new CallHandlerElement() { Name = "HandlerWithElements", TypeName = "CallCountHandler" }; handlerWithMembers.Injection.Add(new ConstructorElement()); handlerWithMembers.Injection.Add(new PropertyElement() { Name = "MyProp" }); policy.CallHandlers.Add(handlerWithMembers); interceptionElement.Policies.Add(policy); c.ConfiguringElements.Add(interceptionElement); }
private static void CreateConfigWithMatchingRules(ContainerElement c) { var interceptionElement = new InterceptionElement(); var policy = new PolicyElement() { Name = "PolicyOne" }; policy.MatchingRules.Add(new MatchingRuleElement() { Name = "NameOnly" }); policy.MatchingRules.Add(new MatchingRuleElement() { Name = "NameAndType", TypeName = "AlwaysMatchingRule" }); policy.MatchingRules.Add(new MatchingRuleElement { Name = "RuleWithLifetime", TypeName = "AlwaysMatchingRule", Lifetime = new LifetimeElement() { TypeName = "singleton" } }); var ruleWithMembers = new MatchingRuleElement { Name = "RuleWithElements", TypeName = "AlwaysMatchingRule" }; ruleWithMembers.Injection.Add(new ConstructorElement()); ruleWithMembers.Injection.Add(new PropertyElement() { Name = "MyProp" }); policy.MatchingRules.Add(ruleWithMembers); interceptionElement.Policies.Add(policy); c.ConfiguringElements.Add(interceptionElement); }
public override ErrorList Validate() { var result = new ErrorList(); result.AddRange(base.Validate()); if (Target != null) { Target.ForEach(elem => result.AddRange(elem.Validate())); } if (Period != null) { result.AddRange(Period.Validate()); } if (RecordedElement != null) { result.AddRange(RecordedElement.Validate()); } if (Reason != null) { result.AddRange(Reason.Validate()); } if (Location != null) { result.AddRange(Location.Validate()); } if (PolicyElement != null) { PolicyElement.ForEach(elem => result.AddRange(elem.Validate())); } if (Agent != null) { Agent.ForEach(elem => result.AddRange(elem.Validate())); } if (Entity != null) { Entity.ForEach(elem => result.AddRange(elem.Validate())); } if (SignatureElement != null) { result.AddRange(SignatureElement.Validate()); } return(result); }
private PolicyElement CreatePolicyElementByName(string labelName) { var policy = new PolicyElement(); policy.Model.Name = labelName; var pcolor = ""; foreach (var color in PoliciesColor) { if (!PolicyColorExisted.Contains(color)) { pcolor = color; break; } } policy.Model.IsAddState = true; policy.Model.ExpanderBackgroundColor = pcolor; policy._editTimeStart = DateTime.Now; return(policy); }
/// <summary> /// Creates a new runtime policy set evaluation. /// </summary> /// <param name="engine">The evaluation engine.</param> /// <param name="policySet">The policy set defined in the policy document.</param> public PolicySet(EvaluationEngine engine, PolicySetElement policySet) { if (engine == null) { throw new ArgumentNullException("engine"); } if (policySet == null) { throw new ArgumentNullException("policySet"); } _policySet = policySet; // Create a runtime target of this policy set. if (policySet.Target != null) { _target = new Target((TargetElement)policySet.Target); foreach (ResourceElement resource in policySet.Target.Resources.ItemsList) { foreach (ResourceMatchElement rmatch in resource.Match) { if (!_allResources.Contains(rmatch.AttributeValue.Contents)) { _allResources.Add(rmatch.AttributeValue.Contents); } } } } // Add all the policies (or policy set) inside this policy set. foreach (object child in policySet.Policies) { var childPolicySet = child as PolicySetElement; var childPolicyElement = child as PolicyElement; var childPolicySetIdReference = child as PolicySetIdReferenceElement; var childPolicyIdReferenceElement = child as PolicyIdReferenceElement; if (childPolicySet != null) { var policySetEv = new PolicySet(engine, childPolicySet); foreach (string rName in policySetEv.AllResources) { if (!_allResources.Contains(rName)) { _allResources.Add(rName); } } _policies.Add(policySetEv); } else if (childPolicyElement != null) { var policyEv = new Policy(childPolicyElement); foreach (string rName in policyEv.AllResources) { if (!_allResources.Contains(rName)) { _allResources.Add(rName); } } _policies.Add(policyEv); } else if (childPolicySetIdReference != null) { PolicySetElement policySetDefinition = EvaluationEngine.Resolve(childPolicySetIdReference); if (policySetDefinition != null) { var policySetEv = new PolicySet(engine, policySetDefinition); foreach (string rName in policySetEv.AllResources) { if (!_allResources.Contains(rName)) { _allResources.Add(rName); } } _policies.Add(policySetEv); } else { throw new EvaluationException(string.Format(Properties.Resource.exc_policyset_reference_not_resolved, ((PolicySetIdReferenceElement)child).PolicySetId)); } } else if (childPolicyIdReferenceElement != null) { PolicyElement policyDefinition = EvaluationEngine.Resolve(childPolicyIdReferenceElement); if (policyDefinition != null) { var policyEv = new Policy(policyDefinition); foreach (string rName in policyEv.AllResources) { if (!_allResources.Contains(rName)) { _allResources.Add(rName); } } _policies.Add(policyEv); } else { throw new EvaluationException(string.Format(Properties.Resource.exc_policy_reference_not_resolved, ((PolicyIdReferenceElement)child).PolicyId)); } } } }
public PolicyElementViewModel(PolicyElement view) { _view = view; EditPolicyCommand = new RelayCommand(ExecuteEditPolicy); ChangeSelectedCommand = new RelayCommand(OnChangeSelectedCommand); }
private static void CreateConfigWithMatchingRules(ContainerElement c) { var interceptionElement = new InterceptionElement(); var policy = new PolicyElement() {Name = "PolicyOne"}; policy.MatchingRules.Add(new MatchingRuleElement() { Name = "NameOnly" }); policy.MatchingRules.Add(new MatchingRuleElement() { Name = "NameAndType", TypeName = "AlwaysMatchingRule" }); policy.MatchingRules.Add(new MatchingRuleElement { Name = "RuleWithLifetime", TypeName = "AlwaysMatchingRule", Lifetime = new LifetimeElement() { TypeName = "singleton" } }); var ruleWithMembers = new MatchingRuleElement { Name = "RuleWithElements", TypeName = "AlwaysMatchingRule" }; ruleWithMembers.Injection.Add(new ConstructorElement()); ruleWithMembers.Injection.Add(new PropertyElement() { Name = "MyProp" } ); policy.MatchingRules.Add(ruleWithMembers); interceptionElement.Policies.Add(policy); c.ConfiguringElements.Add(interceptionElement); }
private void BuildPage() { ApplicationContext.PoliciesList = new List <PolicyElementViewModel>(); if (ApplicationContext.POCAgentList == null) { Functions.GetAllPolicies(); } if (ApplicationContext.POCAgentList.Count > 0) { BtnSaveVisible = true; } else { BtnSaveVisible = false; } _view.PnlPolicyContainer.Children.Clear(); PolicyColorExisted = new List <string>(); var count = 0; foreach (var pocAgent in ApplicationContext.POCAgentList) { var policyElem = new PolicyElement(); policyElem.Model.Name = pocAgent.Name; policyElem.Model.Id = pocAgent.Id; policyElem.Model.ExpanderBackgroundColor = pocAgent.Color; _view.PnlPolicyContainer.Children.Add(policyElem); PolicyColorExisted.Add(pocAgent.Color); if (count == 0 && Id == 0) { policyElem.Model.IsActived = true; POCServer = pocAgent.POCServer; Key = pocAgent.Key; Port = pocAgent.Port; pocServerOrigin = pocAgent.POCServer; portOrigin = pocAgent.Port; keyOrigin = pocAgent.Key; UpdateSource = pocAgent.UpdateSource; ActiveTransfer = pocAgent.ActiveTransfer; SynchronizationInterval = pocAgent.SyncInterval; TransferInterval = pocAgent.TransferInterval; NeighborhoodWatch = pocAgent.NeighborhoodWatch; Id = pocAgent.Id; Name = pocAgent.Name; PolicyColor = pocAgent.Color; } else if (Id == pocAgent.Id) { policyElem.Model.IsActived = true; POCServer = pocAgent.POCServer; Key = pocAgent.Key; Port = pocAgent.Port; pocServerOrigin = pocAgent.POCServer; portOrigin = pocAgent.Port; keyOrigin = pocAgent.Key; UpdateSource = pocAgent.UpdateSource; ActiveTransfer = pocAgent.ActiveTransfer; SynchronizationInterval = pocAgent.SyncInterval; TransferInterval = pocAgent.TransferInterval; NeighborhoodWatch = pocAgent.NeighborhoodWatch; Name = pocAgent.Name; PolicyColor = pocAgent.Color; } count++; } }