[firebase][database] Added Database stuff

- Added binding
- Added sample
- Added license
- Added build.cake
- Added nuspec
- Added icons
This commit is contained in:
SotoiGhost 2016-11-03 11:49:20 -06:00
Родитель ea41c8a54a
Коммит 859a4e4382
43 изменённых файлов: 3248 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,45 @@
#load "../common.cake"
var TARGET = Argument ("t", Argument ("target", "Default"));
buildSpec = new BuildSpec () {
Libs = new ISolutionBuilder [] {
new DefaultSolutionBuilder {
SolutionPath = "source/Firebase.Database.sln",
BuildsOn = BuildPlatforms.Mac,
OutputFiles = new [] {
new OutputFileCopy {
FromFile = "./source/Firebase.Database/bin/Release/Firebase.Database.dll",
},
}
}
},
Samples = new ISolutionBuilder [] {
new IOSSolutionBuilder { SolutionPath = "./samples/DatabaseSample/DatabaseSample.sln", BuildsOn = BuildPlatforms.Mac },
},
NuGets = new [] {
new NuGetInfo { NuSpec = "./nuget/Xamarin.Firebase.iOS.Database.nuspec", BuildsOn = BuildPlatforms.Mac},
},
Components = new [] {
new Component {ManifestDirectory = "./component", BuildsOn = BuildPlatforms.Mac},
},
};
// "Firebase.InstanceID" implied from Firebase.Analytics
MyDependencies = new [] {"Firebase.Analytics"};
Task ("clean").IsDependentOn ("clean-base").Does (() =>
{
InvokeOtherGoogleModules (MyDependencies, "clean");
RunMake ("./externals/", "clean");
DeleteFiles ("../tmp-nugets/Xamarin.Firebase.iOS.Database*");
});
SetupXamarinBuildTasks (buildSpec, Tasks, Task);
RunTarget (TARGET);

Просмотреть файл

