コード例 #1
0
        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));
            }
        }
コード例 #2
0
 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);
     }
 }
コード例 #3
0
 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);
         }
     }
 }
コード例 #4
0
        /// <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;
        }