Skip to content
Permalink
Browse files

Add files via upload

  • Loading branch information
EsquivelJC committed Nov 30, 2019
1 parent 9d6a37f commit 6a8aa0433fbb3b0a6845ae4e6cbe94756c63a974
Showing with 1,107 additions and 0 deletions.
  1. +67 −0 samples/SimpleCalculatorSystem/CalculatorClient/CalculatorClient.csproj
  2. +33 −0 samples/SimpleCalculatorSystem/CalculatorClient/Program.cs
  3. +36 −0 samples/SimpleCalculatorSystem/CalculatorClient/Properties/AssemblyInfo.cs
  4. +58 −0 samples/SimpleCalculatorSystem/CalculatorCommonLib/CalculatorCommonLib.csproj
  5. +15 −0 samples/SimpleCalculatorSystem/CalculatorCommonLib/ICalculatorService.cs
  6. +36 −0 samples/SimpleCalculatorSystem/CalculatorCommonLib/Properties/AssemblyInfo.cs
  7. +67 −0 samples/SimpleCalculatorSystem/CalculatorServer/CalculatorServer.csproj
  8. +46 −0 samples/SimpleCalculatorSystem/CalculatorServer/Program.cs
  9. +36 −0 samples/SimpleCalculatorSystem/CalculatorServer/Properties/AssemblyInfo.cs
  10. +54 −0 samples/SimpleCalculatorSystem/SimpleCalculatorSystem.sln
  11. +61 −0 samples/SimpleMessaging/ClientApp/ClientApp.csproj
  12. +51 −0 samples/SimpleMessaging/ClientApp/Program.cs
  13. +36 −0 samples/SimpleMessaging/ClientApp/Properties/AssemblyInfo.cs
  14. +43 −0 samples/SimpleMessaging/RequestReplyStyleClient/Program.cs
  15. +36 −0 samples/SimpleMessaging/RequestReplyStyleClient/Properties/AssemblyInfo.cs
  16. +61 −0 samples/SimpleMessaging/RequestReplyStyleClient/RequestReplyStyleClient.csproj
  17. +66 −0 samples/SimpleMessaging/ServerApp/Program.cs
  18. +36 −0 samples/SimpleMessaging/ServerApp/Properties/AssemblyInfo.cs
  19. +61 −0 samples/SimpleMessaging/ServerApp/ServerApp.csproj
  20. +66 −0 samples/SimpleMessaging/SimpleMessaging.sln
  21. +46 −0 samples/SimpleMessaging/SynchronizedClient/Program.cs
  22. +36 −0 samples/SimpleMessaging/SynchronizedClient/Properties/AssemblyInfo.cs
  23. +60 −0 samples/SimpleMessaging/SynchronizedClient/SynchronizedClient.csproj
@@ -0,0 +1,67 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{6DD6F730-E353-4B0C-9655-8370A943A7BF}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>CalculatorClient</RootNamespace>
<AssemblyName>CalculatorClient</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Scs, Version=1.0.0.1, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\Binaries\Scs.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\CalculatorCommonLib\CalculatorCommonLib.csproj">
<Project>{6F2D58C9-0395-4048-A304-17304D12BC63}</Project>
<Name>CalculatorCommonLib</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
@@ -0,0 +1,33 @@
using System;
using CalculatorCommonLib;
using Hik.Communication.Scs.Communication.EndPoints.Tcp;
using Hik.Communication.ScsServices.Client;

namespace CalculatorClient
{
class Program
{
static void Main()
{
Console.WriteLine("Press enter to connect to server and call methods...");
Console.ReadLine();

//Create a client that can call methods of Calculator Service that is running on local computer and 10083 TCP port
//Since IScsServiceClient is IDisposible, it closes connection at the end of the using block
using (var client = ScsServiceClientBuilder.CreateClient<ICalculatorService>(new ScsTcpEndPoint("127.0.0.1", 10083)))
{
//Connect to the server
client.Connect();

//Call a remote method of server
var division = client.ServiceProxy.Divide(42, 3);

//Write the result to the screen
Console.WriteLine("Result: " + division);
}

Console.WriteLine("Press enter to stop client application");
Console.ReadLine();
}
}
}
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("CalculatorClient")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("CalculatorClient")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2011")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("5712ded0-d09a-4e56-8de4-1d9145854ee5")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
@@ -0,0 +1,58 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{6F2D58C9-0395-4048-A304-17304D12BC63}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>CalculatorCommonLib</RootNamespace>
<AssemblyName>CalculatorCommonLib</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Scs, Version=1.0.0.1, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\Binaries\Scs.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="ICalculatorService.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
@@ -0,0 +1,15 @@
using Hik.Communication.ScsServices.Service;

namespace CalculatorCommonLib
{
/// <summary>
/// This interface defines methods of calculator service that can be called by clients.
/// </summary>
[ScsService]
public interface ICalculatorService
{
int Add(int number1, int number2);

double Divide(double number1, double number2);
}
}
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("CalculatorCommonLib")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("CalculatorCommonLib")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2011")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("8a08ef54-dde6-4f7a-8656-57518c5098ea")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
@@ -0,0 +1,67 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{1BB6B428-E4C3-467F-824F-1DB84E310FF2}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>CalculatorServer</RootNamespace>
<AssemblyName>CalculatorServer</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Scs, Version=1.0.0.1, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\Binaries\Scs.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\CalculatorCommonLib\CalculatorCommonLib.csproj">
<Project>{6F2D58C9-0395-4048-A304-17304D12BC63}</Project>
<Name>CalculatorCommonLib</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
@@ -0,0 +1,46 @@
using System;
using CalculatorCommonLib;
using Hik.Communication.Scs.Communication.EndPoints.Tcp;
using Hik.Communication.ScsServices.Service;

namespace CalculatorServer
{
class Program
{
static void Main()
{
//Create a service application that runs on 10083 TCP port
var serviceApplication = ScsServiceBuilder.CreateService(new ScsTcpEndPoint(10083));

//Create a CalculatorService and add it to service application
serviceApplication.AddService<ICalculatorService, CalculatorService>(new CalculatorService());

//Start service application
serviceApplication.Start();

Console.WriteLine("Calculator service is started. Press enter to stop...");
Console.ReadLine();

//Stop service application
serviceApplication.Stop();
}
}

public class CalculatorService : ScsService, ICalculatorService
{
public int Add(int number1, int number2)
{
return number1 + number2;
}

public double Divide(double number1, double number2)
{
if(number2 == 0.0)
{
throw new DivideByZeroException("number2 can not be zero!");
}

return number1 / number2;
}
}
}

0 comments on commit 6a8aa04

Please sign in to comment.
You can’t perform that action at this time.