@ -0,0 +1,17 @@
**Xamarin is not responsible for, nor does it grant any licenses to, third-party packages. Some packages may require or install dependencies which are governed by additional licenses.**
Note: This component depends on [Firebase Database for iOS](https://firebase.google.com/docs/database/ios/start), which is subject to the [Terms of Service for Firebase Services](https://firebase.google.com/terms/).
### Xamarin Component for Firebase Database for iOS
**The MIT License (MIT)**
Copyright (c) .NET Foundation Contributors
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20160910

Просмотреть файл

@ -0,0 +1,42 @@
version: 3.0.3.0
name: Firebase Database for iOS
id: firebaseiosdatabase
publisher: Xamarin Inc.
publisher-url: http://xamarin.com
src-url: https://github.com/xamarin/GoogleApisForiOSComponents/tree/master/Firebase.Database
summary: Store and sync data with the Firebase Realtime Database. Data is synced across all clients in realtime, and remains available when your app goes offline.
icons:
- ../../icons/firebaseiosdatabase_128x128.png
- ../../icons/firebaseiosdatabase_512x512.png
docs-url: https://firebase.google.com/docs/database/
libraries:
ios-unified:
- ../output/Firebase.Database.dll
- ../../Firebase.Analytics/output/Firebase.Analytics.dll
- ../../Firebase.InstanceID/output/Firebase.InstanceID.dll
is_shell: true
packages:
ios-unified:
- Xamarin.Firebase.iOS.Database, Version=3.0.3.0
samples:
- name: "Database Sample"
path: ../samples/DatabaseSample/DatabaseSample.sln
removeProjects:
- Firebase.Database
- Firebase.Auth
- Firebase.Analytics
- Firebase.InstanceID
installNuGets:
- project: DatabaseSample
packages:
- Xamarin.Firebase.iOS.Database
- Xamarin.Firebase.iOS.Auth
- Xamarin.Firebase.iOS.Analytics
- Xamarin.Firebase.iOS.InstanceID
removeNodes:
- "//xNS:Import[contains (@Project, 'Firebase.Database.targets')]"
- "//xNS:Import[contains (@Project, 'Firebase.Auth.targets')]"
- "//xNS:Import[contains (@Project, 'Firebase.Analytics.targets')]"
- "//xNS:Import[contains (@Project, 'Firebase.InstanceID.targets')]"
local-nuget-repo: ../../tmp-nugets
no_build: true

12
Firebase.Database/externals/Makefile поставляемый Normal file
Просмотреть файл

@ -0,0 +1,12 @@
POD=pod
all: Podfile.lock
Podfile.lock :
$(POD) install
clean:
rm -rf Podfile.lock Pods
.PHONY: all clean

34
Firebase.Database/externals/Podfile поставляемый Normal file
Просмотреть файл

@ -0,0 +1,34 @@
=begin
Last run FirebaseDatabase installed:
- FirebaseAnalytics (3.4.2)
- FirebaseDatabase (3.0.3)
- FirebaseInstanceID (1.0.8)
- GoogleInterchangeUtilities (1.2.1)
- GoogleSymbolUtilities (1.1.1)
- GoogleUtilities (1.3.1)
Check if main version or subversion number has changed.
If yes, please, update *.targets files located in binding
projects, also, update Podfile files if needed.
In .targets file, located in Firebase.Database binding, you can find:
- FirebaseDatabase (3.0.3)
In .targets file, located in Firebase.Analytics binding, you can find:
- FirebaseAnalytics (3.4.2)
- GoogleInterchangeUtilities (1.2.1)
- GoogleSymbolUtilities (1.1.1)
- GoogleUtilities (1.3.1)
In .targets file, located in Firebase.InstanceID binding, you can find:
- FirebaseInstanceID (1.0.8)
=end
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '7.0'
install! 'cocoapods', :integrate_targets => false
target 'FirebaseDatabase' do
pod 'FirebaseDatabase', '3.0.3'
end

Просмотреть файл

@ -0,0 +1,27 @@
<?xml version="1.0"?>
<package >
<metadata>
<id>Xamarin.Firebase.iOS.Database</id>
<title>Firebase APIs Database iOS Library</title>
<version>3.0.3.0</version>
<authors>Xamarin Inc.</authors>
<owners>Xamarin Inc.</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>C# bindings for Firebase APIs Database iOS Library</description>
<copyright>Copyright 2016 Microsoft</copyright>
<projectUrl>https://components.xamarin.com/view/firebaseiosdatabase</projectUrl>
<licenseUrl>https://components.xamarin.com/license/firebaseiosdatabase</licenseUrl>
<iconUrl>https://raw.githubusercontent.com/xamarin/GoogleApisForiOSComponents/master/icons/firebaseiosdatabase_128x128.png</iconUrl>
<dependencies>
<dependency id="Xamarin.Build.Download" version="0.2.1"/>
<dependency id="Xamarin.Firebase.iOS.Analytics" version="3.4.2.0"/>
<dependency id="Xamarin.Firebase.iOS.InstanceID" version="1.0.8.0"/>
</dependencies>
</metadata>
<files>
<file src="output/Firebase.Database.dll" target="lib/Xamarin.iOS10" />
<!-- Add targets file for external native reference download -->
<file src="source/Firebase.Database/Firebase.Database.targets" target="build/Xamarin.Firebase.iOS.Database.targets" />
</files>
</package>

Просмотреть файл

@ -0,0 +1,63 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DatabaseSample", "DatabaseSample\DatabaseSample.csproj", "{94474EED-2C21-463F-A093-A6FE10C97F50}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Firebase.Database", "..\..\source\Firebase.Database\Firebase.Database.csproj", "{7C28F952-273E-4888-A9D7-61057B5361C3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Firebase.InstanceID", "..\..\..\Firebase.InstanceID\source\Firebase.InstanceID\Firebase.InstanceID.csproj", "{D6AA184C-DA45-4BBB-988A-451B20C7B804}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Firebase.Analytics", "..\..\..\Firebase.Analytics\source\Firebase.Analytics\Firebase.Analytics.csproj", "{87BB564C-85A8-4EC1-AD16-EC0A1ACCEE56}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Firebase.Auth", "..\..\..\Firebase.Auth\source\Firebase.Auth\Firebase.Auth.csproj", "{B6D38028-B1CF-4351-B53B-B5D35F19FC4A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|iPhoneSimulator = Debug|iPhoneSimulator
Release|iPhone = Release|iPhone
Release|iPhoneSimulator = Release|iPhoneSimulator
Debug|iPhone = Debug|iPhone
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{94474EED-2C21-463F-A093-A6FE10C97F50}.Debug|iPhoneSimulator.ActiveCfg = Debug|iPhoneSimulator
{94474EED-2C21-463F-A093-A6FE10C97F50}.Debug|iPhoneSimulator.Build.0 = Debug|iPhoneSimulator
{94474EED-2C21-463F-A093-A6FE10C97F50}.Release|iPhone.ActiveCfg = Release|iPhone
{94474EED-2C21-463F-A093-A6FE10C97F50}.Release|iPhone.Build.0 = Release|iPhone
{94474EED-2C21-463F-A093-A6FE10C97F50}.Release|iPhoneSimulator.ActiveCfg = Release|iPhoneSimulator
{94474EED-2C21-463F-A093-A6FE10C97F50}.Release|iPhoneSimulator.Build.0 = Release|iPhoneSimulator
{94474EED-2C21-463F-A093-A6FE10C97F50}.Debug|iPhone.ActiveCfg = Debug|iPhone
{94474EED-2C21-463F-A093-A6FE10C97F50}.Debug|iPhone.Build.0 = Debug|iPhone
{7C28F952-273E-4888-A9D7-61057B5361C3}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{7C28F952-273E-4888-A9D7-61057B5361C3}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
{7C28F952-273E-4888-A9D7-61057B5361C3}.Release|iPhone.ActiveCfg = Release|Any CPU
{7C28F952-273E-4888-A9D7-61057B5361C3}.Release|iPhone.Build.0 = Release|Any CPU
{7C28F952-273E-4888-A9D7-61057B5361C3}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{7C28F952-273E-4888-A9D7-61057B5361C3}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
{7C28F952-273E-4888-A9D7-61057B5361C3}.Debug|iPhone.ActiveCfg = Debug|Any CPU
{7C28F952-273E-4888-A9D7-61057B5361C3}.Debug|iPhone.Build.0 = Debug|Any CPU
{D6AA184C-DA45-4BBB-988A-451B20C7B804}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{D6AA184C-DA45-4BBB-988A-451B20C7B804}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
{D6AA184C-DA45-4BBB-988A-451B20C7B804}.Release|iPhone.ActiveCfg = Release|Any CPU
{D6AA184C-DA45-4BBB-988A-451B20C7B804}.Release|iPhone.Build.0 = Release|Any CPU
{D6AA184C-DA45-4BBB-988A-451B20C7B804}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{D6AA184C-DA45-4BBB-988A-451B20C7B804}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
{D6AA184C-DA45-4BBB-988A-451B20C7B804}.Debug|iPhone.ActiveCfg = Debug|Any CPU
{D6AA184C-DA45-4BBB-988A-451B20C7B804}.Debug|iPhone.Build.0 = Debug|Any CPU
{87BB564C-85A8-4EC1-AD16-EC0A1ACCEE56}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{87BB564C-85A8-4EC1-AD16-EC0A1ACCEE56}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
{87BB564C-85A8-4EC1-AD16-EC0A1ACCEE56}.Release|iPhone.ActiveCfg = Release|Any CPU
{87BB564C-85A8-4EC1-AD16-EC0A1ACCEE56}.Release|iPhone.Build.0 = Release|Any CPU
{87BB564C-85A8-4EC1-AD16-EC0A1ACCEE56}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{87BB564C-85A8-4EC1-AD16-EC0A1ACCEE56}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
{87BB564C-85A8-4EC1-AD16-EC0A1ACCEE56}.Debug|iPhone.ActiveCfg = Debug|Any CPU
{87BB564C-85A8-4EC1-AD16-EC0A1ACCEE56}.Debug|iPhone.Build.0 = Debug|Any CPU
{B6D38028-B1CF-4351-B53B-B5D35F19FC4A}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{B6D38028-B1CF-4351-B53B-B5D35F19FC4A}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
{B6D38028-B1CF-4351-B53B-B5D35F19FC4A}.Release|iPhone.ActiveCfg = Release|Any CPU
{B6D38028-B1CF-4351-B53B-B5D35F19FC4A}.Release|iPhone.Build.0 = Release|Any CPU
{B6D38028-B1CF-4351-B53B-B5D35F19FC4A}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{B6D38028-B1CF-4351-B53B-B5D35F19FC4A}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
{B6D38028-B1CF-4351-B53B-B5D35F19FC4A}.Debug|iPhone.ActiveCfg = Debug|Any CPU
{B6D38028-B1CF-4351-B53B-B5D35F19FC4A}.Debug|iPhone.Build.0 = Debug|Any CPU
EndGlobalSection
EndGlobal

Просмотреть файл

@ -0,0 +1,51 @@
using Foundation;
using UIKit;
using Firebase.Analytics;
using Firebase.Database;
using System;
using System.Collections.Generic;
namespace DatabaseSample
{
// The UIApplicationDelegate for the application. This class is responsible for launching the
// User Interface of the application, as well as listening (and optionally responding) to application events from iOS.
[Register ("AppDelegate")]
public class AppDelegate : UIApplicationDelegate
{
// class-level declarations
public override UIWindow Window {
get;
set;
}
public static string UserUid { get; set; }
public static DatabaseReference RootNode { get; set; }
public override bool FinishedLaunching (UIApplication application, NSDictionary launchOptions)
{
// Override point for customization after application launch.
// If not required for your application you can safely delete this method
UINavigationBar.Appearance.TintColor = UIColor.White;
App.Configure ();
Database.DefaultInstance.PersistenceEnabled = true;
RootNode = Database.DefaultInstance.RootReference;
return true;
}
public static double GetUtcTimestamp ()
{
return double.Parse (DateTime.UtcNow.ToString ("yyyyMMddHHmmss"));
}
public static string ConvertUnformattedUtcDateToCurrentDate (string utcDate)
{
var date = System.DateTime.ParseExact (utcDate, "yyyyMMddHHmmss", System.Globalization.CultureInfo.GetCultureInfo ("en-US"));
return date.ToString ("MM/dd/yy");
}
}
}

Просмотреть файл

@ -0,0 +1,157 @@
{
"images": [
{
"idiom": "iphone",
"size": "29x29",
"scale": "1x"
},
{
"idiom": "iphone",
"size": "29x29",
"scale": "2x"
},
{
"idiom": "iphone",
"size": "29x29",
"scale": "3x"
},
{
"idiom": "iphone",
"size": "40x40",
"scale": "2x"
},
{
"idiom": "iphone",
"size": "40x40",
"scale": "3x"
},
{
"idiom": "iphone",
"size": "57x57",
"scale": "1x"
},
{
"idiom": "iphone",
"size": "57x57",
"scale": "2x"
},
{
"idiom": "iphone",
"size": "60x60",
"scale": "2x"
},
{
"idiom": "iphone",
"size": "60x60",
"scale": "3x"
},
{
"idiom": "ipad",
"size": "29x29",
"scale": "1x"
},
{
"idiom": "ipad",
"size": "29x29",
"scale": "2x"
},
{
"idiom": "ipad",
"size": "40x40",
"scale": "1x"
},
{
"idiom": "ipad",
"size": "40x40",
"scale": "2x"
},
{
"idiom": "ipad",
"size": "50x50",
"scale": "1x"
},
{
"idiom": "ipad",
"size": "50x50",
"scale": "2x"
},
{
"idiom": "ipad",
"size": "72x72",
"scale": "1x"
},
{
"idiom": "ipad",
"size": "72x72",
"scale": "2x"
},
{
"idiom": "ipad",
"size": "76x76",
"scale": "1x"
},
{
"idiom": "ipad",
"size": "76x76",
"scale": "2x"
},
{
"size": "24x24",
"idiom": "watch",
"scale": "2x",
"role": "notificationCenter",
"subtype": "38mm"
},
{
"size": "27.5x27.5",
"idiom": "watch",
"scale": "2x",
"role": "notificationCenter",
"subtype": "42mm"
},
{
"size": "29x29",
"idiom": "watch",
"role": "companionSettings",
"scale": "2x"
},
{
"size": "29x29",
"idiom": "watch",
"role": "companionSettings",
"scale": "3x"
},
{
"size": "40x40",
"idiom": "watch",
"scale": "2x",
"role": "appLauncher",
"subtype": "38mm"
},
{
"size": "44x44",
"idiom": "watch",
"scale": "2x",
"role": "longLook",
"subtype": "42mm"
},
{
"size": "86x86",
"idiom": "watch",
"scale": "2x",
"role": "quickLook",
"subtype": "38mm"
},
{
"size": "98x98",
"idiom": "watch",
"scale": "2x",
"role": "quickLook",
"subtype": "42mm"
}
],
"info": {
"version": 1,
"author": "xcode"
}
}

Просмотреть файл

@ -0,0 +1,6 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}

Просмотреть файл

@ -0,0 +1,167 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\Xamarin.Build.Download.0.2.2\build\Xamarin.Build.Download.props" Condition="Exists('..\packages\Xamarin.Build.Download.0.2.2\build\Xamarin.Build.Download.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">iPhoneSimulator</Platform>
<ProjectGuid>{94474EED-2C21-463F-A093-A6FE10C97F50}</ProjectGuid>
<ProjectTypeGuids>{FEACFBD2-3405-455C-9665-78FE426C6842};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<OutputType>Exe</OutputType>
<RootNamespace>DatabaseSample</RootNamespace>
<AssemblyName>DatabaseSample</AssemblyName>
<IPhoneResourcePrefix>Resources</IPhoneResourcePrefix>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhoneSimulator' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\iPhoneSimulator\Debug</OutputPath>
<DefineConstants>DEBUG;ENABLE_TEST_CLOUD;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodesignKey>iPhone Developer</CodesignKey>
<MtouchDebug>true</MtouchDebug>
<MtouchFastDev>true</MtouchFastDev>
<MtouchProfiling>true</MtouchProfiling>
<MtouchUseSGen>true</MtouchUseSGen>
<MtouchUseRefCounting>true</MtouchUseRefCounting>
<MtouchLink>None</MtouchLink>
<MtouchArch>i386</MtouchArch>
<MtouchHttpClientHandler>HttpClientHandler</MtouchHttpClientHandler>
<MtouchTlsProvider>Default</MtouchTlsProvider>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhone' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\iPhone\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodesignKey>iPhone Developer</CodesignKey>
<MtouchUseSGen>true</MtouchUseSGen>
<MtouchUseRefCounting>true</MtouchUseRefCounting>
<MtouchFloat32>true</MtouchFloat32>
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
<MtouchLink>SdkOnly</MtouchLink>
<MtouchArch>ARMv7, ARM64</MtouchArch>
<MtouchHttpClientHandler>HttpClientHandler</MtouchHttpClientHandler>
<MtouchTlsProvider>Default</MtouchTlsProvider>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhoneSimulator' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\iPhoneSimulator\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodesignKey>iPhone Developer</CodesignKey>
<MtouchUseSGen>true</MtouchUseSGen>
<MtouchUseRefCounting>true</MtouchUseRefCounting>
<MtouchLink>None</MtouchLink>
<MtouchArch>i386</MtouchArch>
<MtouchHttpClientHandler>HttpClientHandler</MtouchHttpClientHandler>
<MtouchTlsProvider>Default</MtouchTlsProvider>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhone' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\iPhone\Debug</OutputPath>
<DefineConstants>DEBUG;ENABLE_TEST_CLOUD;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodesignKey>iPhone Developer</CodesignKey>
<DeviceSpecificBuild>true</DeviceSpecificBuild>
<MtouchDebug>true</MtouchDebug>
<MtouchFastDev>false</MtouchFastDev>
<MtouchProfiling>true</MtouchProfiling>
<MtouchUseSGen>true</MtouchUseSGen>
<MtouchUseRefCounting>true</MtouchUseRefCounting>
<MtouchFloat32>true</MtouchFloat32>
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
<MtouchLink>SdkOnly</MtouchLink>
<MtouchArch>ARMv7, ARM64</MtouchArch>
<MtouchHttpClientHandler>HttpClientHandler</MtouchHttpClientHandler>
<MtouchTlsProvider>Default</MtouchTlsProvider>
<PlatformTarget>x86</PlatformTarget>
<MtouchExtraArgs></MtouchExtraArgs>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Xml" />
<Reference Include="System.Core" />
<Reference Include="Xamarin.iOS" />
</ItemGroup>
<ItemGroup>
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\Contents.json" />
<ImageAsset Include="Assets.xcassets\Contents.json" />
</ItemGroup>
<ItemGroup>
<Folder Include="Resources\" />
</ItemGroup>
<ItemGroup>
<InterfaceDefinition Include="LaunchScreen.storyboard" />
<InterfaceDefinition Include="Main.storyboard" />
</ItemGroup>
<ItemGroup>
<None Include="Info.plist" />
<None Include="Entitlements.plist" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Compile Include="Main.cs" />
<Compile Include="AppDelegate.cs" />
<Compile Include="NotesViewController.cs" />
<Compile Include="NotesViewController.designer.cs">
<DependentUpon>NotesViewController.cs</DependentUpon>
</Compile>
<Compile Include="ExtensionMethods.cs" />
<Compile Include="NoteViewController.cs" />
<Compile Include="NoteViewController.designer.cs">
<DependentUpon>NoteViewController.cs</DependentUpon>
</Compile>
<Compile Include="FoldersViewController.cs" />
<Compile Include="FoldersViewController.designer.cs">
<DependentUpon>FoldersViewController.cs</DependentUpon>
</Compile>
<Compile Include="FolderCell.cs" />
<Compile Include="FolderCell.designer.cs">
<DependentUpon>FolderCell.cs</DependentUpon>
</Compile>
<Compile Include="Folder.cs" />
<Compile Include="UIAlertHelper.cs" />
<Compile Include="NoteCell.cs" />
<Compile Include="NoteCell.designer.cs">
<DependentUpon>NoteCell.cs</DependentUpon>
</Compile>
<Compile Include="Note.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\..\Firebase.Analytics\source\Firebase.Analytics\Firebase.Analytics.csproj">
<Project>{87BB564C-85A8-4EC1-AD16-EC0A1ACCEE56}</Project>
<Name>Firebase.Analytics</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\source\Firebase.Database\Firebase.Database.csproj">
<Project>{7C28F952-273E-4888-A9D7-61057B5361C3}</Project>
<Name>Firebase.Database</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\..\Firebase.InstanceID\source\Firebase.InstanceID\Firebase.InstanceID.csproj">
<Project>{D6AA184C-DA45-4BBB-988A-451B20C7B804}</Project>
<Name>Firebase.InstanceID</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\..\Firebase.Auth\source\Firebase.Auth\Firebase.Auth.csproj">
<Project>{B6D38028-B1CF-4351-B53B-B5D35F19FC4A}</Project>
<Name>Firebase.Auth</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<BundleResource Include="GoogleService-Info.plist" />
</ItemGroup>
<Import Project="$(MSBuildThisFileDirectory)..\..\..\..\Firebase.InstanceID\source\Firebase.InstanceID\Firebase.InstanceID.targets" />
<Import Project="$(MSBuildThisFileDirectory)..\..\..\..\Firebase.Analytics\source\Firebase.Analytics\Firebase.Analytics.targets" />
<Import Project="$(MSBuildThisFileDirectory)..\..\..\..\Firebase.Auth\source\Firebase.Auth\Firebase.Auth.targets" />
<Import Project="$(MSBuildThisFileDirectory)..\..\..\source\Firebase.Database\Firebase.Database.targets" />
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" />
<Import Project="..\packages\Xamarin.Build.Download.0.2.2\build\Xamarin.Build.Download.targets" Condition="Exists('..\packages\Xamarin.Build.Download.0.2.2\build\Xamarin.Build.Download.targets')" />
</Project>

Просмотреть файл

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict/>
</plist>

Просмотреть файл

@ -0,0 +1,12 @@
using System;
using Foundation;
namespace DatabaseSample
{
public static class ExtensionMethods
{
public static NSString ToNSString (this string str)
{
return new NSString (str);
}
}
}

Просмотреть файл

@ -0,0 +1,14 @@
using System;
namespace DatabaseSample
{
public class Folder
{
public string Node { get; set; }
public string Name { get; set; }
public string Created { get; set; }
public string CreatedUnformatted { get; set; }
public string LastModified { get; set; }
public string LastModifiedUnformatted { get; set; }
public uint NotesCount { get; set; }
}
}

Просмотреть файл

@ -0,0 +1,17 @@
using System;
using Foundation;
using UIKit;
namespace DatabaseSample
{
public partial class FolderCell : UITableViewCell
{
public static readonly NSString Key = new NSString ("FolderCellID");
protected FolderCell (IntPtr handle) : base (handle)
{
// Note: this .ctor should not contain any initialization logic.
}
}
}

Просмотреть файл

@ -0,0 +1,18 @@
// WARNING
//
// This file has been generated automatically by Xamarin Studio from the outlets and
// actions declared in your storyboard file.
// Manual changes to this file will not be maintained.
//
using Foundation;
namespace DatabaseSample
{
[Register ("FolderCell")]
partial class FolderCell
{
void ReleaseDesignerOutlets ()
{
}
}
}

Просмотреть файл

@ -0,0 +1,356 @@
using System;
using UIKit;
using CoreGraphics;
using Foundation;
using Firebase.Auth;
using System.Collections.Generic;
using Firebase.Database;
using System.Text.RegularExpressions;
namespace DatabaseSample
{
public partial class FoldersViewController : UITableViewController
{
UIBarButtonItem space;
UIActivityIndicatorView indicatorView;
UIBarButtonItem btnNewFolder;
UIBarButtonItem btnRefresh;
DatabaseReference userNode;
DatabaseReference foldersCountNode;
DatabaseReference foldersNode;
DatabaseQuery foldersByDate;
List<Folder> folders;
nuint foldersCount;
Auth auth;
protected FoldersViewController (IntPtr handle) : base (handle)
{
// Note: this .ctor should not contain any initialization logic.
}
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
// Perform any additional setup after loading the view, typically from a nib.
InitializeComponents ();
}
public override void ViewWillAppear (bool animated)
{
if (string.IsNullOrWhiteSpace (AppDelegate.UserUid)) {
auth.SignInAnonymously (SignInAnonymouslyCompleted);
} else {
GetFoldersCount ();
}
base.ViewWillAppear (animated);
}
public override void ViewWillDisappear (bool animated)
{
RemoveObserversFromNodes ();
base.ViewWillDisappear (animated);
}
void InitializeComponents ()
{
folders = new List<Folder> ();
auth = Auth.DefaultInstance;
space = new UIBarButtonItem (UIBarButtonSystemItem.FlexibleSpace);
indicatorView = new UIActivityIndicatorView (UIActivityIndicatorViewStyle.White) {
Frame = new CGRect (0, 0, 20, 20),
HidesWhenStopped = true
};
var btnIndicator = new UIBarButtonItem (indicatorView);
btnNewFolder = new UIBarButtonItem ("New Folder", UIBarButtonItemStyle.Plain, btnNewFolder_Clicked) {
TintColor = UIColor.White,
Enabled = false
};
SetToolbarItems (new [] { space, btnIndicator, space, btnNewFolder }, false);
btnRefresh = new UIBarButtonItem (UIBarButtonSystemItem.Refresh);
btnRefresh.Clicked += BtnRefresh_Clicked;
NavigationItem.RightBarButtonItem = btnRefresh;
indicatorView.StartAnimating ();
}
void RemoveObserversFromNodes ()
{
userNode.RemoveAllObservers ();
foldersCountNode.RemoveAllObservers ();
foldersNode.RemoveAllObservers ();
foldersByDate.RemoveAllObservers ();
}
void BtnRefresh_Clicked (object sender, EventArgs e)
{
if (string.IsNullOrWhiteSpace (AppDelegate.UserUid)) {
auth.SignInAnonymously (SignInAnonymouslyCompleted);
} else {
GetFoldersCount ();
}
}
void btnNewFolder_Clicked (object sender, EventArgs e)
{
UIAlertHelper.ShowMessage ("Create a new folder",
"Type a folder name.\nName can contain letters, numbers, spaces, dashes and underscores only",
NavigationController,
"Create",
new [] { "Folder name" },
(alertCanceled, textfieldInputs) => {
if (alertCanceled)
return;
var folderName = textfieldInputs [0].Trim ();
if (string.IsNullOrWhiteSpace (folderName)) {
UIAlertHelper.ShowMessage ("Empty name!", "A folder name cannot be a space or an empty name.", NavigationController, "Ok");
return;
}
if (!VerifyFolderName (folderName)) {
UIAlertHelper.ShowMessage ("Bad folder name!", "A name can contain letters, numbers, spaces, dashes and underscores only.", NavigationController, "Ok");
return;
}
if (VerifyIfFolderExists (folderName)) {
UIAlertHelper.ShowMessage ("Folder exists!", "A folder with that name already exists.", NavigationController, "Ok");
return;
}
CreateFolder (folderName);
});
}
void SignInAnonymouslyCompleted (User user, NSError error)
{
if (error == null) {
AppDelegate.UserUid = user.Uid;
userNode = AppDelegate.RootNode.GetChild ("users").GetChild (AppDelegate.UserUid);
VerifyIfUserExists ();
} else {
AuthErrorCode errorCode;
if (IntPtr.Size == 8) // 64 bits devices
errorCode = (AuthErrorCode)((long)error.Code);
else // 32 bits devices
errorCode = (AuthErrorCode)((int)error.Code);
var title = "Anonymous sign-in failed!";
// Posible error codes that SignInAnonymously method could throw
// Visit https://firebase.google.com/docs/auth/ios/errors for more information
switch (errorCode) {
case AuthErrorCode.OperationNotAllowed:
UIAlertHelper.ShowMessage (title,
"The app uses Anonymous sign-in to work correctly and seems to be disabled…\n" +
"Please, go to Firebase console and enable Anonymous login.\n" +
"Open «Application Output» in Xamarin Studio for more information.",
NavigationController,
"Ok, let me enable it!");
Console.WriteLine ("Anonymous sign-in seems to be disabled. Please, visit the following link to know how " +
"to enable it: https://firebase.google.com/docs/auth/ios/anonymous-auth#before-you-begin");
break;
case AuthErrorCode.NetworkError:
UIAlertHelper.ShowMessage (title,
"Seems to be the first time that you run the sample and you don't have access to internet.\n" +
"The sample needs to run with internet at least once so you can create an Anonymous user.",
NavigationController,
"Ok");
break;
default:
UIAlertHelper.ShowMessage (title,
"An unknown error has ocurred…",
NavigationController,
"Ok");
break;
}
indicatorView.StopAnimating ();
}
}
void VerifyIfUserExists ()
{
userNode.ObserveEvent (DataEventType.Value, (snapshot) => {
if (!snapshot.Exists) {
CreateUser ();
} else {
foldersCountNode = userNode.GetChild ("foldersCount");
foldersNode = AppDelegate.RootNode.GetChild ("folders").GetChild (AppDelegate.UserUid);
foldersByDate = foldersNode.GetQueryOrderedByChild ("negativeLastModified");
GetFoldersCount ();
}
});
}
void CreateUser ()
{
var created = AppDelegate.GetUtcTimestamp ();
foldersCount = 0;
object [] keys = { "created", "foldersCount" };
object [] values = { created, foldersCount };
var data = NSDictionary.FromObjectsAndKeys (values, keys, keys.Length);
userNode.KeepSynced (true);
userNode.SetValue (data);
foldersCountNode = userNode.GetChild ("foldersCount");
foldersNode = AppDelegate.RootNode.GetChild ("folders").GetChild (AppDelegate.UserUid);
foldersByDate = foldersNode.GetQueryOrderedByChild ("negativeLastModified");
}
void CreateFolder (string folderName)
{
var folderNodeName = folderName.Replace (' ', '_');
folderNodeName = char.ToLower (folderNodeName [0]) + folderNodeName.Substring (1, folderNodeName.Length - 1);
var created = AppDelegate.GetUtcTimestamp ();
object [] keys = { "created", "lastModified", "name", "negativeLastModified", "notesCount" };
object [] values = { created, created, folderName, -created, 0 };
var data = NSDictionary.FromObjectsAndKeys (values, keys, keys.Length);
DatabaseReference folderNode = foldersNode.GetChild (folderNodeName);
folderNode.KeepSynced (true);
folderNode.SetValue (data);
foldersCountNode.SetValue (NSNumber.FromNUInt (++foldersCount));
GetFolders ();
}
void GetFoldersCount ()
{
indicatorView.StartAnimating ();
foldersCountNode.ObserveEvent (DataEventType.Value, (snapshot) => {
foldersCount = snapshot.GetValue<NSNumber> ().NUIntValue;
GetFolders ();
});
}
void GetFolders ()
{
folders.Clear ();
if (foldersCount == 0) {
btnNewFolder.Enabled = true;
btnRefresh.Enabled = false;
indicatorView.StopAnimating ();
TableView.ReloadData ();
return;
}
foldersByDate.ObserveEvent (DataEventType.ChildAdded, (snapshot, prevKey) => {
var data = snapshot.GetValue<NSDictionary> ();
var created = (data ["created"] as NSNumber).StringValue;
var lastModified = (data ["lastModified"] as NSNumber).StringValue;
var name = data ["name"].ToString ();
var notesCount = (data ["notesCount"] as NSNumber).UInt32Value;
folders.Add (new Folder {
Node = snapshot.Key,
Name = name,
Created = AppDelegate.ConvertUnformattedUtcDateToCurrentDate (created),
CreatedUnformatted = created,
LastModified = AppDelegate.ConvertUnformattedUtcDateToCurrentDate (lastModified),
LastModifiedUnformatted = lastModified,
NotesCount = notesCount
});
if (folders.Count == (int)foldersCount) {
btnNewFolder.Enabled = true;
btnRefresh.Enabled = false;
indicatorView.StopAnimating ();
TableView.ReloadData ();
}
});
}
void DeleteFolder (Folder folder)
{
foldersNode.GetChild (folder.Node).RemoveValue ();
foldersCountNode.SetValue (NSNumber.FromNUInt (--foldersCount));
folders.Remove (folder);
}
bool VerifyIfFolderExists (string name)
{
return folders.Exists (f => f.Name == name);
}
bool VerifyFolderName (string name)
{
return Regex.IsMatch (name, @"^[\w -]+$");
}
#region UITableView DataSource
public override nint NumberOfSections (UITableView tableView)
{
return 1;
}
public override nint RowsInSection (UITableView tableView, nint section)
{
return Auth.DefaultInstance.CurrentUser != null ? folders.Count : 0;
}
public override UITableViewCell GetCell (UITableView tableView, NSIndexPath indexPath)
{
var folder = folders [indexPath.Row];
var cell = tableView.DequeueReusableCell (FolderCell.Key) as FolderCell;
cell.TextLabel.Text = folder.Name;
cell.DetailTextLabel.Text = folder.NotesCount.ToString ();
return cell;
}
public override bool CanEditRow (UITableView tableView, NSIndexPath indexPath)
{
return true;
}
public override void CommitEditingStyle (UITableView tableView, UITableViewCellEditingStyle editingStyle, NSIndexPath indexPath)
{
switch (editingStyle) {
case UITableViewCellEditingStyle.Delete:
var folder = folders [indexPath.Row];
DeleteFolder (folder);
tableView.DeleteRows (new [] { indexPath }, UITableViewRowAnimation.Automatic);
break;
default:
break;
}
}
#endregion
#region UITableView Delegate
public override void RowSelected (UITableView tableView, NSIndexPath indexPath)
{
var folder = folders [indexPath.Row];
var viewController = Storyboard.InstantiateViewController ("NotesViewControllerID") as NotesViewController;
viewController.Folder = folder;
NavigationController.PushViewController (viewController, true);
}
#endregion
}
}

Просмотреть файл

@ -0,0 +1,20 @@
// WARNING
//
// This file has been generated automatically by Xamarin Studio to store outlets and
// actions made in the UI designer. If it is removed, they will be lost.
// Manual changes to this file may not be handled correctly.
//
using Foundation;
using System.CodeDom.Compiler;
namespace DatabaseSample
{
[Register ("FoldersViewController")]
partial class FoldersViewController
{
void ReleaseDesignerOutlets ()
{
}
}
}

Просмотреть файл

@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>AD_UNIT_ID_FOR_BANNER_TEST</key>
<string>ca-app-pub-3940256099942544/2934735716</string>
<key>AD_UNIT_ID_FOR_INTERSTITIAL_TEST</key>
<string>ca-app-pub-3940256099942544/4411468910</string>
<key>CLIENT_ID</key>
<string>542613023302-jjh4mlc91ehslg1htadg7c9vtam0ekuo.apps.googleusercontent.com</string>
<key>REVERSED_CLIENT_ID</key>
<string>com.googleusercontent.apps.542613023302-jjh4mlc91ehslg1htadg7c9vtam0ekuo</string>
<key>API_KEY</key>
<string>AIzaSyD36zdfPJDkRValUgcv2JKxM0TShl6a1go</string>
<key>GCM_SENDER_ID</key>
<string>542613023302</string>
<key>PLIST_VERSION</key>
<string>1</string>
<key>BUNDLE_ID</key>
<string>com.xamarin.firebase.ios.databasesample</string>
<key>PROJECT_ID</key>
<string>xamarinfirebase-67094</string>
<key>STORAGE_BUCKET</key>
<string>xamarinfirebase-67094.appspot.com</string>
<key>IS_ADS_ENABLED</key>
<false/>
<key>IS_ANALYTICS_ENABLED</key>
<false/>
<key>IS_APPINVITE_ENABLED</key>
<false/>
<key>IS_GCM_ENABLED</key>
<false/>
<key>IS_SIGNIN_ENABLED</key>
<false/>
<key>GOOGLE_APP_ID</key>
<string>1:542613023302:ios:4182147f7af91bf9</string>
<key>DATABASE_URL</key>
<string>https://xamarinfirebase-67094.firebaseio.com</string>
</dict>
</plist>

Просмотреть файл

@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleName</key>
<string>DatabaseSample</string>
<key>CFBundleIdentifier</key>
<string>com.xamarin.firebase.ios.databasesample</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>MinimumOSVersion</key>
<string>8.0</string>
<key>UIDeviceFamily</key>
<array>
<integer>1</integer>
</array>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
<string>Main</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>XSAppIconAssets</key>
<string>Assets.xcassets/AppIcon.appiconset</string>
</dict>
</plist>

Просмотреть файл

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="9532" systemVersion="15D21" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" initialViewController="01J-lp-oVM">
<dependencies>
<deployment identifier="iOS" />
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9530" />
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="EHf-IW-A2E">
<objects>
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="Llm-lL-Icb" />
<viewControllerLayoutGuide type="bottom" id="xb3-aO-Qok" />
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
<rect key="frame" x="0.0" y="0.0" width="600" height="600" />
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES" />
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite" />
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder" />
</objects>
<point key="canvasLocation" x="53" y="375" />
</scene>
</scenes>
</document>

Просмотреть файл

@ -0,0 +1,15 @@
using UIKit;
namespace DatabaseSample
{
public class Application
{
// This is the main entry point of the application.
static void Main (string [] args)
{
// if you want to use a different Application Delegate class from "AppDelegate"
// you can specify it here.
UIApplication.Main (args, null, "AppDelegate");
}
}
}

Просмотреть файл

@ -0,0 +1,197 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11542" systemVersion="15G1108" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="aY8-zM-LUd">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11524"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--Navigation Controller-->
<scene sceneID="MLO-sQ-R4s">
<objects>
<navigationController toolbarHidden="NO" id="aY8-zM-LUd" sceneMemberID="viewController">
<navigationBar key="navigationBar" contentMode="scaleToFill" id="dDW-pd-MgG">
<rect key="frame" x="0.0" y="0.0" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<color key="barTintColor" red="0.0" green="0.52156862749999999" blue="0.8862745098" alpha="1" colorSpace="calibratedRGB"/>
<textAttributes key="titleTextAttributes">
<color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</textAttributes>
</navigationBar>
<toolbar key="toolbar" opaque="NO" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" id="AZI-Hl-XbL">
<rect key="frame" x="0.0" y="623" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<color key="tintColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<color key="barTintColor" red="0.0" green="0.52156862749999999" blue="0.8862745098" alpha="1" colorSpace="calibratedRGB"/>
</toolbar>
<connections>
<segue destination="80F-9t-KkE" kind="relationship" relationship="rootViewController" id="5uf-u5-r3D"/>
</connections>
</navigationController>
<placeholder placeholderIdentifier="IBFirstResponder" id="RG1-Xa-ml0" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-724" y="37"/>
</scene>
<!--Folders-->
<scene sceneID="sAt-aD-Vcu">
<objects>
<tableViewController storyboardIdentifier="FoldersViewControllerID" id="80F-9t-KkE" customClass="FoldersViewController" sceneMemberID="viewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" id="54D-VC-BEJ">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" accessoryType="disclosureIndicator" indentationWidth="10" reuseIdentifier="FolderCellID" textLabel="xyz-0U-i6T" detailTextLabel="Uts-sF-q4p" style="IBUITableViewCellStyleValue1" id="qC0-Nf-IcM" customClass="FolderCell">
<rect key="frame" x="0.0" y="28" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="qC0-Nf-IcM" id="gSU-M8-faF">
<rect key="frame" x="0.0" y="0.0" width="342" height="43"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="xyz-0U-i6T">
<rect key="frame" x="15" y="11" width="34" height="21"/>
<autoresizingMask key="autoresizingMask"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Detail" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="Uts-sF-q4p">
<rect key="frame" x="296" y="11" width="44" height="21"/>
<autoresizingMask key="autoresizingMask"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</tableViewCellContentView>
</tableViewCell>
</prototypes>
<connections>
<outlet property="dataSource" destination="80F-9t-KkE" id="Hfb-eh-ZOs"/>
<outlet property="delegate" destination="80F-9t-KkE" id="Qzs-Br-tku"/>
</connections>
</tableView>
<navigationItem key="navigationItem" title="Folders" id="RBq-FW-mO7"/>
<simulatedNavigationBarMetrics key="simulatedTopBarMetrics" prompted="NO"/>
<simulatedTabBarMetrics key="simulatedBottomBarMetrics"/>
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="vKh-5I-5v0" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="30" y="36"/>
</scene>
<!--Notes-->
<scene sceneID="16s-OL-hBB">
<objects>
<tableViewController storyboardIdentifier="NotesViewControllerID" id="bKV-dp-dcd" customClass="NotesViewController" sceneMemberID="viewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" id="wYd-Va-bJu">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="NoteCellID" id="s5x-k1-cyN" customClass="NoteCell">
<rect key="frame" x="0.0" y="28" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="s5x-k1-cyN" id="Nio-aa-IuH">
<rect key="frame" x="0.0" y="0.0" width="375" height="43"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="S5F-bM-noQ">
<rect key="frame" x="15" y="4" width="352" height="21"/>
<constraints>
<constraint firstAttribute="height" constant="21" id="Gwx-eD-ESb"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Subtitle" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="uX1-ci-csd">
<rect key="frame" x="15" y="25" width="55" height="15"/>
<constraints>
<constraint firstAttribute="width" constant="55" id="hKM-mM-zcd"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="12"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Preview" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="OXH-Mv-YgQ">
<rect key="frame" x="78" y="25" width="289" height="15"/>
<fontDescription key="fontDescription" type="italicSystem" pointSize="12"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<constraints>
<constraint firstItem="OXH-Mv-YgQ" firstAttribute="top" secondItem="S5F-bM-noQ" secondAttribute="bottom" id="1Pa-m1-Ae7"/>
<constraint firstAttribute="trailing" secondItem="OXH-Mv-YgQ" secondAttribute="trailing" constant="8" id="AYh-eL-wXa"/>
<constraint firstItem="OXH-Mv-YgQ" firstAttribute="leading" secondItem="uX1-ci-csd" secondAttribute="trailing" constant="8" id="ArL-Vw-dmX"/>
<constraint firstAttribute="bottom" secondItem="OXH-Mv-YgQ" secondAttribute="bottom" constant="3" id="Emq-OV-Cz2"/>
<constraint firstAttribute="bottom" secondItem="uX1-ci-csd" secondAttribute="bottom" constant="3" id="GNo-iR-RYh"/>
<constraint firstItem="uX1-ci-csd" firstAttribute="top" secondItem="S5F-bM-noQ" secondAttribute="bottom" id="RGM-h9-U8j"/>
<constraint firstItem="S5F-bM-noQ" firstAttribute="leading" secondItem="Nio-aa-IuH" secondAttribute="leading" constant="15" id="VoN-LM-S9d"/>
<constraint firstItem="S5F-bM-noQ" firstAttribute="top" secondItem="Nio-aa-IuH" secondAttribute="top" constant="4" id="lZf-Bc-xAv"/>
<constraint firstItem="uX1-ci-csd" firstAttribute="leading" secondItem="Nio-aa-IuH" secondAttribute="leading" constant="15" id="uSO-q2-KUO"/>
<constraint firstAttribute="trailing" secondItem="S5F-bM-noQ" secondAttribute="trailing" constant="8" id="vhK-VM-v4F"/>
</constraints>
</tableViewCellContentView>
<connections>
<outlet property="LblPreview" destination="OXH-Mv-YgQ" id="3kg-SV-qjo"/>
<outlet property="LblSubtitle" destination="uX1-ci-csd" id="nUG-Wb-A99"/>
<outlet property="LblTitle" destination="S5F-bM-noQ" id="mL3-m6-oFC"/>
</connections>
</tableViewCell>
</prototypes>
<connections>
<outlet property="dataSource" destination="bKV-dp-dcd" id="mlO-WN-npL"/>
<outlet property="delegate" destination="bKV-dp-dcd" id="UDc-ej-70U"/>
</connections>
</tableView>
<navigationItem key="navigationItem" title="Notes" id="noB-9a-PQf"/>
<simulatedNavigationBarMetrics key="simulatedTopBarMetrics" prompted="NO"/>
<simulatedTabBarMetrics key="simulatedBottomBarMetrics"/>
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="pAQ-Xk-STV" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="813.60000000000002" y="35.532233883058474"/>
</scene>
<!--Note View Controller-->
<scene sceneID="qSw-yt-UCI">
<objects>
<viewController storyboardIdentifier="NoteViewControllerID" id="Pvg-Rw-Itl" customClass="NoteViewController" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="UFV-Nd-eT3"/>
<viewControllerLayoutGuide type="bottom" id="RSJ-MX-s2d"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="sOh-si-mb3">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" textAlignment="justified" translatesAutoresizingMaskIntoConstraints="NO" id="BYg-rk-pnE">
<rect key="frame" x="0.0" y="0.0" width="375" height="618"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
</textView>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="RSJ-MX-s2d" firstAttribute="top" secondItem="BYg-rk-pnE" secondAttribute="bottom" id="7K2-tB-U3j"/>
<constraint firstItem="BYg-rk-pnE" firstAttribute="top" secondItem="sOh-si-mb3" secondAttribute="top" id="Ayk-iR-qeR"/>
<constraint firstItem="BYg-rk-pnE" firstAttribute="leading" secondItem="sOh-si-mb3" secondAttribute="leading" id="b5s-p8-pvJ"/>
<constraint firstAttribute="trailing" secondItem="BYg-rk-pnE" secondAttribute="trailing" id="jpg-mP-Qwz"/>
</constraints>
</view>
<simulatedNavigationBarMetrics key="simulatedTopBarMetrics" prompted="NO"/>
<simulatedTabBarMetrics key="simulatedBottomBarMetrics"/>
<connections>
<outlet property="TxtContent" destination="BYg-rk-pnE" id="b40-Fl-xCr"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="wYj-lz-Ofe" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="1612" y="35.532233883058474"/>
</scene>
</scenes>
</document>

Просмотреть файл

@ -0,0 +1,14 @@
using System;
namespace DatabaseSample
{
public class Note
{
public string Node { get; set; }
public string Title { get; set; }
public string Content { get; set; }
public string Created { get; set; }
public string CreatedUnformatted { get; set; }
public string LastModified { get; set; }
public string LastModifiedUnformatted { get; set; }
}
}

Просмотреть файл

@ -0,0 +1,32 @@
using System;
using Foundation;
using UIKit;
namespace DatabaseSample
{
public partial class NoteCell : UITableViewCell
{
public static readonly NSString Key = new NSString ("NoteCellID");
public string TitleText {
get { return LblTitle.Text; }
set { LblTitle.Text = value; }
}
public string SubtitleText {
get { return LblSubtitle.Text; }
set { LblSubtitle.Text = value; }
}
public string PreviewText {
get { return LblPreview.Text; }
set { LblPreview.Text = value; }
}
protected NoteCell (IntPtr handle) : base (handle)
{
// Note: this .ctor should not contain any initialization logic.
}
}
}

Просмотреть файл

@ -0,0 +1,42 @@
// WARNING
//
// This file has been generated automatically by Xamarin Studio to store outlets and
// actions made in the UI designer. If it is removed, they will be lost.
// Manual changes to this file may not be handled correctly.
//
using Foundation;
using System.CodeDom.Compiler;
namespace DatabaseSample
{
[Register ("NoteCell")]
partial class NoteCell
{
[Outlet]
UIKit.UILabel LblPreview { get; set; }
[Outlet]
UIKit.UILabel LblSubtitle { get; set; }
[Outlet]
UIKit.UILabel LblTitle { get; set; }
void ReleaseDesignerOutlets ()
{
if (LblTitle != null) {
LblTitle.Dispose ();
LblTitle = null;
}
if (LblSubtitle != null) {
LblSubtitle.Dispose ();
LblSubtitle = null;
}
if (LblPreview != null) {
LblPreview.Dispose ();
LblPreview = null;
}
}
}
}

Просмотреть файл

@ -0,0 +1,137 @@
using System;
using UIKit;
using CoreGraphics;
using Firebase.Database;
using Foundation;
namespace DatabaseSample
{
public partial class NoteViewController : UIViewController
{
UIBarButtonItem space;
UIBarButtonItem btnDeleteNote;
UITextField txtTitle;
DatabaseReference folderLastModifiedNode;
DatabaseReference folderNegativeLastModifiedNode;
DatabaseReference notesCountNode;
DatabaseReference noteNode;
DatabaseReference deletedFolderNode;
bool deleteNote;
public Folder Folder { get; set; }
public Note Note { get; set; }
public nuint NotesCount { get; set; }
protected NoteViewController (IntPtr handle) : base (handle)
{
// Note: this .ctor should not contain any initialization logic.
}
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
// Perform any additional setup after loading the view, typically from a nib.
InitializeComponents ();
}
public override void ViewWillAppear (bool animated)
{
if (Note == null) {
CreateNote ();
}
txtTitle.Text = Note.Title;
TxtContent.Text = Note.Content;
CreateNodes ();
base.ViewWillAppear (animated);
}
public override void ViewWillDisappear (bool animated)
{
var title = txtTitle.Text;
var content = TxtContent.Text;
if (deleteNote || (string.IsNullOrWhiteSpace (title) && string.IsNullOrWhiteSpace (content)))
DeleteNote ();
else if (title != Note.Title || content != Note.Content)
SaveNote ();
base.ViewWillDisappear (animated);
}
void InitializeComponents ()
{
txtTitle = new UITextField (new CGRect (0, 0, NavigationController.NavigationBar.Bounds.Width, 22)) {
Placeholder = "Type your title here",
TextColor = UIColor.White,
TextAlignment = UITextAlignment.Center,
};
NavigationItem.TitleView = txtTitle;
space = new UIBarButtonItem (UIBarButtonSystemItem.FlexibleSpace);
btnDeleteNote = new UIBarButtonItem (UIBarButtonSystemItem.Trash, btnDeleteNote_Clicked) {
TintColor = UIColor.White
};
SetToolbarItems (new [] { space, btnDeleteNote }, false);
}
void CreateNodes ()
{
var folderNode = AppDelegate.RootNode.GetChild ("folders").GetChild (AppDelegate.UserUid).GetChild (Folder.Node);
folderLastModifiedNode = folderNode.GetChild ("lastModified");
folderNegativeLastModifiedNode = folderNode.GetChild ("negativeLastModified");
notesCountNode = folderNode.GetChild ("notesCount");
noteNode = noteNode ?? AppDelegate.RootNode.GetChild ("notes").GetChild (AppDelegate.UserUid).GetChild (Folder.Node).GetChild (Note.Node);
}
void btnDeleteNote_Clicked (object sender, EventArgs e)
{
deleteNote = true;
NavigationController.PopViewController (true);
}
void CreateNote ()
{
noteNode = AppDelegate.RootNode.GetChild ("notes").GetChild (AppDelegate.UserUid).GetChild (Folder.Node).GetChildByAutoId ();
Note = new Note {
Node = noteNode.Key
};
++NotesCount;
}
void DeleteNote ()
{
noteNode.RemoveValue ();
notesCountNode.SetValue (NSNumber.FromNUInt (--NotesCount));
}
void SaveNote ()
{
var title = txtTitle.Text.Trim ();
var content = TxtContent.Text.Trim ();
var lastModified = AppDelegate.GetUtcTimestamp ();
var created = Note.CreatedUnformatted ?? lastModified.ToString ();
title = string.IsNullOrWhiteSpace (title) ? null : title;
content = string.IsNullOrWhiteSpace (content) ? null : content;
object [] keys = { "content", "created", "lastModified", "negativeLastModified", "title" };
object [] values = { content, double.Parse (created), lastModified, -lastModified, title };
var data = NSDictionary.FromObjectsAndKeys (values, keys, keys.Length);
noteNode.KeepSynced (true);
noteNode.SetValue (data);
notesCountNode.SetValue (NSNumber.FromNUInt (NotesCount));
folderLastModifiedNode.SetValue (NSNumber.FromDouble (lastModified));
folderNegativeLastModifiedNode.SetValue (NSNumber.FromDouble (-lastModified));
}
}
}

Просмотреть файл

@ -0,0 +1,26 @@
// WARNING
//
// This file has been generated automatically by Xamarin Studio to store outlets and
// actions made in the UI designer. If it is removed, they will be lost.
// Manual changes to this file may not be handled correctly.
//
using Foundation;
using System.CodeDom.Compiler;
namespace DatabaseSample
{
[Register ("NoteViewController")]
partial class NoteViewController
{
[Outlet]
UIKit.UITextView TxtContent { get; set; }
void ReleaseDesignerOutlets ()
{
if (TxtContent != null) {
TxtContent.Dispose ();
TxtContent = null;
}
}
}
}

Просмотреть файл

@ -0,0 +1,221 @@
using System;
using UIKit;
using CoreGraphics;
using Firebase.Database;
using System.Collections.Generic;
using Foundation;
namespace DatabaseSample
{
public partial class NotesViewController : UITableViewController
{
UIBarButtonItem space;
UIActivityIndicatorView indicatorView;
UIBarButtonItem btnNewNote;
UILabel lblNotesCount;
DatabaseReference lastModifiedNode;
DatabaseReference negativeLastModifiedNode;
DatabaseReference notesCountNode;
DatabaseReference notesNode;
DatabaseQuery notesByDate;
List<Note> notes;
nuint notesCount;
public Folder Folder { get; set; }
protected NotesViewController (IntPtr handle) : base (handle)
{
// Note: this .ctor should not contain any initialization logic.
}
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
// Perform any additional setup after loading the view, typically from a nib.
InitializeComponents ();
}
public override void ViewWillAppear (bool animated)
{
CreateNodes ();
GetNotesCount ();
base.ViewWillAppear (animated);
}
public override void ViewWillDisappear (bool animated)
{
RemoveObserversFromNodes ();
base.ViewWillDisappear (animated);
}
void InitializeComponents ()
{
notes = new List<Note> ();
space = new UIBarButtonItem (UIBarButtonSystemItem.FlexibleSpace);
indicatorView = new UIActivityIndicatorView (UIActivityIndicatorViewStyle.White) {
Frame = new CGRect (0, 0, 20, 20),
HidesWhenStopped = true
};
var btnIndicator = new UIBarButtonItem (indicatorView);
var count = Folder.NotesCount;
lblNotesCount = new UILabel (new CGRect (0, 0, 50, 15)) {
Font = UIFont.SystemFontOfSize (12)
};
lblNotesCount.Text = $"{count} note{count != 1 ? "s" : ""}";
var btnNotesCount = new UIBarButtonItem (lblNotesCount);
btnNewNote = new UIBarButtonItem (UIBarButtonSystemItem.Compose, btnNewNote_Clicked) {
TintColor = UIColor.White
};
SetToolbarItems (new [] { space, space, btnIndicator, btnNotesCount, space, space, btnNewNote }, false);
}
void CreateNodes ()
{
var folderNode = AppDelegate.RootNode.GetChild ("folders").GetChild (AppDelegate.UserUid).GetChild (Folder.Node);
lastModifiedNode = folderNode.GetChild ("lastModified");
negativeLastModifiedNode = folderNode.GetChild ("negativeLastModified");
notesCountNode = folderNode.GetChild ("notesCount");
notesNode = AppDelegate.RootNode.GetChild ("notes").GetChild (AppDelegate.UserUid).GetChild (Folder.Node);
notesByDate = notesNode.GetQueryOrderedByChild ("negativeLastModified");
}
void RemoveObserversFromNodes ()
{
lastModifiedNode.RemoveAllObservers ();
negativeLastModifiedNode.RemoveAllObservers ();
notesCountNode.RemoveAllObservers ();
notesNode.RemoveAllObservers ();
}
void btnNewNote_Clicked (object sender, EventArgs e)
{
var viewController = Storyboard.InstantiateViewController ("NoteViewControllerID") as NoteViewController;
viewController.Folder = Folder;
viewController.NotesCount = notesCount;
NavigationController.PushViewController (viewController, true);
}
void GetNotesCount ()
{
indicatorView.StartAnimating ();
notesCountNode.ObserveEvent (DataEventType.Value, (snapshot) => {
notesCount = snapshot.GetValue<NSNumber> ().NUIntValue;
GetNotes ();
});
}
void GetNotes ()
{
notes.Clear ();
if (notesCount == 0) {
TableView.ReloadData ();
return;
}
notesByDate.ObserveEvent (DataEventType.ChildAdded, (snapshot, prevKey) => {
var data = snapshot.GetValue<NSDictionary> ();
var content = data ["content"]?.ToString ();
var created = (data ["created"] as NSNumber).StringValue;
var lastModified = (data ["lastModified"] as NSNumber).StringValue;
var title = data ["title"]?.ToString ();
notes.Add (new Note {
Node = snapshot.Key,
Content = content,
Created = AppDelegate.ConvertUnformattedUtcDateToCurrentDate (created),
CreatedUnformatted = created,
LastModified = AppDelegate.ConvertUnformattedUtcDateToCurrentDate (lastModified),
LastModifiedUnformatted = lastModified,
Title = title
});
if (notes.Count == (int)notesCount)
TableView.ReloadData ();
});
}
void DeleteNote (Note note)
{
notesNode.GetChild (note.Node).RemoveValue ();
notesCountNode.SetValue (NSNumber.FromNUInt (--notesCount));
notes.Remove (note);
}
#region UITableView DataSource
public override nint NumberOfSections (UITableView tableView)
{
return 1;
}
public override nint RowsInSection (UITableView tableView, nint section)
{
indicatorView.StopAnimating ();
return notes.Count;
}
public override UITableViewCell GetCell (UITableView tableView, NSIndexPath indexPath)
{
var note = notes [indexPath.Row];
var cell = tableView.DequeueReusableCell (NoteCell.Key) as NoteCell;
cell.TitleText = note.Title ?? "<No Title>";
cell.SubtitleText = note.LastModified;
var content = note.Content ?? "<No content>";
var textLength = content.Length > 70 ? 70 : content.Length;
cell.PreviewText = content.Substring (0, textLength);
return cell;
}
public override bool CanEditRow (UITableView tableView, NSIndexPath indexPath)
{
return true;
}
public override void CommitEditingStyle (UITableView tableView, UITableViewCellEditingStyle editingStyle, NSIndexPath indexPath)
{
switch (editingStyle) {
case UITableViewCellEditingStyle.Delete:
var note = notes [indexPath.Row];
DeleteNote (note);
tableView.DeleteRows (new [] { indexPath }, UITableViewRowAnimation.Automatic);
break;
default:
break;
}
}
#endregion
#region UITableView Delegate
public override void RowSelected (UITableView tableView, NSIndexPath indexPath)
{
var note = notes [indexPath.Row];
var viewController = Storyboard.InstantiateViewController ("NoteViewControllerID") as NoteViewController;
viewController.Folder = Folder;
viewController.Note = note;
viewController.NotesCount = notesCount;
NavigationController.PushViewController (viewController, true);
}
#endregion
}
}

