Saltarelle / SaltarelleCompiler

C# to JavaScript compiler – Now http://bridge.net
http://saltarelle-compiler.com
Other
297 stars 74 forks source link

WebSQL: There is no way to obtain a reference to an "SqlDatabase" object. #410

Closed JechoJekov closed 9 years ago

JechoJekov commented 9 years ago

While WebSQL is deprecated IndexedDB is not supported by all browsers (especially iOS) so WebSQL is still needed. Saltarelle provides classes to use WebSQL in C#, however, it does not implement the "window.openDatabase" method used to open a database and to obtain a reference to an SqlDatabase object.

There are two classes this method can belong to - the "Window" class and the "SqlDatabase" class. Putting it in the "Window" class will correspond to the way the method is invoked in JavaScript. However, putting it in the SqlDatabase class may make its usage more intuitive.

    [ScriptAlias("window.openDatabase")]
    public static SqlDatabase Open(string name, string version, string displayName, int estimatedSize)
    {
        return null;
    }

I may also be nice to add a property or method that checks if WebSQL is supported by the browser:

    public static bool IsSupported
    {
        [InlineCode("typeof(window.openDatabase) == typeof(Function)")]
        get
        {
            return false;
        }
    }

I can create a pull request if there is a consensus on the matter.

erik-kallen commented 9 years ago

I think it's better to keep it on Window.

JechoJekov commented 9 years ago

Created pull requests for "Window.cs" and "WindowInstance.cs"