<commit_before>﻿// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

namespace Microsoft.MixedReality.Toolkit.Utilities
{
    /// <summary>
    /// Response to a REST Call.
    /// </summary>
    public struct Response
    {
        /// <summary>
        /// Was the REST call successful?
        /// </summary>
        public bool Successful { get; }

        /// <summary>
        /// Response body from the resource.
        /// </summary>
        public string ResponseBody => cachedResponseBody ?? (cachedResponseBody = responseBodyAction?.Invoke());
        private string cachedResponseBody;
        private System.Func<string> responseBodyAction;

        /// <summary>
        /// Response data from the resource.
        /// </summary>
        public byte[] ResponseData => responseDataAction?.Invoke();
        private System.Func<byte[]> responseDataAction;

        /// <summary>
        /// Response code from the resource.
        /// </summary>
        public long ResponseCode { get; }

        /// <summary>
        /// Constructor.
        /// </summary>
        public Response(bool successful, string responseBody, byte[] responseData, long responseCode)
        {
            Successful = successful;
            responseBodyAction = responseBody == null ? null : (System.Func<string>)(() => responseBody);
            cachedResponseBody = null;
            responseDataAction = responseData == null ? null : (System.Func<byte[]>)(() => responseData);
            ResponseCode = responseCode;
        }

        public Response(bool successful, System.Func<string> responseBodyAction, System.Func<byte[]> responseDataAction, long responseCode)
        {
            Successful = successful;
            this.responseBodyAction = responseBodyAction;
            cachedResponseBody = null;
            this.responseDataAction = responseDataAction;
            ResponseCode = responseCode;
        }
    }
}<commit_msg>Either there is data, then use it directly, or there is not, then try to get it via callback<commit_after>﻿// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

namespace Microsoft.MixedReality.Toolkit.Utilities
{
    /// <summary>
    /// Response to a REST Call.
    /// </summary>
    public struct Response
    {
        /// <summary>
        /// Was the REST call successful?
        /// </summary>
        public bool Successful { get; }

        /// <summary>
        /// Response body from the resource.
        /// </summary>
        public string ResponseBody => responseBody ?? (responseBody = responseBodyAction?.Invoke());
        private string responseBody;
        private System.Func<string> responseBodyAction;

        /// <summary>
        /// Response data from the resource.
        /// </summary>
        public byte[] ResponseData => responseData ?? (responseData = responseDataAction?.Invoke());
        private byte[] responseData;
        private System.Func<byte[]> responseDataAction;

        /// <summary>
        /// Response code from the resource.
        /// </summary>
        public long ResponseCode { get; }

        /// <summary>
        /// Constructor.
        /// </summary>
        public Response(bool successful, string responseBody, byte[] responseData, long responseCode)
        {
            Successful = successful;
            responseBodyAction = null;
            this.responseBody = responseBody;
            responseDataAction = null;
            this.responseData = responseData;
            ResponseCode = responseCode;
        }

        public Response(bool successful, System.Func<string> responseBodyAction, System.Func<byte[]> responseDataAction, long responseCode)
        {
            Successful = successful;
            this.responseBodyAction = responseBodyAction;
            responseBody = null;
            this.responseDataAction = responseDataAction;
            responseData = null;
            ResponseCode = responseCode;
        }
    }
}
{'fraction_non_alphanumeric': 0.10565583634175692, 'fraction_numerical': 0.0, 'mean_word_length': 2.083086053412463, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 43, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2270239', 'n_tokens_mistral': 972, 'n_tokens_neox': 957, 'n_words': 295}