Просмотреть файл

@ -0,0 +1,20 @@
// WARNING
//
// This file has been generated automatically by Xamarin Studio to store outlets and
// actions made in the UI designer. If it is removed, they will be lost.
// Manual changes to this file may not be handled correctly.
//
using Foundation;
using System.CodeDom.Compiler;
namespace DatabaseSample
{
[Register ("NotesViewController")]
partial class NotesViewController
{
void ReleaseDesignerOutlets ()
{
}
}
}

Просмотреть файл

@ -0,0 +1,182 @@
using System;
using UIKit;
using System.Collections.Generic;
namespace DatabaseSample
{
public class UIAlertHelper
{
public delegate void UIAlertControllerTextFieldResultHandler (bool alertCanceled, string [] textfieldInputs);
/// <summary>
/// Shows a simple alert with a single button.
/// </summary>
/// <param name="title">The title of the alert.</param>
/// <param name="message">Message to show to user.</param>
/// <param name="fromViewController">From which view the alert will be presented.</param>
/// <param name="okAction">Action to be done when user press the Ok button.</param>
public static void ShowMessage (string title, string message, UIViewController fromViewController, string okTitle, Action okAction = null)
{
if (UIDevice.CurrentDevice.CheckSystemVersion (8, 0)) {
var alert = UIAlertController.Create (title, message, UIAlertControllerStyle.Alert);
alert.AddAction (UIAlertAction.Create (okTitle, UIAlertActionStyle.Default, (obj) => {
okAction?.Invoke ();
}));
fromViewController.PresentViewController (alert, true, null);
} else {
var alert = new UIAlertView (title, message, null, "Ok", null);
alert.Dismissed += (sender, e) => {
okAction?.Invoke ();
};
alert.Show ();
}
}
/// <summary>
/// Shows an alert with custom buttons.
/// </summary>
/// <param name="title">The title of the alert.</param>
/// <param name="message">Message to show to user.</param>
/// <param name="fromViewController">From which view the alert will be presented.</param>
/// <param name="cancelTitle">Title for Cancel button. Pass null if you don't want a Cancel button.</param>
/// <param name="cancelAction">Action to be done when user press the Cancel button. Pass null if action no needed</param>
/// <param name="destructiveTitle">Title for Destructive button. Pass null if you don't want a Destructive button.</param>
/// <param name="destructiveAction">Action to be done when user press the Destructive button. Pass null if action no needed.</param>
/// <param name="otherTitles">Title for custom buttons.</param>
/// <param name="otherActions">Actions for custom buttons.</param>
public static void ShowMessage (string title, string message, UIViewController fromViewController,
string cancelTitle, Action cancelAction,
string destructiveTitle, Action destructiveAction,
string [] otherTitles, Action [] otherActions)
{
if (string.IsNullOrWhiteSpace (cancelTitle) &&
string.IsNullOrWhiteSpace (destructiveTitle) &&
otherTitles == null) {
ShowMessage (title, message, fromViewController, "Ok");
return;
}
if (otherTitles != null &&
otherActions != null &&
otherTitles.Length != otherActions.Length)
throw new ArgumentException ("otherTitles and otherActions arrays have different sizes");
if (UIDevice.CurrentDevice.CheckSystemVersion (8, 0)) {
var alert = UIAlertController.Create (title, message, UIAlertControllerStyle.Alert);
if (!string.IsNullOrWhiteSpace (destructiveTitle))
alert.AddAction (UIAlertAction.Create (destructiveTitle, UIAlertActionStyle.Destructive, (obj) => {
destructiveAction?.Invoke ();
}));
if (!string.IsNullOrWhiteSpace (cancelTitle))
alert.AddAction (UIAlertAction.Create (cancelTitle, UIAlertActionStyle.Cancel, (obj) => {
cancelAction?.Invoke ();
}));
if (otherTitles != null && otherActions != null) {
for (int i = 0; i < otherTitles.Length; i++) {
var otherTitle = otherTitles [i];
var otherAction = otherActions [i];
alert.AddAction (UIAlertAction.Create (otherTitle, UIAlertActionStyle.Default, (obj) => {
otherAction?.Invoke ();
}));
}
}
fromViewController.PresentViewController (alert, true, null);
} else {
var buttons = new List<string> ();
if (otherTitles != null)
buttons.AddRange (otherTitles);
if (!string.IsNullOrWhiteSpace (cancelTitle))
buttons.Add (cancelTitle);
var alert = new UIAlertView (title, message, null, destructiveTitle, buttons.ToArray ());
alert.Dismissed += (sender, e) => {
if (e.ButtonIndex <= 0)
destructiveAction?.Invoke ();
else if (otherTitles == null || e.ButtonIndex > otherTitles.Length)
cancelAction?.Invoke ();
else
otherActions [e.ButtonIndex - 1]?.Invoke ();
};
alert.Show ();
}
}
/// <summary>
/// Shows an alert with Textfields.
/// For iOS 7 or before, an alert with a Textfield will be shown.
/// </summary>
/// <param name="title">The title of the alert.</param>
/// <param name="message">Message to show to user.</param>
/// <param name="fromViewController">From which view the alert will be presented.</param>
/// <param name="okTitle">Title for Ok button.</param>
/// <param name="placeholders">
/// Placeholders to be shown in textfields. A Textfield will be added for each placeholder
/// If null or an empty array is passed, a simple alert will be shown.
/// </param>
/// <param name="result">
/// Action to be done when user press one button of alert.
/// Will return all inputs from Textfields in order that were shown or null if Cancel button was tapped.
/// </param>
public static void ShowMessage (string title, string message, UIViewController fromViewController,
string okTitle, string [] placeholders, UIAlertControllerTextFieldResultHandler result)
{
if (string.IsNullOrWhiteSpace (okTitle))
okTitle = "Ok";
if (placeholders == null || placeholders.Length == 0) {
ShowMessage (title, message, fromViewController, okTitle);
return;
}
if (UIDevice.CurrentDevice.CheckSystemVersion (8, 0)) {
var alert = UIAlertController.Create (title, message, UIAlertControllerStyle.Alert);
foreach (var placeholder in placeholders) {
alert.AddTextField ((textField) => {
textField.Placeholder = placeholder;
textField.TextAlignment = UITextAlignment.Center;
});
}
alert.AddAction (UIAlertAction.Create (okTitle, UIAlertActionStyle.Default, (obj) => {
var textfields = alert.TextFields;
var inputs = new string [textfields.Length];
for (int i = 0; i < textfields.Length; i++)
inputs [i] = textfields [i].Text;
result?.Invoke (false, inputs);
}));
alert.AddAction (UIAlertAction.Create ("Cancel", UIAlertActionStyle.Cancel, (obj) => {
result?.Invoke (true, null);
}));
fromViewController.PresentViewController (alert, true, null);
} else {
var alert = new UIAlertView (title, message, null, "Cancel", okTitle) {
AlertViewStyle = UIAlertViewStyle.PlainTextInput
};
alert.Dismissed += (sender, e) => {
if (e.ButtonIndex == 0) {
result?.Invoke (true, null);
} else {
var value = (sender as UIAlertView).GetTextField (0).Text;
result?.Invoke (false, new [] { value });
}
};
alert.Show ();
}
}
}
}

