/// <summary> /// Constructor. /// </summary> /// <param name="name">Name of the header. Must not be null. </param> /// <param name="value">The value of the header. </param> /// <param name="persistence">Indicates whether the header should exist. </param> public Header(string name, string value, Moksy.Common.Persistence persistence) { if (null == name) throw new System.ArgumentNullException("name"); Name = name; Value = value; if (persistence == Common.Persistence.NotExists) { ComparisonType = Moksy.Common.ComparisonType.NotExists; } HasValue = true; }
/// <summary> /// Create a simulation. The resource is specified as POST /TheResource with the body content being the Json representation of a Simulation; /// </summary> /// <param name="s">The simulation to be created. This is typically passed to this handler via the Proxy class in Moksy.Common. </param> /// <param name="request">The request. </param> /// <param name="cancellationToken">Cancellation token. </param> /// <returns></returns> protected Task<HttpResponseMessage> Create(Moksy.Common.Simulation s, HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) { HttpResponseMessage message = new HttpResponseMessage(System.Net.HttpStatusCode.Created); var response = Task<HttpResponseMessage>.Factory.StartNew(() => { bool added = Storage.SimulationManager.Instance.Add(s); if (!added) { message.StatusCode = System.Net.HttpStatusCode.BadRequest; message.Content = new StringContent(string.Format("ERROR: The Simulation with a name of {0} already exists. ", s.Name)); } return message; }); return response; }
/// <summary> /// Returns true if the parameter name is valid (based on the ParamType and other contexts). /// </summary> /// <param name="parameter"></param> /// <returns></returns> public static bool IsParameterNameValid(Moksy.Common.Swagger12.Api api, Moksy.Common.Swagger12.Parameter parameter) { if (null == parameter) return false; if (api != null) { if (api.Path != parameter.Name) { return false; } } if (parameter.ParamType == "query" && string.IsNullOrEmpty(parameter.Name)) return false; if (parameter.ParamType == "body" && parameter.Name != "body") return false; if (parameter.ParamType == "header" && string.IsNullOrEmpty(parameter.Name)) return false; if (parameter.ParamType == "form" && string.IsNullOrEmpty(parameter.Name)) return false; return true; }
/// <summary> /// Constructor. /// </summary> /// <param name="name">Name of the header. Must not be null. </param> /// <param name="value">The value of the header. </param> /// <param name="comparison">How the header will be compared. </param> public Header(string name, string value, Moksy.Common.ComparisonType comparison) { if (null == name) throw new System.ArgumentNullException("name"); Name = name; Value = value; ComparisonType = comparison; HasValue = true; }
/// <summary> /// Constructor. /// </summary> /// <param name="name">Name of the header. </param> /// <param name="comparison">How the header will be compared. </param> public Header(string name, Moksy.Common.ComparisonType comparison) { Name = name; ComparisonType = comparison; HasValue = false; }
public SimulationCondition Header(string name, string value, Moksy.Common.Persistence persistence) { Header header = new Header(name, value, persistence); SimulationConditionContent.RequestHeadersStorage.Add(header); return this; }