/// <summary> /// </summary> /// <param name="xml"> /// </param> /// <returns> /// </returns> public static PriceMatrix Load(string xml) { if (string.IsNullOrEmpty(xml)) { return(new PriceMatrix()); } var serializer = new XmlSerializer(typeof(PriceMatrix)); TextReader tr = new StringReader(xml); PriceMatrix priceMatrixItem = null; try { priceMatrixItem = (PriceMatrix)serializer.Deserialize(tr); } catch (InvalidOperationException) { } finally { tr.Close(); } return(priceMatrixItem); }
/// <summary> /// When overridden in a derived class, this method contains the code /// to determine whether the value in the input control is valid. /// </summary> /// <returns> /// The result of the evaluation. /// </returns> protected override ValidatorResult Evaluate() { var priceMatrixItem = PriceMatrix.Load(this.ControlValidationValue); var item = Sitecore.Context.Database.SelectSingleItem("/*/system/Modules/*[@@templatekey='configuration']").Children["PriceMatrix"]; if (priceMatrixItem != null) { this.IterateRecursiveToLoad(priceMatrixItem.MainCategory, item); } if (string.IsNullOrEmpty(this.message)) { return(ValidatorResult.Valid); } this.Text = string.Format("Field \"{0}\" has some invalid fields.\n", this.GetFieldDisplayName()) + this.message; return(this.GetFailedResult(ValidatorResult.CriticalError)); }