예제 #1
0
파일: Formatters.cs 프로젝트: wpq0/FormNG
 private static string FormatCustomType(object input, FieldSchema schema, IContext context)
 {
     string result;
     if (input == null)
     {
         result = String.Empty;
     }
     else
     {
         var binder = context.GetBinder(schema.CustomType);
         Trace.WriteLineIf(binder == null, "Binder resolving failed for complex type: " + schema.CustomType);
         result = binder == null
                      ? String.Empty
                      : binder.Format(input, schema, context);
     }
     return result;
 }
예제 #2
0
파일: Validation.cs 프로젝트: wpq0/FormNG
        //NOTE:type dependant
        private static bool ValidateEnumeration(object value, DataType type, Node node, string listStr, bool isBlackList)
        {
            bool result;
            if (!String.IsNullOrWhiteSpace(listStr)
                && value != null
                && type.IsPrimitive())
            {
                var enumSchema = new FieldSchema { DataType = type };
                var list = listStr.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
                                  .Select(x => Parsers.ParseString(x, enumSchema, node.Context))
                                  .Where(x => x != null);
                var inList = list.Cast<dynamic>()
                                 .Any(x => x.Equals(value));
                result = isBlackList
                            ? !inList
                            : inList;
            }
            else
            {
                result = true;
            }

            return result;
        }
예제 #3
0
파일: Parsers.cs 프로젝트: wpq0/FormNG
 private static object ParseCustomType(string input, FieldSchema schema, IContext context)
 {
     object result;
     if (!String.IsNullOrWhiteSpace(schema.CustomType))
     {
         var binder = context.GetBinder(schema.CustomType);
         Trace.WriteLineIf(binder == null, "Binder resolving failed for complex type: " + schema.CustomType);
         result = binder == null
                      ? null
                      : binder.Parse(input, schema, context);
     }
     else
     {
         result = input ?? String.Empty;
     }
     return result;
 }