From 1c2b7130cad04b5e28dc0fe7b7ebdefa31607a73 Mon Sep 17 00:00:00 2001 From: Abdelwahab Afifi Date: Wed, 8 Nov 2023 17:40:33 +0200 Subject: [PATCH] Update WCF sample ErrorLogging client to support .NET framework / Core --- .../ErrorLogging/CS/client/App.config | 3 +- .../ConnectedService.json | 17 ++ .../Reference.cs | 194 ++++++++++++++++++ .../CS/client/Properties/AssemblyInfo.cs | 34 --- .../CS/client/Properties/Resources.cs | 58 ------ .../CS/client/Properties/Resources.resx | 117 ----------- .../CS/client/Properties/Settings.cs | 38 ---- .../CS/client/Properties/Settings.settings | 7 - .../ErrorLogging/CS/client/client.cs | 2 - .../ErrorLogging/CS/client/client.csproj | 110 +++------- .../CS/service/Properties/AssemblyInfo.cs | 2 - .../ErrorLogging/CS/service/Web.config | 1 - .../ErrorLogging/CS/service/service.cs | 34 +-- .../ErrorLogging/CS/service/service.csproj | 63 +----- 14 files changed, 256 insertions(+), 424 deletions(-) create mode 100644 framework/wcf/Extensibility/ErrorHandling/ErrorLogging/CS/client/Connected Services/Microsoft.ServiceModel.Samples/ConnectedService.json create mode 100644 framework/wcf/Extensibility/ErrorHandling/ErrorLogging/CS/client/Connected Services/Microsoft.ServiceModel.Samples/Reference.cs delete mode 100644 framework/wcf/Extensibility/ErrorHandling/ErrorLogging/CS/client/Properties/AssemblyInfo.cs delete mode 100644 framework/wcf/Extensibility/ErrorHandling/ErrorLogging/CS/client/Properties/Resources.cs delete mode 100644 framework/wcf/Extensibility/ErrorHandling/ErrorLogging/CS/client/Properties/Resources.resx delete mode 100644 framework/wcf/Extensibility/ErrorHandling/ErrorLogging/CS/client/Properties/Settings.cs delete mode 100644 framework/wcf/Extensibility/ErrorHandling/ErrorLogging/CS/client/Properties/Settings.settings diff --git a/framework/wcf/Extensibility/ErrorHandling/ErrorLogging/CS/client/App.config b/framework/wcf/Extensibility/ErrorHandling/ErrorLogging/CS/client/App.config index f12e9980297..80896cfafea 100644 --- a/framework/wcf/Extensibility/ErrorHandling/ErrorLogging/CS/client/App.config +++ b/framework/wcf/Extensibility/ErrorHandling/ErrorLogging/CS/client/App.config @@ -7,5 +7,4 @@ - - + diff --git a/framework/wcf/Extensibility/ErrorHandling/ErrorLogging/CS/client/Connected Services/Microsoft.ServiceModel.Samples/ConnectedService.json b/framework/wcf/Extensibility/ErrorHandling/ErrorLogging/CS/client/Connected Services/Microsoft.ServiceModel.Samples/ConnectedService.json new file mode 100644 index 00000000000..77d4156f6cc --- /dev/null +++ b/framework/wcf/Extensibility/ErrorHandling/ErrorLogging/CS/client/Connected Services/Microsoft.ServiceModel.Samples/ConnectedService.json @@ -0,0 +1,17 @@ +{ + "ExtendedData": { + "inputs": [ + "http://localhost/servicemodelsamples/service.svc" + ], + "collectionTypes": [ + "System.Array", + "System.Collections.Generic.Dictionary`2" + ], + "namespaceMappings": [ + "*, Microsoft.ServiceModel.Samples" + ], + "sync": true, + "targetFramework": "net6.0", + "typeReuseMode": "None" + } +} \ No newline at end of file diff --git a/framework/wcf/Extensibility/ErrorHandling/ErrorLogging/CS/client/Connected Services/Microsoft.ServiceModel.Samples/Reference.cs b/framework/wcf/Extensibility/ErrorHandling/ErrorLogging/CS/client/Connected Services/Microsoft.ServiceModel.Samples/Reference.cs new file mode 100644 index 00000000000..19086c3d422 --- /dev/null +++ b/framework/wcf/Extensibility/ErrorHandling/ErrorLogging/CS/client/Connected Services/Microsoft.ServiceModel.Samples/Reference.cs @@ -0,0 +1,194 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Microsoft.ServiceModel.Samples +{ + + + [System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Tools.ServiceModel.Svcutil", "2.1.0")] + [System.ServiceModel.ServiceContractAttribute(Namespace="http://Microsoft.ServiceModel.Samples", ConfigurationName="Microsoft.ServiceModel.Samples.IErrorCalculator")] + public interface IErrorCalculator + { + + [System.ServiceModel.OperationContractAttribute(Action="http://Microsoft.ServiceModel.Samples/IErrorCalculator/Add", ReplyAction="http://Microsoft.ServiceModel.Samples/IErrorCalculator/AddResponse")] + int Add(int n1, int n2); + + [System.ServiceModel.OperationContractAttribute(Action="http://Microsoft.ServiceModel.Samples/IErrorCalculator/Add", ReplyAction="http://Microsoft.ServiceModel.Samples/IErrorCalculator/AddResponse")] + System.Threading.Tasks.Task AddAsync(int n1, int n2); + + [System.ServiceModel.OperationContractAttribute(Action="http://Microsoft.ServiceModel.Samples/IErrorCalculator/Subtract", ReplyAction="http://Microsoft.ServiceModel.Samples/IErrorCalculator/SubtractResponse")] + int Subtract(int n1, int n2); + + [System.ServiceModel.OperationContractAttribute(Action="http://Microsoft.ServiceModel.Samples/IErrorCalculator/Subtract", ReplyAction="http://Microsoft.ServiceModel.Samples/IErrorCalculator/SubtractResponse")] + System.Threading.Tasks.Task SubtractAsync(int n1, int n2); + + [System.ServiceModel.OperationContractAttribute(Action="http://Microsoft.ServiceModel.Samples/IErrorCalculator/Multiply", ReplyAction="http://Microsoft.ServiceModel.Samples/IErrorCalculator/MultiplyResponse")] + int Multiply(int n1, int n2); + + [System.ServiceModel.OperationContractAttribute(Action="http://Microsoft.ServiceModel.Samples/IErrorCalculator/Multiply", ReplyAction="http://Microsoft.ServiceModel.Samples/IErrorCalculator/MultiplyResponse")] + System.Threading.Tasks.Task MultiplyAsync(int n1, int n2); + + [System.ServiceModel.OperationContractAttribute(Action="http://Microsoft.ServiceModel.Samples/IErrorCalculator/Divide", ReplyAction="http://Microsoft.ServiceModel.Samples/IErrorCalculator/DivideResponse")] + int Divide(int n1, int n2); + + [System.ServiceModel.OperationContractAttribute(Action="http://Microsoft.ServiceModel.Samples/IErrorCalculator/Divide", ReplyAction="http://Microsoft.ServiceModel.Samples/IErrorCalculator/DivideResponse")] + System.Threading.Tasks.Task DivideAsync(int n1, int n2); + + [System.ServiceModel.OperationContractAttribute(Action="http://Microsoft.ServiceModel.Samples/IErrorCalculator/Factorial", ReplyAction="http://Microsoft.ServiceModel.Samples/IErrorCalculator/FactorialResponse")] + int Factorial(int n); + + [System.ServiceModel.OperationContractAttribute(Action="http://Microsoft.ServiceModel.Samples/IErrorCalculator/Factorial", ReplyAction="http://Microsoft.ServiceModel.Samples/IErrorCalculator/FactorialResponse")] + System.Threading.Tasks.Task FactorialAsync(int n); + } + + [System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Tools.ServiceModel.Svcutil", "2.1.0")] + public interface IErrorCalculatorChannel : Microsoft.ServiceModel.Samples.IErrorCalculator, System.ServiceModel.IClientChannel + { + } + + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Tools.ServiceModel.Svcutil", "2.1.0")] + public partial class ErrorCalculatorClient : System.ServiceModel.ClientBase, Microsoft.ServiceModel.Samples.IErrorCalculator + { + + /// + /// Implement this partial method to configure the service endpoint. + /// + /// The endpoint to configure + /// The client credentials + static partial void ConfigureEndpoint(System.ServiceModel.Description.ServiceEndpoint serviceEndpoint, System.ServiceModel.Description.ClientCredentials clientCredentials); + + public ErrorCalculatorClient() : + base(ErrorCalculatorClient.GetDefaultBinding(), ErrorCalculatorClient.GetDefaultEndpointAddress()) + { + this.Endpoint.Name = EndpointConfiguration.BasicHttpBinding_IErrorCalculator.ToString(); + ConfigureEndpoint(this.Endpoint, this.ClientCredentials); + } + + public ErrorCalculatorClient(EndpointConfiguration endpointConfiguration) : + base(ErrorCalculatorClient.GetBindingForEndpoint(endpointConfiguration), ErrorCalculatorClient.GetEndpointAddress(endpointConfiguration)) + { + this.Endpoint.Name = endpointConfiguration.ToString(); + ConfigureEndpoint(this.Endpoint, this.ClientCredentials); + } + + public ErrorCalculatorClient(EndpointConfiguration endpointConfiguration, string remoteAddress) : + base(ErrorCalculatorClient.GetBindingForEndpoint(endpointConfiguration), new System.ServiceModel.EndpointAddress(remoteAddress)) + { + this.Endpoint.Name = endpointConfiguration.ToString(); + ConfigureEndpoint(this.Endpoint, this.ClientCredentials); + } + + public ErrorCalculatorClient(EndpointConfiguration endpointConfiguration, System.ServiceModel.EndpointAddress remoteAddress) : + base(ErrorCalculatorClient.GetBindingForEndpoint(endpointConfiguration), remoteAddress) + { + this.Endpoint.Name = endpointConfiguration.ToString(); + ConfigureEndpoint(this.Endpoint, this.ClientCredentials); + } + + public ErrorCalculatorClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) : + base(binding, remoteAddress) + { + } + + public int Add(int n1, int n2) + { + return base.Channel.Add(n1, n2); + } + + public System.Threading.Tasks.Task AddAsync(int n1, int n2) + { + return base.Channel.AddAsync(n1, n2); + } + + public int Subtract(int n1, int n2) + { + return base.Channel.Subtract(n1, n2); + } + + public System.Threading.Tasks.Task SubtractAsync(int n1, int n2) + { + return base.Channel.SubtractAsync(n1, n2); + } + + public int Multiply(int n1, int n2) + { + return base.Channel.Multiply(n1, n2); + } + + public System.Threading.Tasks.Task MultiplyAsync(int n1, int n2) + { + return base.Channel.MultiplyAsync(n1, n2); + } + + public int Divide(int n1, int n2) + { + return base.Channel.Divide(n1, n2); + } + + public System.Threading.Tasks.Task DivideAsync(int n1, int n2) + { + return base.Channel.DivideAsync(n1, n2); + } + + public int Factorial(int n) + { + return base.Channel.Factorial(n); + } + + public System.Threading.Tasks.Task FactorialAsync(int n) + { + return base.Channel.FactorialAsync(n); + } + + 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.ServiceModel.ICommunicationObject)(this)).EndOpen)); + } + + private static System.ServiceModel.Channels.Binding GetBindingForEndpoint(EndpointConfiguration endpointConfiguration) + { + if ((endpointConfiguration == EndpointConfiguration.BasicHttpBinding_IErrorCalculator)) + { + System.ServiceModel.BasicHttpBinding result = new System.ServiceModel.BasicHttpBinding(); + result.MaxBufferSize = int.MaxValue; + result.ReaderQuotas = System.Xml.XmlDictionaryReaderQuotas.Max; + result.MaxReceivedMessageSize = int.MaxValue; + result.AllowCookies = true; + return result; + } + throw new System.InvalidOperationException(string.Format("Could not find endpoint with name \'{0}\'.", endpointConfiguration)); + } + + private static System.ServiceModel.EndpointAddress GetEndpointAddress(EndpointConfiguration endpointConfiguration) + { + if ((endpointConfiguration == EndpointConfiguration.BasicHttpBinding_IErrorCalculator)) + { + return new System.ServiceModel.EndpointAddress("http://localhost/servicemodelsamples/service.svc"); + } + throw new System.InvalidOperationException(string.Format("Could not find endpoint with name \'{0}\'.", endpointConfiguration)); + } + + private static System.ServiceModel.Channels.Binding GetDefaultBinding() + { + return ErrorCalculatorClient.GetBindingForEndpoint(EndpointConfiguration.BasicHttpBinding_IErrorCalculator); + } + + private static System.ServiceModel.EndpointAddress GetDefaultEndpointAddress() + { + return ErrorCalculatorClient.GetEndpointAddress(EndpointConfiguration.BasicHttpBinding_IErrorCalculator); + } + + public enum EndpointConfiguration + { + + BasicHttpBinding_IErrorCalculator, + } + } +} diff --git a/framework/wcf/Extensibility/ErrorHandling/ErrorLogging/CS/client/Properties/AssemblyInfo.cs b/framework/wcf/Extensibility/ErrorHandling/ErrorLogging/CS/client/Properties/AssemblyInfo.cs deleted file mode 100644 index b8c905afe00..00000000000 --- a/framework/wcf/Extensibility/ErrorHandling/ErrorLogging/CS/client/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,34 +0,0 @@ -#region Using directives - -using System; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Security.Permissions; - -#endregion - -// 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: ComVisible(false)] -[assembly: CLSCompliant(true)] -[assembly: AssemblyTitle("client")] -[assembly: AssemblyDescription("Error Logging")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Microsoft")] -[assembly: AssemblyProduct("client")] -[assembly: AssemblyCopyright("Copyright @ Microsoft 2004")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// 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 Revision and Build Numbers -// by using the '*' as shown below: -[assembly: AssemblyVersion("1.0.*")] diff --git a/framework/wcf/Extensibility/ErrorHandling/ErrorLogging/CS/client/Properties/Resources.cs b/framework/wcf/Extensibility/ErrorHandling/ErrorLogging/CS/client/Properties/Resources.cs deleted file mode 100644 index db82d9baa27..00000000000 --- a/framework/wcf/Extensibility/ErrorHandling/ErrorLogging/CS/client/Properties/Resources.cs +++ /dev/null @@ -1,58 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:2.0.40903.19 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace Properties { - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the Strongly Typed Resource Builder - // class via a tool like ResGen or Visual Studio.NET. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - class Resources { - - private static System.Resources.ResourceManager _resMgr; - - private static System.Globalization.CultureInfo _resCulture; - - /*FamANDAssem*/ internal Resources() { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] - public static System.Resources.ResourceManager ResourceManager { - get { - if ((_resMgr == null)) { - System.Resources.ResourceManager temp = new System.Resources.ResourceManager("Properties.Resources", typeof(Resources).Assembly); - _resMgr = temp; - } - return _resMgr; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] - public static System.Globalization.CultureInfo Culture { - get { - return _resCulture; - } - set { - _resCulture = value; - } - } - } -} diff --git a/framework/wcf/Extensibility/ErrorHandling/ErrorLogging/CS/client/Properties/Resources.resx b/framework/wcf/Extensibility/ErrorHandling/ErrorLogging/CS/client/Properties/Resources.resx deleted file mode 100644 index fe52bb6e966..00000000000 --- a/framework/wcf/Extensibility/ErrorHandling/ErrorLogging/CS/client/Properties/Resources.resx +++ /dev/null @@ -1,117 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - diff --git a/framework/wcf/Extensibility/ErrorHandling/ErrorLogging/CS/client/Properties/Settings.cs b/framework/wcf/Extensibility/ErrorHandling/ErrorLogging/CS/client/Properties/Settings.cs deleted file mode 100644 index 2a1d033374d..00000000000 --- a/framework/wcf/Extensibility/ErrorHandling/ErrorLogging/CS/client/Properties/Settings.cs +++ /dev/null @@ -1,38 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:2.0.40903.19 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace Properties { - - - sealed partial class Settings : System.Configuration.ApplicationSettingsBase { - - private static Settings m_Value; - - private static object m_SyncObject = new object(); - - [System.Diagnostics.DebuggerNonUserCode()] - public static Settings Value { - get { - if ((Settings.m_Value == null)) { - System.Threading.Monitor.Enter(Settings.m_SyncObject); - if ((Settings.m_Value == null)) { - try { - Settings.m_Value = new Settings(); - } - finally { - System.Threading.Monitor.Exit(Settings.m_SyncObject); - } - } - } - return Settings.m_Value; - } - } - } -} diff --git a/framework/wcf/Extensibility/ErrorHandling/ErrorLogging/CS/client/Properties/Settings.settings b/framework/wcf/Extensibility/ErrorHandling/ErrorLogging/CS/client/Properties/Settings.settings deleted file mode 100644 index 099a656bee6..00000000000 --- a/framework/wcf/Extensibility/ErrorHandling/ErrorLogging/CS/client/Properties/Settings.settings +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/framework/wcf/Extensibility/ErrorHandling/ErrorLogging/CS/client/client.cs b/framework/wcf/Extensibility/ErrorHandling/ErrorLogging/CS/client/client.cs index 119347dd694..c7f0ff67d9a 100644 --- a/framework/wcf/Extensibility/ErrorHandling/ErrorLogging/CS/client/client.cs +++ b/framework/wcf/Extensibility/ErrorHandling/ErrorLogging/CS/client/client.cs @@ -2,8 +2,6 @@ // Copyright (c) Microsoft Corporation. All Rights Reserved. using System; - -using System.ServiceModel.Channels; using System.ServiceModel; namespace Microsoft.ServiceModel.Samples diff --git a/framework/wcf/Extensibility/ErrorHandling/ErrorLogging/CS/client/client.csproj b/framework/wcf/Extensibility/ErrorHandling/ErrorLogging/CS/client/client.csproj index 15af4395b72..eeec9b3a2b1 100644 --- a/framework/wcf/Extensibility/ErrorHandling/ErrorLogging/CS/client/client.csproj +++ b/framework/wcf/Extensibility/ErrorHandling/ErrorLogging/CS/client/client.csproj @@ -1,92 +1,32 @@ - - + - Debug - AnyCPU - 8.0.50110 - 2.0 - {F6D8FC2E-62D0-4554-AC3E-1964042590E3} + net462;net6.0 Exe - Properties - - - client - v4.0 - - - 2.0 - - publish\ - true - Disk - false - Foreground - 7 - Days - false - false - true - 0 - 1.0.0.%2a - false - false - true - + Client + Error Logging + Microsoft Corporation + Windows Communication Foundation and Windows Workflow Foundation SDK + Copyright (c) Microsoft Corporation - - true - full - false - bin\ - DEBUG;TRACE - prompt - 4 - AllRules.ruleset - - - pdbonly - true - bin\ - TRACE - prompt - 4 - AllRules.ruleset - - - - - - + + + + + - - - - + + + + + - - + + + - - - False - .NET Framework 3.5 SP1 Client Profile - false - - - False - .NET Framework 3.5 SP1 - true - - - False - Microsoft Visual Basic PowerPacks 10.0 - true - - - False - Windows Installer 3.1 - true - + + + + - - \ No newline at end of file + diff --git a/framework/wcf/Extensibility/ErrorHandling/ErrorLogging/CS/service/Properties/AssemblyInfo.cs b/framework/wcf/Extensibility/ErrorHandling/ErrorLogging/CS/service/Properties/AssemblyInfo.cs index 6ed37ac9f4b..45fc355421f 100644 --- a/framework/wcf/Extensibility/ErrorHandling/ErrorLogging/CS/service/Properties/AssemblyInfo.cs +++ b/framework/wcf/Extensibility/ErrorHandling/ErrorLogging/CS/service/Properties/AssemblyInfo.cs @@ -2,9 +2,7 @@ using System; using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -using System.Security.Permissions; #endregion diff --git a/framework/wcf/Extensibility/ErrorHandling/ErrorLogging/CS/service/Web.config b/framework/wcf/Extensibility/ErrorHandling/ErrorLogging/CS/service/Web.config index a8764666d0f..c369438dd61 100644 --- a/framework/wcf/Extensibility/ErrorHandling/ErrorLogging/CS/service/Web.config +++ b/framework/wcf/Extensibility/ErrorHandling/ErrorLogging/CS/service/Web.config @@ -12,5 +12,4 @@ - diff --git a/framework/wcf/Extensibility/ErrorHandling/ErrorLogging/CS/service/service.cs b/framework/wcf/Extensibility/ErrorHandling/ErrorLogging/CS/service/service.cs index 3fae531dbd4..47d361005a3 100644 --- a/framework/wcf/Extensibility/ErrorHandling/ErrorLogging/CS/service/service.cs +++ b/framework/wcf/Extensibility/ErrorHandling/ErrorLogging/CS/service/service.cs @@ -3,7 +3,6 @@ using System; using System.IO; -using System.Runtime.Serialization; using System.ServiceModel; using System.ServiceModel.Channels; using System.ServiceModel.Description; @@ -12,7 +11,7 @@ namespace Microsoft.ServiceModel.Samples { // Define a service contract - [ServiceContract(Namespace="http://Microsoft.ServiceModel.Samples")] + [ServiceContract(Namespace = "http://Microsoft.ServiceModel.Samples")] public interface IErrorCalculator { [OperationContract] @@ -36,20 +35,11 @@ public interface IErrorCalculator [ErrorBehavior(typeof(CalculatorErrorHandler))] public class CalculatorService : IErrorCalculator { - public int Add(int n1, int n2) - { - return n1 + n2; - } + public int Add(int n1, int n2) => n1 + n2; - public int Subtract(int n1, int n2) - { - return n1 - n2; - } + public int Subtract(int n1, int n2) => n1 - n2; - public int Multiply(int n1, int n2) - { - return n1 * n2; - } + public int Multiply(int n1, int n2) => n1 * n2; public int Divide(int n1, int n2) { @@ -106,17 +96,9 @@ public bool HandleError(Exception error) // This attribute can be used to install a custom error handler for a service public sealed class ErrorBehaviorAttribute : Attribute, IServiceBehavior { - Type errorHandlerType; + public ErrorBehaviorAttribute(Type errorHandlerType) => ErrorHandlerType = errorHandlerType; - public ErrorBehaviorAttribute(Type errorHandlerType) - { - this.errorHandlerType = errorHandlerType; - } - - public Type ErrorHandlerType - { - get { return this.errorHandlerType; } - } + public Type ErrorHandlerType { get; } void IServiceBehavior.Validate(ServiceDescription description, ServiceHostBase serviceHostBase) { @@ -132,7 +114,7 @@ void IServiceBehavior.ApplyDispatchBehavior(ServiceDescription description, Serv try { - errorHandler = (IErrorHandler)Activator.CreateInstance(errorHandlerType); + errorHandler = (IErrorHandler)Activator.CreateInstance(ErrorHandlerType); } catch (MissingMethodException e) { @@ -147,7 +129,7 @@ void IServiceBehavior.ApplyDispatchBehavior(ServiceDescription description, Serv { ChannelDispatcher channelDispatcher = channelDispatcherBase as ChannelDispatcher; channelDispatcher.ErrorHandlers.Add(errorHandler); - } + } } } } diff --git a/framework/wcf/Extensibility/ErrorHandling/ErrorLogging/CS/service/service.csproj b/framework/wcf/Extensibility/ErrorHandling/ErrorLogging/CS/service/service.csproj index bb88c6d8cf7..782fe387504 100644 --- a/framework/wcf/Extensibility/ErrorHandling/ErrorLogging/CS/service/service.csproj +++ b/framework/wcf/Extensibility/ErrorHandling/ErrorLogging/CS/service/service.csproj @@ -1,37 +1,16 @@  - + + Debug AnyCPU 8.0.50110 - 2.0 {73D6E51B-9EAB-4EBE-BAA3-794D636BD176} Library Properties - - service - v4.0 - - - 2.0 - + v4.6.2 publish\ - true - Disk - false - Foreground - 7 - Days - false - false - true - 0 - 1.0.0.%2a - false - false - true - true @@ -42,6 +21,7 @@ prompt 4 AllRules.ruleset + false pdbonly @@ -51,6 +31,7 @@ prompt 4 AllRules.ruleset + false @@ -68,34 +49,12 @@ - - - False - .NET Framework 3.5 SP1 Client Profile - false - - - False - .NET Framework 3.5 SP1 - true - - - False - Microsoft Visual Basic PowerPacks 10.0 - true - - - False - Windows Installer 3.1 - true - - - + - copy "$(TargetDir)service.dll" %SystemDrive%\inetpub\wwwroot\servicemodelsamples\bin - copy "$(ProjectDir)service.svc" %SystemDrive%\inetpub\wwwroot\servicemodelsamples - copy "$(ProjectDir)web.config" %SystemDrive%\inetpub\wwwroot\servicemodelsamples - + copy "$(TargetDir)service.dll" %SystemDrive%\inetpub\wwwroot\servicemodelsamples\bin + copy "$(ProjectDir)service.svc" %SystemDrive%\inetpub\wwwroot\servicemodelsamples + copy "$(ProjectDir)web.config" %SystemDrive%\inetpub\wwwroot\servicemodelsamples + - \ No newline at end of file +