示例#1
0
        public void ValidateStreamingFragment(JObject ssmd, JObject schema)
        {
            var ex = new MetadataValidationException(typeof(object), "streaming", "streaming validation failed", "see AggregatedExceptions");


            IEnumerable <JProperty> services = ((JObject)ssmd["services"]).Properties();

            foreach (JProperty service in services)
            {
                JToken svc         = service.Value;
                var    returnValue = svc["returns"]["$ref"].Value <string>();
                if (returnValue.StartsWith("#."))
                {
                    returnValue = returnValue.Substring(2);
                }
                if (schema["properties"][returnValue] == null)
                {
                    var method = svc["target"].Value <string>() + "." + svc["channel"].Value <string>();
                    ex.AggregatedExceptions.Add(new MetadataValidationException(typeof(Object), method, "Every service return type must be represented in the json-schema.", "ensure that the return type is represented in the json schema"));
                }
            }

            if (ex.AggregatedExceptions.Count > 0)
            {
                throw ex;
            }
        }
        public override string ToString()
        {
            string message = string.Format("MetadataGenerationError: MetadataType={0}, Type={1},\r\n\tErrorReason={2},\r\n\tSuggestedSolution={3}", MetadataType, Type, ErrorReason, SuggestedSolution);

            if (MetadataValidationException != null)
            {
                message += Environment.NewLine + MetadataValidationException.ToString();
            }
            return(message);
        }
 public MetadataGenerationError(MetadataType metadataType, Type type, MetadataValidationException metadataValidationException) :
     this(metadataType, type, metadataValidationException.Message, metadataValidationException.SuggestedSolution)
 {
     MetadataValidationException = metadataValidationException;
 }