Просмотреть файл

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Xamarin.Build.Download" version="0.2.2" targetFramework="xamarinios10" />
</packages>

Просмотреть файл

@ -0,0 +1,29 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Firebase.Database", "Firebase.Database\Firebase.Database.csproj", "{7C28F952-273E-4888-A9D7-61057B5361C3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Firebase.InstanceID", "..\..\Firebase.InstanceID\source\Firebase.InstanceID\Firebase.InstanceID.csproj", "{D6AA184C-DA45-4BBB-988A-451B20C7B804}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Firebase.Analytics", "..\..\Firebase.Analytics\source\Firebase.Analytics\Firebase.Analytics.csproj", "{87BB564C-85A8-4EC1-AD16-EC0A1ACCEE56}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{7C28F952-273E-4888-A9D7-61057B5361C3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7C28F952-273E-4888-A9D7-61057B5361C3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7C28F952-273E-4888-A9D7-61057B5361C3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7C28F952-273E-4888-A9D7-61057B5361C3}.Release|Any CPU.Build.0 = Release|Any CPU
{D6AA184C-DA45-4BBB-988A-451B20C7B804}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D6AA184C-DA45-4BBB-988A-451B20C7B804}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D6AA184C-DA45-4BBB-988A-451B20C7B804}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D6AA184C-DA45-4BBB-988A-451B20C7B804}.Release|Any CPU.Build.0 = Release|Any CPU
{87BB564C-85A8-4EC1-AD16-EC0A1ACCEE56}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{87BB564C-85A8-4EC1-AD16-EC0A1ACCEE56}.Debug|Any CPU.Build.0 = Debug|Any CPU
{87BB564C-85A8-4EC1-AD16-EC0A1ACCEE56}.Release|Any CPU.ActiveCfg = Release|Any CPU
{87BB564C-85A8-4EC1-AD16-EC0A1ACCEE56}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal

