private static object AttachDataContractCollectionExtender(DataContractCollectionBase element, Type collectionType) { AsmxDataContractCollection extender = new AsmxDataContractCollection(); extender.CollectionType = collectionType; extender.ModelElement = element; return(extender); }
private bool PropertyIsEmpty(DataContractCollectionBase collection) { if (collection.ObjectExtender != null) { PropertyInfo property = collection.ObjectExtender.GetType().GetProperty(propertyName); if (property != null) { return(property.GetValue(collection.ObjectExtender, null) == null); } } return(true); }
private bool PropertyIsEmpty(DataContractCollectionBase collection) { if (collection.ObjectExtender != null) { PropertyInfo property = collection.ObjectExtender.GetType().GetProperty(propertyName); if (property != null) { return property.GetValue(collection.ObjectExtender, null) == null; } } return true; }
public override void DoValidate(object objectToValidate, object currentTarget, string key, ValidationResults validationResults) { DataContractCollectionBase dc = currentTarget as DataContractCollectionBase; if (dc == null) { return; } if (PropertyIsEmpty(dc)) { validationResults.AddResult( new ValidationResult(String.Format(CultureInfo.CurrentUICulture, this.MessageTemplate, dc.Name, propertyName), currentTarget, key, String.Empty, this)); } }
// We do not currently have a way to add rules for object extenders, so this is looking // for an appropriate property for an object extender. private void UpdateDataContractCollectionType(DataContractCollectionBase dcElement, Type collectionType) { if (dcElement != null && dcElement.ObjectExtender != null) { PropertyInfo property = dcElement.ObjectExtender.GetType().GetProperty("CollectionType"); if (property != null) { object value = property.GetValue(dcElement.ObjectExtender, null); if (value == null) property.SetValue(dcElement.ObjectExtender, collectionType, null); } } }
// We do not currently have a way to add rules for object extenders, so this is looking // for an appropriate property for an object extender. private void UpdateDataContractCollectionType(DataContractCollectionBase dcElement, Type collectionType) { if (dcElement != null && dcElement.ObjectExtender != null) { PropertyInfo property = dcElement.ObjectExtender.GetType().GetProperty("CollectionType"); if (property != null) { object value = property.GetValue(dcElement.ObjectExtender, null); if (value == null) { property.SetValue(dcElement.ObjectExtender, collectionType, null); } } } }
private static object AttachDataContractCollectionExtender(DataContractCollectionBase element, Type collectionType) { WCFDataContractCollection extender = new WCFDataContractCollection(); extender.CollectionType = collectionType; extender.ModelElement = element; return extender; }