ArchiSteamFarm/IPC/Controllers/Api/StructureController.cs
/// <summary>
///     Fetches structure of given type.
/// </summary>
/// <remarks>
///     Structure is defined as a representation of given object in its default state.
/// </remarks>
Fetches structure of given type.
Fetches structure of given type .
[HttpGet("{structure:required}")]
	[ProducesResponseType(typeof(GenericResponse<object>), (int) HttpStatusCode.OK)]
	[ProducesResponseType(typeof(GenericResponse), (int) HttpStatusCode.BadRequest)]
	public ActionResult<GenericResponse> StructureGet(string structure) {
		if (string.IsNullOrEmpty(structure)) {
			throw new ArgumentNullException(nameof(structure));
		}
		Type? targetType = WebUtilities.ParseType(structure);
		if (targetType == null) {
			return BadRequest(new GenericResponse(false, string.Format(CultureInfo.CurrentCulture, Strings.ErrorIsInvalid, structure)));
		}
		object? obj;
		try {
			obj = Activator.CreateInstance(targetType, true);
		} catch (Exception e) {
			return BadRequest(new GenericResponse(false, $"{string.Format(CultureInfo.CurrentCulture, Strings.ErrorParsingObject, nameof(targetType))}{Environment.NewLine}{e}"));
		}
		return Ok(new GenericResponse<object>(obj));
	}
[ HttpGet ( " " ) ] [ ProducesResponseType ( typeof ( GenericResponse < object > ) , ( int ) HttpStatusCode . OK ) ] [ ProducesResponseType ( typeof ( GenericResponse ) , ( int ) HttpStatusCode . BadRequest ) ] public ActionResult < GenericResponse > StructureGet ( string structure ) { if ( string . IsNullOrEmpty ( structure ) ) { throw new ArgumentNullException ( nameof ( structure ) ) ; } Type ? targetType = WebUtilities . ParseType ( structure ) ; if ( targetType == null ) { return BadRequest ( new GenericResponse ( false , string . Format ( CultureInfo . CurrentCulture , Strings . ErrorIsInvalid , structure ) ) ) ; } object ? obj ; try { obj = Activator . CreateInstance ( targetType , true ) ; } catch ( Exception e ) { return BadRequest ( new GenericResponse ( false , $" { string . Format ( CultureInfo . CurrentCulture , Strings . ErrorParsingObject , nameof ( targetType ) ) } { Environment . NewLine } { e } " ) ) ; } return Ok ( new GenericResponse < object > ( obj ) ) ; }
Fetches structure of given type.
Fetches structure of given type .
structure
string
remarks
Structure is defined as a representation of given object in its default state.
Structure is defined as a representation of given object in its default state .