Просмотреть файл

@ -0,0 +1,564 @@
using System;
using UIKit;
using Foundation;
using ObjCRuntime;
using CoreGraphics;
using CoreFoundation;
namespace Firebase.Database
{
// @interface FIRDatabase : NSObject
[BaseType (typeof (NSObject), Name = "FIRDatabase")]
interface Database
{
// +(FIRDatabase * _Nonnull)database;
[Static]
[Export ("database")]
Database DefaultInstance { get; }
// +(FIRDatabase * _Nonnull)databaseForApp:(FIRApp * _Nonnull)app;
[Static]
[Export ("databaseForApp:")]
Database From (Firebase.Analytics.App app);
// @property (readonly, nonatomic, weak) FIRApp * _Nullable app;
[NullAllowed, Export ("app", ArgumentSemantic.Weak)]
Firebase.Analytics.App App { get; }
// -(FIRDatabaseReference * _Nonnull)reference;
[Export ("reference")]
DatabaseReference RootReference { get; }
// -(FIRDatabaseReference * _Nonnull)referenceWithPath:(NSString * _Nonnull)path;
[Export ("referenceWithPath:")]
DatabaseReference GetReferenceFromPath (string path);
// -(FIRDatabaseReference * _Nonnull)referenceFromURL:(NSString * _Nonnull)databaseUrl;
[Export ("referenceFromURL:")]
DatabaseReference GetReferenceFromUrl (string databaseUrl);
// -(void)purgeOutstandingWrites;
[Export ("purgeOutstandingWrites")]
void PurgeOutstandingWrites ();
// -(void)goOffline;
[Export ("goOffline")]
void GoOffline ();
// -(void)goOnline;
[Export ("goOnline")]
void GoOnline ();
// @property (nonatomic) BOOL persistenceEnabled;
[Export ("persistenceEnabled")]
bool PersistenceEnabled { get; set; }
// @property (nonatomic, strong) dispatch_queue_t _Nonnull callbackQueue;
[Export ("callbackQueue", ArgumentSemantic.Strong)]
DispatchQueue CallbackQueue { get; set; }
// +(void)setLoggingEnabled:(BOOL)enabled;
[Static]
[Export ("setLoggingEnabled:")]
void SetLoggingEnabled (bool enabled);
// +(NSString * _Nonnull)sdkVersion;
[Static]
[Export ("sdkVersion")]
string SdkVersion { get; }
}
delegate void DatabaseQueryUpdateHandler (DataSnapshot snapshot);
delegate void DatabaseQueryPreviousSiblingKeyUpdateHandler (DataSnapshot snapshot, [NullAllowed] string prevKey);
delegate void DatabaseQueryCancelHandler (NSError error);
// @interface FIRDatabaseQuery : NSObject
[BaseType (typeof (NSObject), Name = "FIRDatabaseQuery")]
interface DatabaseQuery
{
// -(FIRDatabaseHandle)observeEventType:(FIRDataEventType)eventType withBlock:(void (^ _Nonnull)(FIRDataSnapshot * _Nonnull))block;
[Export ("observeEventType:withBlock:")]
nuint ObserveEvent (DataEventType eventType, DatabaseQueryUpdateHandler completionHandler);
// -(FIRDatabaseHandle)observeEventType:(FIRDataEventType)eventType andPreviousSiblingKeyWithBlock:(void (^ _Nonnull)(FIRDataSnapshot * _Nonnull, NSString * _Nullable))block;
[Export ("observeEventType:andPreviousSiblingKeyWithBlock:")]
nuint ObserveEvent (DataEventType eventType, DatabaseQueryPreviousSiblingKeyUpdateHandler completionHandler);
// -(FIRDatabaseHandle)observeEventType:(FIRDataEventType)eventType withBlock:(void (^ _Nonnull)(FIRDataSnapshot * _Nonnull))block withCancelBlock:(void (^ _Nullable)(NSError * _Nonnull))cancelBlock;
[Export ("observeEventType:withBlock:withCancelBlock:")]
nuint ObserveEvent (DataEventType eventType, DatabaseQueryUpdateHandler completionHandler, [NullAllowed] DatabaseQueryCancelHandler cancelHandler);
// -(FIRDatabaseHandle)observeEventType:(FIRDataEventType)eventType andPreviousSiblingKeyWithBlock:(void (^ _Nonnull)(FIRDataSnapshot * _Nonnull, NSString * _Nullable))block withCancelBlock:(void (^ _Nullable)(NSError * _Nonnull))cancelBlock;
[Export ("observeEventType:andPreviousSiblingKeyWithBlock:withCancelBlock:")]
nuint ObserveEvent (DataEventType eventType, DatabaseQueryPreviousSiblingKeyUpdateHandler completionHandler, [NullAllowed] DatabaseQueryCancelHandler cancelHandler);
// -(void)observeSingleEventOfType:(FIRDataEventType)eventType withBlock:(void (^ _Nonnull)(FIRDataSnapshot * _Nonnull))block;
[Export ("observeSingleEventOfType:withBlock:")]
void ObserveSingleEvent (DataEventType eventType, DatabaseQueryUpdateHandler completionHandler);
// -(void)observeSingleEventOfType:(FIRDataEventType)eventType andPreviousSiblingKeyWithBlock:(void (^ _Nonnull)(FIRDataSnapshot * _Nonnull, NSString * _Nullable))block;
[Export ("observeSingleEventOfType:andPreviousSiblingKeyWithBlock:")]
void ObserveSingleEvent (DataEventType eventType, DatabaseQueryPreviousSiblingKeyUpdateHandler completionHandler);
// -(void)observeSingleEventOfType:(FIRDataEventType)eventType withBlock:(void (^ _Nonnull)(FIRDataSnapshot * _Nonnull))block withCancelBlock:(void (^ _Nullable)(NSError * _Nonnull))cancelBlock;
[Export ("observeSingleEventOfType:withBlock:withCancelBlock:")]
void ObserveSingleEvent (DataEventType eventType, DatabaseQueryUpdateHandler completionHandler, [NullAllowed] DatabaseQueryCancelHandler cancelHandler);
// -(void)observeSingleEventOfType:(FIRDataEventType)eventType andPreviousSiblingKeyWithBlock:(void (^ _Nonnull)(FIRDataSnapshot * _Nonnull, NSString * _Nullable))block withCancelBlock:(void (^ _Nullable)(NSError * _Nonnull))cancelBlock;
[Export ("observeSingleEventOfType:andPreviousSiblingKeyWithBlock:withCancelBlock:")]
void ObserveSingleEvent (DataEventType eventType, DatabaseQueryPreviousSiblingKeyUpdateHandler completionHandler, [NullAllowed] DatabaseQueryCancelHandler cancelHandler);
// -(void)removeObserverWithHandle:(FIRDatabaseHandle)handle;
[Export ("removeObserverWithHandle:")]
void RemoveObserver (nuint handle);
// -(void)removeAllObservers;
[Export ("removeAllObservers")]
void RemoveAllObservers ();
// -(void)keepSynced:(BOOL)keepSynced;
[Export ("keepSynced:")]
void KeepSynced (bool keepSynced);
// -(FIRDatabaseQuery * _Nonnull)queryLimitedToFirst:(NSUInteger)limit;
[Export ("queryLimitedToFirst:")]
DatabaseQuery GetQueryLimitedToFirst (nuint limit);
// -(FIRDatabaseQuery * _Nonnull)queryLimitedToLast:(NSUInteger)limit;
[Export ("queryLimitedToLast:")]
DatabaseQuery GetQueryLimitedToLast (nuint limit);
// -(FIRDatabaseQuery * _Nonnull)queryOrderedByChild:(NSString * _Nonnull)key;
[Export ("queryOrderedByChild:")]
DatabaseQuery GetQueryOrderedByChild (string key);
// -(FIRDatabaseQuery * _Nonnull)queryOrderedByKey;
[Export ("queryOrderedByKey")]
DatabaseQuery GetQueryOrderedByKey ();
// -(FIRDatabaseQuery * _Nonnull)queryOrderedByValue;
[Export ("queryOrderedByValue")]
DatabaseQuery GetQueryOrderedByValue ();
// -(FIRDatabaseQuery * _Nonnull)queryOrderedByPriority;
[Export ("queryOrderedByPriority")]
DatabaseQuery GetQueryOrderedByPriority ();
// -(FIRDatabaseQuery * _Nonnull)queryStartingAtValue:(id _Nullable)startValue;
[Export ("queryStartingAtValue:")]
DatabaseQuery GetQueryStartingAtValue ([NullAllowed] NSObject startValue);
// -(FIRDatabaseQuery * _Nonnull)queryStartingAtValue:(id _Nullable)startValue childKey:(NSString * _Nullable)childKey;
[Export ("queryStartingAtValue:childKey:")]
DatabaseQuery GetQueryStartingAtValue ([NullAllowed] NSObject startValue, [NullAllowed] string childKey);
// -(FIRDatabaseQuery * _Nonnull)queryEndingAtValue:(id _Nullable)endValue;
[Export ("queryEndingAtValue:")]
DatabaseQuery GetQueryEndingAtValue ([NullAllowed] NSObject endValue);
// -(FIRDatabaseQuery * _Nonnull)queryEndingAtValue:(id _Nullable)endValue childKey:(NSString * _Nullable)childKey;
[Export ("queryEndingAtValue:childKey:")]
DatabaseQuery GetQueryEndingAtValue ([NullAllowed] NSObject endValue, [NullAllowed] string childKey);
// -(FIRDatabaseQuery * _Nonnull)queryEqualToValue:(id _Nullable)value;
[Export ("queryEqualToValue:")]
DatabaseQuery GetQueryEqualToValue ([NullAllowed] NSObject value);
// -(FIRDatabaseQuery * _Nonnull)queryEqualToValue:(id _Nullable)value childKey:(NSString * _Nullable)childKey;
[Export ("queryEqualToValue:childKey:")]
DatabaseQuery GetQueryEqualToValue ([NullAllowed] NSObject value, [NullAllowed] string childKey);
// @property (readonly, nonatomic, strong) FIRDatabaseReference * _Nonnull ref;
[Export ("ref", ArgumentSemantic.Strong)]
DatabaseReference Reference { get; }
}
delegate void DatabaseReferenceCompletionHandler ([NullAllowed] NSError error, DatabaseReference reference);
delegate TransactionResult DatabaseReferenceTransactionHandler (MutableData currentData);
delegate void DatabaseReferenceTransactionCompletionHandler ([NullAllowed] NSError error, bool commited, [NullAllowed] DatabaseReference reference);
// @interface FIRDatabaseReference : FIRDatabaseQuery
[BaseType (typeof (DatabaseQuery), Name = "FIRDatabaseReference")]
interface DatabaseReference
{
// -(FIRDatabaseReference * _Nonnull)child:(NSString * _Nonnull)pathString;
[Export ("child:")]
DatabaseReference GetChild (string pathString);
// -(FIRDatabaseReference * _Nonnull)childByAppendingPath:(NSString * _Nonnull)pathString __attribute__((deprecated("use child: instead")));
[Obsolete ("use GetChild method instead.")]
[Export ("childByAppendingPath:")]
DatabaseReference GetChildByAppendingPath (string pathString);
// -(FIRDatabaseReference * _Nonnull)childByAutoId;
[Export ("childByAutoId")]
DatabaseReference GetChildByAutoId ();
// -(void)setValue:(id _Nullable)value;
[Internal]
[Export ("setValue:")]
void _SetValue ([NullAllowed] NSObject value);
// -(void)setValue:(id _Nullable)value withCompletionBlock:(void (^ _Nonnull)(NSError * _Nullable, FIRDatabaseReference * _Nonnull))block;
[Internal]
[Export ("setValue:withCompletionBlock:")]
void _SetValue ([NullAllowed] NSObject value, DatabaseReferenceCompletionHandler completionHandler);
// -(void)setValue:(id _Nullable)value andPriority:(id _Nullable)priority;
[Internal]
[Export ("setValue:andPriority:")]
void _SetValue ([NullAllowed] NSObject value, [NullAllowed] NSObject priority);
// -(void)setValue:(id _Nullable)value andPriority:(id _Nullable)priority withCompletionBlock:(void (^ _Nonnull)(NSError * _Nullable, FIRDatabaseReference * _Nonnull))block;
[Internal]
[Export ("setValue:andPriority:withCompletionBlock:")]
void _SetValue ([NullAllowed] NSObject value, [NullAllowed] NSObject priority, DatabaseReferenceCompletionHandler completionHandler);
// -(void)removeValue;
[Export ("removeValue")]
void RemoveValue ();
// -(void)removeValueWithCompletionBlock:(void (^ _Nonnull)(NSError * _Nullable, FIRDatabaseReference * _Nonnull))block;
[Export ("removeValueWithCompletionBlock:")]
void RemoveValue (DatabaseReferenceCompletionHandler completionHandler);
// -(void)setPriority:(id _Nullable)priority;
[Export ("setPriority:")]
void SetPriority ([NullAllowed] NSObject priority);
// -(void)setPriority:(id _Nullable)priority withCompletionBlock:(void (^ _Nonnull)(NSError * _Nullable, FIRDatabaseReference * _Nonnull))block;
[Export ("setPriority:withCompletionBlock:")]
void SetPriority ([NullAllowed] NSObject priority, DatabaseReferenceCompletionHandler completionHandler);
// -(void)updateChildValues:(NSDictionary * _Nonnull)values;
[Export ("updateChildValues:")]
void UpdateChildValues (NSDictionary values);
// -(void)updateChildValues:(NSDictionary * _Nonnull)values withCompletionBlock:(void (^ _Nonnull)(NSError * _Nullable, FIRDatabaseReference * _Nonnull))block;
[Export ("updateChildValues:withCompletionBlock:")]
void UpdateChildValues (NSDictionary values, DatabaseReferenceCompletionHandler completionHandler);
// -(FIRDatabaseHandle)observeEventType:(FIRDataEventType)eventType withBlock:(void (^ _Nonnull)(FIRDataSnapshot * _Nonnull))block;
[New]
[Export ("observeEventType:withBlock:")]
nuint ObserveEvent (DataEventType eventType, DatabaseQueryUpdateHandler completionHandler);
// -(FIRDatabaseHandle)observeEventType:(FIRDataEventType)eventType andPreviousSiblingKeyWithBlock:(void (^ _Nonnull)(FIRDataSnapshot * _Nonnull, NSString * _Nullable))block;
[New]
[Export ("observeEventType:andPreviousSiblingKeyWithBlock:")]
nuint ObserveEvent (DataEventType eventType, DatabaseQueryPreviousSiblingKeyUpdateHandler completionHandler);
// -(FIRDatabaseHandle)observeEventType:(FIRDataEventType)eventType withBlock:(void (^ _Nonnull)(FIRDataSnapshot * _Nonnull))block withCancelBlock:(void (^ _Nullable)(NSError * _Nonnull))cancelBlock;
[New]
[Export ("observeEventType:withBlock:withCancelBlock:")]
nuint ObserveEvent (DataEventType eventType, DatabaseQueryUpdateHandler completionHandler, [NullAllowed] DatabaseQueryCancelHandler cancelHandler);
// -(FIRDatabaseHandle)observeEventType:(FIRDataEventType)eventType andPreviousSiblingKeyWithBlock:(void (^ _Nonnull)(FIRDataSnapshot * _Nonnull, NSString * _Nullable))block withCancelBlock:(void (^ _Nullable)(NSError * _Nonnull))cancelBlock;
[New]
[Export ("observeEventType:andPreviousSiblingKeyWithBlock:withCancelBlock:")]
nuint ObserveEvent (DataEventType eventType, DatabaseQueryPreviousSiblingKeyUpdateHandler completionHandler, [NullAllowed] DatabaseQueryCancelHandler cancelHandler);
// -(void)observeSingleEventOfType:(FIRDataEventType)eventType withBlock:(void (^ _Nonnull)(FIRDataSnapshot * _Nonnull))block;
[New]
[Export ("observeSingleEventOfType:withBlock:")]
void ObserveSingleEvent (DataEventType eventType, DatabaseQueryUpdateHandler completionHandler);
// -(void)observeSingleEventOfType:(FIRDataEventType)eventType andPreviousSiblingKeyWithBlock:(void (^ _Nonnull)(FIRDataSnapshot * _Nonnull, NSString * _Nullable))block;
[New]
[Export ("observeSingleEventOfType:andPreviousSiblingKeyWithBlock:")]
void ObserveSingleEvent (DataEventType eventType, DatabaseQueryPreviousSiblingKeyUpdateHandler completionHandler);
// -(void)observeSingleEventOfType:(FIRDataEventType)eventType withBlock:(void (^ _Nonnull)(FIRDataSnapshot * _Nonnull))block withCancelBlock:(void (^ _Nullable)(NSError * _Nonnull))cancelBlock;
[New]
[Export ("observeSingleEventOfType:withBlock:withCancelBlock:")]
void ObserveSingleEvent (DataEventType eventType, DatabaseQueryUpdateHandler completionHandler, [NullAllowed] DatabaseQueryCancelHandler cancelHandler);
// -(void)observeSingleEventOfType:(FIRDataEventType)eventType andPreviousSiblingKeyWithBlock:(void (^ _Nonnull)(FIRDataSnapshot * _Nonnull, NSString * _Nullable))block withCancelBlock:(void (^ _Nullable)(NSError * _Nonnull))cancelBlock;
[New]
[Export ("observeSingleEventOfType:andPreviousSiblingKeyWithBlock:withCancelBlock:")]
void ObserveSingleEvent (DataEventType eventType, DatabaseQueryPreviousSiblingKeyUpdateHandler completionHandler, [NullAllowed] DatabaseQueryCancelHandler cancelHandler);
// -(void)removeObserverWithHandle:(FIRDatabaseHandle)handle;
[New]
[Export ("removeObserverWithHandle:")]
void RemoveObserver (nuint handle);
// -(void)keepSynced:(BOOL)keepSynced;
[New]
[Export ("keepSynced:")]
void KeepSynced (bool keepSynced);
// -(void)removeAllObservers;
[New]
[Export ("removeAllObservers")]
void RemoveAllObservers ();
// -(FIRDatabaseQuery * _Nonnull)queryLimitedToFirst:(NSUInteger)limit;
[New]
[Export ("queryLimitedToFirst:")]
DatabaseQuery GetQueryLimitedToFirst (nuint limit);
// -(FIRDatabaseQuery * _Nonnull)queryLimitedToLast:(NSUInteger)limit;
[New]
[Export ("queryLimitedToLast:")]
DatabaseQuery GetQueryLimitedToLast (nuint limit);
// -(FIRDatabaseQuery * _Nonnull)queryOrderedByChild:(NSString * _Nonnull)key;
[New]
[Export ("queryOrderedByChild:")]
DatabaseQuery GetQueryOrderedByChild (string key);
// -(FIRDatabaseQuery * _Nonnull)queryOrderedByKey;
[New]
[Export ("queryOrderedByKey")]
DatabaseQuery GetQueryOrderedByKey ();
// -(FIRDatabaseQuery * _Nonnull)queryOrderedByPriority;
[New]
[Export ("queryOrderedByPriority")]
DatabaseQuery GetQueryOrderedByPriority ();
// -(FIRDatabaseQuery * _Nonnull)queryStartingAtValue:(id _Nullable)startValue;
[New]
[Export ("queryStartingAtValue:")]
DatabaseQuery GetQueryStartingAtValue ([NullAllowed] NSObject startValue);
// -(FIRDatabaseQuery * _Nonnull)queryStartingAtValue:(id _Nullable)startValue childKey:(NSString * _Nullable)childKey;
[New]
[Export ("queryStartingAtValue:childKey:")]
DatabaseQuery GetQueryStartingAtValue ([NullAllowed] NSObject startValue, [NullAllowed] string childKey);
// -(FIRDatabaseQuery * _Nonnull)queryEndingAtValue:(id _Nullable)endValue;
[New]
[Export ("queryEndingAtValue:")]
DatabaseQuery GetQueryEndingAtValue ([NullAllowed] NSObject endValue);
// -(FIRDatabaseQuery * _Nonnull)queryEndingAtValue:(id _Nullable)endValue childKey:(NSString * _Nullable)childKey;
[New]
[Export ("queryEndingAtValue:childKey:")]
DatabaseQuery GetQueryEndingAtValue ([NullAllowed] NSObject endValue, [NullAllowed] string childKey);
// -(FIRDatabaseQuery * _Nonnull)queryEqualToValue:(id _Nullable)value;
[New]
[Export ("queryEqualToValue:")]
DatabaseQuery GetQueryEqualToValue ([NullAllowed] NSObject value);
// -(FIRDatabaseQuery * _Nonnull)queryEqualToValue:(id _Nullable)value childKey:(NSString * _Nullable)childKey;
[New]
[Export ("queryEqualToValue:childKey:")]
DatabaseQuery GetQueryEqualToValue ([NullAllowed] NSObject value, [NullAllowed] string childKey);
// -(void)onDisconnectSetValue:(id _Nullable)value;
[Internal]
[Export ("onDisconnectSetValue:")]
void _SetValueOnDisconnect ([NullAllowed] NSObject value);
// -(void)onDisconnectSetValue:(id _Nullable)value withCompletionBlock:(void (^ _Nonnull)(NSError * _Nullable, FIRDatabaseReference * _Nonnull))block;
[Internal]
[Export ("onDisconnectSetValue:withCompletionBlock:")]
void _SetValueOnDisconnect ([NullAllowed] NSObject value, DatabaseReferenceCompletionHandler completionHandler);
// -(void)onDisconnectSetValue:(id _Nullable)value andPriority:(id _Nonnull)priority;
[Internal]
[Export ("onDisconnectSetValue:andPriority:")]
void _SetValueOnDisconnect ([NullAllowed] NSObject value, NSObject priority);
// -(void)onDisconnectSetValue:(id _Nullable)value andPriority:(id _Nullable)priority withCompletionBlock:(void (^ _Nonnull)(NSError * _Nullable, FIRDatabaseReference * _Nonnull))block;
[Internal]
[Export ("onDisconnectSetValue:andPriority:withCompletionBlock:")]
void _SetValueOnDisconnect ([NullAllowed] NSObject value, [NullAllowed] NSObject priority, DatabaseReferenceCompletionHandler completionHandler);
// -(void)onDisconnectRemoveValue;
[Export ("onDisconnectRemoveValue")]
void RemoveValueOnDisconnect ();
// -(void)onDisconnectRemoveValueWithCompletionBlock:(void (^ _Nonnull)(NSError * _Nullable, FIRDatabaseReference * _Nonnull))block;
[Export ("onDisconnectRemoveValueWithCompletionBlock:")]
void RemoveValueOnDisconnect (DatabaseReferenceCompletionHandler completionHandler);
// -(void)onDisconnectUpdateChildValues:(NSDictionary * _Nonnull)values;
[Export ("onDisconnectUpdateChildValues:")]
void UpdateChildValuesOnDisconnect (NSDictionary values);
// -(void)onDisconnectUpdateChildValues:(NSDictionary * _Nonnull)values withCompletionBlock:(void (^ _Nonnull)(NSError * _Nullable, FIRDatabaseReference * _Nonnull))block;
[Export ("onDisconnectUpdateChildValues:withCompletionBlock:")]
void UpdateChildValuesOnDisconnect (NSDictionary values, DatabaseReferenceCompletionHandler completionHandler);
// -(void)cancelDisconnectOperations;
[Export ("cancelDisconnectOperations")]
void CancelDisconnectOperations ();
// -(void)cancelDisconnectOperationsWithCompletionBlock:(void (^ _Nullable)(NSError * _Nullable, FIRDatabaseReference * _Nonnull))block;
[Export ("cancelDisconnectOperationsWithCompletionBlock:")]
void CancelDisconnectOperations ([NullAllowed] DatabaseReferenceCompletionHandler completionHandler);
// +(void)goOffline;
[Static]
[Export ("goOffline")]
void GoOffline ();
// +(void)goOnline;
[Static]
[Export ("goOnline")]
void GoOnline ();
// -(void)runTransactionBlock:(FIRTransactionResult * _Nonnull (^ _Nonnull)(FIRMutableData * _Nonnull))block;
[Export ("runTransactionBlock:")]
void RunTransaction (DatabaseReferenceTransactionHandler transactionHandler);
// -(void)runTransactionBlock:(FIRTransactionResult * _Nonnull (^ _Nonnull)(FIRMutableData * _Nonnull))block andCompletionBlock:(void (^ _Nonnull)(NSError * _Nullable, BOOL, FIRDataSnapshot * _Nullable))completionBlock;
[Export ("runTransactionBlock:andCompletionBlock:")]
void RunTransaction (DatabaseReferenceTransactionHandler transactionHandler, DatabaseReferenceTransactionCompletionHandler completionBlock);
// -(void)runTransactionBlock:(FIRTransactionResult * _Nonnull (^ _Nonnull)(FIRMutableData * _Nonnull))block andCompletionBlock:(void (^ _Nullable)(NSError * _Nullable, BOOL, FIRDataSnapshot * _Nullable))completionBlock withLocalEvents:(BOOL)localEvents;
[Export ("runTransactionBlock:andCompletionBlock:withLocalEvents:")]
void RunTransaction (DatabaseReferenceTransactionHandler transactionHandler, DatabaseReferenceTransactionCompletionHandler completionBlock, bool localEvents);
// -(NSString * _Nonnull)description;
[New]
[Export ("description")]
string Description { get; }
// @property (readonly, nonatomic, strong) FIRDatabaseReference * _Nullable parent;
[NullAllowed]
[Export ("parent", ArgumentSemantic.Strong)]
DatabaseReference Parent { get; }
// @property (readonly, nonatomic, strong) FIRDatabaseReference * _Nonnull root;
[Export ("root", ArgumentSemantic.Strong)]
DatabaseReference Root { get; }
// @property (readonly, nonatomic, strong) NSString * _Nonnull key;
[Export ("key", ArgumentSemantic.Strong)]
string Key { get; }
// @property (readonly, nonatomic, strong) NSString * _Nonnull URL;
[Export ("URL", ArgumentSemantic.Strong)]
string Url { get; }
// @property (readonly, nonatomic, strong) FIRDatabase * _Nonnull database;
[Export ("database", ArgumentSemantic.Strong)]
Database Database { get; }
}
// @interface FIRDataSnapshot : NSObject
[BaseType (typeof (NSObject), Name = "FIRDataSnapshot")]
interface DataSnapshot
{
// -(FIRDataSnapshot * _Nonnull)childSnapshotForPath:(NSString * _Nonnull)childPathString;
[Export ("childSnapshotForPath:")]
DataSnapshot GetChildSnapshot (string childPathString);
// -(BOOL)hasChild:(NSString * _Nonnull)childPathString;
[Export ("hasChild:")]
bool HasChild (string childPathString);
// -(BOOL)hasChildren;
[Export ("hasChildren")]
bool HasChildren { get; }
// -(BOOL)exists;
[Export ("exists")]
bool Exists { get; }
// -(id _Nullable)valueInExportFormat;
[NullAllowed]
[Export ("valueInExportFormat")]
NSObject ValueInExportFormat { get; }
// @property (readonly, nonatomic, strong) id _Nullable value;
[Internal]
[NullAllowed]
[Export ("value")]
IntPtr _Value { get; }
// @property (readonly, nonatomic) NSUInteger childrenCount;
[Export ("childrenCount")]
nuint ChildrenCount { get; }
// @property (readonly, nonatomic, strong) FIRDatabaseReference * _Nonnull ref;
[Export ("ref", ArgumentSemantic.Strong)]
DatabaseReference Reference { get; }
// @property (readonly, nonatomic, strong) NSString * _Nonnull key;
[Export ("key", ArgumentSemantic.Strong)]
string Key { get; }
// @property (readonly, nonatomic, strong) NSEnumerator * _Nonnull children;
[Export ("children", ArgumentSemantic.Strong)]
NSEnumerator Children { get; }
// @property (readonly, nonatomic, strong) id _Nullable priority;
[NullAllowed]
[Export ("priority", ArgumentSemantic.Strong)]
NSObject Priority { get; }
}
// @interface FIRMutableData : NSObject
[BaseType (typeof (NSObject), Name = "FIRMutableData")]
interface MutableData
{
// -(BOOL)hasChildren;
[Export ("hasChildren")]
bool HasChildren { get; }
// -(BOOL)hasChildAtPath:(NSString * _Nonnull)path;
[Export ("hasChildAtPath:")]
bool HasChildAtPath (string path);
// -(FIRMutableData * _Nonnull)childDataByAppendingPath:(NSString * _Nonnull)path;
[Export ("childDataByAppendingPath:")]
MutableData GetChildData (string path);
// @property (nonatomic, strong) id _Nullable value;
[Internal]
[NullAllowed]
[Export ("value", ArgumentSemantic.Strong)]
IntPtr _Value { get; set; }
// @property (nonatomic, strong) id _Nullable priority;
[NullAllowed]
[Export ("priority", ArgumentSemantic.Strong)]
NSObject Priority { get; set; }
// @property (readonly, nonatomic) NSUInteger childrenCount;
[Export ("childrenCount")]
nuint ChildrenCount { get; }
// @property (readonly, nonatomic, strong) NSEnumerator * _Nonnull children;
[Export ("children", ArgumentSemantic.Strong)]
NSEnumerator Children { get; }
// @property (readonly, nonatomic, strong) NSString * _Nullable key;
[NullAllowed, Export ("key", ArgumentSemantic.Strong)]
string Key { get; }
}
// @interface FIRServerValue : NSObject
[DisableDefaultCtor]
[BaseType (typeof (NSObject), Name = "FIRServerValue")]
interface ServerValue
{
// +(NSDictionary * _Nonnull)timestamp;
[Static]
[Export ("timestamp")]
NSDictionary Timestamp { get; }
}
// @interface FIRTransactionResult : NSObject
[DisableDefaultCtor]
[BaseType (typeof (NSObject), Name = "FIRTransactionResult")]
interface TransactionResult
{
// +(FIRTransactionResult * _Nonnull)successWithValue:(FIRMutableData * _Nonnull)value;
[Static]
[Export ("successWithValue:")]
TransactionResult Success (MutableData value);
// +(FIRTransactionResult * _Nonnull)abort;
[Static]
[Export ("abort")]
TransactionResult Abort ();
}
}

