public void Extend(Type commandType, string propertyName, Observable observable) { var property = commandType.GetProperty(propertyName.ToPascalCase()); if (property != null) { var type = property.PropertyType; if (type.IsConcept()) type = type.GetConceptValueType(); var clientType = string.Empty; if (type == typeof(byte) || type == typeof(Int16) || type == typeof(Int32) || type == typeof(Int64) || type == typeof(UInt16) || type == typeof(UInt32) || type == typeof(UInt64)) { clientType = "Number"; } else if (type == typeof(DateTime)) { clientType = "Date"; } if (!string.IsNullOrEmpty(clientType)) observable.ExtendWith("typeConverter", string.Format("\"{0}\"",clientType)); } }
public void Extend(Type commandType, string propertyName, Observable observable) { var metaData = _validationMetaData.GetMetaDataFor(commandType); if (metaData.Properties.ContainsKey(propertyName)) { var options = JsonConvert.SerializeObject(metaData.Properties[propertyName], new JsonSerializerSettings { ContractResolver = new Newtonsoft.Json.Serialization.CamelCasePropertyNamesContractResolver() }); observable.ExtendWith("validation", options); } }
public void Extend(Type commandType, string propertyName, Observable observable) { var inputValidator = _commandValidatorProvider.GetInputValidatorFor(commandType) as IValidator; if (inputValidator != null) { var metaData = _validationMetaDataGenerator.GenerateFrom(inputValidator); if (metaData.Properties.ContainsKey(propertyName)) { var options = JsonConvert.SerializeObject(metaData.Properties[propertyName], new JsonSerializerSettings { ContractResolver = new Newtonsoft.Json.Serialization.CamelCasePropertyNamesContractResolver() }); observable.ExtendWith("validation", options); } } }
/// <summary> /// Assign an observable /// </summary> /// <param name="assignment"><see cref="Assignment"/> to assign to</param> /// <param name="visitor">Optional <see cref="Action{Observable}"/> that gets called to build the observable</param> /// <returns>The <see cref="Assignment"/> to build on</returns> public static Assignment WithObservable(this Assignment assignment, ObservableVisitor visitor = null) { var observable = new Observable(); assignment.Value = observable; if (visitor != null) visitor(assignment.Name, observable); return assignment; }