public static SingleValueArgument CreateSingleValueArgument(object obj)
        {
            var arg = new SingleValueArgument();

            var jObject = obj as JObject;
            var bObject = obj as byte[];

            if (jObject != null)
            {
                try {
                    arg.Value        = GetValue(jObject, "Single");
                    arg.ValidateOnly = GetValidateOnlyFlag(jObject);
                    arg.IsMalformed  = (!arg.HasValue && GetNonReservedProperties(jObject).Any()) ||
                                       (arg.HasValue && GetNonReservedProperties(jObject).Count() > 1);
                }
                catch (Exception e) {
                    Logger.ErrorFormat("Malformed single value argument: {0}", e.Message);
                    arg.IsMalformed = true;
                }
            }

            if (bObject != null)
            {
                arg.Value        = new AttachmentValue(bObject);
                arg.ValidateOnly = false; // not supported on blob/clob
            }

            return(arg);
        }
Exemplo n.º 2
0
        public static SingleValueArgument CreateSingleValueArgument(object obj) {
            var arg = new SingleValueArgument();

            var jObject = obj as JObject;
            var bObject = obj as byte[];

            if (jObject != null) {
                try {
                    arg.Value = GetValue(jObject, "Single");
                    arg.ValidateOnly = GetValidateOnlyFlag(jObject);
                    arg.IsMalformed = (!arg.HasValue && GetNonReservedProperties(jObject).Any()) ||
                                      (arg.HasValue && GetNonReservedProperties(jObject).Count() > 1);
                }
                catch (Exception e) {
                    Logger.ErrorFormat("Malformed single value argument: {0}", e.Message);
                    arg.IsMalformed = true;
                }
            }

            if (bObject != null) {
                arg.Value = new AttachmentValue(bObject);
                arg.ValidateOnly = false; // not supported on blob/clob
            }

            return arg;
        }