コード例 #1
0
        public LambdaContext(RuntimeApiHeaders runtimeApiHeaders, LambdaEnvironment lambdaEnvironment)
        {
            _lambdaEnvironment = lambdaEnvironment;
            _runtimeApiHeaders = runtimeApiHeaders;

            int.TryParse(_lambdaEnvironment.FunctionMemorySize, out _memoryLimitInMB);
            long.TryParse(_runtimeApiHeaders.DeadlineMs, out _deadlineMs);
            _cognitoIdentityLazy      = new Lazy <CognitoIdentity>(() => CognitoIdentity.FromJson(runtimeApiHeaders.CognitoIdentityJson));
            _cognitoClientContextLazy = new Lazy <CognitoClientContext>(() => CognitoClientContext.FromJson(runtimeApiHeaders.ClientContextJson));

            // set environment variable so that if the function uses the XRay client it will work correctly
            _lambdaEnvironment.SetXAmznTraceId(_runtimeApiHeaders.TraceId);
        }
コード例 #2
0
        internal static CognitoIdentity FromJson(string json)
        {
            var result = new CognitoIdentity();

            if (!string.IsNullOrWhiteSpace(json))
            {
                var jsonData = JsonMapper.ToObject(json);
                if (jsonData["identityId"] != null)
                {
                    result.IdentityId = jsonData["identityId"].ToString();
                }
                if (jsonData["identityPoolId"] != null)
                {
                    result.IdentityPoolId = jsonData["identityPoolId"].ToString();
                }
            }

            return(result);
        }
コード例 #3
0
        internal static CognitoIdentity FromJson(string json)
        {
            var result = new CognitoIdentity();

            if (!string.IsNullOrWhiteSpace(json))
            {
                var jsonData = JsonDocument.Parse(json).RootElement;

                if (jsonData.TryGetProperty("cognitoIdentityId", out var cognitoIdentityId))
                {
                    result.IdentityId = cognitoIdentityId.GetString();
                }
                if (jsonData.TryGetProperty("cognitoIdentityPoolId", out var cognitoIdentityPoolId))
                {
                    result.IdentityPoolId = cognitoIdentityPoolId.GetString();
                }
            }

            return(result);
        }