Просмотреть файл

@ -0,0 +1,420 @@
using System;
using Foundation;
namespace Firebase.Database
{
public partial class DatabaseReference
{
public void SetValue<T> (T value) where T : NSObject
{
if (!VerifyValidType (value))
throw new InvalidOperationException ("Invalid parameter types");
_SetValue (value);
}
public void SetValues (NSObject [] values)
{
if (values == null)
_SetValue (null);
var nsArray = VerifyArray (values);
_SetValue (nsArray);
}
public void SetValues<T> (T [] values) where T : NSObject
{
if (values == null)
_SetValue (null);
var nsArray = VerifyArray (values);
_SetValue (nsArray);
}
public void SetValue<T> (T value, DatabaseReferenceCompletionHandler completionHandler) where T : NSObject
{
if (completionHandler == null)
throw new ArgumentNullException (nameof (completionHandler));
if (!VerifyValidType (value))
throw new InvalidOperationException ("Invalid parameter types");
_SetValue (value, completionHandler);
}
public void SetValues (NSObject [] values, DatabaseReferenceCompletionHandler completionHandler)
{
if (completionHandler == null)
throw new ArgumentNullException (nameof (completionHandler));
if (values == null)
_SetValue (null, completionHandler);
var nsArray = VerifyArray (values);
_SetValue (nsArray, completionHandler);
}
public void SetValue<T> (T value, NSObject priority) where T : NSObject
{
if (!VerifyValidType (value))
throw new InvalidOperationException ("Invalid parameter types");
_SetValue (value, priority);
}
public void SetValues (NSObject [] values, NSObject priority)
{
if (values == null)
_SetValue (null, priority);
var nsArray = VerifyArray (values);
_SetValue (nsArray, priority);
}
public void SetValues<T> (T [] values, NSObject priority) where T : NSObject
{
if (values == null)
_SetValue (null, priority);
var nsArray = VerifyArray (values);
_SetValue (nsArray, priority);
}
public void SetValue<T> (T value, NSObject priority, DatabaseReferenceCompletionHandler completionHandler) where T : NSObject
{
if (completionHandler == null)
throw new ArgumentNullException (nameof (completionHandler));
if (!VerifyValidType (value))
throw new InvalidOperationException ("Invalid parameter types");
_SetValue (value, priority, completionHandler);
}
public void SetValues (NSObject [] values, NSObject priority, DatabaseReferenceCompletionHandler completionHandler)
{
if (completionHandler == null)
throw new ArgumentNullException (nameof (completionHandler));
if (values == null)
_SetValue (null, priority);
var nsArray = VerifyArray (values);
_SetValue (nsArray, priority, completionHandler);
}
public void SetValues<T> (T [] values, NSObject priority, DatabaseReferenceCompletionHandler completionHandler) where T : NSObject
{
if (completionHandler == null)
throw new ArgumentNullException (nameof (completionHandler));
if (values == null)
_SetValue (null, priority);
var nsArray = VerifyArray (values);
_SetValue (nsArray, priority, completionHandler);
}
public void SetValueOnDisconnect<T> (T value) where T : NSObject
{
if (!VerifyValidType (value))
throw new InvalidOperationException ("Invalid parameter types");
_SetValueOnDisconnect (value);
}
public void SetValuesOnDisconnect (NSObject [] values)
{
if (values == null)
_SetValueOnDisconnect (null);
var nsArray = VerifyArray (values);
_SetValueOnDisconnect (nsArray);
}
public void SetValuesOnDisconnect<T> (T [] values) where T : NSObject
{
if (values == null)
_SetValueOnDisconnect (null);
var nsArray = VerifyArray (values);
_SetValueOnDisconnect (nsArray);
}
public void SetValueOnDisconnect<T> (T value, DatabaseReferenceCompletionHandler completionHandler) where T : NSObject
{
if (completionHandler == null)
throw new ArgumentNullException (nameof (completionHandler));
if (!VerifyValidType (value))
throw new InvalidOperationException ("Invalid parameter types");
_SetValueOnDisconnect (value, completionHandler);
}
public void SetValuesOnDisconnect (NSObject [] values, DatabaseReferenceCompletionHandler completionHandler)
{
if (completionHandler == null)
throw new ArgumentNullException (nameof (completionHandler));
if (values == null)
_SetValueOnDisconnect (null, completionHandler);
var nsArray = VerifyArray (values);
_SetValueOnDisconnect (nsArray, completionHandler);
}
public void SetValuesOnDisconnect<T> (T [] values, DatabaseReferenceCompletionHandler completionHandler) where T : NSObject
{
if (completionHandler == null)
throw new ArgumentNullException (nameof (completionHandler));
if (values == null)
_SetValueOnDisconnect (null, completionHandler);
var nsArray = VerifyArray (values);
_SetValueOnDisconnect (nsArray, completionHandler);
}
public void SetValueOnDisconnect<T> (T value, NSObject priority) where T : NSObject
{
if (priority == null)
throw new ArgumentNullException (nameof (priority));
if (!VerifyValidType (value))
throw new InvalidOperationException ("Invalid parameter types");
_SetValueOnDisconnect (value, priority);
}
public void SetValuesOnDisconnect (NSObject [] values, NSObject priority)
{
if (priority == null)
throw new ArgumentNullException (nameof (priority));
if (values == null)
_SetValueOnDisconnect (null, priority);
var nsArray = VerifyArray (values);
_SetValueOnDisconnect (nsArray, priority);
}
public void SetValuesOnDisconnect<T> (T [] values, NSObject priority) where T : NSObject
{
if (priority == null)
throw new ArgumentNullException (nameof (priority));
if (values == null)
_SetValueOnDisconnect (null, priority);
var nsArray = VerifyArray (values);
_SetValueOnDisconnect (nsArray, priority);
}
public void SetValueOnDisconnect<T> (T value, NSObject priority, DatabaseReferenceCompletionHandler completionHandler) where T : NSObject
{
if (completionHandler == null)
throw new ArgumentNullException (nameof (completionHandler));
if (!VerifyValidType (value))
throw new InvalidOperationException ("Invalid parameter types");
_SetValueOnDisconnect (value, priority, completionHandler);
}
public void SetValuesOnDisconnect (NSObject [] values, NSObject priority, DatabaseReferenceCompletionHandler completionHandler)
{
if (completionHandler == null)
throw new ArgumentNullException (nameof (completionHandler));
if (values == null)
_SetValueOnDisconnect (null, priority, completionHandler);
var nsArray = VerifyArray (values);
_SetValueOnDisconnect (nsArray, priority, completionHandler);
}
public void SetValuesOnDisconnect<T> (T [] values, NSObject priority, DatabaseReferenceCompletionHandler completionHandler) where T : NSObject
{
if (completionHandler == null)
throw new ArgumentNullException (nameof (completionHandler));
if (values == null)
_SetValueOnDisconnect (null, priority, completionHandler);
var nsArray = VerifyArray (values);
_SetValueOnDisconnect (nsArray, priority, completionHandler);
}
bool VerifyValidType<T> (T value) where T : NSObject
{
return value == null ||
value is NSString ||
value is NSNumber ||
value is NSDictionary ||
value is NSArray;
}
NSArray VerifyArray<T> (T [] values) where T : NSObject
{
if (values.Length > 0 && !VerifyValidType (values [0]))
throw new InvalidOperationException ("Invalid parameter types");
var nsArray = NSArray.FromNSObjects (values.Length, values);
if (nsArray == null)
throw new InvalidOperationException ("Invalid parameter types");
return nsArray;
}
}
public partial class DataSnapshot
{
public NSObject GetValue ()
{
var ret = _Value;
if (ret == IntPtr.Zero)
return null;
var nsObject = ObjCRuntime.Runtime.GetNSObject<NSObject> (ret);
return nsObject;
}
public T GetValue<T> () where T : NSObject
{
var ret = _Value;
if (ret == IntPtr.Zero)
return null;
var nsObject = ObjCRuntime.Runtime.GetNSObject<T> (ret);
return nsObject;
}
public NSObject [] GetValues ()
{
var ret = _Value;
if (ret == IntPtr.Zero)
return null;
var objects = NSArray.ArrayFromHandle<NSObject> (ret);
return objects;
}
public T [] GetValues<T> () where T : NSObject
{
var ret = _Value;
if (ret == IntPtr.Zero)
return null;
var objects = NSArray.ArrayFromHandle<T> (ret);
return objects;
}
}
public partial class MutableData
{
public NSObject GetValue ()
{
var ret = _Value;
if (ret == IntPtr.Zero)
return null;
var nsObject = ObjCRuntime.Runtime.GetNSObject<NSObject> (ret);
return nsObject;
}
public T GetValue<T> () where T : NSObject
{
var ret = _Value;
if (ret == IntPtr.Zero)
return null;
var nsObject = ObjCRuntime.Runtime.GetNSObject<T> (ret);
return nsObject;
}
public NSObject [] GetValues ()
{
var ret = _Value;
if (ret == IntPtr.Zero)
return null;
var objects = NSArray.ArrayFromHandle<NSObject> (ret);
return objects;
}
public T [] GetValues<T> () where T : NSObject
{
var ret = _Value;
if (ret == IntPtr.Zero)
return null;
var objects = NSArray.ArrayFromHandle<T> (ret);
return objects;
}
public void SetValue<T> (T value) where T : NSObject
{
if (!VerifyValidType (value))
throw new InvalidOperationException ("Invalid parameter types");
_Value = value == null ? IntPtr.Zero : value.Handle;
}
public void SetValues (NSObject [] values)
{
if (values == null)
_Value = IntPtr.Zero;
var nsArray = VerifyArray (values);
_Value = nsArray.Handle;
}
public void SetValues<T> (T [] values) where T : NSObject
{
if (values == null)
_Value = IntPtr.Zero;
var nsArray = VerifyArray (values);
_Value = nsArray.Handle;
}
bool VerifyValidType<T> (T value) where T : NSObject
{
return value == null ||
value is NSNull ||
value is NSString ||
value is NSNumber ||
value is NSDictionary ||
value is NSArray;
}
NSArray VerifyArray<T> (T [] values) where T : NSObject
{
if (values.Length > 0 && !VerifyValidType (values [0]))
throw new InvalidOperationException ("Invalid parameter types");
var nsArray = NSArray.FromNSObjects (values.Length, values);
if (nsArray == null)
throw new InvalidOperationException ("Invalid parameter types");
return nsArray;
}
}
}

