/// <summary> /// Checks the value against the Minimum and Maximum categories /// </summary> /// <returns>If the entry is valid or not.</returns> public override bool IsValid() { bool MinMet = true; bool MaxMet = true; if (MinimumRelationships > -1) { if (ValidationHelper.GetString(frmFormControl.Value, "").Trim().Split(SeparatorCharacter.ToCharArray(), StringSplitOptions.RemoveEmptyEntries).Length < MinimumRelationships) { MinMet = false; } } if (MaximumRelationships > -1) { if (ValidationHelper.GetString(frmFormControl.Value, "").Trim().Split(SeparatorCharacter.ToCharArray(), StringSplitOptions.RemoveEmptyEntries).Length > MaximumRelationships) { MaxMet = false; } } if (!MinMet || !MaxMet) { ValidationError = string.Format("{0} {1} {2}", (!MinMet ? "Minimum " + MinimumRelationships + " selections allowed" : ""), (!MinMet && !MaxMet ? " and " : ""), (!MaxMet ? "Maximum " + MaximumRelationships + " selections allowed" : "")); } return(MinMet && MaxMet); }
private List <string> GetSelectedObjects() { string ObjectRefIDs = ValidationHelper.GetString(frmFormControl.Value, ""); List <string> SelectedObjects = ObjectRefIDs.Split(SeparatorCharacter.ToCharArray(), StringSplitOptions.RemoveEmptyEntries).ToList(); if (!string.IsNullOrWhiteSpace(RelatedObjectRestrainingWhere)) { List <string> AllPossibleObjects = GetPossibleObjects(); SelectedObjects.RemoveAll(x => !AllPossibleObjects.Contains(x)); } return(SelectedObjects); }
/// <summary> /// Gets the header attributes for the given <paramref name="headerName"/> /// using the information from the given <paramref name="attribute"/>. /// This adds the header to the list of container headers if-and-only-if the /// header is a container header. /// </summary> /// <param name="headerName">the header name</param> /// <param name="attribute">the attribute for the given header name</param> /// <param name="allContainerHeaders">the list of all container headers</param> /// <returns>the header attributes</returns> private static HeaderAttributes GetHeaderAttributes(Mpeg4HeaderName headerName, Mpeg4Attribute attribute, ICollection <Mpeg4HeaderName> allContainerHeaders) { // Retrieve list of header start codes List <uint> headerStartCodes = new List <uint>(); if (attribute.HeaderStartCode != null) { const string SeparatorCharacter = "-"; if (attribute.HeaderStartCode.Contains(SeparatorCharacter)) { Debug.Assert(attribute.HeaderStartCode.Length == 5); // Example: "40-5F" string[] startCodes = attribute.HeaderStartCode.Split(SeparatorCharacter.ToCharArray()); uint firstStartCode = uint.Parse(startCodes[0], System.Globalization.NumberStyles.HexNumber, CultureInfo.InvariantCulture); uint lastStartCode = uint.Parse(startCodes[1], System.Globalization.NumberStyles.HexNumber, CultureInfo.InvariantCulture); Debug.Assert(firstStartCode < lastStartCode); for (uint startCode = firstStartCode; startCode <= lastStartCode; startCode++) { headerStartCodes.Add(0x100 + startCode); } } else { headerStartCodes.Add(0x100 + uint.Parse(attribute.HeaderStartCode, System.Globalization.NumberStyles.HexNumber, CultureInfo.InvariantCulture)); } } // Retrieve suitable parents, all container headers if empty list ICollection <Mpeg4HeaderName> suitableParents = attribute.SuitableParents; if (suitableParents.Count == 0) { suitableParents = allContainerHeaders; } // Update list of all container headers if ((attribute.HeaderFlags & HeaderFlags.MasterHeader) == HeaderFlags.MasterHeader) { allContainerHeaders.Add(headerName); } return(new HeaderAttributes(headerStartCodes.AsReadOnly(), attribute.HeaderFlags, suitableParents)); }
/// <summary> /// Takes the existing value and sets the Category Tree /// </summary> protected void InitializeControl() { // Get initial values from Join Table and set the control's value if (!IsPostBack) { // Setup Form Control //InitializeFormControl(); frmFormControl.Value = string.Join(SeparatorCharacter, GetCurrentObjects()).Trim(SeparatorCharacter.ToCharArray()); } /*else if () * { * // Set from Text value * string initialCategories = txtValue.Text; * var CurrentObjectsOfDoc = BaseInfoProvider.GetCategories("CategoryID in ('" + string.Join("','", SplitAndSecure(initialCategories)) + "')", null, -1, null, SiteContext.CurrentSiteID); * if (CurrentObjectsOfDoc != null) * { * CurrentObjects.AddRange(CurrentObjectsOfDoc); * } * }*/ }