private void ReadValidators(PropertyValidatorDescriptorCollection collection, XElement container) { foreach (var item in container.Elements("validator")) { collection.Add(ValidatorFromNode(item)); } }
public override object Deserialize(IDictionary <string, object> dictionary, Type type, JavaScriptSerializer serializer) { SchemaPropertyDefine sechemaPropertyDefine = new SchemaPropertyDefine(); #region "PropertyDefine" sechemaPropertyDefine.Name = DictionaryHelper.GetValue(dictionary, "name", string.Empty); sechemaPropertyDefine.DisplayName = DictionaryHelper.GetValue(dictionary, "displayName", string.Empty); sechemaPropertyDefine.Category = DictionaryHelper.GetValue(dictionary, "category", string.Empty); sechemaPropertyDefine.DefaultValue = DictionaryHelper.GetValue(dictionary, "defaultValue", string.Empty); sechemaPropertyDefine.DataType = DictionaryHelper.GetValue(dictionary, "dataType", PropertyDataType.String); sechemaPropertyDefine.Description = DictionaryHelper.GetValue(dictionary, "description", string.Empty); sechemaPropertyDefine.ReadOnly = DictionaryHelper.GetValue(dictionary, "readOnly", false); sechemaPropertyDefine.Visible = DictionaryHelper.GetValue(dictionary, "visible", true); sechemaPropertyDefine.EditorKey = DictionaryHelper.GetValue(dictionary, "editorKey", string.Empty); sechemaPropertyDefine.EditorParams = DictionaryHelper.GetValue(dictionary, "editorParams", string.Empty); sechemaPropertyDefine.SortOrder = DictionaryHelper.GetValue(dictionary, "sortOrder", 0xFFFF); if (dictionary.ContainsKey("validators") == true) { PropertyValidatorDescriptorCollection validators = JSONSerializerExecute.Deserialize <PropertyValidatorDescriptorCollection>(dictionary["validators"]); sechemaPropertyDefine.Validators.Clear(); sechemaPropertyDefine.Validators.CopyFrom(validators); } #endregion sechemaPropertyDefine.Tab = DictionaryHelper.GetValue(dictionary, "tab", string.Empty); sechemaPropertyDefine.SnapshotMode = DictionaryHelper.GetValue(dictionary, "snapshotMode", default(SnapshotModeDefinition)); sechemaPropertyDefine.SnapshotFieldName = DictionaryHelper.GetValue(dictionary, "snapshotFieldName", string.Empty); return(sechemaPropertyDefine); }
internal static PropertyValidatorDescriptorCollection PreparePropertyValidatorDescriptorCollection() { PropertyValidatorDescriptorCollection pvDespCollection = new PropertyValidatorDescriptorCollection(); pvDespCollection.Add(PreparePropertyValidatorDescriptor()); pvDespCollection.Add(DefalutPreparePropertyValidatorDescriptor()); return pvDespCollection; }
internal static PropertyValidatorDescriptorCollection PreparePropertyValidatorDescriptorCollection() { PropertyValidatorDescriptorCollection pvDespCollection = new PropertyValidatorDescriptorCollection(); pvDespCollection.Add(PreparePropertyValidatorDescriptor()); pvDespCollection.Add(DefalutPreparePropertyValidatorDescriptor()); return(pvDespCollection); }
public void PropertyValidatorCollectionSerializeTest() { PropertyValidatorDescriptorCollection pvDespCollection = PreparePropertyValidatorDescriptorCollection(); XElementFormatter formatter = new XElementFormatter(); XElement root = formatter.Serialize(pvDespCollection); Console.WriteLine(root.ToString()); PropertyValidatorDescriptorCollection newpvDespCollection = (PropertyValidatorDescriptorCollection)formatter.Deserialize(root); XElement rootReserialized = formatter.Serialize(newpvDespCollection); Assert.AreEqual(root.ToString(), rootReserialized.ToString()); Assert.AreEqual(pvDespCollection.Count, newpvDespCollection.Count); }