Skip to content

Commit

Permalink
Update WCF sample Compression Encoder code to conditionally support .…
Browse files Browse the repository at this point in the history
…NET framework / Core
  • Loading branch information
afifi-ins committed Oct 31, 2023
1 parent 6d83421 commit 7fd2c7a
Show file tree
Hide file tree
Showing 12 changed files with 215 additions and 315 deletions.
Original file line number Diff line number Diff line change
@@ -1,99 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{97E8A065-31ED-4506-B3A4-6B2E2ED5B124}</ProjectGuid>
<TargetFrameworks>net462;net6.0</TargetFrameworks>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Microsoft.Samples.GZipEncoder</RootNamespace>
<AssemblyName>Client</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileUpgradeFlags>
</FileUpgradeFlags>
<OldToolsVersion>2.0</OldToolsVersion>
<UpgradeBackupLocation />
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
<TargetFrameworkProfile />
<Title>Client</Title>
<Description>GZipEncoder</Description>
<Company>Microsoft Corporation</Company>
<Product>Windows Communication Foundation and Windows Workflow Foundation SDK</Product>
<Copyright>Copyright (c) Microsoft Corporation</Copyright>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</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>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.configuration" />
<Reference Include="System.Data" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.ServiceModel" />
<Reference Include="System.Xml" />

<ItemGroup Condition=" '$(TargetFramework)' == 'net462' ">
<None Remove="Connected Services\Microsoft.Samples.GZipEncoder\ConnectedService.json" />
<Compile Remove="Connected Services\Microsoft.Samples.GZipEncoder\Reference.cs" />
<None Include="Connected Services\Microsoft.Samples.GZipEncoder\Reference.cs" />
</ItemGroup>
<ItemGroup>
<Compile Include="generatedClient.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />

<ItemGroup Condition=" '$(TargetFramework)' == 'net6.0' ">
<None Remove="App.config" />
<Compile Remove="generatedClient.cs" />
<None Include="generatedClient.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />

<ItemGroup Condition=" '$(TargetFramework)' == 'net462' ">
<Reference Include="System.ServiceModel" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\GZipEncoder\GZipEncoder.csproj">
<Project>{3EB736C4-62EA-4887-B040-948B13EF29B9}</Project>
<Name>GZipEncoder</Name>
</ProjectReference>

<ItemGroup Condition=" '$(TargetFramework)' == 'net6.0' ">
<PackageReference Include="System.ServiceModel.Primitives" Version="6.*" />
<PackageReference Include="System.ServiceModel.Http" Version="6.*" />
</ItemGroup>