Просмотреть файл

@ -0,0 +1,62 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{7C28F952-273E-4888-A9D7-61057B5361C3}</ProjectGuid>
<ProjectTypeGuids>{8FFB629D-F513-41CE-95D2-7ECE97B6EEEC};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<RootNamespace>Firebase.Database</RootNamespace>
<AssemblyName>Firebase.Database</AssemblyName>
<IPhoneResourcePrefix>Resources</IPhoneResourcePrefix>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug</OutputPath>
<DefineConstants>DEBUG;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<Optimize>true</Optimize>
<OutputPath>bin\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="Xamarin.iOS" />
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Extension.cs" />
<Compile Include="FirebaseDatabase.linkwith.cs">
<DependentUpon>FirebaseDatabase</DependentUpon>
</Compile>
<Compile Include="Loader.cs" />
</ItemGroup>
<ItemGroup>
<ObjcBindingApiDefinition Include="ApiDefinition.cs" />
</ItemGroup>
<ItemGroup>
<ObjcBindingCoreSource Include="Structs.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\Firebase.Analytics\source\Firebase.Analytics\Firebase.Analytics.csproj">
<Project>{87BB564C-85A8-4EC1-AD16-EC0A1ACCEE56}</Project>
<Name>Firebase.Analytics</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\Firebase.InstanceID\source\Firebase.InstanceID\Firebase.InstanceID.csproj">
<Project>{D6AA184C-DA45-4BBB-988A-451B20C7B804}</Project>
<Name>Firebase.InstanceID</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="Firebase.Database.targets" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.ObjCBinding.CSharp.targets" />
</Project>

