Exemplo n.º 1
0
        /// <summary>
        /// Use for a client validation. Server contract is determined automatically by MapFromContractAttribute
        /// </summary>
        public static bool CheckClientMatchesServer <TClientData>(out FieldMismatch[] fieldMismatches)
        {
            var mapFromContractAttribute = ReflectionProvider.FindMapFromContractAttribute(typeof(TClientData));

            if (mapFromContractAttribute == null)
            {
                var message = $"Type {typeof(TClientData)} should have {nameof(MapFromContractAttribute)} attribute";
                throw new InvalidOperationException(message);
            }
            var serverType = mapFromContractAttribute.DataContractType;

            fieldMismatches = ResponseSpecificationMatcher.FindClientFieldMismatches(typeof(TClientData), serverType);
            return(fieldMismatches.Length == 0);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Use for a server validation when usually client expected CLR type is unknown
 /// </summary>
 public static bool CheckClientMatchesServer <TServerData>(ResponseSpecification clientResponseSpecification,
                                                           out FieldMismatch[] fieldsMismatches)
 {
     fieldsMismatches = ResponseSpecificationMatcher.FindClientFieldMismatches <TServerData>(clientResponseSpecification);
     return(fieldsMismatches.Length == 0);
 }