protected static bool CheckNullOrWhiteSpace(string parameter, string parameterName, out Response errorResponse) { errorResponse = null; if (string.IsNullOrWhiteSpace(parameter)) { errorResponse = new SyncResponse { ErrorMessage = "Required parameter is missing or empty: " + parameterName, Error = (int)SyncResponseError.RequiredParameterMissing }; return false; } return true; }
public override bool CheckValidate(out Response errorResponse) { if (!CheckDeviceId(out errorResponse) || !CheckDeviceMediaRoot(out errorResponse)) { return false; } DeviceMediaRoot = DeviceMediaRoot.Trim(); if (!DeviceMediaRoot.EndsWith("/")) DeviceMediaRoot = DeviceMediaRoot + "/"; return true; }
protected bool CheckDeviceMediaRoot(out Response errorResponse) { return CheckNullOrWhiteSpace(DeviceMediaRoot, "DeviceMediaRoot", out errorResponse); }
protected bool CheckDeviceId(out Response errorResponse) { return CheckNullOrWhiteSpace(DeviceId, "DeviceId", out errorResponse); }
/// <summary> /// Checks and validates the contents of the request. /// </summary> /// <param name="errorResponse">If a check failed, an error that can be sent to be client.</param> /// <returns>True, if the request is valid, otherwise false.</returns> public abstract bool CheckValidate(out Response errorResponse);