<ItemGroup>
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.VisualBasic.PowerPacks.10.0">
<Visible>False</Visible>
<ProductName>Microsoft Visual Basic PowerPacks 10.0</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
<Visible>False</Visible>
<ProductName>Windows Installer 3.1</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<ProjectReference Include="..\GZipEncoder\GZipEncoder.csproj" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
</Project>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"ExtendedData": {
"inputs": [
"http://localhost:8000/samples/GZipEncoder?wsdl"
],
"collectionTypes": [
"System.Array",
"System.Collections.Generic.Dictionary`2"
],
"namespaceMappings": [
"*, Microsoft.Samples.GZipEncoder"
],
"sync": true,
"targetFramework": "net6.0",
"typeReuseMode": "None"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace Microsoft.Samples.GZipEncoder
{


[System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Tools.ServiceModel.Svcutil", "2.1.0")]
[System.ServiceModel.ServiceContractAttribute(ConfigurationName="Microsoft.Samples.GZipEncoder.ISampleServer")]
public interface ISampleServer
{

[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/ISampleServer/Echo", ReplyAction="http://tempuri.org/ISampleServer/EchoResponse")]
string Echo(string input);

[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/ISampleServer/Echo", ReplyAction="http://tempuri.org/ISampleServer/EchoResponse")]
System.Threading.Tasks.Task<string> EchoAsync(string input);

[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/ISampleServer/BigEcho", ReplyAction="http://tempuri.org/ISampleServer/BigEchoResponse")]
string[] BigEcho(string[] input);

[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/ISampleServer/BigEcho", ReplyAction="http://tempuri.org/ISampleServer/BigEchoResponse")]
System.Threading.Tasks.Task<string[]> BigEchoAsync(string[] input);
}

[System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Tools.ServiceModel.Svcutil", "2.1.0")]
public interface ISampleServerChannel : Microsoft.Samples.GZipEncoder.ISampleServer, System.ServiceModel.IClientChannel
{
}

[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Tools.ServiceModel.Svcutil", "2.1.0")]
public partial class SampleServerClient : System.ServiceModel.ClientBase<Microsoft.Samples.GZipEncoder.ISampleServer>, Microsoft.Samples.GZipEncoder.ISampleServer
{

public SampleServerClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) :
base(binding, remoteAddress)
{
}

public string Echo(string input)
{
return base.Channel.Echo(input);
}

public System.Threading.Tasks.Task<string> EchoAsync(string input)
{
return base.Channel.EchoAsync(input);
}

public string[] BigEcho(string[] input)
{
return base.Channel.BigEcho(input);
}

public System.Threading.Tasks.Task<string[]> BigEchoAsync(string[] input)
{
return base.Channel.BigEchoAsync(input);
}

public virtual System.Threading.Tasks.Task OpenAsync()
{
return System.Threading.Tasks.Task.Factory.FromAsync(((System.ServiceModel.ICommunicationObject)(this)).BeginOpen(null, null), new System.Action<System.IAsyncResult>(((System.ServiceModel.ICommunicationObject)(this)).EndOpen));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,23 @@
//----------------------------------------------------------------

using System;
using System.ServiceModel;
using System.ServiceModel.Channels;

namespace Microsoft.Samples.GZipEncoder
{
static class Program
{
static void Main()
{
#if NET6_0_OR_GREATER
Binding binding = new CustomBinding(new GZipMessageEncodingBindingElement(), new HttpTransportBindingElement());
EndpointAddress endpointAddress = new EndpointAddress(new Uri("http://localhost:8000/samples/GZipEncoder"));
SampleServerClient client = new SampleServerClient(binding, endpointAddress);
#else
SampleServerClient client = new SampleServerClient();
#endif


Console.WriteLine("Calling Echo(string):");
Console.WriteLine("Server responds: {0}", client.Echo("Simple hello"));
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@
</customBinding>
</bindings>
</system.serviceModel>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>
</configuration>
Original file line number Diff line number Diff line change
@@ -1,87 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{3EB736C4-62EA-4887-B040-948B13EF29B9}</ProjectGuid>
<TargetFrameworks>net462;net6.0</TargetFrameworks>
<OutputType>Library</OutputType>
<RootNamespace>Microsoft.Samples.GZipEncoder</RootNamespace>
<AssemblyName>GZipEncoder</AssemblyName>
<WarningLevel>4</WarningLevel>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileUpgradeFlags>
</FileUpgradeFlags>
<OldToolsVersion>2.0</OldToolsVersion>
<UpgradeBackupLocation />
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
<TargetFrameworkProfile />
<Title>GZipEncoder</Title>
<Description>GZipEncoder</Description>
<Company>Microsoft Corporation</Company>
<Product>Windows Communication Foundation and Windows Workflow Foundation SDK</Product>
<Copyright>Copyright (c) Microsoft Corporation</Copyright>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>.\bin\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>.\bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />

<ItemGroup Condition=" '$(TargetFramework)' == 'net462' ">
<Reference Include="System.Configuration" />
<Reference Include="System.Data" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.ServiceModel" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="GZipMessageEncoderFactory.cs" />
<Compile Include="GZipMessageEncodingBindingElement.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="GZipMessageEncodingBindingElementImporter.cs" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.VisualBasic.PowerPacks.10.0">
<Visible>False</Visible>
<ProductName>Microsoft Visual Basic PowerPacks 10.0</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
<Visible>False</Visible>
<ProductName>Windows Installer 3.1</ProductName>
<Install>true</Install>
</BootstrapperPackage>

<ItemGroup Condition=" '$(TargetFramework)' == 'net6.0' ">
<PackageReference Include="System.ServiceModel.Primitives" Version="6.*" />
<PackageReference Include="System.ServiceModel.Http" Version="6.*" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
</Project>

</Project>
Loading

0 comments on commit 7fd2c7a

Please sign in to comment.