Просмотреть файл

@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<_FirebaseDatabaseAssemblyName>Firebase.Database, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null</_FirebaseDatabaseAssemblyName>
<_FirebaseDatabaseItemsFolder>FDtbs-3.0.3</_FirebaseDatabaseItemsFolder>
</PropertyGroup>
<ItemGroup Condition="('$(OutputType)'!='Library' OR '$(IsAppExtension)'=='True')">
<XamarinBuildDownload Include="$(_FirebaseDatabaseItemsFolder)">
<Url>https://www.gstatic.com/cpdc/dd2185c8104bac0e/FirebaseDatabase-3.0.3.tar.gz</Url>
<Kind>Tgz</Kind>
</XamarinBuildDownload>
<XamarinBuildRestoreResources Include="_FirebaseDatabaseItems"/>
</ItemGroup>
<Target Name="_FirebaseDatabaseItems">
<PropertyGroup>
<_FirebaseDatabaseSDKBaseFolder>$(XamarinBuildDownloadDir)$(_FirebaseDatabaseItemsFolder)\Frameworks\</_FirebaseDatabaseSDKBaseFolder>
</PropertyGroup>
<ItemGroup>
<RestoreAssemblyResource Include="$(_FirebaseDatabaseSDKBaseFolder)FirebaseDatabase.framework\FirebaseDatabase">
<LogicalName>FirebaseDatabase</LogicalName>
<AssemblyName>$(_FirebaseDatabaseAssemblyName)</AssemblyName>
</RestoreAssemblyResource>
</ItemGroup>
</Target>
</Project>

Просмотреть файл

@ -0,0 +1,9 @@
using System;
using ObjCRuntime;
[assembly: LinkWith ("FirebaseDatabase",
LinkTarget.ArmV7 | LinkTarget.Arm64 | LinkTarget.Simulator | LinkTarget.Simulator64,
Frameworks = "CFNetwork Security SystemConfiguration",
LinkerFlags = "-ObjC -lc++ -licucore",
ForceLoad = true,
SmartLink = true)]

Просмотреть файл

@ -0,0 +1,26 @@
using System;
namespace Firebase.Database
{
public class Loader
{
static Loader ()
{
Firebase.InstanceID.Loader.ForceLoad ();
Firebase.Analytics.Loader.ForceLoad ();
}
public static void ForceLoad () { }
}
}
namespace ApiDefinition
{
partial class Messaging
{
static Messaging ()
{
Firebase.Database.Loader.ForceLoad ();
}
}
}

Просмотреть файл

@ -0,0 +1,34 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using Foundation;
// This attribute allows you to mark your assemblies as “safe to link”.
// When the attribute is present, the linker—if enabled—will process the assembly
// even if youre using the “Link SDK assemblies only” option, which is the default for device builds.
[assembly: LinkerSafe]
// Information about this assembly is defined by the following attributes.
// Change them to the values specific to your project.
[assembly: AssemblyTitle ("Firebase.Database")]
[assembly: AssemblyDescription ("")]
[assembly: AssemblyConfiguration ("")]
[assembly: AssemblyCompany ("")]
[assembly: AssemblyProduct ("")]
[assembly: AssemblyCopyright ("(c) Xamarin")]
[assembly: AssemblyTrademark ("")]
[assembly: AssemblyCulture ("")]
// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
// and "{Major}.{Minor}.{Build}.*" will update just the revision.
[assembly: AssemblyVersion ("1.0.*")]
// The following attributes are used to specify the signing key for the assembly,
// if desired. See the Mono documentation for more information about signing.
//[assembly: AssemblyDelaySign(false)]
//[assembly: AssemblyKeyFile("")]

Просмотреть файл

@ -0,0 +1,15 @@
using System;
using ObjCRuntime;
namespace Firebase.Database
{
[Native]
public enum DataEventType : long
{
ChildAdded,
ChildRemoved,
ChildChanged,
ChildMoved,
Value
}
}

Двоичные данные
icons/firebaseiosdatabase_128x128.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 6.3 KiB

Двоичные данные
icons/firebaseiosdatabase_512x512.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 54 KiB