/// <summary> /// Removes a <see cref="StatePropertyDefinition"/> from of the <see cref="StateProperties"/> list. /// </summary> /// <param name="stateProperty">The <see cref="StatePropertyDefinition"/> to be removed. Must not be <see langword="null" />.</param> /// <remarks> /// Also deletes all entries from the <see cref="StatefulAccessControlLists"/> list that use only the removed <see cref="StatePropertyDefinition"/> /// as a selection criteria. /// </remarks> /// <exception cref="ArgumentException"> /// The <paramref name="stateProperty"/> does not exist on the <see cref="SecurableClassDefinition"/>. /// </exception> public void RemoveStateProperty(StatePropertyDefinition stateProperty) { ArgumentUtility.CheckNotNull("stateProperty", stateProperty); var statePropertyReference = StatePropertyReferences.SingleOrDefault(r => r.StateProperty == stateProperty); if (statePropertyReference == null) { throw CreateArgumentException( "stateProperty", "The property '{0}' does not exist on the securable class definition.", stateProperty.Name); } statePropertyReference.Delete(); foreach (var acl in StatefulAccessControlLists.ToList()) { var stateCombinationsContainingRemovedStateProperty = acl.StateCombinations.Where(sc => sc.GetStates().Any(sd => sd.StateProperty == stateProperty)).ToList(); foreach (var stateCombination in stateCombinationsContainingRemovedStateProperty) { stateCombination.Delete(); if (!acl.StateCombinations.Any()) { acl.Delete(); } } } RegisterForCommit(); }
private StatePropertyDefinition CreateStatePropertyDefinition(XmlNamespaceManager namespaceManager, XmlNode statePropertyDefinitionNode) { StatePropertyDefinition statePropertyDefinition = StatePropertyDefinition.NewObject(); statePropertyDefinition.MetadataItemID = new Guid(statePropertyDefinitionNode.Attributes["id"].Value); statePropertyDefinition.Name = statePropertyDefinitionNode.Attributes["name"].Value; statePropertyDefinition.Index = _statePropertyDefinitionCount; _statePropertyDefinitionCount++; XmlNodeList stateNodes = statePropertyDefinitionNode.SelectNodes("md:state", namespaceManager); foreach (XmlNode stateNode in stateNodes) { statePropertyDefinition.AddState(CreateStateDefinition(namespaceManager, stateNode)); } return(statePropertyDefinition); }
/// <summary> /// Adds a <see cref="StatePropertyDefinition"/> to the <see cref="StateProperties"/> list. /// </summary> /// <param name="stateProperty">The <see cref="StatePropertyDefinition"/> to be added. Must not be <see langword="null" />.</param> /// <exception cref="ArgumentException"> /// The <paramref name="stateProperty"/> already exists on the <see cref="SecurableClassDefinition"/>. /// </exception> public void AddStateProperty(StatePropertyDefinition stateProperty) { ArgumentUtility.CheckNotNull("stateProperty", stateProperty); if (StatePropertyReferences.Where(r => r.StateProperty == stateProperty).Any()) { throw CreateArgumentException( "stateProperty", "The property '{0}' has already been added to the securable class definition.", stateProperty.Name); } var reference = StatePropertyReference.NewObject(); reference.StateProperty = stateProperty; StatePropertyReferences.Add(reference); RegisterForCommit(); }
public static ObjectList <StatePropertyReference> GetStatePropertyReferencesForQuery(this StatePropertyDefinition statePropertyDefinition) { throw new NotSupportedException("GetStatePropertyReferences() is only supported for building LiNQ query expressions."); }
public static ObjectList <StateDefinition> GetDefinedStatesForQuery(this StatePropertyDefinition statePropertyDefinition) { ArgumentUtility.CheckNotNull("statePropertyDefinition", statePropertyDefinition); return(new ObjectList <StateDefinition> (statePropertyDefinition.DefinedStates)); }