Exemplo n.º 1
0
        // where to put the async definitions?
        // keep the original callback/Promise api also visible?

        // tested by
        // X:\jsc.svn\examples\javascript\async\Test\TestWebCryptoAsync\TestWebCryptoAsync\Application.cs

        //[Obsolete("workaround until jsc implicitly turns Promis into Task for return values.")]
        public static Task <KeyPair> generateKeyAsync(
            this SubtleCrypto that,

            object algorithm,
            bool extractable,
            string[] keyUsages
            )
        {
            var x = new TaskCompletionSource <KeyPair>();

            // Error	1	Keyword 'this' is not valid in a static property, static method, or static field initializer	X:\jsc.svn\core\ScriptCoreLib\JavaScript\DOM\SubtleCrypto.cs	59	13	ScriptCoreLib
            //this.generateKey();

            var promise = that.generateKey(algorithm, extractable, keyUsages);

            // we are taking a delegate of a BCL function, and then converting it to IFunction! nice.

            return(promise.AsTask());
        }