diff options
Diffstat (limited to 'examples/csharp/HelloworldXamarin/iOS')
12 files changed, 740 insertions, 0 deletions
diff --git a/examples/csharp/HelloworldXamarin/iOS/AppDelegate.cs b/examples/csharp/HelloworldXamarin/iOS/AppDelegate.cs new file mode 100644 index 0000000000..e7620f91a2 --- /dev/null +++ b/examples/csharp/HelloworldXamarin/iOS/AppDelegate.cs @@ -0,0 +1,77 @@ +#region Copyright notice and license + +// Copyright 2018 The gRPC Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#endregion + +using Foundation; +using UIKit; + +namespace HelloworldXamarin.iOS +{ + // 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 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 + + return true; + } + + public override void OnResignActivation(UIApplication application) + { + // Invoked when the application is about to move from active to inactive state. + // This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) + // or when the user quits the application and it begins the transition to the background state. + // Games should use this method to pause the game. + } + + public override void DidEnterBackground(UIApplication application) + { + // Use this method to release shared resources, save user data, invalidate timers and store the application state. + // If your application supports background exection this method is called instead of WillTerminate when the user quits. + } + + public override void WillEnterForeground(UIApplication application) + { + // Called as part of the transiton from background to active state. + // Here you can undo many of the changes made on entering the background. + } + + public override void OnActivated(UIApplication application) + { + // Restart any tasks that were paused (or not yet started) while the application was inactive. + // If the application was previously in the background, optionally refresh the user interface. + } + + public override void WillTerminate(UIApplication application) + { + // Called when the application is about to terminate. Save data, if needed. See also DidEnterBackground. + } + } +} + diff --git a/examples/csharp/HelloworldXamarin/iOS/Assets.xcassets/AppIcon.appiconset/Contents.json b/examples/csharp/HelloworldXamarin/iOS/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000000..64d0e3ddf8 --- /dev/null +++ b/examples/csharp/HelloworldXamarin/iOS/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,202 @@ +{ + "images" : [ + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "3x" + }, + { + "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" : "60x60", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "3x" + }, + { + "idiom" : "ipad", + "size" : "20x20", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "20x20", + "scale" : "2x" + }, + { + "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" : "76x76", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "76x76", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "83.5x83.5", + "scale" : "2x" + }, + { + "idiom" : "ios-marketing", + "size" : "1024x1024", + "scale" : "1x" + }, + { + "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" + }, + { + "idiom" : "mac", + "size" : "16x16", + "scale" : "1x" + }, + { + "idiom" : "mac", + "size" : "16x16", + "scale" : "2x" + }, + { + "idiom" : "mac", + "size" : "32x32", + "scale" : "1x" + }, + { + "idiom" : "mac", + "size" : "32x32", + "scale" : "2x" + }, + { + "idiom" : "mac", + "size" : "128x128", + "scale" : "1x" + }, + { + "idiom" : "mac", + "size" : "128x128", + "scale" : "2x" + }, + { + "idiom" : "mac", + "size" : "256x256", + "scale" : "1x" + }, + { + "idiom" : "mac", + "size" : "256x256", + "scale" : "2x" + }, + { + "idiom" : "mac", + "size" : "512x512", + "scale" : "1x" + }, + { + "idiom" : "mac", + "size" : "512x512", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} diff --git a/examples/csharp/HelloworldXamarin/iOS/Assets.xcassets/Contents.json b/examples/csharp/HelloworldXamarin/iOS/Assets.xcassets/Contents.json new file mode 100644 index 0000000000..4caf392f92 --- /dev/null +++ b/examples/csharp/HelloworldXamarin/iOS/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +}
\ No newline at end of file diff --git a/examples/csharp/HelloworldXamarin/iOS/Entitlements.plist b/examples/csharp/HelloworldXamarin/iOS/Entitlements.plist new file mode 100644 index 0000000000..9ae599370b --- /dev/null +++ b/examples/csharp/HelloworldXamarin/iOS/Entitlements.plist @@ -0,0 +1,6 @@ +<?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> +</dict> +</plist> diff --git a/examples/csharp/HelloworldXamarin/iOS/HelloworldXamarin.iOS.csproj b/examples/csharp/HelloworldXamarin/iOS/HelloworldXamarin.iOS.csproj new file mode 100644 index 0000000000..b5c0d1d119 --- /dev/null +++ b/examples/csharp/HelloworldXamarin/iOS/HelloworldXamarin.iOS.csproj @@ -0,0 +1,126 @@ +<?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)' == '' ">iPhoneSimulator</Platform>
+ <ProjectGuid>{62336DF0-60D8-478F-8140-B3CB089B417E}</ProjectGuid>
+ <ProjectTypeGuids>{FEACFBD2-3405-455C-9665-78FE426C6842};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <OutputType>Exe</OutputType>
+ <RootNamespace>HelloworldXamarin.iOS</RootNamespace>
+ <AssemblyName>HelloworldXamarin.iOS</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>
+ <MtouchNoSymbolStrip>true</MtouchNoSymbolStrip>
+ <MtouchFastDev>true</MtouchFastDev>
+ <IOSDebuggerPort>45216</IOSDebuggerPort>
+ <MtouchLink>None</MtouchLink>
+ <MtouchArch>x86_64</MtouchArch>
+ <MtouchHttpClientHandler>HttpClientHandler</MtouchHttpClientHandler>
+ <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>
+ <MtouchFloat32>true</MtouchFloat32>
+ <CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
+ <MtouchLink>SdkOnly</MtouchLink>
+ <MtouchArch>ARM64</MtouchArch>
+ <MtouchHttpClientHandler>HttpClientHandler</MtouchHttpClientHandler>
+ <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>
+ <MtouchNoSymbolStrip>true</MtouchNoSymbolStrip>
+ <MtouchLink>None</MtouchLink>
+ <MtouchArch>x86_64</MtouchArch>
+ <MtouchHttpClientHandler>HttpClientHandler</MtouchHttpClientHandler>
+ <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>
+ <MtouchNoSymbolStrip>true</MtouchNoSymbolStrip>
+ <MtouchFastDev>true</MtouchFastDev>
+ <MtouchFloat32>true</MtouchFloat32>
+ <CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
+ <IOSDebuggerPort>35164</IOSDebuggerPort>
+ <MtouchLink>SdkOnly</MtouchLink>
+ <MtouchArch>ARM64</MtouchArch>
+ <MtouchHttpClientHandler>HttpClientHandler</MtouchHttpClientHandler>
+ <PlatformTarget>x86</PlatformTarget>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Xml" />
+ <Reference Include="System.Core" />
+ <Reference Include="Xamarin.iOS" />
+ <Reference Include="System.IO.Compression" />
+ <Reference Include="System.Net.Http" />
+ <Reference Include="System.Runtime.Loader">
+ <HintPath>..\packages\System.Runtime.Loader.4.0.0\lib\netstandard1.5\System.Runtime.Loader.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Interactive.Async">
+ <HintPath>..\packages\System.Interactive.Async.3.1.1\lib\netstandard1.3\System.Interactive.Async.dll</HintPath>
+ </Reference>
+ <Reference Include="Grpc.Core">
+ <HintPath>..\packages\Grpc.Core.1.15.0-dev\lib\netstandard1.5\Grpc.Core.dll</HintPath>
+ </Reference>
+ <Reference Include="Google.Protobuf">
+ <HintPath>..\packages\Google.Protobuf.3.6.0\lib\netstandard1.0\Google.Protobuf.dll</HintPath>
+ </Reference>
+ </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="ViewController.cs" />
+ <Compile Include="ViewController.designer.cs">
+ <DependentUpon>ViewController.cs</DependentUpon>
+ </Compile>
+ </ItemGroup>
+ <Import Project="..\HelloworldXamarin\HelloworldXamarin.projitems" Label="Shared" Condition="Exists('..\HelloworldXamarin\HelloworldXamarin.projitems')" />
+ <Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" />
+ <Import Project="..\packages\Grpc.Core.1.15.0-dev\build\Xamarin.iOS\Grpc.Core.targets" Condition="Exists('..\packages\Grpc.Core.1.15.0-dev\build\Xamarin.iOS\Grpc.Core.targets')" />
+</Project>
\ No newline at end of file diff --git a/examples/csharp/HelloworldXamarin/iOS/Info.plist b/examples/csharp/HelloworldXamarin/iOS/Info.plist new file mode 100644 index 0000000000..1663f19452 --- /dev/null +++ b/examples/csharp/HelloworldXamarin/iOS/Info.plist @@ -0,0 +1,48 @@ +<?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>HelloworldXamarin</string> + <key>CFBundleIdentifier</key> + <string>io.grpc.examples.HelloworldXamarin</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> + <integer>2</integer> + </array> + <key>UILaunchStoryboardName</key> + <string>LaunchScreen</string> + <key>UIMainStoryboardFile</key> + <string>Main</string> + <key>UIMainStoryboardFile~ipad</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>UISupportedInterfaceOrientations~ipad</key> + <array> + <string>UIInterfaceOrientationPortrait</string> + <string>UIInterfaceOrientationPortraitUpsideDown</string> + <string>UIInterfaceOrientationLandscapeLeft</string> + <string>UIInterfaceOrientationLandscapeRight</string> + </array> + <key>XSAppIconAssets</key> + <string>Assets.xcassets/AppIcon.appiconset</string> +</dict> +</plist> diff --git a/examples/csharp/HelloworldXamarin/iOS/LaunchScreen.storyboard b/examples/csharp/HelloworldXamarin/iOS/LaunchScreen.storyboard new file mode 100644 index 0000000000..5d2e905aa8 --- /dev/null +++ b/examples/csharp/HelloworldXamarin/iOS/LaunchScreen.storyboard @@ -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> diff --git a/examples/csharp/HelloworldXamarin/iOS/Main.cs b/examples/csharp/HelloworldXamarin/iOS/Main.cs new file mode 100644 index 0000000000..a4ddf35c70 --- /dev/null +++ b/examples/csharp/HelloworldXamarin/iOS/Main.cs @@ -0,0 +1,38 @@ +#region Copyright notice and license + +// Copyright 2018 The gRPC Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#endregion + +using System; +using System.Collections.Generic; +using System.Linq; + +using Foundation; +using UIKit; + +namespace HelloworldXamarin.iOS +{ + 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"); + } + } +} diff --git a/examples/csharp/HelloworldXamarin/iOS/Main.storyboard b/examples/csharp/HelloworldXamarin/iOS/Main.storyboard new file mode 100644 index 0000000000..92a28ce08d --- /dev/null +++ b/examples/csharp/HelloworldXamarin/iOS/Main.storyboard @@ -0,0 +1,40 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6750" systemVersion="14C109" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="BYZ-38-t0r"> + <dependencies> + <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6735" /> + </dependencies> + <scenes> + <!--View Controller--> + <scene sceneID="tne-QT-ifu"> + <objects> + <viewController id="BYZ-38-t0r" customClass="ViewController" sceneMemberID="viewController"> + <layoutGuides> + <viewControllerLayoutGuide type="top" id="y3c-jy-aDJ" /> + <viewControllerLayoutGuide type="bottom" id="wfy-db-euE" /> + </layoutGuides> + <view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC"> + <rect key="frame" x="0.0" y="0.0" width="600" height="600" /> + <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES" /> + <subviews> + <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="oBE-Ac-vcx"> + <rect key="frame" x="224" y="285" width="152" height="30" /> + <state key="normal" title="Hello World, Click Me!"> + <color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite" /> + </state> + </button> + </subviews> + <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite" /> + <constraints> + <constraint firstItem="oBE-Ac-vcx" firstAttribute="centerX" secondItem="8bC-Xf-vdC" secondAttribute="centerX" id="HiD-uS-i16" /> + <constraint firstItem="oBE-Ac-vcx" firstAttribute="centerY" secondItem="8bC-Xf-vdC" secondAttribute="centerY" id="YgX-7e-bMc" /> + </constraints> + </view> + <connections> + <outlet property="Button" destination="oBE-Ac-vcx" id="OkX-0Z-gth" /> + </connections> + </viewController> + <placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder" /> + </objects> + </scene> + </scenes> +</document> diff --git a/examples/csharp/HelloworldXamarin/iOS/ViewController.cs b/examples/csharp/HelloworldXamarin/iOS/ViewController.cs new file mode 100644 index 0000000000..c553c1eb48 --- /dev/null +++ b/examples/csharp/HelloworldXamarin/iOS/ViewController.cs @@ -0,0 +1,91 @@ +#region Copyright notice and license + +// Copyright 2018 The gRPC Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#endregion + +using System; +using System.Threading.Tasks; + +using Grpc.Core; +using Helloworld; + +using UIKit; + +namespace HelloworldXamarin.iOS +{ + public partial class ViewController : UIViewController + { + const int Port = 50051; + int count = 1; + + public ViewController(IntPtr handle) : base(handle) + { + } + + public override void ViewDidLoad() + { + base.ViewDidLoad(); + + // Perform any additional setup after loading the view, typically from a nib. + Button.AccessibilityIdentifier = "myButton"; + Button.TouchUpInside += delegate + {
+ var title = SayHello(); + Button.SetTitle(title, UIControlState.Normal); + }; + } + + public override void DidReceiveMemoryWarning() + { + base.DidReceiveMemoryWarning(); + // Release any cached data, images, etc that aren't in use. + } + + private string SayHello() + { + Server server = new Server + { + Services = { Greeter.BindService(new GreeterImpl()) }, + Ports = { new ServerPort("localhost", Port, ServerCredentials.Insecure) } + }; + server.Start(); + + Channel channel = new Channel("localhost:50051", ChannelCredentials.Insecure); + + var client = new Greeter.GreeterClient(channel); + string user = "Xamarin " + count; + + var reply = client.SayHello(new HelloRequest { Name = user }); + + channel.ShutdownAsync().Wait(); + server.ShutdownAsync().Wait(); + + count++; + + return "Greeting: " + reply.Message; + } + + + class GreeterImpl : Greeter.GreeterBase + { + // Server side handler of the SayHello RPC + public override Task<HelloReply> SayHello(HelloRequest request, ServerCallContext context) + { + return Task.FromResult(new HelloReply { Message = "Hello " + request.Name }); + } + } + } +} diff --git a/examples/csharp/HelloworldXamarin/iOS/ViewController.designer.cs b/examples/csharp/HelloworldXamarin/iOS/ViewController.designer.cs new file mode 100644 index 0000000000..2677a068dc --- /dev/null +++ b/examples/csharp/HelloworldXamarin/iOS/ViewController.designer.cs @@ -0,0 +1,25 @@ +// +// This file has been generated automatically by MonoDevelop to store outlets and +// actions made in the Xcode designer. If it is removed, they will be lost. +// Manual changes to this file may not be handled correctly. +// +using Foundation; + +namespace HelloworldXamarin.iOS +{ + [Register("ViewController")] + partial class ViewController + { + [Outlet] + UIKit.UIButton Button { get; set; } + + void ReleaseDesignerOutlets() + { + if (Button != null) + { + Button.Dispose(); + Button = null; + } + } + } +} diff --git a/examples/csharp/HelloworldXamarin/iOS/packages.config b/examples/csharp/HelloworldXamarin/iOS/packages.config new file mode 100644 index 0000000000..ce4bceb62a --- /dev/null +++ b/examples/csharp/HelloworldXamarin/iOS/packages.config @@ -0,0 +1,54 @@ +<?xml version="1.0" encoding="utf-8"?> +<packages> + <package id="Google.Protobuf" version="3.6.0" targetFramework="xamarinios10" /> + <package id="Grpc.Core" version="1.15.0-dev" targetFramework="xamarinios10" /> + <package id="Microsoft.NETCore.Platforms" version="1.1.0" targetFramework="xamarinios10" /> + <package id="Microsoft.Win32.Primitives" version="4.3.0" targetFramework="xamarinios10" /> + <package id="NETStandard.Library" version="1.6.1" targetFramework="xamarinios10" /> + <package id="System.AppContext" version="4.3.0" targetFramework="xamarinios10" /> + <package id="System.Collections" version="4.3.0" targetFramework="xamarinios10" /> + <package id="System.Collections.Concurrent" version="4.3.0" targetFramework="xamarinios10" /> + <package id="System.Console" version="4.3.0" targetFramework="xamarinios10" /> + <package id="System.Diagnostics.Debug" version="4.3.0" targetFramework="xamarinios10" /> + <package id="System.Diagnostics.Tools" version="4.3.0" targetFramework="xamarinios10" /> + <package id="System.Diagnostics.Tracing" version="4.3.0" targetFramework="xamarinios10" /> + <package id="System.Globalization" version="4.3.0" targetFramework="xamarinios10" /> + <package id="System.Globalization.Calendars" version="4.3.0" targetFramework="xamarinios10" /> + <package id="System.Interactive.Async" version="3.1.1" targetFramework="xamarinios10" /> + <package id="System.IO" version="4.3.0" targetFramework="xamarinios10" /> + <package id="System.IO.Compression" version="4.3.0" targetFramework="xamarinios10" /> + <package id="System.IO.Compression.ZipFile" version="4.3.0" targetFramework="xamarinios10" /> + <package id="System.IO.FileSystem" version="4.3.0" targetFramework="xamarinios10" /> + <package id="System.IO.FileSystem.Primitives" version="4.3.0" targetFramework="xamarinios10" /> + <package id="System.Linq" version="4.3.0" targetFramework="xamarinios10" /> + <package id="System.Linq.Expressions" version="4.3.0" targetFramework="xamarinios10" /> + <package id="System.Net.Http" version="4.3.0" targetFramework="xamarinios10" /> + <package id="System.Net.Primitives" version="4.3.0" targetFramework="xamarinios10" /> + <package id="System.Net.Sockets" version="4.3.0" targetFramework="xamarinios10" /> + <package id="System.ObjectModel" version="4.3.0" targetFramework="xamarinios10" /> + <package id="System.Reflection" version="4.3.0" targetFramework="xamarinios10" /> + <package id="System.Reflection.Extensions" version="4.3.0" targetFramework="xamarinios10" /> + <package id="System.Reflection.Primitives" version="4.3.0" targetFramework="xamarinios10" /> + <package id="System.Resources.ResourceManager" version="4.3.0" targetFramework="xamarinios10" /> + <package id="System.Runtime" version="4.3.0" targetFramework="xamarinios10" /> + <package id="System.Runtime.Extensions" version="4.3.0" targetFramework="xamarinios10" /> + <package id="System.Runtime.Handles" version="4.3.0" targetFramework="xamarinios10" /> + <package id="System.Runtime.InteropServices" version="4.3.0" targetFramework="xamarinios10" /> + <package id="System.Runtime.InteropServices.RuntimeInformation" version="4.3.0" targetFramework="xamarinios10" /> + <package id="System.Runtime.Loader" version="4.0.0" targetFramework="xamarinios10" /> + <package id="System.Runtime.Numerics" version="4.3.0" targetFramework="xamarinios10" /> + <package id="System.Security.Cryptography.Algorithms" version="4.3.0" targetFramework="xamarinios10" /> + <package id="System.Security.Cryptography.Encoding" version="4.3.0" targetFramework="xamarinios10" /> + <package id="System.Security.Cryptography.Primitives" version="4.3.0" targetFramework="xamarinios10" /> + <package id="System.Security.Cryptography.X509Certificates" version="4.3.0" targetFramework="xamarinios10" /> + <package id="System.Text.Encoding" version="4.3.0" targetFramework="xamarinios10" /> + <package id="System.Text.Encoding.Extensions" version="4.3.0" targetFramework="xamarinios10" /> + <package id="System.Text.RegularExpressions" version="4.3.0" targetFramework="xamarinios10" /> + <package id="System.Threading" version="4.3.0" targetFramework="xamarinios10" /> + <package id="System.Threading.Tasks" version="4.3.0" targetFramework="xamarinios10" /> + <package id="System.Threading.Thread" version="4.0.0" targetFramework="xamarinios10" /> + <package id="System.Threading.ThreadPool" version="4.0.10" targetFramework="xamarinios10" /> + <package id="System.Threading.Timer" version="4.3.0" targetFramework="xamarinios10" /> + <package id="System.Xml.ReaderWriter" version="4.3.0" targetFramework="xamarinios10" /> + <package id="System.Xml.XDocument" version="4.3.0" targetFramework="xamarinios10" /> +</packages>
\ No newline at end of file |