diff --git a/docs/core/extensions/snippets/configuration/custom-yaml-provider/custom-yaml-provider/Program.cs b/docs/core/extensions/snippets/configuration/custom-yaml-provider/custom-yaml-provider/Program.cs deleted file mode 100644 index 9a7e3c8b36715..0000000000000 --- a/docs/core/extensions/snippets/configuration/custom-yaml-provider/custom-yaml-provider/Program.cs +++ /dev/null @@ -1,30 +0,0 @@ -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Hosting; -using Microsoft.Extensions.Options; -using CustomProvider.Example; - -using IHost host = Host.CreateDefaultBuilder(args) - .ConfigureAppConfiguration((_, configuration) => - { - configuration.Sources.Clear(); - configuration.AddYamlFile("config.yaml", optional: false, reloadOnChange: true); - }) - .ConfigureServices((context, services) => - services.Configure( - context.Configuration.GetSection("WidgetOptions"))) - .Build(); - -var options = host.Services.GetRequiredService>().Value; -Console.WriteLine($"DisplayLabel={options.DisplayLabel}"); -Console.WriteLine($"EndpointId={options.EndpointId}"); -Console.WriteLine($"WidgetRoute={options.WidgetRoute}"); -Console.WriteLine($"IPAddressRange={string.Join(", ", options.IPAddressRange)}"); -Console.WriteLine($"FeatureFlags.IsTelemetryEnabled={string.Join(", ", options.FeatureFlags.IsTelemetryEnabled)}"); - -await host.RunAsync(); -// Sample output: -// DisplayLabel=Widgets Incorporated, LLC. -// EndpointId=b3da3c4c-9c4e-4411-bc4d-609e2dcc5c67 -// WidgetRoute=api/widgets -// IPAddressRange=46.36.198.123, 46.36.198.124, 46.36.198.125 -// FeatureFlags.IsTelemetryEnabled=True diff --git a/docs/core/extensions/snippets/configuration/custom-yaml-provider/custom-yaml-provider/WidgetOptions.cs b/docs/core/extensions/snippets/configuration/custom-yaml-provider/custom-yaml-provider/WidgetOptions.cs deleted file mode 100644 index 669a7d377b887..0000000000000 --- a/docs/core/extensions/snippets/configuration/custom-yaml-provider/custom-yaml-provider/WidgetOptions.cs +++ /dev/null @@ -1,19 +0,0 @@ -namespace CustomProvider.Example; - -public class WidgetOptions -{ - public Guid EndpointId { get; set; } - - public string DisplayLabel { get; set; } = null!; - - public string WidgetRoute { get; set; } = null!; - - public string[] IPAddressRange { get; set; } = null!; - - public FeatureFlags FeatureFlags { get; set; } = null!; -} - -public class FeatureFlags -{ - public bool IsTelemetryEnabled { get; set; } -} diff --git a/docs/core/extensions/snippets/configuration/custom-yaml-provider/custom-yaml-provider/YamlConfigurationExtensions.cs b/docs/core/extensions/snippets/configuration/custom-yaml-provider/custom-yaml-provider/YamlConfigurationExtensions.cs deleted file mode 100644 index a6b1b6ea16945..0000000000000 --- a/docs/core/extensions/snippets/configuration/custom-yaml-provider/custom-yaml-provider/YamlConfigurationExtensions.cs +++ /dev/null @@ -1,111 +0,0 @@ -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.FileProviders; - -namespace CustomProvider.Example; - -/// -/// Extension methods for adding . -/// -public static class YamlConfigurationExtensions -{ - /// - /// Adds the YAML configuration provider at to . - /// - /// The to add to. - /// Path relative to the base path stored in - /// of . - /// The . - public static IConfigurationBuilder AddYamlFile( - this IConfigurationBuilder builder, - string path) => - AddYamlFile(builder, provider: null, path: path, optional: false, reloadOnChange: false); - - /// - /// Adds the YAML configuration provider at to . - /// - /// The to add to. - /// Path relative to the base path stored in - /// of . - /// Whether the file is optional. - /// The . - public static IConfigurationBuilder AddYamlFile( - this IConfigurationBuilder builder, - string path, - bool optional) => - AddYamlFile(builder, provider: null, path: path, optional: optional, reloadOnChange: false); - - /// - /// Adds the YAML configuration provider at to . - /// - /// The to add to. - /// Path relative to the base path stored in - /// of . - /// Whether the file is optional. - /// Whether the configuration should be reloaded if the file changes. - /// The . - public static IConfigurationBuilder AddYamlFile( - this IConfigurationBuilder builder, - string path, - bool optional, - bool reloadOnChange) => - AddYamlFile(builder, provider: null, path: path, optional: optional, reloadOnChange: reloadOnChange); - - /// - /// Adds a Yaml configuration source to . - /// - /// The to add to. - /// The to use to access the file. - /// Path relative to the base path stored in - /// of . - /// Whether the file is optional. - /// Whether the configuration should be reloaded if the file changes. - /// The . - public static IConfigurationBuilder AddYamlFile( - this IConfigurationBuilder builder, - IFileProvider? provider, - string path, - bool optional, - bool reloadOnChange) - { - ArgumentNullException.ThrowIfNull(builder); - - if (string.IsNullOrEmpty(path)) - { - throw new ArgumentException("Invalid file path.", nameof(path)); - } - - return builder.AddYamlFile(s => - { - s.FileProvider = provider; - s.Path = path; - s.Optional = optional; - s.ReloadOnChange = reloadOnChange; - s.ResolveFileProvider(); - }); - } - - /// - /// Adds a Yaml configuration source to . - /// - /// The to add to. - /// Configures the source. - /// The . - public static IConfigurationBuilder AddYamlFile( - this IConfigurationBuilder builder, - Action? configureSource) => builder.Add(configureSource); - - /// - /// Adds a Yaml configuration source to . - /// - /// The to add to. - /// The to read the Yaml configuration data from. - /// The . - public static IConfigurationBuilder AddYamlStream( - this IConfigurationBuilder builder, - Stream stream) - { - ArgumentNullException.ThrowIfNull(builder); - - return builder.Add(s => s.Stream = stream); - } -} diff --git a/docs/core/extensions/snippets/configuration/custom-yaml-provider/custom-yaml-provider/YamlConfigurationFileParser.cs b/docs/core/extensions/snippets/configuration/custom-yaml-provider/custom-yaml-provider/YamlConfigurationFileParser.cs deleted file mode 100644 index 8883b7814a346..0000000000000 --- a/docs/core/extensions/snippets/configuration/custom-yaml-provider/custom-yaml-provider/YamlConfigurationFileParser.cs +++ /dev/null @@ -1,102 +0,0 @@ -using System.Diagnostics; -using Microsoft.Extensions.Configuration; -using YamlDotNet.RepresentationModel; - -namespace CustomProvider.Example; - -internal sealed class YamlConfigurationFileParser -{ - private YamlConfigurationFileParser() { } - - private readonly Dictionary _data = new(StringComparer.OrdinalIgnoreCase); - private readonly Stack _paths = new(); - - public static IDictionary Parse(Stream input) => - new YamlConfigurationFileParser().ParseStream(input); - - private IDictionary ParseStream(Stream input) - { - using TextReader reader = new StreamReader(input); - - var yaml = new YamlStream(); - yaml.Load(reader); - - foreach (YamlDocument document in yaml) - { - VisitMappingNode((YamlMappingNode)document.RootNode); - } - - return _data; - } - - private bool VisitScalarNode(YamlScalarNode node) - { - string key = _paths.Peek(); - if (_data.ContainsKey(key)) - { - throw new FormatException($"Error: the key is duplicated {key}"); - } - _data[key] = node.Value!; - return true; - } - - private bool VisitSequenceNode(YamlSequenceNode node) - { - int index = 0; - - foreach (YamlNode child in node.Children) - { - EnterContext(index.ToString()); - VisitValue(child); - ExitContext(); - ++ index; - } - - SetNullIfElementIsEmpty(isEmpty: index == 0); - return index == 0; - } - - private bool VisitMappingNode(YamlMappingNode node) - { - var isEmpty = true; - - foreach (var (key, value) in node.Children) - { - isEmpty = false; - EnterContext(((YamlScalarNode)key).Value!); - VisitValue(value); - ExitContext(); - } - - SetNullIfElementIsEmpty(isEmpty); - return isEmpty; - } - - private void SetNullIfElementIsEmpty(bool isEmpty) - { - if (isEmpty && _paths.Count > 0) - { - _data[_paths.Peek()] = null; - } - } - - private void VisitValue(YamlNode value) - { - Debug.Assert(_paths.Count > 0); - - _ = (value.NodeType, value) switch - { - (YamlNodeType.Scalar, YamlScalarNode scalar) => VisitScalarNode(scalar), - (YamlNodeType.Sequence, YamlSequenceNode sequence) => VisitSequenceNode(sequence), - (YamlNodeType.Mapping, YamlMappingNode mapping) => VisitMappingNode(mapping), - _ => throw new NotSupportedException($"Node type {value.NodeType} is not supported.") - }; - } - - private void EnterContext(string context) => - _paths.Push(_paths.Count > 0 - ? $"{_paths.Peek()}{ConfigurationPath.KeyDelimiter}{context}" - : context); - - private void ExitContext() => _paths.Pop(); -} diff --git a/docs/core/extensions/snippets/configuration/custom-yaml-provider/custom-yaml-provider/YamlConfigurationProvider.cs b/docs/core/extensions/snippets/configuration/custom-yaml-provider/custom-yaml-provider/YamlConfigurationProvider.cs deleted file mode 100644 index 2a5ccef3bae94..0000000000000 --- a/docs/core/extensions/snippets/configuration/custom-yaml-provider/custom-yaml-provider/YamlConfigurationProvider.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System.Text.Json; -using Microsoft.Extensions.Configuration; - -namespace CustomProvider.Example; - -/// -/// A YAML file based . -/// -public class YamlConfigurationProvider : FileConfigurationProvider -{ - /// - /// Initializes a new instance with the specified source. - /// - /// The source settings. - public YamlConfigurationProvider(YamlConfigurationSource source) : base(source) { } - - /// - /// Loads the YAML data from a stream. - /// - /// The stream to read. - public override void Load(Stream stream) - { - try - { - Data = YamlConfigurationFileParser.Parse(stream); - } - catch (Exception ex) - { - throw new FormatException("Unable to parse YAML.", ex); - } - } -} diff --git a/docs/core/extensions/snippets/configuration/custom-yaml-provider/custom-yaml-provider/YamlConfigurationSource.cs b/docs/core/extensions/snippets/configuration/custom-yaml-provider/custom-yaml-provider/YamlConfigurationSource.cs deleted file mode 100644 index 53737386f31b8..0000000000000 --- a/docs/core/extensions/snippets/configuration/custom-yaml-provider/custom-yaml-provider/YamlConfigurationSource.cs +++ /dev/null @@ -1,20 +0,0 @@ -using Microsoft.Extensions.Configuration; - -namespace CustomProvider.Example; - -/// -/// Represents a YAML file as an . -/// -public class YamlConfigurationSource : FileConfigurationSource -{ - /// - /// Builds the for this source. - /// - /// The . - /// A - public override IConfigurationProvider Build(IConfigurationBuilder builder) - { - EnsureDefaults(builder); - return new YamlConfigurationProvider(this); - } -} diff --git a/docs/core/extensions/snippets/configuration/custom-yaml-provider/custom-yaml-provider/YamlStreamConfigurationProvider.cs b/docs/core/extensions/snippets/configuration/custom-yaml-provider/custom-yaml-provider/YamlStreamConfigurationProvider.cs deleted file mode 100644 index 4d8e513f374e7..0000000000000 --- a/docs/core/extensions/snippets/configuration/custom-yaml-provider/custom-yaml-provider/YamlStreamConfigurationProvider.cs +++ /dev/null @@ -1,22 +0,0 @@ -using Microsoft.Extensions.Configuration; - -namespace CustomProvider.Example; - -/// -/// Loads configuration key/values from a YAML stream into a provider. -/// -public class YamlStreamConfigurationProvider : StreamConfigurationProvider -{ - /// - /// Constructor. - /// - /// The . - public YamlStreamConfigurationProvider(YamlStreamConfigurationSource source) : base(source) { } - - /// - /// Loads Yaml configuration key/values from a stream into a provider. - /// - /// The YAML to load configuration data from. - public override void Load(Stream stream) => - Data = YamlConfigurationFileParser.Parse(stream); -} diff --git a/docs/core/extensions/snippets/configuration/custom-yaml-provider/custom-yaml-provider/YamlStreamConfigurationSource.cs b/docs/core/extensions/snippets/configuration/custom-yaml-provider/custom-yaml-provider/YamlStreamConfigurationSource.cs deleted file mode 100644 index 36fc0f78efbd2..0000000000000 --- a/docs/core/extensions/snippets/configuration/custom-yaml-provider/custom-yaml-provider/YamlStreamConfigurationSource.cs +++ /dev/null @@ -1,18 +0,0 @@ -using Microsoft.Extensions.Configuration; - -namespace CustomProvider.Example; - - -/// -/// Represents a YAML file as an . -/// -public class YamlStreamConfigurationSource : StreamConfigurationSource -{ - /// - /// Builds the for this source. - /// - /// The . - /// An - public override IConfigurationProvider Build(IConfigurationBuilder builder) => - new YamlStreamConfigurationProvider(this); -} diff --git a/docs/core/extensions/snippets/configuration/custom-yaml-provider/custom-yaml-provider/config.yaml b/docs/core/extensions/snippets/configuration/custom-yaml-provider/custom-yaml-provider/config.yaml deleted file mode 100644 index e616dca2e7bf7..0000000000000 --- a/docs/core/extensions/snippets/configuration/custom-yaml-provider/custom-yaml-provider/config.yaml +++ /dev/null @@ -1,10 +0,0 @@ -widgetOptions: - endpointId: b3da3c4c-9c4e-4411-bc4d-609e2dcc5c67 - displayLabel: Widgets Incorporated, LLC. - widgetRoute: api/widgets - ipAddressRange: - - "46.36.198.123" - - "46.36.198.124" - - "46.36.198.125" - featureFlags: - isTelemetryEnabled: true diff --git a/docs/core/extensions/snippets/configuration/custom-yaml-provider/custom-yaml-provider/custom-yaml-provider.csproj b/docs/core/extensions/snippets/configuration/custom-yaml-provider/custom-yaml-provider/custom-yaml-provider.csproj deleted file mode 100644 index d9b9d90ce0672..0000000000000 --- a/docs/core/extensions/snippets/configuration/custom-yaml-provider/custom-yaml-provider/custom-yaml-provider.csproj +++ /dev/null @@ -1,26 +0,0 @@ - - - - Exe - net6.0 - enable - true - CustomProvider.Example - - - - - - - - - Always - - - - - - - - - diff --git a/docs/core/extensions/snippets/configuration/winforms-xml/App.config b/docs/core/extensions/snippets/configuration/winforms-xml/App.config deleted file mode 100644 index d6944ad759a69..0000000000000 --- a/docs/core/extensions/snippets/configuration/winforms-xml/App.config +++ /dev/null @@ -1,14 +0,0 @@ - - - Secret key value - - true - 00:00:07 - - - - Information - Warning - - - diff --git a/docs/core/extensions/snippets/configuration/winforms-xml/MainForm.Designer.cs b/docs/core/extensions/snippets/configuration/winforms-xml/MainForm.Designer.cs deleted file mode 100644 index ddb98928adaf8..0000000000000 --- a/docs/core/extensions/snippets/configuration/winforms-xml/MainForm.Designer.cs +++ /dev/null @@ -1,119 +0,0 @@ -namespace WinForms.Xml -{ - partial class MainForm - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this._settingLabel = new System.Windows.Forms.Label(); - this._settingsDataGridView = new System.Windows.Forms.DataGridView(); - this._keyColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this._typeColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this._valueColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); - ((System.ComponentModel.ISupportInitialize)(this._settingsDataGridView)).BeginInit(); - this.SuspendLayout(); - // - // _settingLabel - // - this._settingLabel.AutoSize = true; - this._settingLabel.Location = new System.Drawing.Point(25, 25); - this._settingLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); - this._settingLabel.Name = "_settingLabel"; - this._settingLabel.Size = new System.Drawing.Size(527, 23); - this._settingLabel.TabIndex = 0; - this._settingLabel.Text = "Settings from winforms-xml.dll.config XML file:"; - // - // _settingsDataGridView - // - this._settingsDataGridView.AllowUserToAddRows = false; - this._settingsDataGridView.AllowUserToDeleteRows = false; - this._settingsDataGridView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this._settingsDataGridView.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.Single; - this._settingsDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; - this._settingsDataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { - this._keyColumn, - this._typeColumn, - this._valueColumn}); - this._settingsDataGridView.Location = new System.Drawing.Point(25, 69); - this._settingsDataGridView.Name = "_settingsDataGridView"; - this._settingsDataGridView.ReadOnly = true; - this._settingsDataGridView.RowHeadersWidth = 51; - this._settingsDataGridView.RowTemplate.Height = 29; - this._settingsDataGridView.Size = new System.Drawing.Size(1088, 424); - this._settingsDataGridView.TabIndex = 2; - // - // _keyColumn - // - this._keyColumn.HeaderText = "Key"; - this._keyColumn.MinimumWidth = 6; - this._keyColumn.Name = "_keyColumn"; - this._keyColumn.ReadOnly = true; - this._keyColumn.Width = 125; - // - // _typeColumn - // - this._typeColumn.HeaderText = "Type"; - this._typeColumn.MinimumWidth = 6; - this._typeColumn.Name = "_typeColumn"; - this._typeColumn.ReadOnly = true; - this._typeColumn.Width = 125; - // - // _valueColumn - // - this._valueColumn.HeaderText = "Value"; - this._valueColumn.MinimumWidth = 6; - this._valueColumn.Name = "_valueColumn"; - this._valueColumn.ReadOnly = true; - this._valueColumn.Width = 125; - // - // MainForm - // - this.AutoScaleDimensions = new System.Drawing.SizeF(11F, 23F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(1138, 518); - this.Controls.Add(this._settingsDataGridView); - this.Controls.Add(this._settingLabel); - this.Font = new System.Drawing.Font("Consolas", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); - this.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); - this.Name = "MainForm"; - this.Text = "Config Example (XML)"; - ((System.ComponentModel.ISupportInitialize)(this._settingsDataGridView)).EndInit(); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private Label _settingLabel; - private DataGridView _settingsDataGridView; - private DataGridViewTextBoxColumn _keyColumn; - private DataGridViewTextBoxColumn _typeColumn; - private DataGridViewTextBoxColumn _valueColumn; - } -} diff --git a/docs/core/extensions/snippets/configuration/winforms-xml/MainForm.cs b/docs/core/extensions/snippets/configuration/winforms-xml/MainForm.cs deleted file mode 100644 index 55e80965f265b..0000000000000 --- a/docs/core/extensions/snippets/configuration/winforms-xml/MainForm.cs +++ /dev/null @@ -1,49 +0,0 @@ -using Microsoft.Extensions.Configuration; - -namespace WinForms.Xml; - -public sealed partial class MainForm : Form -{ - private readonly IConfiguration _config; - - public MainForm() - { - _config = new ConfigurationBuilder() - .AddXmlFile("winforms-xml.dll.config", optional: true) - .AddXmlFile("winforms-xml.exe.config", optional: true) - .Build(); - - InitializeComponent(); - } - - protected override void OnLoad(EventArgs e) - { - base.OnLoad(e); - - var secretKey = _config["SecretKey"]; - AddItemToGrid("SecretKey", secretKey); - - var transientFaultHandlingOptions = - _config.GetRequiredSection("TransientFaultHandlingOptions"); - var isEnabled = - transientFaultHandlingOptions.GetValue("Enabled"); - var autoRetryDelay = - transientFaultHandlingOptions.GetValue("AutoRetryDelay"); - - AddItemToGrid("TransientFaultHandlingOptions:Enabled", isEnabled); - AddItemToGrid("TransientFaultHandlingOptions:AutoRetryDelay", autoRetryDelay); - - _settingsDataGridView.AutoResizeColumns( - DataGridViewAutoSizeColumnsMode.AllCells); - } - - void AddItemToGrid(string key, T value) - { - var row = new DataGridViewRow(); - row.Cells.Add(new DataGridViewTextBoxCell { Value = key }); - row.Cells.Add(new DataGridViewTextBoxCell { Value = typeof(T) }); - row.Cells.Add(new DataGridViewTextBoxCell { Value = value }); - - _settingsDataGridView.Rows.Add(row); - } -} diff --git a/docs/core/extensions/snippets/configuration/winforms-xml/MainForm.resx b/docs/core/extensions/snippets/configuration/winforms-xml/MainForm.resx deleted file mode 100644 index 658a6b56ac114..0000000000000 --- a/docs/core/extensions/snippets/configuration/winforms-xml/MainForm.resx +++ /dev/null @@ -1,69 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - True - - - True - - - True - - \ No newline at end of file diff --git a/docs/core/extensions/snippets/configuration/winforms-xml/Program.cs b/docs/core/extensions/snippets/configuration/winforms-xml/Program.cs deleted file mode 100644 index b55fef9a6cf65..0000000000000 --- a/docs/core/extensions/snippets/configuration/winforms-xml/Program.cs +++ /dev/null @@ -1,16 +0,0 @@ -using WinForms.Xml; - -internal static class Program -{ - /// - /// The main entry point for the application. - /// - [STAThread] - static void Main() - { - // To customize application configuration such as set high DPI settings or default font, - // see https://aka.ms/applicationconfiguration. - ApplicationConfiguration.Initialize(); - Application.Run(new MainForm()); - } -} diff --git a/docs/core/extensions/snippets/configuration/winforms-xml/winforms-xml.csproj b/docs/core/extensions/snippets/configuration/winforms-xml/winforms-xml.csproj deleted file mode 100644 index 18c7ae3d2c1f3..0000000000000 --- a/docs/core/extensions/snippets/configuration/winforms-xml/winforms-xml.csproj +++ /dev/null @@ -1,17 +0,0 @@ - - - - WinExe - net6.0-windows - enable - true - enable - WinForms.Xml - - - - - - - - \ No newline at end of file diff --git a/docs/core/porting/snippets/upgrade-assistant-wcf-framework/CalculatorSample/CalculatorClient/App.config b/docs/core/porting/snippets/upgrade-assistant-wcf-framework/CalculatorSample/CalculatorClient/App.config deleted file mode 100644 index 25571e467a8ea..0000000000000 --- a/docs/core/porting/snippets/upgrade-assistant-wcf-framework/CalculatorSample/CalculatorClient/App.config +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - diff --git a/docs/core/porting/snippets/upgrade-assistant-wcf-framework/CalculatorSample/CalculatorClient/CalculatorClient.csproj b/docs/core/porting/snippets/upgrade-assistant-wcf-framework/CalculatorSample/CalculatorClient/CalculatorClient.csproj deleted file mode 100644 index 38b8875ae4c4c..0000000000000 --- a/docs/core/porting/snippets/upgrade-assistant-wcf-framework/CalculatorSample/CalculatorClient/CalculatorClient.csproj +++ /dev/null @@ -1,86 +0,0 @@ - - - - Debug - AnyCPU - 8.0.50110 - 2.0 - {F6D8FC2E-62D0-4554-AC3E-1964042590E3} - Exe - - - client - 4 - v4.8 - - - - - 2.0 - false - publish\ - true - Disk - false - Foreground - 7 - Days - false - false - true - 0 - 1.0.0.%2a - false - true - - - - true - full - false - bin\ - DEBUG;TRACE - AllRules.ruleset - false - - - false - true - bin\ - TRACE - AllRules.ruleset - false - - - - C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System\v4.0_4.0.0.0__b77a5c561934e089\System.dll - - - - - - - - - - - - - - False - .NET Framework 3.5 SP1 Client Profile - false - - - False - .NET Framework 3.5 SP1 - true - - - False - Windows Installer 3.1 - true - - - - \ No newline at end of file diff --git a/docs/core/porting/snippets/upgrade-assistant-wcf-framework/CalculatorSample/CalculatorClient/Properties/AssemblyInfo.cs b/docs/core/porting/snippets/upgrade-assistant-wcf-framework/CalculatorSample/CalculatorClient/Properties/AssemblyInfo.cs deleted file mode 100644 index c0ea33c2ee74c..0000000000000 --- a/docs/core/porting/snippets/upgrade-assistant-wcf-framework/CalculatorSample/CalculatorClient/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (c) Microsoft Corporation. All Rights Reserved. - -#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: SecurityPermissionAttribute(SecurityAction.RequestMinimum)] -[assembly: AssemblyTitle("client")] -[assembly: AssemblyDescription("SelfHost")] -[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/docs/core/porting/snippets/upgrade-assistant-wcf-framework/CalculatorSample/CalculatorClient/client.cs b/docs/core/porting/snippets/upgrade-assistant-wcf-framework/CalculatorSample/CalculatorClient/client.cs deleted file mode 100644 index edb73ed671e0c..0000000000000 --- a/docs/core/porting/snippets/upgrade-assistant-wcf-framework/CalculatorSample/CalculatorClient/client.cs +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (c) Microsoft Corporation. All Rights Reserved. - -using System; -using System.ServiceModel; - -namespace CalculatorSample -{ - class CalculatorClient - { - static void Main() - { - // Create a client - var channelFactory = new ChannelFactory(new NetTcpBinding(), new EndpointAddress("net.tcp://localhost:8090/CalculatorSample/service")); - - // Call the Add/Subtract/Multiply/Divide service operation. - var proxy = channelFactory.CreateChannel(); - Console.WriteLine("x + y = {2} when x = {0} and y = {1}", 1, -1, proxy.Add(1, -1)); - Console.WriteLine("x - y = {2} when x = {0} and y = {1}", 1, -1, proxy.Subtract(1, -1)); - Console.WriteLine("x * y = {2} when x = {0} and y = {1}", 1, -1, proxy.Multiply(1, -1)); - Console.WriteLine("x / y = {2} when x = {0} and y = {1}", 1, -1, proxy.Divide(1, -1)); - Console.ReadLine(); - - //Closing the client gracefully closes the connection and cleans up resources - channelFactory.Close(); - - Console.WriteLine(); - Console.WriteLine("Press to terminate client."); - Console.ReadLine(); - } - } - - // Define a service contract. - [ServiceContract] - public interface ICalculator - { - [OperationContract] - double Add(double n1, double n2); - [OperationContract] - double Subtract(double n1, double n2); - [OperationContract] - double Multiply(double n1, double n2); - [OperationContract] - double Divide(double n1, double n2); - } -} - diff --git a/docs/core/porting/snippets/upgrade-assistant-wcf-framework/CalculatorSample/CalculatorService/App.config b/docs/core/porting/snippets/upgrade-assistant-wcf-framework/CalculatorSample/CalculatorService/App.config deleted file mode 100644 index d37d1ed69e951..0000000000000 --- a/docs/core/porting/snippets/upgrade-assistant-wcf-framework/CalculatorSample/CalculatorService/App.config +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/docs/core/porting/snippets/upgrade-assistant-wcf-framework/CalculatorSample/CalculatorService/CalculatorService.csproj b/docs/core/porting/snippets/upgrade-assistant-wcf-framework/CalculatorSample/CalculatorService/CalculatorService.csproj deleted file mode 100644 index 7fd470b22db7c..0000000000000 --- a/docs/core/porting/snippets/upgrade-assistant-wcf-framework/CalculatorSample/CalculatorService/CalculatorService.csproj +++ /dev/null @@ -1,89 +0,0 @@ - - - - Debug - AnyCPU - 8.0.50110 - 2.0 - {66C5F965-7C66-479A-9960-A3CA6080A71B} - Exe - Properties - service - service - v4.8 - - - - - 2.0 - publish\ - true - Disk - false - Foreground - 7 - Days - false - false - true - 0 - 1.0.0.%2a - false - false - true - - - - true - full - false - bin\ - DEBUG;TRACE - prompt - 4 - AllRules.ruleset - false - - - pdbonly - true - bin\ - TRACE - prompt - 4 - AllRules.ruleset - false - - - - - - - - - - - - - - - - - - False - .NET Framework 3.5 SP1 Client Profile - false - - - False - .NET Framework 3.5 SP1 - true - - - False - Windows Installer 3.1 - true - - - - diff --git a/docs/core/porting/snippets/upgrade-assistant-wcf-framework/CalculatorSample/CalculatorService/Properties/AssemblyInfo.cs b/docs/core/porting/snippets/upgrade-assistant-wcf-framework/CalculatorSample/CalculatorService/Properties/AssemblyInfo.cs deleted file mode 100644 index 166c871319050..0000000000000 --- a/docs/core/porting/snippets/upgrade-assistant-wcf-framework/CalculatorSample/CalculatorService/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (c) Microsoft Corporation. All Rights Reserved. - -#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: SecurityPermissionAttribute(SecurityAction.RequestMinimum)] -[assembly: AssemblyTitle("service")] -[assembly: AssemblyDescription("SelfHost")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Microsoft")] -[assembly: AssemblyProduct("service")] -[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/docs/core/porting/snippets/upgrade-assistant-wcf-framework/CalculatorSample/CalculatorService/service.cs b/docs/core/porting/snippets/upgrade-assistant-wcf-framework/CalculatorSample/CalculatorService/service.cs deleted file mode 100644 index d283dbc6286c3..0000000000000 --- a/docs/core/porting/snippets/upgrade-assistant-wcf-framework/CalculatorSample/CalculatorService/service.cs +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright (c) Microsoft Corporation. All Rights Reserved. - -using System; -using System.ServiceModel; - -namespace CalculatorSample -{ - // Define a service contract. - [ServiceContract] - public interface ICalculator - { - [OperationContract] - double Add(double n1, double n2); - [OperationContract] - double Subtract(double n1, double n2); - [OperationContract] - double Multiply(double n1, double n2); - [OperationContract] - double Divide(double n1, double n2); - } - - // Service class which implements the service contract. - // Added code to write output to the console window - public class CalculatorService : ICalculator - { - public double Add(double n1, double n2) - { - double result = n1 + n2; - Console.WriteLine("Received Add({0},{1}). Return: {2}", n1, n2, result); - return result; - } - - public double Subtract(double n1, double n2) - { - double result = n1 - n2; - Console.WriteLine("Received Subtract({0},{1}). Return: {2}", n1, n2, result); - return result; - } - - public double Multiply(double n1, double n2) - { - double result = n1 * n2; - Console.WriteLine("Received Multiply({0},{1}). Return: {2}", n1, n2, result); - return result; - } - - public double Divide(double n1, double n2) - { - double result = n1 / n2; - Console.WriteLine("Received Divide({0},{1}). Return: {2}", n1, n2, result); - return result; - } - - - // Host the service within console application. - public static void Main() - { - // Create a ServiceHost for the CalculatorService type. - using (ServiceHost serviceHost = new ServiceHost(typeof(CalculatorService))) - { - // Open the ServiceHost to create listeners and start listening for messages. - serviceHost.Open(); - - Console.WriteLine("The service is ready."); - Console.WriteLine("Press to terminate service."); - Console.WriteLine(); - Console.ReadLine(); - } - } - } -} - diff --git a/docs/core/porting/snippets/upgrade-assistant-wpf-framework/csharp/StarVoteControl/Properties/AssemblyInfo.cs b/docs/core/porting/snippets/upgrade-assistant-wpf-framework/csharp/StarVoteControl/Properties/AssemblyInfo.cs deleted file mode 100644 index 317f9cc33a3c6..0000000000000 --- a/docs/core/porting/snippets/upgrade-assistant-wpf-framework/csharp/StarVoteControl/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,55 +0,0 @@ -using System.Reflection; -using System.Resources; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Windows; - -// 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("StarVoteControl")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("StarVoteControl")] -[assembly: AssemblyCopyright("Copyright © 2022")] -[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)] - -//In order to begin building localizable applications, set -//CultureYouAreCodingWith in your .csproj file -//inside a . For example, if you are using US english -//in your source files, set the to en-US. Then uncomment -//the NeutralResourceLanguage attribute below. Update the "en-US" in -//the line below to match the UICulture setting in the project file. - -//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] - - -[assembly:ThemeInfo( - ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located - //(used if a resource is not found in the page, - // or application resource dictionaries) - ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located - //(used if a resource is not found in the page, - // app, or any theme specific resource dictionaries) -)] - - -// 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")] diff --git a/docs/core/porting/snippets/upgrade-assistant-wpf-framework/csharp/StarVoteControl/Properties/Resources.Designer.cs b/docs/core/porting/snippets/upgrade-assistant-wpf-framework/csharp/StarVoteControl/Properties/Resources.Designer.cs deleted file mode 100644 index 9ca72627bce83..0000000000000 --- a/docs/core/porting/snippets/upgrade-assistant-wpf-framework/csharp/StarVoteControl/Properties/Resources.Designer.cs +++ /dev/null @@ -1,62 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace StarVoteControl.Properties { - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Resources { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Resources() { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { - get { - if ((resourceMan == null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("StarVoteControl.Properties.Resources", typeof(Resources).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - } -} diff --git a/docs/core/porting/snippets/upgrade-assistant-wpf-framework/csharp/StarVoteControl/Properties/Resources.resx b/docs/core/porting/snippets/upgrade-assistant-wpf-framework/csharp/StarVoteControl/Properties/Resources.resx deleted file mode 100644 index af7dbebbacef5..0000000000000 --- a/docs/core/porting/snippets/upgrade-assistant-wpf-framework/csharp/StarVoteControl/Properties/Resources.resx +++ /dev/null @@ -1,117 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/docs/core/porting/snippets/upgrade-assistant-wpf-framework/csharp/StarVoteControl/Properties/Settings.Designer.cs b/docs/core/porting/snippets/upgrade-assistant-wpf-framework/csharp/StarVoteControl/Properties/Settings.Designer.cs deleted file mode 100644 index ca2b743f98188..0000000000000 --- a/docs/core/porting/snippets/upgrade-assistant-wpf-framework/csharp/StarVoteControl/Properties/Settings.Designer.cs +++ /dev/null @@ -1,30 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace StarVoteControl.Properties -{ - - - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] - internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase - { - - private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); - - public static Settings Default - { - get - { - return defaultInstance; - } - } - } -} diff --git a/docs/core/porting/snippets/upgrade-assistant-wpf-framework/csharp/StarVoteControl/Properties/Settings.settings b/docs/core/porting/snippets/upgrade-assistant-wpf-framework/csharp/StarVoteControl/Properties/Settings.settings deleted file mode 100644 index 033d7a5e9e226..0000000000000 --- a/docs/core/porting/snippets/upgrade-assistant-wpf-framework/csharp/StarVoteControl/Properties/Settings.settings +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/docs/core/porting/snippets/upgrade-assistant-wpf-framework/csharp/StarVoteControl/StarVoteControl.csproj b/docs/core/porting/snippets/upgrade-assistant-wpf-framework/csharp/StarVoteControl/StarVoteControl.csproj deleted file mode 100644 index 69b084259d1d1..0000000000000 --- a/docs/core/porting/snippets/upgrade-assistant-wpf-framework/csharp/StarVoteControl/StarVoteControl.csproj +++ /dev/null @@ -1,17 +0,0 @@ - - - net6.0-windows - Library - false - true - true - - - - - - all - - - - \ No newline at end of file diff --git a/docs/core/porting/snippets/upgrade-assistant-wpf-framework/csharp/StarVoteControl/Vote.xaml b/docs/core/porting/snippets/upgrade-assistant-wpf-framework/csharp/StarVoteControl/Vote.xaml deleted file mode 100644 index d220fb133171a..0000000000000 --- a/docs/core/porting/snippets/upgrade-assistant-wpf-framework/csharp/StarVoteControl/Vote.xaml +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - - - - - - diff --git a/docs/core/porting/snippets/upgrade-assistant-wpf-framework/csharp/StarVoteControl/Vote.xaml.cs b/docs/core/porting/snippets/upgrade-assistant-wpf-framework/csharp/StarVoteControl/Vote.xaml.cs deleted file mode 100644 index 14490038dd647..0000000000000 --- a/docs/core/porting/snippets/upgrade-assistant-wpf-framework/csharp/StarVoteControl/Vote.xaml.cs +++ /dev/null @@ -1,89 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; - -namespace StarVoteControl -{ - /// - /// Interaction logic for UserControl1.xaml - /// - public partial class Vote : UserControl - { - public int VoteCount - { - get { return (int)GetValue(VoteCountProperty); } - set { SetValue(VoteCountProperty, value); } - } - - // Using a DependencyProperty as the backing store for VoteCount. This enables animation, styling, binding, etc... - public static readonly DependencyProperty VoteCountProperty = - DependencyProperty.Register("VoteCount", typeof(int), typeof(Vote), new PropertyMetadata(0, (s, e) => - { - if (s is Vote voteInstance) - { - if ((int)e.NewValue < 0) - s.SetValue(VoteCountProperty, 0); - else if ((int)e.NewValue > 5) - s.SetValue(VoteCountProperty, 5); - else - { - Style unfilled = (Style)voteInstance.Resources["LabelStarUnfilled"]; - Style filled = (Style)voteInstance.Resources["LabelStarFilled"]; - - voteInstance.lbl1.Style = unfilled; - voteInstance.lbl2.Style = unfilled; - voteInstance.lbl3.Style = unfilled; - voteInstance.lbl4.Style = unfilled; - voteInstance.lbl5.Style = unfilled; - - int value = (int)e.NewValue; - - if (value > 0) voteInstance.lbl1.Style = filled; - if (value > 1) voteInstance.lbl2.Style = filled; - if (value > 2) voteInstance.lbl3.Style = filled; - if (value > 3) voteInstance.lbl4.Style = filled; - if (value > 4) voteInstance.lbl5.Style = filled; - } - } - })); - - - - public static int GetVoteValue(DependencyObject obj) - { - return (int)obj.GetValue(VoteValueProperty); - } - - public static void SetVoteValue(DependencyObject obj, int value) - { - obj.SetValue(VoteValueProperty, value); - } - - // Using a DependencyProperty as the backing store for VoteValue. This enables animation, styling, binding, etc... - public static readonly DependencyProperty VoteValueProperty = - DependencyProperty.RegisterAttached("VoteValue", typeof(int), typeof(Vote), new PropertyMetadata(0)); - - - - public Vote() - { - InitializeComponent(); - } - - private void vote_MouseUp(object sender, MouseButtonEventArgs e) - { - VoteCount = GetVoteValue((Label)sender); - } - } -} diff --git a/docs/fundamentals/networking/snippets/shared/GlobalUsings.cs b/docs/fundamentals/networking/snippets/shared/GlobalUsings.cs deleted file mode 100644 index 4015a9c10c0b0..0000000000000 --- a/docs/fundamentals/networking/snippets/shared/GlobalUsings.cs +++ /dev/null @@ -1,3 +0,0 @@ -global using System.Net; -global using System.Net.Sockets; -global using System.Net.NetworkInformation; diff --git a/docs/fundamentals/networking/snippets/shared/NetworkDiscovery.cs b/docs/fundamentals/networking/snippets/shared/NetworkDiscovery.cs deleted file mode 100644 index 556da991ebff7..0000000000000 --- a/docs/fundamentals/networking/snippets/shared/NetworkDiscovery.cs +++ /dev/null @@ -1,36 +0,0 @@ -public static class NetworkDiscovery -{ - public static ValueTask GetTcpEndPointAsync(int port = 13) => - GetLocalEndPointAsync(port); - - public static ValueTask GetSocketEndPointAsync(int port = 9_000) => - GetLocalEndPointAsync(port); - - static async ValueTask GetLocalEndPointAsync(int startingPort) - { - var port = startingPort; - while (IsActivelyBeingUsed(port) && port > IPEndPoint.MaxPort) ++ port; - - var localIP = await GetLocalhostIPAddressAsync(); - - Console.WriteLine($"Found: {localIP} available on port {port}."); - - return new IPEndPoint(localIP, port); - } - - public static async ValueTask GetLocalhostIPAddressAsync() - { - var localhost = await Dns.GetHostEntryAsync(Dns.GetHostName()); - var isInterNetwork = static (IPAddress ip) => - ip.AddressFamily is AddressFamily.InterNetwork; - var localIP = localhost.AddressList.FirstOrDefault(isInterNetwork) - ?? throw new Exception("Unable to get a local inter network IP."); - - return localIP; - } - - static bool IsActivelyBeingUsed(int port) => - IPGlobalProperties.GetIPGlobalProperties() - .GetActiveTcpListeners() - .Any(ip => ip.Port == port); -} diff --git a/docs/fundamentals/networking/snippets/shared/shared.csproj b/docs/fundamentals/networking/snippets/shared/shared.csproj deleted file mode 100644 index 27ac3865b58fe..0000000000000 --- a/docs/fundamentals/networking/snippets/shared/shared.csproj +++ /dev/null @@ -1,9 +0,0 @@ - - - - net6.0 - enable - enable - - - diff --git a/docs/standard/assembly/snippets/type-forwarders/after/Common/Common.csproj b/docs/standard/assembly/snippets/type-forwarders/after/Common/Common.csproj deleted file mode 100644 index dc6ac6cacbc38..0000000000000 --- a/docs/standard/assembly/snippets/type-forwarders/after/Common/Common.csproj +++ /dev/null @@ -1,9 +0,0 @@ - - - - net6.0 - enable - true - - - diff --git a/docs/standard/assembly/snippets/type-forwarders/after/Common/Example.cs b/docs/standard/assembly/snippets/type-forwarders/after/Common/Example.cs deleted file mode 100644 index 2d617bd3e5904..0000000000000 --- a/docs/standard/assembly/snippets/type-forwarders/after/Common/Example.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; - -namespace Common.Objects; - -public class Example -{ - public string Message { get; init; } = "Hi friends!"; - - public Guid Id { get; init; } = Guid.NewGuid(); - - public DateOnly Date { get; init; } = DateOnly.FromDateTime(DateTime.Today); - - public sealed override string ToString() => - $"[{Id} - {Date}]: {Message}"; -} diff --git a/docs/standard/assembly/snippets/type-forwarders/after/Consumer/Consumer.csproj b/docs/standard/assembly/snippets/type-forwarders/after/Consumer/Consumer.csproj deleted file mode 100644 index 43a2733c0cfca..0000000000000 --- a/docs/standard/assembly/snippets/type-forwarders/after/Consumer/Consumer.csproj +++ /dev/null @@ -1,14 +0,0 @@ - - - - exe - net6.0 - enable - true - - - - - - - diff --git a/docs/standard/assembly/snippets/type-forwarders/after/Consumer/Program.cs b/docs/standard/assembly/snippets/type-forwarders/after/Consumer/Program.cs deleted file mode 100644 index 3d8bd29866393..0000000000000 --- a/docs/standard/assembly/snippets/type-forwarders/after/Consumer/Program.cs +++ /dev/null @@ -1,6 +0,0 @@ -using System; -using Common.Objects; - -Example example = new(); - -Console.WriteLine(example); diff --git a/samples/snippets/core/tutorials/cli-create-console-app/FibonacciBetterMsBuild/csharp/Fibonacci.csproj b/samples/snippets/core/tutorials/cli-create-console-app/FibonacciBetterMsBuild/csharp/Fibonacci.csproj deleted file mode 100644 index d5b0362e0a429..0000000000000 --- a/samples/snippets/core/tutorials/cli-create-console-app/FibonacciBetterMsBuild/csharp/Fibonacci.csproj +++ /dev/null @@ -1,8 +0,0 @@ - - - - Exe - netcoreapp3.1 - - - \ No newline at end of file diff --git a/samples/snippets/core/tutorials/cli-create-console-app/FibonacciBetterMsBuild/csharp/FibonacciGenerator.cs b/samples/snippets/core/tutorials/cli-create-console-app/FibonacciBetterMsBuild/csharp/FibonacciGenerator.cs deleted file mode 100644 index e9c4fb06ea491..0000000000000 --- a/samples/snippets/core/tutorials/cli-create-console-app/FibonacciBetterMsBuild/csharp/FibonacciGenerator.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace Hello -{ - public class FibonacciGenerator - { - private Dictionary _cache = new Dictionary(); - - private int Fib(int n) => n < 2 ? n : FibValue(n - 1) + FibValue(n - 2); - - private int FibValue(int n) - { - if (!_cache.ContainsKey(n)) - { - _cache.Add(n, Fib(n)); - } - - return _cache[n]; - } - - public IEnumerable Generate(int n) - { - for (int i = 0; i < n; i++) - { - yield return FibValue(i); - } - } - } -} diff --git a/samples/snippets/core/tutorials/cli-create-console-app/FibonacciBetterMsBuild/csharp/Program.cs b/samples/snippets/core/tutorials/cli-create-console-app/FibonacciBetterMsBuild/csharp/Program.cs deleted file mode 100644 index caa2f522ffaf2..0000000000000 --- a/samples/snippets/core/tutorials/cli-create-console-app/FibonacciBetterMsBuild/csharp/Program.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; - -namespace Hello -{ - class Program - { - static void Main(string[] args) - { - var generator = new FibonacciGenerator(); - foreach (var digit in generator.Generate(15)) - { - Console.WriteLine(digit); - } - } - } -} diff --git a/samples/snippets/core/tutorials/cli-create-console-app/FibonacciBetterMsBuild/csharp/README.md b/samples/snippets/core/tutorials/cli-create-console-app/FibonacciBetterMsBuild/csharp/README.md deleted file mode 100644 index b927dfe2f0c20..0000000000000 --- a/samples/snippets/core/tutorials/cli-create-console-app/FibonacciBetterMsBuild/csharp/README.md +++ /dev/null @@ -1,23 +0,0 @@ -Better Fibonacci Sample -================ - -This sample is part of the [step-by-step tutorial](https://learn.microsoft.com/dotnet/core/tutorials/using-with-xplat-cli) -for creating .NET Core Console Applications. Please see that topic for detailed steps on the code -for this sample. - -Key Features ------------- - -This sample demonstrates a multiple source file project, adding recursion and caching previous -results to the initial Fibonacci sample. - -Build and Run -------------- - -To build and run the sample, type the following command: - -To build and run the sample, type the following command: - -`dotnet run` - -`dotnet run` builds the sample and runs the output assembly. It implicitly calls `dotnet restore` on .NET Core 2.0 and later versions. If you're using a .NET Core 1.x SDK, you first have to call `dotnet restore` yourself. diff --git a/samples/snippets/core/tutorials/cli-create-console-app/HelloMsBuild/csharp/Hello.csproj b/samples/snippets/core/tutorials/cli-create-console-app/HelloMsBuild/csharp/Hello.csproj deleted file mode 100644 index 9acff6d2afa81..0000000000000 --- a/samples/snippets/core/tutorials/cli-create-console-app/HelloMsBuild/csharp/Hello.csproj +++ /dev/null @@ -1,8 +0,0 @@ - - - - Exe - netcoreapp3.1 - - - diff --git a/samples/snippets/core/tutorials/cli-create-console-app/HelloMsBuild/csharp/Program.cs b/samples/snippets/core/tutorials/cli-create-console-app/HelloMsBuild/csharp/Program.cs deleted file mode 100644 index 873c2b2598533..0000000000000 --- a/samples/snippets/core/tutorials/cli-create-console-app/HelloMsBuild/csharp/Program.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; - -namespace Hello -{ - class Program - { - static void Main(string[] args) - { - Console.WriteLine("Hello World!"); - } - } -} \ No newline at end of file diff --git a/samples/snippets/core/tutorials/cli-create-console-app/HelloMsBuild/csharp/README.md b/samples/snippets/core/tutorials/cli-create-console-app/HelloMsBuild/csharp/README.md deleted file mode 100644 index 19d65f67edbb1..0000000000000 --- a/samples/snippets/core/tutorials/cli-create-console-app/HelloMsBuild/csharp/README.md +++ /dev/null @@ -1,19 +0,0 @@ -# Hello Sample - -This sample is part of the [step-by-step tutorial](https://learn.microsoft.com/dotnet/core/tutorials/using-with-xplat-cli) -for creating .NET Core Console Applications. Please see that topic for detailed steps on the code -for this sample. - -## Key Features - -This is the basic Hello World sample. It demonstrates the basics of the environment. - -## Build and Run - -To build and run the sample, type the following command: - -`dotnet run` - -`dotnet run` builds the sample and runs the output assembly. It implicitly calls `dotnet restore` on .NET Core 2.0 and later versions. If you're using a .NET Core 1.x SDK, you first have to call `dotnet restore` yourself. - -**Note:** Starting with .NET Core 2.0 SDK, you don't have to run [`dotnet restore`](https://learn.microsoft.com/dotnet/core/tools/dotnet-restore) because it's run implicitly by all commands that require a restore to occur, such as `dotnet new`, `dotnet build` and `dotnet run`. It's still a valid command in certain scenarios where doing an explicit restore makes sense, such as [continuous integration builds in Azure DevOps Services](https://learn.microsoft.com/azure/devops/build-release/apps/aspnet/build-aspnet-core) or in build systems that need to explicitly control the time at which the restore occurs. diff --git a/samples/snippets/core/tutorials/cli-create-console-app/fibonacci-msbuild/csharp/Hello.csproj b/samples/snippets/core/tutorials/cli-create-console-app/fibonacci-msbuild/csharp/Hello.csproj deleted file mode 100644 index d5b0362e0a429..0000000000000 --- a/samples/snippets/core/tutorials/cli-create-console-app/fibonacci-msbuild/csharp/Hello.csproj +++ /dev/null @@ -1,8 +0,0 @@ - - - - Exe - netcoreapp3.1 - - - \ No newline at end of file diff --git a/samples/snippets/core/tutorials/cli-create-console-app/fibonacci-msbuild/csharp/Program.cs b/samples/snippets/core/tutorials/cli-create-console-app/fibonacci-msbuild/csharp/Program.cs deleted file mode 100644 index c671866dba322..0000000000000 --- a/samples/snippets/core/tutorials/cli-create-console-app/fibonacci-msbuild/csharp/Program.cs +++ /dev/null @@ -1,42 +0,0 @@ -using System; - -namespace Hello -{ - class Program - { - static void Main(string[] args) - { - if (args.Length > 0) - { - Console.WriteLine($"Hello {args[0]}!"); - } - else - { - Console.WriteLine("Hello!"); - } - - Console.WriteLine("Fibonacci Numbers 1-15:"); - - for (int i = 0; i < 15; i++) - { - Console.WriteLine($"{i + 1}: {FibonacciNumber(i)}"); - } - } - - static int FibonacciNumber(int n) - { - int a = 0; - int b = 1; - int tmp; - - for (int i = 0; i < n; i++) - { - tmp = a; - a = b; - b += tmp; - } - - return a; - } - } -} \ No newline at end of file diff --git a/samples/snippets/core/tutorials/cli-create-console-app/fibonacci-msbuild/csharp/README.md b/samples/snippets/core/tutorials/cli-create-console-app/fibonacci-msbuild/csharp/README.md deleted file mode 100644 index 553037997c65c..0000000000000 --- a/samples/snippets/core/tutorials/cli-create-console-app/fibonacci-msbuild/csharp/README.md +++ /dev/null @@ -1,20 +0,0 @@ -Hello Sample -================ - -This sample is part of the [step-by-step tutorial](https://learn.microsoft.com/dotnet/core/tutorials/using-with-xplat-cli) -for creating .NET Core Console Applications. Please see that topic for detailed steps on the code -for this sample. - -Key Features ------------- - -This is the basic Hello World sample. It demonstrates the basics of the environment. - -Build and Run -------------- - -To build and run the sample, type the following command: - -`dotnet run` - -`dotnet run` builds the sample and runs the output assembly. It implicitly calls `dotnet restore` on .NET Core 2.0 and later versions. If you're using a .NET Core 1.x SDK, you first have to call `dotnet restore` yourself. diff --git a/samples/snippets/csharp/VS_Snippets_ADO.NET/DataWorks SqlBulkCopy.ColumnMapping/CS/source.cs b/samples/snippets/csharp/VS_Snippets_ADO.NET/DataWorks SqlBulkCopy.ColumnMapping/CS/source.cs deleted file mode 100644 index 5202103f3eb1b..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_ADO.NET/DataWorks SqlBulkCopy.ColumnMapping/CS/source.cs +++ /dev/null @@ -1,92 +0,0 @@ -using System; -using System.Data; -// -using System.Data.SqlClient; - -class Program -{ - static void Main() - { - string connectionString = GetConnectionString(); - // Open a sourceConnection to the AdventureWorks database. - using (SqlConnection sourceConnection = - new SqlConnection(connectionString)) - { - sourceConnection.Open(); - - // Perform an initial count on the destination table. - SqlCommand commandRowCount = new SqlCommand( - "SELECT COUNT(*) FROM " + - "dbo.BulkCopyDemoDifferentColumns;", - sourceConnection); - long countStart = System.Convert.ToInt32( - commandRowCount.ExecuteScalar()); - Console.WriteLine("Starting row count = {0}", countStart); - - // Get data from the source table as a SqlDataReader. - SqlCommand commandSourceData = new SqlCommand( - "SELECT ProductID, Name, " + - "ProductNumber " + - "FROM Production.Product;", sourceConnection); - SqlDataReader reader = - commandSourceData.ExecuteReader(); - - // Set up the bulk copy object. - using (SqlBulkCopy bulkCopy = - new SqlBulkCopy(connectionString)) - { - bulkCopy.DestinationTableName = - "dbo.BulkCopyDemoDifferentColumns"; - - // Set up the column mappings by name. - SqlBulkCopyColumnMapping mapID = - new SqlBulkCopyColumnMapping("ProductID", "ProdID"); - bulkCopy.ColumnMappings.Add(mapID); - - SqlBulkCopyColumnMapping mapName = - new SqlBulkCopyColumnMapping("Name", "ProdName"); - bulkCopy.ColumnMappings.Add(mapName); - - SqlBulkCopyColumnMapping mapMumber = - new SqlBulkCopyColumnMapping("ProductNumber", "ProdNum"); - bulkCopy.ColumnMappings.Add(mapMumber); - - // Write from the source to the destination. - try - { - bulkCopy.WriteToServer(reader); - } - catch (Exception ex) - { - Console.WriteLine(ex.Message); - } - finally - { - // Close the SqlDataReader. The SqlBulkCopy - // object is automatically closed at the end - // of the using block. - reader.Close(); - } - } - - // Perform a final count on the destination - // table to see how many rows were added. - long countEnd = System.Convert.ToInt32( - commandRowCount.ExecuteScalar()); - Console.WriteLine("Ending row count = {0}", countEnd); - Console.WriteLine("{0} rows were added.", countEnd - countStart); - Console.WriteLine("Press Enter to finish."); - Console.ReadLine(); - } - } - - private static string GetConnectionString() - // To avoid storing the sourceConnection string in your code, - // you can retrieve it from a configuration file. - { - return "Data Source=(local); " + - " Integrated Security=true;" + - "Initial Catalog=AdventureWorks;"; - } -} -// diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_duplexservices/cs/generatedclient.cs b/samples/snippets/csharp/VS_Snippets_CFX/c_duplexservices/cs/generatedclient.cs deleted file mode 100644 index e06e72cbc1cc9..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CFX/c_duplexservices/cs/generatedclient.cs +++ /dev/null @@ -1,108 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:2.0.50727.42 -// -// 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("System.ServiceModel", "3.0.0.0")] - [System.ServiceModel.ServiceContractAttribute(Namespace="http://Microsoft.ServiceModel.Samples", ConfigurationName="Microsoft.ServiceModel.Samples.ICalculatorDuplex", CallbackContract=typeof(Microsoft.ServiceModel.Samples.ICalculatorDuplexCallback), SessionMode=System.ServiceModel.SessionMode.Required)] - public interface ICalculatorDuplex - { - - [System.ServiceModel.OperationContractAttribute(IsOneWay=true, Action="http://Microsoft.ServiceModel.Samples/ICalculatorDuplex/Clear")] - void Clear(); - - [System.ServiceModel.OperationContractAttribute(IsOneWay=true, Action="http://Microsoft.ServiceModel.Samples/ICalculatorDuplex/AddTo")] - void AddTo(double n); - - [System.ServiceModel.OperationContractAttribute(IsOneWay=true, Action="http://Microsoft.ServiceModel.Samples/ICalculatorDuplex/SubtractFrom")] - void SubtractFrom(double n); - - [System.ServiceModel.OperationContractAttribute(IsOneWay=true, Action="http://Microsoft.ServiceModel.Samples/ICalculatorDuplex/MultiplyBy")] - void MultiplyBy(double n); - - [System.ServiceModel.OperationContractAttribute(IsOneWay=true, Action="http://Microsoft.ServiceModel.Samples/ICalculatorDuplex/DivideBy")] - void DivideBy(double n); - } - - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")] - public interface ICalculatorDuplexCallback - { - - [System.ServiceModel.OperationContractAttribute(IsOneWay=true, Action="http://Microsoft.ServiceModel.Samples/ICalculatorDuplex/Equals")] - void Equals(double result); - - [System.ServiceModel.OperationContractAttribute(IsOneWay=true, Action="http://Microsoft.ServiceModel.Samples/ICalculatorDuplex/Equation")] - void Equation(string eqn); - } - - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")] - public interface ICalculatorDuplexChannel : Microsoft.ServiceModel.Samples.ICalculatorDuplex, System.ServiceModel.IClientChannel - { - } - - [System.Diagnostics.DebuggerStepThroughAttribute()] - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")] - public partial class CalculatorDuplexClient : System.ServiceModel.DuplexClientBase, Microsoft.ServiceModel.Samples.ICalculatorDuplex - { - - public CalculatorDuplexClient(System.ServiceModel.InstanceContext callbackInstance) : - base(callbackInstance) - { - } - - public CalculatorDuplexClient(System.ServiceModel.InstanceContext callbackInstance, string endpointConfigurationName) : - base(callbackInstance, endpointConfigurationName) - { - } - - public CalculatorDuplexClient(System.ServiceModel.InstanceContext callbackInstance, string endpointConfigurationName, string remoteAddress) : - base(callbackInstance, endpointConfigurationName, remoteAddress) - { - } - - public CalculatorDuplexClient(System.ServiceModel.InstanceContext callbackInstance, string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) : - base(callbackInstance, endpointConfigurationName, remoteAddress) - { - } - - public CalculatorDuplexClient(System.ServiceModel.InstanceContext callbackInstance, System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) : - base(callbackInstance, binding, remoteAddress) - { - } - - public void Clear() - { - base.Channel.Clear(); - } - - public void AddTo(double n) - { - base.Channel.AddTo(n); - } - - public void SubtractFrom(double n) - { - base.Channel.SubtractFrom(n); - } - - public void MultiplyBy(double n) - { - base.Channel.MultiplyBy(n); - } - - public void DivideBy(double n) - { - base.Channel.DivideBy(n); - } - } -} diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_how_to_cf_async/cs/generatedclient.cs b/samples/snippets/csharp/VS_Snippets_CFX/c_how_to_cf_async/cs/generatedclient.cs deleted file mode 100644 index 0cd0757f30baf..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CFX/c_how_to_cf_async/cs/generatedclient.cs +++ /dev/null @@ -1,150 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:2.0.50727.42 -// -// 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("System.ServiceModel", "3.0.0.0")] - [System.ServiceModel.ServiceContractAttribute(Namespace="http://Microsoft.ServiceModel.Samples", ConfigurationName="Microsoft.ServiceModel.Samples.ICalculator")] - // - public interface ICalculator - { - - [System.ServiceModel.OperationContractAttribute(Action="http://Microsoft.ServiceModel.Samples/ICalculator/Add", ReplyAction="http://Microsoft.ServiceModel.Samples/ICalculator/AddResponse")] - double Add(double n1, double n2); - - [System.ServiceModel.OperationContractAttribute(AsyncPattern=true, Action="http://Microsoft.ServiceModel.Samples/ICalculator/Add", ReplyAction="http://Microsoft.ServiceModel.Samples/ICalculator/AddResponse")] - System.IAsyncResult BeginAdd(double n1, double n2, System.AsyncCallback callback, object asyncState); - - double EndAdd(System.IAsyncResult result); - // - - [System.ServiceModel.OperationContractAttribute(Action="http://Microsoft.ServiceModel.Samples/ICalculator/Subtract", ReplyAction="http://Microsoft.ServiceModel.Samples/ICalculator/SubtractResponse")] - double Subtract(double n1, double n2); - - [System.ServiceModel.OperationContractAttribute(AsyncPattern=true, Action="http://Microsoft.ServiceModel.Samples/ICalculator/Subtract", ReplyAction="http://Microsoft.ServiceModel.Samples/ICalculator/SubtractResponse")] - System.IAsyncResult BeginSubtract(double n1, double n2, System.AsyncCallback callback, object asyncState); - - double EndSubtract(System.IAsyncResult result); - - [System.ServiceModel.OperationContractAttribute(Action="http://Microsoft.ServiceModel.Samples/ICalculator/Multiply", ReplyAction="http://Microsoft.ServiceModel.Samples/ICalculator/MultiplyResponse")] - double Multiply(double n1, double n2); - - [System.ServiceModel.OperationContractAttribute(AsyncPattern=true, Action="http://Microsoft.ServiceModel.Samples/ICalculator/Multiply", ReplyAction="http://Microsoft.ServiceModel.Samples/ICalculator/MultiplyResponse")] - System.IAsyncResult BeginMultiply(double n1, double n2, System.AsyncCallback callback, object asyncState); - - double EndMultiply(System.IAsyncResult result); - - [System.ServiceModel.OperationContractAttribute(Action="http://Microsoft.ServiceModel.Samples/ICalculator/Divide", ReplyAction="http://Microsoft.ServiceModel.Samples/ICalculator/DivideResponse")] - double Divide(double n1, double n2); - - [System.ServiceModel.OperationContractAttribute(AsyncPattern=true, Action="http://Microsoft.ServiceModel.Samples/ICalculator/Divide", ReplyAction="http://Microsoft.ServiceModel.Samples/ICalculator/DivideResponse")] - System.IAsyncResult BeginDivide(double n1, double n2, System.AsyncCallback callback, object asyncState); - - double EndDivide(System.IAsyncResult result); - } - - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")] - public interface ICalculatorChannel : Microsoft.ServiceModel.Samples.ICalculator, System.ServiceModel.IClientChannel - { - } - - [System.Diagnostics.DebuggerStepThroughAttribute()] - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")] - public partial class CalculatorClient : System.ServiceModel.ClientBase, Microsoft.ServiceModel.Samples.ICalculator - { - - public CalculatorClient() - { - } - - public CalculatorClient(string endpointConfigurationName) : - base(endpointConfigurationName) - { - } - - public CalculatorClient(string endpointConfigurationName, string remoteAddress) : - base(endpointConfigurationName, remoteAddress) - { - } - - public CalculatorClient(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) : - base(endpointConfigurationName, remoteAddress) - { - } - - public CalculatorClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) : - base(binding, remoteAddress) - { - } - - public double Add(double n1, double n2) - { - return base.Channel.Add(n1, n2); - } - - public System.IAsyncResult BeginAdd(double n1, double n2, System.AsyncCallback callback, object asyncState) - { - return base.Channel.BeginAdd(n1, n2, callback, asyncState); - } - - public double EndAdd(System.IAsyncResult result) - { - return base.Channel.EndAdd(result); - } - - public double Subtract(double n1, double n2) - { - return base.Channel.Subtract(n1, n2); - } - - public System.IAsyncResult BeginSubtract(double n1, double n2, System.AsyncCallback callback, object asyncState) - { - return base.Channel.BeginSubtract(n1, n2, callback, asyncState); - } - - public double EndSubtract(System.IAsyncResult result) - { - return base.Channel.EndSubtract(result); - } - - public double Multiply(double n1, double n2) - { - return base.Channel.Multiply(n1, n2); - } - - public System.IAsyncResult BeginMultiply(double n1, double n2, System.AsyncCallback callback, object asyncState) - { - return base.Channel.BeginMultiply(n1, n2, callback, asyncState); - } - - public double EndMultiply(System.IAsyncResult result) - { - return base.Channel.EndMultiply(result); - } - - public double Divide(double n1, double n2) - { - return base.Channel.Divide(n1, n2); - } - - public System.IAsyncResult BeginDivide(double n1, double n2, System.AsyncCallback callback, object asyncState) - { - return base.Channel.BeginDivide(n1, n2, callback, asyncState); - } - - public double EndDivide(System.IAsyncResult result) - { - return base.Channel.EndDivide(result); - } - } -} diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_howto_codeclientbinding/cs/generatedclient.cs b/samples/snippets/csharp/VS_Snippets_CFX/c_howto_codeclientbinding/cs/generatedclient.cs deleted file mode 100644 index 16633f9261a40..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CFX/c_howto_codeclientbinding/cs/generatedclient.cs +++ /dev/null @@ -1,82 +0,0 @@ - - -namespace Microsoft.ServiceModel.Samples -{ - - // - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")] - [System.ServiceModel.ServiceContractAttribute(Namespace="http://Microsoft.ServiceModel.Samples", ConfigurationName="Microsoft.ServiceModel.Samples.ICalculator")] - public interface ICalculator - { - - [System.ServiceModel.OperationContractAttribute(Action="http://Microsoft.ServiceModel.Samples/ICalculator/Add", ReplyAction="http://Microsoft.ServiceModel.Samples/ICalculator/AddResponse")] - double Add(double n1, double n2); - - [System.ServiceModel.OperationContractAttribute(Action="http://Microsoft.ServiceModel.Samples/ICalculator/Subtract", ReplyAction="http://Microsoft.ServiceModel.Samples/ICalculator/SubtractResponse")] - double Subtract(double n1, double n2); - - [System.ServiceModel.OperationContractAttribute(Action="http://Microsoft.ServiceModel.Samples/ICalculator/Multiply", ReplyAction="http://Microsoft.ServiceModel.Samples/ICalculator/MultiplyResponse")] - double Multiply(double n1, double n2); - - [System.ServiceModel.OperationContractAttribute(Action="http://Microsoft.ServiceModel.Samples/ICalculator/Divide", ReplyAction="http://Microsoft.ServiceModel.Samples/ICalculator/DivideResponse")] - double Divide(double n1, double n2); - } -// - - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")] - public interface ICalculatorChannel : Microsoft.ServiceModel.Samples.ICalculator, System.ServiceModel.IClientChannel - { - } - - // - [System.Diagnostics.DebuggerStepThroughAttribute()] - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")] - public partial class CalculatorClient : System.ServiceModel.ClientBase, Microsoft.ServiceModel.Samples.ICalculator - { - - public CalculatorClient() - { - } - - public CalculatorClient(string endpointConfigurationName) : - base(endpointConfigurationName) - { - } - - public CalculatorClient(string endpointConfigurationName, string remoteAddress) : - base(endpointConfigurationName, remoteAddress) - { - } - - public CalculatorClient(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) : - base(endpointConfigurationName, remoteAddress) - { - } - - public CalculatorClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) : - base(binding, remoteAddress) - { - } - - public double Add(double n1, double n2) - { - return base.Channel.Add(n1, n2); - } - - public double Subtract(double n1, double n2) - { - return base.Channel.Subtract(n1, n2); - } - - public double Multiply(double n1, double n2) - { - return base.Channel.Multiply(n1, n2); - } - - public double Divide(double n1, double n2) - { - return base.Channel.Divide(n1, n2); - } - } - // -} diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_howtousechannelfactory/source.vb b/samples/snippets/csharp/VS_Snippets_CFX/c_howtousechannelfactory/source.vb deleted file mode 100644 index a6c1297b4bfea..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CFX/c_howtousechannelfactory/source.vb +++ /dev/null @@ -1,43 +0,0 @@ -' -Imports System.ServiceModel - -' This code generated by svcutil.exe. - _ -Interface IMath - _ - Function Add(ByVal A As Double, ByVal B As Double) As Double -End Interface - -public class Math - Implements IMath - - Function Add(ByVal A As Double, ByVal B As Double) As Double Implements IMath.Add - Return A + B - End Function -End Class - -Public Class Test - Public Shared Sub Main() - End Sub - - Public Sub Run() - ' This code is written by an application developer. - ' Create a channel factory. - Dim myBinding As New BasicHttpBinding - Dim myEndpoint As New EndpointAddress("http://localhost/MathService/Ep1") - - Dim myChannelFactory As ChannelFactory(Of IMath) = _ - New ChannelFactory(Of IMath)(myBinding, myEndpoint) - - 'Create a channel. - Dim proxy1 As IMath = myChannelFactory.CreateChannel() - Dim s As Integer = proxy1.Add(3, 39) - Console.WriteLine(s.ToString()) - - ' Create another channel - Dim proxy2 As IMath = myChannelFactory.CreateChannel() - s = proxy2.Add(15, 27) - Console.WriteLine(s.ToString()) - End Sub -End Class -' diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_wcfclienttowseservice/cs/generatedclient.cs b/samples/snippets/csharp/VS_Snippets_CFX/c_wcfclienttowseservice/cs/generatedclient.cs deleted file mode 100644 index 446b0848d8cff..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CFX/c_wcfclienttowseservice/cs/generatedclient.cs +++ /dev/null @@ -1,88 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:2.0.50727.42 -// -// 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("System.ServiceModel", "3.0.0.0")] - [System.ServiceModel.ServiceContractAttribute(Namespace="http://Microsoft.ServiceModel.Samples", ConfigurationName="Microsoft.ServiceModel.Samples.ICalculator")] - public interface ICalculator - { - - [System.ServiceModel.OperationContractAttribute(Action="http://Microsoft.ServiceModel.Samples/ICalculator/Add", ReplyAction="http://Microsoft.ServiceModel.Samples/ICalculator/AddResponse")] - double Add(double n1, double n2); - - [System.ServiceModel.OperationContractAttribute(Action="http://Microsoft.ServiceModel.Samples/ICalculator/Subtract", ReplyAction="http://Microsoft.ServiceModel.Samples/ICalculator/SubtractResponse")] - double Subtract(double n1, double n2); - - [System.ServiceModel.OperationContractAttribute(Action="http://Microsoft.ServiceModel.Samples/ICalculator/Multiply", ReplyAction="http://Microsoft.ServiceModel.Samples/ICalculator/MultiplyResponse")] - double Multiply(double n1, double n2); - - [System.ServiceModel.OperationContractAttribute(Action="http://Microsoft.ServiceModel.Samples/ICalculator/Divide", ReplyAction="http://Microsoft.ServiceModel.Samples/ICalculator/DivideResponse")] - double Divide(double n1, double n2); - } - - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")] - public interface ICalculatorChannel : Microsoft.ServiceModel.Samples.ICalculator, System.ServiceModel.IClientChannel - { - } - - [System.Diagnostics.DebuggerStepThroughAttribute()] - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")] - public partial class CalculatorClient : System.ServiceModel.ClientBase, Microsoft.ServiceModel.Samples.ICalculator - { - - public CalculatorClient() - { - } - - public CalculatorClient(string endpointConfigurationName) : - base(endpointConfigurationName) - { - } - - public CalculatorClient(string endpointConfigurationName, string remoteAddress) : - base(endpointConfigurationName, remoteAddress) - { - } - - public CalculatorClient(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) : - base(endpointConfigurationName, remoteAddress) - { - } - - public CalculatorClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) : - base(binding, remoteAddress) - { - } - - public double Add(double n1, double n2) - { - return base.Channel.Add(n1, n2); - } - - public double Subtract(double n1, double n2) - { - return base.Channel.Subtract(n1, n2); - } - - public double Multiply(double n1, double n2) - { - return base.Channel.Multiply(n1, n2); - } - - public double Divide(double n1, double n2) - { - return base.Channel.Divide(n1, n2); - } - } -} diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_wcfclienttowseservice/cs/wseclient.cs b/samples/snippets/csharp/VS_Snippets_CFX/c_wcfclienttowseservice/cs/wseclient.cs deleted file mode 100644 index 6dc27bd954a96..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CFX/c_wcfclienttowseservice/cs/wseclient.cs +++ /dev/null @@ -1,350 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:2.0.50727.42 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - - - -/// -[System.CodeDom.Compiler.GeneratedCodeAttribute("svcutil", "3.0.4011.0")] -[System.SerializableAttribute()] -[System.Diagnostics.DebuggerStepThroughAttribute()] -[System.ComponentModel.DesignerCategoryAttribute("code")] -[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://stockservice.contoso.com/wse/samples/2003/06")] -public partial class StockQuote -{ - - private string symbolField; - - private double lastField; - - private System.DateTime dateField; - - private double changeField; - - private double openField; - - private double highField; - - private double lowField; - - private long volumeField; - - private long marketCapField; - - private double previousCloseField; - - private double previousChangeField; - - private double low52WeekField; - - private double high52WeekField; - - private string nameField; - - /// - [System.Xml.Serialization.XmlElementAttribute(Order=0)] - public string Symbol - { - get - { - return this.symbolField; - } - set - { - this.symbolField = value; - } - } - - /// - [System.Xml.Serialization.XmlElementAttribute(Order=1)] - public double Last - { - get - { - return this.lastField; - } - set - { - this.lastField = value; - } - } - - /// - [System.Xml.Serialization.XmlElementAttribute(Order=2)] - public System.DateTime Date - { - get - { - return this.dateField; - } - set - { - this.dateField = value; - } - } - - /// - [System.Xml.Serialization.XmlElementAttribute(Order=3)] - public double Change - { - get - { - return this.changeField; - } - set - { - this.changeField = value; - } - } - - /// - [System.Xml.Serialization.XmlElementAttribute(Order=4)] - public double Open - { - get - { - return this.openField; - } - set - { - this.openField = value; - } - } - - /// - [System.Xml.Serialization.XmlElementAttribute(Order=5)] - public double High - { - get - { - return this.highField; - } - set - { - this.highField = value; - } - } - - /// - [System.Xml.Serialization.XmlElementAttribute(Order=6)] - public double Low - { - get - { - return this.lowField; - } - set - { - this.lowField = value; - } - } - - /// - [System.Xml.Serialization.XmlElementAttribute(Order=7)] - public long Volume - { - get - { - return this.volumeField; - } - set - { - this.volumeField = value; - } - } - - /// - [System.Xml.Serialization.XmlElementAttribute(Order=8)] - public long MarketCap - { - get - { - return this.marketCapField; - } - set - { - this.marketCapField = value; - } - } - - /// - [System.Xml.Serialization.XmlElementAttribute(Order=9)] - public double PreviousClose - { - get - { - return this.previousCloseField; - } - set - { - this.previousCloseField = value; - } - } - - /// - [System.Xml.Serialization.XmlElementAttribute(Order=10)] - public double PreviousChange - { - get - { - return this.previousChangeField; - } - set - { - this.previousChangeField = value; - } - } - - /// - [System.Xml.Serialization.XmlElementAttribute(Order=11)] - public double Low52Week - { - get - { - return this.low52WeekField; - } - set - { - this.low52WeekField = value; - } - } - - /// - [System.Xml.Serialization.XmlElementAttribute(Order=12)] - public double High52Week - { - get - { - return this.high52WeekField; - } - set - { - this.high52WeekField = value; - } - } - - /// - [System.Xml.Serialization.XmlElementAttribute(Order=13)] - public string Name - { - get - { - return this.nameField; - } - set - { - this.nameField = value; - } - } -} - - - -[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")] -[System.ServiceModel.ServiceContractAttribute(Namespace="http://stockservice.contoso.com/wse/samples/2005/10", ConfigurationName="WSSecurityAnonymousServiceSoap")] -public interface WSSecurityAnonymousServiceSoap -{ - - // CODEGEN: Generating message contract since the wrapper name (StockQuotes) of message StockQuoteRequestResponse does not match the default value (StockQuoteRequest) - [System.ServiceModel.OperationContractAttribute(Action="http://stockservice.contoso.com/wse/samples/2005/10/StockQuoteRequest", ReplyAction="*")] - [System.ServiceModel.XmlSerializerFormatAttribute()] - StockQuoteRequestResponse StockQuoteRequest(StockQuoteRequestRequest request); -} - -[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")] -public interface WSSecurityAnonymousServiceSoapChannel : WSSecurityAnonymousServiceSoap, System.ServiceModel.IClientChannel -{ -} - -[System.Diagnostics.DebuggerStepThroughAttribute()] -[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")] -public partial class WSSecurityAnonymousServiceSoapClient : System.ServiceModel.ClientBase, WSSecurityAnonymousServiceSoap -{ - - public WSSecurityAnonymousServiceSoapClient() - { - } - - public WSSecurityAnonymousServiceSoapClient(string endpointConfigurationName) : - base(endpointConfigurationName) - { - } - - public WSSecurityAnonymousServiceSoapClient(string endpointConfigurationName, string remoteAddress) : - base(endpointConfigurationName, remoteAddress) - { - } - - public WSSecurityAnonymousServiceSoapClient(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) : - base(endpointConfigurationName, remoteAddress) - { - } - - public WSSecurityAnonymousServiceSoapClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) : - base(binding, remoteAddress) - { - } - - StockQuoteRequestResponse WSSecurityAnonymousServiceSoap.StockQuoteRequest(StockQuoteRequestRequest request) - { - return base.Channel.StockQuoteRequest(request); - } - - public StockQuote[] StockQuoteRequest(string[] symbols) - { - StockQuoteRequestRequest inValue = new StockQuoteRequestRequest(); - inValue.symbols = symbols; - StockQuoteRequestResponse retVal = ((WSSecurityAnonymousServiceSoap)(this)).StockQuoteRequest(inValue); - return retVal.StockQuote; - } -} - - -[System.Diagnostics.DebuggerStepThroughAttribute()] -[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")] -[System.ServiceModel.MessageContractAttribute(WrapperName="StockQuoteRequest", WrapperNamespace="http://stockservice.contoso.com/wse/samples/2005/10", IsWrapped=true)] -public partial class StockQuoteRequestRequest -{ - - [System.ServiceModel.MessageBodyMemberAttribute(Namespace="http://stockservice.contoso.com/wse/samples/2005/10", Order=0)] - [System.Xml.Serialization.XmlArrayAttribute(IsNullable=true)] - [System.Xml.Serialization.XmlArrayItemAttribute("Symbol", IsNullable=false)] - public string[] symbols; - - public StockQuoteRequestRequest() - { - } - - public StockQuoteRequestRequest(string[] symbols) - { - this.symbols = symbols; - } -} - -[System.Diagnostics.DebuggerStepThroughAttribute()] -[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")] -[System.ServiceModel.MessageContractAttribute(WrapperName="StockQuotes", WrapperNamespace="http://stockservice.contoso.com/wse/samples/2005/10", IsWrapped=true)] -public partial class StockQuoteRequestResponse -{ - - [System.ServiceModel.MessageBodyMemberAttribute(Namespace="http://stockservice.contoso.com/wse/samples/2005/10", Order=0)] - [System.Xml.Serialization.XmlElementAttribute("StockQuote")] - public StockQuote[] StockQuote; - - public StockQuoteRequestResponse() - { - } - - public StockQuoteRequestResponse(StockQuote[] StockQuote) - { - this.StockQuote = StockQuote; - } -} - - diff --git a/samples/snippets/csharp/VS_Snippets_CFX/c_wcfclienttowseservice/cs/wsesecurityassertion.cs b/samples/snippets/csharp/VS_Snippets_CFX/c_wcfclienttowseservice/cs/wsesecurityassertion.cs deleted file mode 100644 index 288d670b7002a..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CFX/c_wcfclienttowseservice/cs/wsesecurityassertion.cs +++ /dev/null @@ -1,15 +0,0 @@ -//------------------------------------------------------------ -// Copyright (c) Microsoft Corporation. All rights reserved. -//------------------------------------------------------------ -namespace Microsoft.ServiceModel.Samples -{ - public enum WseSecurityAssertion - { - UsernameOverTransport = 0, - MutualCertificate10 = 1, - UsernameForCertificate = 2, - AnonymousForCertificate = 3, - MutualCertificate11 = 4, - Kerberos = 5 - } -} diff --git a/samples/snippets/csharp/VS_Snippets_CFX/eventasync/cs/asyncresult.cs b/samples/snippets/csharp/VS_Snippets_CFX/eventasync/cs/asyncresult.cs deleted file mode 100644 index bbaef7792676f..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CFX/eventasync/cs/asyncresult.cs +++ /dev/null @@ -1,196 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. - -using System; -using System.Diagnostics; -using System.Threading; - -namespace Microsoft.ServiceModel.Samples -{ - /// - /// A generic base class for IAsyncResult implementations - /// that wraps a ManualResetEvent. - /// - public abstract class AsyncResult : IAsyncResult - { - AsyncCallback callback; - object state; - bool completedSynchronously; - bool endCalled; - Exception exception; - bool isCompleted; - ManualResetEvent manualResetEvent; - object thisLock; - - protected AsyncResult(AsyncCallback callback, object state) - { - this.callback = callback; - this.state = state; - this.thisLock = new object(); - } - - public object AsyncState - { - get - { - return state; - } - } - - public WaitHandle AsyncWaitHandle - { - get - { - if (manualResetEvent != null) - { - return manualResetEvent; - } - - lock (ThisLock) - { - manualResetEvent ??= new ManualResetEvent(isCompleted); - } - - return manualResetEvent; - } - } - - public bool CompletedSynchronously - { - get - { - return completedSynchronously; - } - } - - public bool IsCompleted - { - get - { - return isCompleted; - } - } - - object ThisLock - { - get - { - return this.thisLock; - } - } - - // Call this version of complete when your asynchronous operation is complete. This will update the state - // of the operation and notify the callback. - protected void Complete(bool completedSynchronously) - { - if (isCompleted) - { - // It is a bug to call Complete twice. - throw new InvalidOperationException("Cannot call Complete twice"); - } - - this.completedSynchronously = completedSynchronously; - - if (completedSynchronously) - { - // If we completedSynchronously, then there is no chance that the manualResetEvent was created so - // we do not need to worry about a race condition. - this.isCompleted = true; - } - else - { - lock (ThisLock) - { - this.isCompleted = true; - if (this.manualResetEvent != null) - { - this.manualResetEvent.Set(); - } - } - } - - // If the callback throws, there is a bug in the callback implementation - if (callback != null) - { - callback(this); - } - } - - // Call this version of complete if you raise an exception during processing. In addition to notifying - // the callback, it will capture the exception and store it to be thrown during AsyncResult.End. - protected void Complete(bool completedSynchronously, Exception exception) - { - this.exception = exception; - Complete(completedSynchronously); - } - - // End should be called when the End function for the asynchronous operation is complete. It - // ensures the asynchronous operation is complete, and does some common validation. - protected static TAsyncResult End(IAsyncResult result) - where TAsyncResult : AsyncResult - { - if (result == null) - { - throw new ArgumentNullException("result"); - } - - TAsyncResult asyncResult = result as TAsyncResult; - - if (asyncResult == null) - { - throw new ArgumentException("Invalid async result.", "result"); - } - - if (asyncResult.endCalled) - { - throw new InvalidOperationException("Async object already ended."); - } - - asyncResult.endCalled = true; - - if (!asyncResult.isCompleted) - { - asyncResult.AsyncWaitHandle.WaitOne(); - } - - if (asyncResult.manualResetEvent != null) - { - asyncResult.manualResetEvent.Close(); - } - - if (asyncResult.exception != null) - { - throw asyncResult.exception; - } - - return asyncResult; - } - } - - //A strongly typed AsyncResult - public abstract class TypedAsyncResult : AsyncResult - { - T data; - - protected TypedAsyncResult(AsyncCallback callback, object state) - : base(callback, state) - { - } - - public T Data - { - get { return data; } - } - - protected void Complete(T data, bool completedSynchronously) - { - this.data = data; - Complete(completedSynchronously); - } - - public static T End(IAsyncResult result) - { - TypedAsyncResult typedResult = AsyncResult.End>(result); - return typedResult.Data; - } - } -} diff --git a/samples/snippets/csharp/VS_Snippets_CFX/message/cs/client.cs b/samples/snippets/csharp/VS_Snippets_CFX/message/cs/client.cs deleted file mode 100644 index d40c1eb195f37..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CFX/message/cs/client.cs +++ /dev/null @@ -1,59 +0,0 @@ -// -using System; -using System.Collections.Generic; -using System.Text; -using System.ServiceModel; -using System.ServiceModel.Channels; -using System.Runtime.Serialization; - -namespace ConsoleApplication1 -{ - class client - { - - static void RunClient() - { - //Step1: create a binding with just HTTP - CustomBinding binding = new CustomBinding(); - binding.Elements.Add(new HttpTransportBindingElement()); - //Step2: use the binding to build the channel factory - IChannelFactory factory = - binding.BuildChannelFactory( - new BindingParameterCollection()); - //open the channel factory - factory.Open(); - //Step3: use the channel factory to create a channel - IRequestChannel channel = factory.CreateChannel( - new EndpointAddress("http://localhost:8080/channelapp")); - channel.Open(); - //Step4: create a message - Message requestmessage = Message.CreateMessage( - MessageVersion.Soap12WSAddressing10, - "http://contoso.com/someaction", - "This is the body data"); - //send message - Message replymessage = channel.Request(requestmessage); - Console.WriteLine("Reply message received"); - Console.WriteLine("Reply action: {0}", - replymessage.Headers.Action); - string data = replymessage.GetBody(); - Console.WriteLine("Reply content: {0}", data); - //Step5: don't forget to close the message - requestmessage.Close(); - replymessage.Close(); - //don't forget to close the channel - channel.Close(); - //don't forget to close the factory - factory.Close(); - } - public static void Main() - { - Console.WriteLine("Press [ENTER] when service is ready"); - Console.ReadLine(); - RunClient(); - Console.WriteLine("Press [ENTER] to exit"); - Console.ReadLine(); - } - } -} -// \ No newline at end of file diff --git a/samples/snippets/csharp/VS_Snippets_CFX/s_deadletter/cs/generatedproxy.cs b/samples/snippets/csharp/VS_Snippets_CFX/s_deadletter/cs/generatedproxy.cs deleted file mode 100644 index 81ce9befdb3a1..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CFX/s_deadletter/cs/generatedproxy.cs +++ /dev/null @@ -1,191 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:2.0.50727.12 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -// Do not add data members to types. Will cause serialization to fail. -namespace Microsoft.ServiceModel.Samples -{ - using System.Runtime.Serialization; - using System.ServiceModel.Channels; - - - [System.Runtime.Serialization.DataContractAttribute()] - public partial class PurchaseOrder : object, System.Runtime.Serialization.IExtensibleDataObject - { - - private System.Runtime.Serialization.ExtensionDataObject extensionDataField; - - private string CustomerIdField; - - private string PONumberField; - - private Microsoft.ServiceModel.Samples.PurchaseOrderLineItem[] orderLineItemsField; - - public System.Runtime.Serialization.ExtensionDataObject ExtensionData - { - get - { - return this.extensionDataField; - } - set - { - this.extensionDataField = value; - } - } - - [System.Runtime.Serialization.DataMemberAttribute()] - public string CustomerId - { - get - { - return this.CustomerIdField; - } - set - { - this.CustomerIdField = value; - } - } - - [System.Runtime.Serialization.DataMemberAttribute()] - public string PONumber - { - get - { - return this.PONumberField; - } - set - { - this.PONumberField = value; - } - } - - [System.Runtime.Serialization.DataMemberAttribute()] - public Microsoft.ServiceModel.Samples.PurchaseOrderLineItem[] orderLineItems - { - get - { - return this.orderLineItemsField; - } - set - { - this.orderLineItemsField = value; - } - } - } - - [System.Runtime.Serialization.DataContractAttribute()] - public partial class PurchaseOrderLineItem : object, System.Runtime.Serialization.IExtensibleDataObject - { - - private System.Runtime.Serialization.ExtensionDataObject extensionDataField; - - private string ProductIdField; - - private int QuantityField; - - private float UnitCostField; - - public System.Runtime.Serialization.ExtensionDataObject ExtensionData - { - get - { - return this.extensionDataField; - } - set - { - this.extensionDataField = value; - } - } - - [System.Runtime.Serialization.DataMemberAttribute()] - public string ProductId - { - get - { - return this.ProductIdField; - } - set - { - this.ProductIdField = value; - } - } - - [System.Runtime.Serialization.DataMemberAttribute()] - public int Quantity - { - get - { - return this.QuantityField; - } - set - { - this.QuantityField = value; - } - } - - [System.Runtime.Serialization.DataMemberAttribute()] - public float UnitCost - { - get - { - return this.UnitCostField; - } - set - { - this.UnitCostField = value; - } - } - } -} - - -[System.ServiceModel.ServiceContractAttribute(Namespace="http://Microsoft.ServiceModel.Samples")] -public interface IOrderProcessor -{ - - [System.ServiceModel.OperationContractAttribute(IsOneWay=true, Action="http://Microsoft.ServiceModel.Samples/IOrderProcessor/SubmitPurchaseOrder")] - void SubmitPurchaseOrder(Microsoft.ServiceModel.Samples.PurchaseOrder po); -} - -public interface IOrderProcessorChannel : IOrderProcessor, System.ServiceModel.IClientChannel -{ -} - -public partial class OrderProcessorClient : System.ServiceModel.ClientBase, IOrderProcessor -{ - - public OrderProcessorClient() - { - } - - public OrderProcessorClient(string endpointConfigurationName) : - base(endpointConfigurationName) - { - } - - public OrderProcessorClient(string endpointConfigurationName, string remoteAddress) : - base(endpointConfigurationName, remoteAddress) - { - } - - public OrderProcessorClient(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) : - base(endpointConfigurationName, remoteAddress) - { - } - - public OrderProcessorClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) : - base(binding, remoteAddress) - { - } - - public void SubmitPurchaseOrder(Microsoft.ServiceModel.Samples.PurchaseOrder po) - { - base.Channel.SubmitPurchaseOrder(po); - } -} diff --git a/samples/snippets/csharp/VS_Snippets_CFX/s_deadletter/cs/orderprocessorservice.cs b/samples/snippets/csharp/VS_Snippets_CFX/s_deadletter/cs/orderprocessorservice.cs deleted file mode 100644 index ad1616f0ee890..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CFX/s_deadletter/cs/orderprocessorservice.cs +++ /dev/null @@ -1,195 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:2.0.50727.42 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace Microsoft.ServiceModel.Samples -{ - using System.Runtime.Serialization; - - - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "3.0.0.0")] - [System.Runtime.Serialization.DataContractAttribute()] - public partial class PurchaseOrder : object, System.Runtime.Serialization.IExtensibleDataObject - { - - private System.Runtime.Serialization.ExtensionDataObject extensionDataField; - - private string CustomerIdField; - - private string PONumberField; - - private Microsoft.ServiceModel.Samples.PurchaseOrderLineItem[] orderLineItemsField; - - public System.Runtime.Serialization.ExtensionDataObject ExtensionData - { - get - { - return this.extensionDataField; - } - set - { - this.extensionDataField = value; - } - } - - [System.Runtime.Serialization.DataMemberAttribute()] - public string CustomerId - { - get - { - return this.CustomerIdField; - } - set - { - this.CustomerIdField = value; - } - } - - [System.Runtime.Serialization.DataMemberAttribute()] - public string PONumber - { - get - { - return this.PONumberField; - } - set - { - this.PONumberField = value; - } - } - - [System.Runtime.Serialization.DataMemberAttribute()] - public Microsoft.ServiceModel.Samples.PurchaseOrderLineItem[] orderLineItems - { - get - { - return this.orderLineItemsField; - } - set - { - this.orderLineItemsField = value; - } - } - } - - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "3.0.0.0")] - [System.Runtime.Serialization.DataContractAttribute()] - public partial class PurchaseOrderLineItem : object, System.Runtime.Serialization.IExtensibleDataObject - { - - private System.Runtime.Serialization.ExtensionDataObject extensionDataField; - - private string ProductIdField; - - private int QuantityField; - - private float UnitCostField; - - public System.Runtime.Serialization.ExtensionDataObject ExtensionData - { - get - { - return this.extensionDataField; - } - set - { - this.extensionDataField = value; - } - } - - [System.Runtime.Serialization.DataMemberAttribute()] - public string ProductId - { - get - { - return this.ProductIdField; - } - set - { - this.ProductIdField = value; - } - } - - [System.Runtime.Serialization.DataMemberAttribute()] - public int Quantity - { - get - { - return this.QuantityField; - } - set - { - this.QuantityField = value; - } - } - - [System.Runtime.Serialization.DataMemberAttribute()] - public float UnitCost - { - get - { - return this.UnitCostField; - } - set - { - this.UnitCostField = value; - } - } - } -} - - -[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")] -[System.ServiceModel.ServiceContractAttribute(Namespace="http://Microsoft.ServiceModel.Samples", ConfigurationName="IOrderProcessor")] -public interface IOrderProcessor -{ - - [System.ServiceModel.OperationContractAttribute(IsOneWay=true, Action="http://Microsoft.ServiceModel.Samples/IOrderProcessor/SubmitPurchaseOrder")] - void SubmitPurchaseOrder(Microsoft.ServiceModel.Samples.PurchaseOrder po); -} - -[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")] -public interface IOrderProcessorChannel : IOrderProcessor, System.ServiceModel.IClientChannel -{ -} - -[System.Diagnostics.DebuggerStepThroughAttribute()] -[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")] -public partial class OrderProcessorClient : System.ServiceModel.ClientBase, IOrderProcessor -{ - - public OrderProcessorClient() - { - } - - public OrderProcessorClient(string endpointConfigurationName) : - base(endpointConfigurationName) - { - } - - public OrderProcessorClient(string endpointConfigurationName, string remoteAddress) : - base(endpointConfigurationName, remoteAddress) - { - } - - public OrderProcessorClient(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) : - base(endpointConfigurationName, remoteAddress) - { - } - - public OrderProcessorClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) : - base(binding, remoteAddress) - { - } - - public void SubmitPurchaseOrder(Microsoft.ServiceModel.Samples.PurchaseOrder po) - { - base.Channel.SubmitPurchaseOrder(po); - } -} diff --git a/samples/snippets/csharp/VS_Snippets_CFX/s_deadletter/cs/service.cs b/samples/snippets/csharp/VS_Snippets_CFX/s_deadletter/cs/service.cs deleted file mode 100644 index 51e0f99c0a4a5..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CFX/s_deadletter/cs/service.cs +++ /dev/null @@ -1,172 +0,0 @@ - -// Copyright (c) Microsoft Corporation. All Rights Reserved. - -using System; - -using System.ServiceModel.Channels; -using System.Configuration; -//using System.Messaging; -using System.ServiceModel; -//using System.Transactions; -using System.Runtime.Serialization; -using System.Collections.Generic; -using System.Text; - -namespace Microsoft.ServiceModel.Samples -{ - // Define the purchase order line item. - [DataContract] - public class PurchaseOrderLineItem - { - [DataMember] - public string ProductId; - - [DataMember] - public float UnitCost; - - [DataMember] - public int Quantity; - - public override string ToString() - { - String displayString = "Order LineItem: " + Quantity + " of " + ProductId + " @unit price: $" + UnitCost + "\n"; - return displayString; - } - - public float TotalCost - { - get { return UnitCost * Quantity; } - } - } - - // Define the purchase order. - [DataContract] - public class PurchaseOrder - { - static readonly string[] OrderStates = { "Pending", "Processed", "Shipped" }; - static Random statusIndexer = new Random(137); - - [DataMember] - public string PONumber; - - [DataMember] - public string CustomerId; - - [DataMember] - public PurchaseOrderLineItem[] orderLineItems; - - public float TotalCost - { - get - { - float totalCost = 0; - foreach (PurchaseOrderLineItem lineItem in orderLineItems) - totalCost += lineItem.TotalCost; - return totalCost; - } - } - - public string Status - { - get - { - return OrderStates[statusIndexer.Next(3)]; - } - } - - public override string ToString() - { - StringBuilder strbuf = new StringBuilder("Purchase Order: " + PONumber + "\n"); - strbuf.Append("\tCustomer: " + CustomerId + "\n"); - strbuf.Append("\tOrderDetails\n"); - - foreach (PurchaseOrderLineItem lineItem in orderLineItems) - { - strbuf.Append("\t\t" + lineItem.ToString()); - } - - strbuf.Append("\tTotal cost of this order: $" + TotalCost + "\n"); - strbuf.Append("\tOrder status: " + Status + "\n"); - return strbuf.ToString(); - } - } - - // Order Processing Logic - // Can replace with transaction-aware resource such as SQL or transacted hashtable to hold the purchase orders. - // This example uses a non-transactional resource. - public class Orders - { - static Dictionary purchaseOrders = new Dictionary(); - - public static void Add(PurchaseOrder po) - { - purchaseOrders.Add(po.PONumber, po); - } - - public static string GetOrderStatus(string poNumber) - { - PurchaseOrder po; - if (purchaseOrders.TryGetValue(poNumber, out po)) - return po.Status; - else - return null; - } - - public static void DeleteOrder(string poNumber) - { - if (purchaseOrders[poNumber] != null) - purchaseOrders.Remove(poNumber); - } - } - - // Define a service contract. - [ServiceContract(Namespace = "http://Microsoft.ServiceModel.Samples")] - public interface IOrderProcessor - { - [OperationContract(IsOneWay = true)] - void SubmitPurchaseOrder(PurchaseOrder po); - } - - // Service class that implements the service contract. - // Added code to write output to the console window. - public class OrderProcessorService : IOrderProcessor - { - [OperationBehavior(TransactionScopeRequired = true, TransactionAutoComplete = true)] - public void SubmitPurchaseOrder(PurchaseOrder po) - { - Orders.Add(po); - Console.WriteLine("Processing {0} ", po); - } - - // Host the service within this EXE console application. - public static void Main() - { - // Get MSMQ queue name from appsettings in configuration. - string queueName = ConfigurationManager.AppSettings["queueName"]; - - // Create the transacted MSMQ queue if necessary. - if (!System.Messaging.MessageQueue.Exists(queueName)) - System.Messaging.MessageQueue.Create(queueName, true); - - // Get the base address that is used to listen for WS-MetaDataExchange requests. - // This is useful to generate a proxy for the client. - string baseAddress = ConfigurationManager.AppSettings["baseAddress"]; - - // Create a ServiceHost for the OrderProcessorService type. - using (ServiceHost serviceHost = new ServiceHost(typeof(OrderProcessorService), new Uri(baseAddress))) - { - // Open the ServiceHostBase to create listeners and start listening for messages. - serviceHost.Open(); - - // The service can now be accessed. - Console.WriteLine("The service is ready."); - Console.WriteLine("Press to terminate service."); - Console.WriteLine(); - Console.ReadLine(); - - // Close the ServiceHostBase to shutdown the service. - serviceHost.Close(); - } - } - } -} diff --git a/samples/snippets/csharp/VS_Snippets_CFX/s_imperative/cs/client.cs b/samples/snippets/csharp/VS_Snippets_CFX/s_imperative/cs/client.cs deleted file mode 100644 index 34b6ccbf2cdfe..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CFX/s_imperative/cs/client.cs +++ /dev/null @@ -1,76 +0,0 @@ - -// Copyright (c) Microsoft Corporation. All Rights Reserved. - -using System; -using System.ServiceModel; -using System.ServiceModel.Channels; - -namespace Microsoft.ServiceModel.Samples -{ - // Define a service contract. - [ServiceContract(Namespace = "http://Microsoft.ServiceModel.Samples")] - public interface ICalculator - { - [OperationContract] - double Add(double n1, double n2); - [OperationContract] - double Subtract(double n1, double n2); - [OperationContract] - double Multiply(double n1, double n2); - [OperationContract] - double Divide(double n1, double n2); - } - - class Client - { - static void Main() - { - Console.WriteLine("Press after the service has been started."); - Console.ReadLine(); - - // Create a custom binding that contains two binding elements. - ReliableSessionBindingElement reliableSession = new ReliableSessionBindingElement(); - reliableSession.Ordered = true; - - HttpTransportBindingElement httpTransport = new HttpTransportBindingElement(); - httpTransport.AuthenticationScheme = System.Net.AuthenticationSchemes.Anonymous; - httpTransport.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard; - - CustomBinding binding = new CustomBinding(reliableSession, httpTransport); - - // Create a channel using that binding. - EndpointAddress address = new EndpointAddress("http://localhost:8000/servicemodelsamples/service"); - ChannelFactory channelFactory = new ChannelFactory(binding, address); - ICalculator channel = channelFactory.CreateChannel(); - - // Call the Add service operation. - double value1 = 100.00D; - double value2 = 15.99D; - double result = channel.Add(value1, value2); - Console.WriteLine("Add({0},{1}) = {2}", value1, value2, result); - - // Call the Subtract service operation. - value1 = 145.00D; - value2 = 76.54D; - result = channel.Subtract(value1, value2); - Console.WriteLine("Subtract({0},{1}) = {2}", value1, value2, result); - - // Call the Multiply service operation. - value1 = 9.00D; - value2 = 81.25D; - result = channel.Multiply(value1, value2); - Console.WriteLine("Multiply({0},{1}) = {2}", value1, value2, result); - - // Call the Divide service operation. - value1 = 22.00D; - value2 = 7.00D; - result = channel.Divide(value1, value2); - Console.WriteLine("Divide({0},{1}) = {2}", value1, value2, result); - - Console.WriteLine(); - Console.WriteLine("Press to terminate client."); - Console.ReadLine(); - ((IChannel)channel).Close(); - } - } -} diff --git a/samples/snippets/csharp/VS_Snippets_CFX/s_imperative/cs/servicesnippets.cs b/samples/snippets/csharp/VS_Snippets_CFX/s_imperative/cs/servicesnippets.cs deleted file mode 100644 index 73ee8ae432162..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CFX/s_imperative/cs/servicesnippets.cs +++ /dev/null @@ -1,147 +0,0 @@ -using System; - -using System.ServiceModel.Channels; -using System.ServiceModel; -using System.ServiceModel.Description; -using System.Collections.Generic; - -namespace Microsoft.ServiceModel.Samples -{ - public class serviceSnippets - { - public static void Snippet3() - { - // - Uri baseAddress = new Uri("http://localhost:8000/servicemodelsamples/service"); - - // Create a ServiceHost for the CalculatorService type and provide the base address. - ServiceHost serviceHost = new ServiceHost(typeof(CalculatorService), baseAddress); - - // Create a custom binding that contains two binding elements. - ReliableSessionBindingElement reliableSession = new ReliableSessionBindingElement(); - reliableSession.Ordered = true; - - HttpTransportBindingElement httpTransport = new HttpTransportBindingElement(); - httpTransport.AuthenticationScheme = System.Net.AuthenticationSchemes.Anonymous; - httpTransport.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard; - - BindingElement[] elements = new BindingElement[2]; - elements[0] = reliableSession; - elements[1] = httpTransport; - - CustomBinding binding = new CustomBinding(elements); - // - - // Add an endpoint using that binding. - serviceHost.AddServiceEndpoint(typeof(ICalculator), binding, ""); - - // Add a MEX endpoint. - ServiceMetadataBehavior smb = new ServiceMetadataBehavior(); - smb.HttpGetEnabled = true; - smb.HttpGetUrl = new Uri("http://localhost:8001/servicemodelsamples"); - serviceHost.Description.Behaviors.Add(smb); - - // Open the ServiceHostBase to create listeners and start listening for messages. - serviceHost.Open(); - - // The service can now be accessed. - Console.WriteLine("The service is ready."); - Console.WriteLine("Press to terminate service."); - Console.WriteLine(); - Console.ReadLine(); - - // Close the ServiceHostBase to shutdown the service. - serviceHost.Close(); - } - - public static void Snippet4() - { - // - Uri baseAddress = new Uri("http://localhost:8000/servicemodelsamples/service"); - - // Create a ServiceHost for the CalculatorService type and provide the base address. - ServiceHost serviceHost = new ServiceHost(typeof(CalculatorService), baseAddress); - - // Create a custom binding that contains two binding elements. - ReliableSessionBindingElement reliableSession = new ReliableSessionBindingElement(); - reliableSession.Ordered = true; - - HttpTransportBindingElement httpTransport = new HttpTransportBindingElement(); - httpTransport.AuthenticationScheme = System.Net.AuthenticationSchemes.Anonymous; - httpTransport.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard; - - SynchronizedCollection coll = new SynchronizedCollection(); - coll.Add(reliableSession); - coll.Add(httpTransport); - - CustomBinding binding = new CustomBinding(coll); - // - - // Add an endpoint using that binding. - serviceHost.AddServiceEndpoint(typeof(ICalculator), binding, ""); - - // Add a MEX endpoint. - ServiceMetadataBehavior smb = new ServiceMetadataBehavior(); - smb.HttpGetEnabled = true; - smb.HttpGetUrl = new Uri("http://localhost:8001/servicemodelsamples"); - serviceHost.Description.Behaviors.Add(smb); - - // Open the ServiceHostBase to create listeners and start listening for messages. - serviceHost.Open(); - - // The service can now be accessed. - Console.WriteLine("The service is ready."); - Console.WriteLine("Press to terminate service."); - Console.WriteLine(); - Console.ReadLine(); - - // Close the ServiceHostBase to shutdown the service. - serviceHost.Close(); - } - - public static void Snippet5() - { - // - Uri baseAddress = new Uri("http://localhost:8000/servicemodelsamples/service"); - - // Create a ServiceHost for the CalculatorService type and provide the base address. - ServiceHost serviceHost = new ServiceHost(typeof(CalculatorService), baseAddress); - - // Create a custom binding that contains two binding elements. - ReliableSessionBindingElement reliableSession = new ReliableSessionBindingElement(); - reliableSession.Ordered = true; - - HttpTransportBindingElement httpTransport = new HttpTransportBindingElement(); - httpTransport.AuthenticationScheme = System.Net.AuthenticationSchemes.Anonymous; - httpTransport.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard; - - BindingElement[] elements = new BindingElement[2]; - elements[0] = reliableSession; - elements[1] = httpTransport; - - CustomBinding binding = new CustomBinding("MyCustomBinding", "http://localhost/service", elements); - // - - // Add an endpoint using that binding. - serviceHost.AddServiceEndpoint(typeof(ICalculator), binding, ""); - - // Add a MEX endpoint. - ServiceMetadataBehavior smb = new ServiceMetadataBehavior(); - smb.HttpGetEnabled = true; - smb.HttpGetUrl = new Uri("http://localhost:8001/servicemodelsamples"); - serviceHost.Description.Behaviors.Add(smb); - - // Open the ServiceHostBase to create listeners and start listening for messages. - serviceHost.Open(); - - // The service can now be accessed. - Console.WriteLine("The service is ready."); - Console.WriteLine("Press to terminate service."); - Console.WriteLine(); - Console.ReadLine(); - - // Close the ServiceHostBase to shutdown the service. - serviceHost.Close(); - } - } -} diff --git a/samples/snippets/csharp/VS_Snippets_CFX/s_msmq_session/cs/ordertakerservice.cs b/samples/snippets/csharp/VS_Snippets_CFX/s_msmq_session/cs/ordertakerservice.cs deleted file mode 100644 index db2ca7ed0737f..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CFX/s_msmq_session/cs/ordertakerservice.cs +++ /dev/null @@ -1,76 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:2.0.50727.42 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - - - -[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")] -[System.ServiceModel.ServiceContractAttribute(Namespace="http://Microsoft.ServiceModel.Samples", ConfigurationName="IOrderTaker", SessionMode=System.ServiceModel.SessionMode.Required)] -public interface IOrderTaker -{ - - [System.ServiceModel.OperationContractAttribute(IsOneWay=true, Action="http://Microsoft.ServiceModel.Samples/IOrderTaker/OpenPurchaseOrder")] - void OpenPurchaseOrder(string customerId); - - [System.ServiceModel.OperationContractAttribute(IsOneWay=true, Action="http://Microsoft.ServiceModel.Samples/IOrderTaker/AddProductLineItem")] - void AddProductLineItem(string productId, int quantity); - - [System.ServiceModel.OperationContractAttribute(IsOneWay=true, Action="http://Microsoft.ServiceModel.Samples/IOrderTaker/EndPurchaseOrder")] - void EndPurchaseOrder(); -} - -[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")] -public interface IOrderTakerChannel : IOrderTaker, System.ServiceModel.IClientChannel -{ -} - -[System.Diagnostics.DebuggerStepThroughAttribute()] -[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")] -public partial class OrderTakerClient : System.ServiceModel.ClientBase, IOrderTaker -{ - - public OrderTakerClient() - { - } - - public OrderTakerClient(string endpointConfigurationName) : - base(endpointConfigurationName) - { - } - - public OrderTakerClient(string endpointConfigurationName, string remoteAddress) : - base(endpointConfigurationName, remoteAddress) - { - } - - public OrderTakerClient(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) : - base(endpointConfigurationName, remoteAddress) - { - } - - public OrderTakerClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) : - base(binding, remoteAddress) - { - } - - public void OpenPurchaseOrder(string customerId) - { - base.Channel.OpenPurchaseOrder(customerId); - } - - public void AddProductLineItem(string productId, int quantity) - { - base.Channel.AddProductLineItem(productId, quantity); - } - - public void EndPurchaseOrder() - { - base.Channel.EndPurchaseOrder(); - } -} diff --git a/samples/snippets/csharp/VS_Snippets_CFX/s_msmq_transacted/cs/generatedclient.cs b/samples/snippets/csharp/VS_Snippets_CFX/s_msmq_transacted/cs/generatedclient.cs deleted file mode 100644 index 54d20f1c3bd1a..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CFX/s_msmq_transacted/cs/generatedclient.cs +++ /dev/null @@ -1,197 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:2.0.50727.42 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -[assembly: System.Runtime.Serialization.ContractNamespaceAttribute("http://Microsoft.ServiceModel.Samples", ClrNamespace="Microsoft.ServiceModel.Samples")] - -namespace Microsoft.ServiceModel.Samples -{ - using System.Runtime.Serialization; - - - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "3.0.0.0")] - [System.Runtime.Serialization.DataContractAttribute()] - public partial class PurchaseOrder : object, System.Runtime.Serialization.IExtensibleDataObject - { - - private System.Runtime.Serialization.ExtensionDataObject extensionDataField; - - private string CustomerIdField; - - private string PONumberField; - - private Microsoft.ServiceModel.Samples.PurchaseOrderLineItem[] orderLineItemsField; - - public System.Runtime.Serialization.ExtensionDataObject ExtensionData - { - get - { - return this.extensionDataField; - } - set - { - this.extensionDataField = value; - } - } - - [System.Runtime.Serialization.DataMemberAttribute()] - public string CustomerId - { - get - { - return this.CustomerIdField; - } - set - { - this.CustomerIdField = value; - } - } - - [System.Runtime.Serialization.DataMemberAttribute()] - public string PONumber - { - get - { - return this.PONumberField; - } - set - { - this.PONumberField = value; - } - } - - [System.Runtime.Serialization.DataMemberAttribute()] - public Microsoft.ServiceModel.Samples.PurchaseOrderLineItem[] orderLineItems - { - get - { - return this.orderLineItemsField; - } - set - { - this.orderLineItemsField = value; - } - } - } - - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "3.0.0.0")] - [System.Runtime.Serialization.DataContractAttribute()] - public partial class PurchaseOrderLineItem : object, System.Runtime.Serialization.IExtensibleDataObject - { - - private System.Runtime.Serialization.ExtensionDataObject extensionDataField; - - private string ProductIdField; - - private int QuantityField; - - private float UnitCostField; - - public System.Runtime.Serialization.ExtensionDataObject ExtensionData - { - get - { - return this.extensionDataField; - } - set - { - this.extensionDataField = value; - } - } - - [System.Runtime.Serialization.DataMemberAttribute()] - public string ProductId - { - get - { - return this.ProductIdField; - } - set - { - this.ProductIdField = value; - } - } - - [System.Runtime.Serialization.DataMemberAttribute()] - public int Quantity - { - get - { - return this.QuantityField; - } - set - { - this.QuantityField = value; - } - } - - [System.Runtime.Serialization.DataMemberAttribute()] - public float UnitCost - { - get - { - return this.UnitCostField; - } - set - { - this.UnitCostField = value; - } - } - } - - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")] - [System.ServiceModel.ServiceContractAttribute(Namespace="http://Microsoft.ServiceModel.Samples", ConfigurationName="Microsoft.ServiceModel.Samples.IOrderProcessor")] - public interface IOrderProcessor - { - - [System.ServiceModel.OperationContractAttribute(IsOneWay=true, Action="http://Microsoft.ServiceModel.Samples/IOrderProcessor/SubmitPurchaseOrder")] - void SubmitPurchaseOrder(Microsoft.ServiceModel.Samples.PurchaseOrder po); - } - - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")] - public interface IOrderProcessorChannel : Microsoft.ServiceModel.Samples.IOrderProcessor, System.ServiceModel.IClientChannel - { - } - - [System.Diagnostics.DebuggerStepThroughAttribute()] - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")] - public partial class OrderProcessorClient : System.ServiceModel.ClientBase, Microsoft.ServiceModel.Samples.IOrderProcessor - { - - public OrderProcessorClient() - { - } - - public OrderProcessorClient(string endpointConfigurationName) : - base(endpointConfigurationName) - { - } - - public OrderProcessorClient(string endpointConfigurationName, string remoteAddress) : - base(endpointConfigurationName, remoteAddress) - { - } - - public OrderProcessorClient(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) : - base(endpointConfigurationName, remoteAddress) - { - } - - public OrderProcessorClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) : - base(binding, remoteAddress) - { - } - - public void SubmitPurchaseOrder(Microsoft.ServiceModel.Samples.PurchaseOrder po) - { - base.Channel.SubmitPurchaseOrder(po); - } - } -} - diff --git a/samples/snippets/csharp/VS_Snippets_CFX/s_msmqtowcf/cs/client.cs b/samples/snippets/csharp/VS_Snippets_CFX/s_msmqtowcf/cs/client.cs deleted file mode 100644 index 7b95fc98b6e9a..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CFX/s_msmqtowcf/cs/client.cs +++ /dev/null @@ -1,54 +0,0 @@ - -// Copyright (c) Microsoft Corporation. All Rights Reserved. - -using System; -using System.Collections.Generic; -using System.Text; -using System.Messaging; -using System.Configuration; -using System.Transactions; -namespace Microsoft.ServiceModel.Samples -{ - class Program - { - static void Main(string[] args) - { - //Connect to the queue. - MessageQueue orderQueue = new MessageQueue(@"FormatName:Direct=OS:" + ConfigurationManager.AppSettings["orderQueueName"]); - - // Create the purchase order. - PurchaseOrder po = new PurchaseOrder(); - po.customerId = "somecustomer.com"; - po.poNumber = Guid.NewGuid().ToString(); - - PurchaseOrderLineItem lineItem1 = new PurchaseOrderLineItem(); - lineItem1.productId = "Blue Widget"; - lineItem1.quantity = 54; - lineItem1.unitCost = 29.99F; - - PurchaseOrderLineItem lineItem2 = new PurchaseOrderLineItem(); - lineItem2.productId = "Red Widget"; - lineItem2.quantity = 890; - lineItem2.unitCost = 45.89F; - - po.orderLineItems = new PurchaseOrderLineItem[2]; - po.orderLineItems[0] = lineItem1; - po.orderLineItems[1] = lineItem2; - - // Submit the purchase order. - Message msg = new Message(); - msg.Body = po; - //Create a transaction scope. - using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required)) - { - - orderQueue.Send(msg, MessageQueueTransactionType.Automatic); - // Complete the transaction. - scope.Complete(); - } - Console.WriteLine("Placed the order:{0}", po); - Console.WriteLine("Press to terminate client."); - Console.ReadLine(); - } - } -} diff --git a/samples/snippets/csharp/VS_Snippets_CFX/s_msmqtowcf/cs/order.cs b/samples/snippets/csharp/VS_Snippets_CFX/s_msmqtowcf/cs/order.cs deleted file mode 100644 index 3c07d19e86389..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CFX/s_msmqtowcf/cs/order.cs +++ /dev/null @@ -1,84 +0,0 @@ - -// Copyright (c) Microsoft Corporation. All Rights Reserved. - -using System; -using System.Text; - -namespace Microsoft.ServiceModel.Samples -{ - // Define the purchase order line item. - [Serializable] - public class PurchaseOrderLineItem - { - - public string productId; - public float unitCost; - public int quantity; - - public override string ToString() - { - String displayString = "Order LineItem: " + quantity + " of " + productId + " @unit price: $" + unitCost + "\n"; - return displayString; - } - - public float TotalCost - { - get { return unitCost * quantity; } - } - } - public enum OrderStates - { - Pending, - Processed, - Shipped - } - - // Define the purchase order. - [Serializable] - public class PurchaseOrder - { - public string poNumber; - public string customerId; - public PurchaseOrderLineItem[] orderLineItems; - public OrderStates orderStatus; - - public float TotalCost - { - get - { - float totalCost = 0; - foreach (PurchaseOrderLineItem lineItem in orderLineItems) - totalCost += lineItem.TotalCost; - return totalCost; - } - } - - public OrderStates Status - { - get - { - return orderStatus; - } - set - { - orderStatus = value; - } - } - - public override string ToString() - { - StringBuilder strbuf = new StringBuilder("Purchase Order: " + poNumber + "\n"); - strbuf.Append("\tCustomer: " + customerId + "\n"); - strbuf.Append("\tOrderDetails\n"); - - foreach (PurchaseOrderLineItem lineItem in orderLineItems) - { - strbuf.Append("\t\t" + lineItem.ToString()); - } - - strbuf.Append("\tTotal cost of this order: $" + TotalCost + "\n"); - strbuf.Append("\tOrder status: " + Status + "\n"); - return strbuf.ToString(); - } - } -} \ No newline at end of file diff --git a/samples/snippets/csharp/VS_Snippets_CFX/s_service_session/cs/client.cs b/samples/snippets/csharp/VS_Snippets_CFX/s_service_session/cs/client.cs deleted file mode 100644 index 97559c9450860..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CFX/s_service_session/cs/client.cs +++ /dev/null @@ -1,46 +0,0 @@ - -// Copyright (c) Microsoft Corporation. All Rights Reserved. - -using System; -using System.ServiceModel; - -namespace Microsoft.ServiceModel.Samples -{ - //The service contract is defined in a file generated from the service by the svcutil tool. - - //Client implementation code. - class Client - { - static void Main() - { - // Create a WCF client with given client endpoint configuration - CalculatorSessionClient wcfClient = new CalculatorSessionClient(); - try - { - wcfClient.Clear(); - wcfClient.AddTo(100.0D); - wcfClient.SubtractFrom(50.0D); - wcfClient.MultiplyBy(17.65D); - wcfClient.DivideBy(2.0D); - double result = wcfClient.Equals(); - Console.WriteLine("0 + 100 - 50 * 17.65 / 2 = {0}", result); - } - catch (TimeoutException timeProblem) - { - Console.WriteLine("The service operation timed out. " + timeProblem.Message); - Console.ReadLine(); - wcfClient.Abort(); - } - catch (CommunicationException commProblem) - { - Console.WriteLine("There was a communication problem. " + commProblem.Message + commProblem.StackTrace); - Console.ReadLine(); - wcfClient.Abort(); - } - - Console.WriteLine(); - Console.WriteLine("Press to terminate client."); - Console.ReadLine(); - } - } -} diff --git a/samples/snippets/csharp/VS_Snippets_CFX/s_service_session/cs/generatedproxy.cs b/samples/snippets/csharp/VS_Snippets_CFX/s_service_session/cs/generatedproxy.cs deleted file mode 100644 index 791af3d7f43d9..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CFX/s_service_session/cs/generatedproxy.cs +++ /dev/null @@ -1,103 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:2.0.50727.42 -// -// 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("System.ServiceModel", "3.0.0.0")] - [System.ServiceModel.ServiceContractAttribute(Namespace="http://Microsoft.ServiceModel.Samples", SessionMode=System.ServiceModel.SessionMode.Required)] - public interface ICalculatorSession - { - - [System.ServiceModel.OperationContractAttribute(IsOneWay=true, Action="http://Microsoft.ServiceModel.Samples/ICalculatorSession/Clear")] - void Clear(); - - [System.ServiceModel.OperationContractAttribute(IsOneWay=true, Action="http://Microsoft.ServiceModel.Samples/ICalculatorSession/AddTo")] - void AddTo(double n); - - [System.ServiceModel.OperationContractAttribute(IsOneWay=true, Action="http://Microsoft.ServiceModel.Samples/ICalculatorSession/SubtractFrom")] - void SubtractFrom(double n); - - [System.ServiceModel.OperationContractAttribute(IsOneWay=true, Action="http://Microsoft.ServiceModel.Samples/ICalculatorSession/MultiplyBy")] - void MultiplyBy(double n); - - [System.ServiceModel.OperationContractAttribute(IsOneWay=true, Action="http://Microsoft.ServiceModel.Samples/ICalculatorSession/DivideBy")] - void DivideBy(double n); - - [System.ServiceModel.OperationContractAttribute(Action="http://Microsoft.ServiceModel.Samples/ICalculatorSession/Equals", ReplyAction="http://Microsoft.ServiceModel.Samples/ICalculatorSession/EqualsResponse")] - double Equals(); - } - - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")] - public interface ICalculatorSessionChannel : ICalculatorSession, System.ServiceModel.IClientChannel - { - } - - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")] - public partial class CalculatorSessionClient : System.ServiceModel.ClientBase, ICalculatorSession - { - - public CalculatorSessionClient() - { - } - - public CalculatorSessionClient(string endpointConfigurationName) : - base(endpointConfigurationName) - { - } - - public CalculatorSessionClient(string endpointConfigurationName, string remoteAddress) : - base(endpointConfigurationName, remoteAddress) - { - } - - public CalculatorSessionClient(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) : - base(endpointConfigurationName, remoteAddress) - { - } - - public CalculatorSessionClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) : - base(binding, remoteAddress) - { - } - - public void Clear() - { - base.Channel.Clear(); - } - - public void AddTo(double n) - { - base.Channel.AddTo(n); - } - - public void SubtractFrom(double n) - { - base.Channel.SubtractFrom(n); - } - - public void MultiplyBy(double n) - { - base.Channel.MultiplyBy(n); - } - - public void DivideBy(double n) - { - base.Channel.DivideBy(n); - } - - public double Equals() - { - return base.Channel.Equals(); - } - } -} diff --git a/samples/snippets/csharp/VS_Snippets_CFX/s_ue_msmq_poison/cs/client.cs b/samples/snippets/csharp/VS_Snippets_CFX/s_ue_msmq_poison/cs/client.cs deleted file mode 100644 index 113667f0daa98..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CFX/s_ue_msmq_poison/cs/client.cs +++ /dev/null @@ -1,68 +0,0 @@ - -// Copyright (c) Microsoft Corporation. All Rights Reserved. - -using System; -using System.Configuration; -using System.Messaging; -using System.ServiceModel; -using System.Transactions; - -namespace Microsoft.ServiceModel.Samples -{ - //The service contract is defined in generatedProxy.cs, generated from the service by the svcutil tool. - - //Client implementation code. - class Client - { - static void Main() - { - // Create a proxy with given client endpoint configuration. - OrderProcessorClient wcfClient = new OrderProcessorClient("OrderProcessorEndpoint"); - try - { - // Create the purchase order. - PurchaseOrder po = new PurchaseOrder(); - po.CustomerId = "somecustomer.com"; - po.PONumber = Guid.NewGuid().ToString(); - - PurchaseOrderLineItem lineItem1 = new PurchaseOrderLineItem(); - lineItem1.ProductId = "Blue Widget"; - lineItem1.Quantity = 54; - lineItem1.UnitCost = 29.99F; - - PurchaseOrderLineItem lineItem2 = new PurchaseOrderLineItem(); - lineItem2.ProductId = "Red Widget"; - lineItem2.Quantity = 890; - lineItem2.UnitCost = 45.89F; - - po.orderLineItems = new PurchaseOrderLineItem[2]; - po.orderLineItems[0] = lineItem1; - po.orderLineItems[1] = lineItem2; - - //Create a transaction scope. - using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required)) - { - // Make a queued call to submit the purchase order. - wcfClient.SubmitPurchaseOrder(po); - // Complete the transaction. - scope.Complete(); - } - } - catch (TimeoutException timeProblem) - { - Console.WriteLine("The service operation timed out. " + timeProblem.Message); - Console.ReadLine(); - wcfClient.Abort(); - } - catch (CommunicationException commProblem) - { - Console.WriteLine("There was a communication problem. " + commProblem.Message + commProblem.StackTrace); - Console.ReadLine(); - wcfClient.Abort(); - } - Console.WriteLine(); - Console.WriteLine("Press to terminate client."); - Console.ReadLine(); - } - } -} diff --git a/samples/snippets/csharp/VS_Snippets_CFX/s_ue_msmq_poison/cs/generatedproxy.cs b/samples/snippets/csharp/VS_Snippets_CFX/s_ue_msmq_poison/cs/generatedproxy.cs deleted file mode 100644 index 81ce9befdb3a1..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CFX/s_ue_msmq_poison/cs/generatedproxy.cs +++ /dev/null @@ -1,191 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:2.0.50727.12 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -// Do not add data members to types. Will cause serialization to fail. -namespace Microsoft.ServiceModel.Samples -{ - using System.Runtime.Serialization; - using System.ServiceModel.Channels; - - - [System.Runtime.Serialization.DataContractAttribute()] - public partial class PurchaseOrder : object, System.Runtime.Serialization.IExtensibleDataObject - { - - private System.Runtime.Serialization.ExtensionDataObject extensionDataField; - - private string CustomerIdField; - - private string PONumberField; - - private Microsoft.ServiceModel.Samples.PurchaseOrderLineItem[] orderLineItemsField; - - public System.Runtime.Serialization.ExtensionDataObject ExtensionData - { - get - { - return this.extensionDataField; - } - set - { - this.extensionDataField = value; - } - } - - [System.Runtime.Serialization.DataMemberAttribute()] - public string CustomerId - { - get - { - return this.CustomerIdField; - } - set - { - this.CustomerIdField = value; - } - } - - [System.Runtime.Serialization.DataMemberAttribute()] - public string PONumber - { - get - { - return this.PONumberField; - } - set - { - this.PONumberField = value; - } - } - - [System.Runtime.Serialization.DataMemberAttribute()] - public Microsoft.ServiceModel.Samples.PurchaseOrderLineItem[] orderLineItems - { - get - { - return this.orderLineItemsField; - } - set - { - this.orderLineItemsField = value; - } - } - } - - [System.Runtime.Serialization.DataContractAttribute()] - public partial class PurchaseOrderLineItem : object, System.Runtime.Serialization.IExtensibleDataObject - { - - private System.Runtime.Serialization.ExtensionDataObject extensionDataField; - - private string ProductIdField; - - private int QuantityField; - - private float UnitCostField; - - public System.Runtime.Serialization.ExtensionDataObject ExtensionData - { - get - { - return this.extensionDataField; - } - set - { - this.extensionDataField = value; - } - } - - [System.Runtime.Serialization.DataMemberAttribute()] - public string ProductId - { - get - { - return this.ProductIdField; - } - set - { - this.ProductIdField = value; - } - } - - [System.Runtime.Serialization.DataMemberAttribute()] - public int Quantity - { - get - { - return this.QuantityField; - } - set - { - this.QuantityField = value; - } - } - - [System.Runtime.Serialization.DataMemberAttribute()] - public float UnitCost - { - get - { - return this.UnitCostField; - } - set - { - this.UnitCostField = value; - } - } - } -} - - -[System.ServiceModel.ServiceContractAttribute(Namespace="http://Microsoft.ServiceModel.Samples")] -public interface IOrderProcessor -{ - - [System.ServiceModel.OperationContractAttribute(IsOneWay=true, Action="http://Microsoft.ServiceModel.Samples/IOrderProcessor/SubmitPurchaseOrder")] - void SubmitPurchaseOrder(Microsoft.ServiceModel.Samples.PurchaseOrder po); -} - -public interface IOrderProcessorChannel : IOrderProcessor, System.ServiceModel.IClientChannel -{ -} - -public partial class OrderProcessorClient : System.ServiceModel.ClientBase, IOrderProcessor -{ - - public OrderProcessorClient() - { - } - - public OrderProcessorClient(string endpointConfigurationName) : - base(endpointConfigurationName) - { - } - - public OrderProcessorClient(string endpointConfigurationName, string remoteAddress) : - base(endpointConfigurationName, remoteAddress) - { - } - - public OrderProcessorClient(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) : - base(endpointConfigurationName, remoteAddress) - { - } - - public OrderProcessorClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) : - base(binding, remoteAddress) - { - } - - public void SubmitPurchaseOrder(Microsoft.ServiceModel.Samples.PurchaseOrder po) - { - base.Channel.SubmitPurchaseOrder(po); - } -} diff --git a/samples/snippets/csharp/VS_Snippets_CFX/s_ue_msmq_poison/cs/hostapp.cs b/samples/snippets/csharp/VS_Snippets_CFX/s_ue_msmq_poison/cs/hostapp.cs deleted file mode 100644 index 72adf1f436afa..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CFX/s_ue_msmq_poison/cs/hostapp.cs +++ /dev/null @@ -1,59 +0,0 @@ -using System; -using System.ServiceModel.Channels; -using System.Configuration; -using System.Messaging; -using System.ServiceModel; -using System.Transactions; -using System.Runtime.Serialization; -using System.Collections.Generic; -using System.Text; - -namespace Microsoft.ServiceModel.Samples - -{ - class HostApp - { - // This sample only runs on Windows Vista. - // Host the service within this EXE console application. - public static void Main() - { - // Get the MSMQ queue name from appsettings in configuration. - string queueName = ConfigurationManager.AppSettings["queueName"]; - - // Create the transacted MSMQ queue if necessary. - if (!MessageQueue.Exists(queueName)) - MessageQueue.Create(queueName, true); - - // Get the base address that is used to listen for WS-MetaDataExchange requests. - // This is useful to generate a proxy for the client. - string baseAddress = ConfigurationManager.AppSettings["baseAddress"]; - - // Create a ServiceHost for the OrderProcessorService type. - ServiceHost serviceHost = new ServiceHost(typeof(OrderProcessorService), new Uri(baseAddress)); - try - { - // Open the ServiceHostBase to create listeners and start listening for messages. - serviceHost.Open(); - - // The service can now be accessed. - Console.WriteLine("The service is ready."); - Console.WriteLine("Press to terminate service."); - Console.WriteLine(); - Console.ReadLine(); - - // Close the ServiceHostBase to shutdown the service. - serviceHost.Close(); - } - catch (TimeoutException timeProblem) - { - Console.WriteLine("The service operation timed out. " + timeProblem.Message); - Console.ReadLine(); - } - catch (CommunicationException commProblem) - { - Console.WriteLine("There was a communication problem. " + commProblem.Message + commProblem.StackTrace); - Console.ReadLine(); - } - } - } -} diff --git a/samples/snippets/csharp/VS_Snippets_CFX/s_ue_msmq_poison/cs/pmservice.cs b/samples/snippets/csharp/VS_Snippets_CFX/s_ue_msmq_poison/cs/pmservice.cs deleted file mode 100644 index 15cbf2656b9cd..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CFX/s_ue_msmq_poison/cs/pmservice.cs +++ /dev/null @@ -1,163 +0,0 @@ - -// Copyright (c) Microsoft Corporation. All Rights Reserved. - -using System; - -using System.ServiceModel.Description; -using System.Configuration; -using System.Messaging; -using System.ServiceModel; -using System.ServiceModel.Channels; -using System.Transactions; -using System.Runtime.Serialization; -using System.Collections.Generic; -using System.Text; - -namespace Microsoft.ServiceModel.Samples -{ - // Define the purchase order line item. - [DataContract] - public class PurchaseOrderLineItem - { - [DataMember] - public string ProductId; - - [DataMember] - public float UnitCost; - - [DataMember] - public int Quantity; - - public override string ToString() - { - String displayString = "Order LineItem: " + Quantity + " of " + ProductId + " @unit price: $" + UnitCost + "\n"; - return displayString; - } - - public float TotalCost - { - get { return UnitCost * Quantity; } - } - } - - // Define the purchase order. - [DataContract] - public class PurchaseOrder - { - static readonly string[] OrderStates = { "Pending", "Processed", "Shipped" }; - static Random statusIndexer = new Random(137); - - [DataMember] - public string PONumber; - - [DataMember] - public string CustomerId; - - [DataMember] - public PurchaseOrderLineItem[] orderLineItems; - - public float TotalCost - { - get - { - float totalCost = 0; - foreach (PurchaseOrderLineItem lineItem in orderLineItems) - totalCost += lineItem.TotalCost; - return totalCost; - } - } - - public string Status - { - get - { - return OrderStates[statusIndexer.Next(3)]; - } - } - - public override string ToString() - { - StringBuilder strbuf = new StringBuilder("Purchase Order: " + PONumber + "\n"); - strbuf.Append("\tCustomer: " + CustomerId + "\n"); - strbuf.Append("\tOrderDetails\n"); - - foreach (PurchaseOrderLineItem lineItem in orderLineItems) - { - strbuf.Append("\t\t" + lineItem.ToString()); - } - - strbuf.Append("\tTotal cost of this order: $" + TotalCost + "\n"); - strbuf.Append("\tOrder status: " + Status + "\n"); - return strbuf.ToString(); - } - } - - // Order Processing Logic - // Can replace with transaction-aware resource such as SQL or transacted hashtable to hold the purchase orders. - // This example uses a non-transactional resource. - public class Orders - { - static Dictionary purchaseOrders = new Dictionary(); - - public static void Add(PurchaseOrder po) - { - purchaseOrders.Add(po.PONumber, po); - } - - public static string GetOrderStatus(string poNumber) - { - PurchaseOrder po; - if (purchaseOrders.TryGetValue(poNumber, out po)) - return po.Status; - else - return null; - } - - public static void DeleteOrder(string poNumber) - { - if (purchaseOrders[poNumber] != null) - purchaseOrders.Remove(poNumber); - } - } - - // Define a service contract. - [ServiceContract(Namespace = "http://Microsoft.ServiceModel.Samples")] - public interface IOrderProcessor - { - [OperationContract(IsOneWay = true)] - void SubmitPurchaseOrder(PurchaseOrder po); - } - - // Service class that implements the service contract. - // Added code to write output to the console window. - [ServiceBehavior(AddressFilterMode=AddressFilterMode.Any)] - public class OrderProcessorService : IOrderProcessor - { - [OperationBehavior(TransactionScopeRequired = true, TransactionAutoComplete = true)] - public void SubmitPurchaseOrder(PurchaseOrder po) - { - Orders.Add(po); - Console.WriteLine("Processing {0} ", po); - } - - // Host the service within this EXE console application. - public static void Main() - { - - // Create a ServiceHost for the OrderProcessorService type. - using (ServiceHost serviceHost = new ServiceHost(typeof(OrderProcessorService))) - { - serviceHost.Open(); - - // The service can now be accessed. - Console.WriteLine("The service is ready."); - Console.WriteLine("Press to terminate service."); - Console.WriteLine(); - Console.ReadLine(); - - // Close the ServiceHostBase to shutdown the service. - serviceHost.Close(); - } - } - } -} diff --git a/samples/snippets/csharp/VS_Snippets_CFX/s_uehelloworld/cs/client.cs b/samples/snippets/csharp/VS_Snippets_CFX/s_uehelloworld/cs/client.cs deleted file mode 100644 index b69f8a410b8dd..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CFX/s_uehelloworld/cs/client.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Client -{ - class Client - { - static void Main(string[] args) - { - using (HelloClient client = new HelloClient()) - { - string s = client.SayHello("Frodo"); - Console.WriteLine(s); - } - - Console.WriteLine(); - Console.WriteLine("Press to terminate client"); - Console.ReadLine(); - } - } -} diff --git a/samples/snippets/csharp/VS_Snippets_CFX/s_uehelloworld/cs/helloservice.cs b/samples/snippets/csharp/VS_Snippets_CFX/s_uehelloworld/cs/helloservice.cs deleted file mode 100644 index b22b0f3346978..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CFX/s_uehelloworld/cs/helloservice.cs +++ /dev/null @@ -1,60 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:2.0.50727.42 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - - - -[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")] -[System.ServiceModel.ServiceContractAttribute(ConfigurationName="IHello")] -public interface IHello -{ - - [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IHello/SayHello", ReplyAction="http://tempuri.org/IHello/SayHelloResponse")] - string SayHello(string name); -} - -[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")] -public interface IHelloChannel : IHello, System.ServiceModel.IClientChannel -{ -} - -[System.Diagnostics.DebuggerStepThroughAttribute()] -[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")] -public partial class HelloClient : System.ServiceModel.ClientBase, IHello -{ - - public HelloClient() - { - } - - public HelloClient(string endpointConfigurationName) : - base(endpointConfigurationName) - { - } - - public HelloClient(string endpointConfigurationName, string remoteAddress) : - base(endpointConfigurationName, remoteAddress) - { - } - - public HelloClient(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) : - base(endpointConfigurationName, remoteAddress) - { - } - - public HelloClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) : - base(binding, remoteAddress) - { - } - - public string SayHello(string name) - { - return base.Channel.SayHello(name); - } -} diff --git a/samples/snippets/csharp/VS_Snippets_CFX/s_uehelloworld/cs/service.cs b/samples/snippets/csharp/VS_Snippets_CFX/s_uehelloworld/cs/service.cs deleted file mode 100644 index cccdae5882ccb..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CFX/s_uehelloworld/cs/service.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System; -using System.ServiceModel; - -namespace UE.Samples -{ - - [ServiceContract] - public interface IHello - { - [OperationContract] - string SayHello(string name); - } - - class HelloService : IHello - { - public string SayHello(string name) - { - return "Hello " + name; - } - - static void Main(string[] args) - { - Uri baseAddress = new Uri("http://localhost:8000/HelloService"); - using (ServiceHost serviceHost = new ServiceHost(typeof(HelloService), baseAddress)) - { - serviceHost.Open(); - Console.WriteLine("Press to terminate service"); - Console.ReadLine(); - serviceHost.Close(); - } - } - } -} diff --git a/samples/snippets/csharp/VS_Snippets_CFX/s_wcftomsmq/cs/order.cs b/samples/snippets/csharp/VS_Snippets_CFX/s_wcftomsmq/cs/order.cs deleted file mode 100644 index 74a2a37e4732e..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CFX/s_wcftomsmq/cs/order.cs +++ /dev/null @@ -1,85 +0,0 @@ - -// Copyright (c) Microsoft Corporation. All Rights Reserved. - -using System; -using System.Text; - -namespace Microsoft.ServiceModel.Samples -{ - // Define the purchase order line item. - [Serializable] - public class PurchaseOrderLineItem - { - - public string productId; - public float unitCost; - public int quantity; - - public override string ToString() - { - String displayString = "Order LineItem: " + quantity + " of " + productId + " @unit price: $" + unitCost + "\n"; - return displayString; - } - - public float TotalCost - { - get { return unitCost * quantity; } - } - } - - public enum OrderStates - { - Pending, - Processed, - Shipped - } - - // Define the purchase order. - [Serializable] - public class PurchaseOrder - { - public string poNumber; - public string customerId; - public PurchaseOrderLineItem[] orderLineItems; - public OrderStates orderStatus; - - public float TotalCost - { - get - { - float totalCost = 0; - foreach (PurchaseOrderLineItem lineItem in orderLineItems) - totalCost += lineItem.TotalCost; - return totalCost; - } - } - - public OrderStates Status - { - get - { - return orderStatus; - } - set - { - orderStatus = value; - } - } - - public override string ToString() - { - StringBuilder strbuf = new StringBuilder("Purchase Order: " + poNumber + "\n"); - strbuf.Append("\tCustomer: " + customerId + "\n"); - strbuf.Append("\tOrderDetails\n"); - - foreach (PurchaseOrderLineItem lineItem in orderLineItems) - { - strbuf.Append("\t\t" + lineItem.ToString()); - } - - strbuf.Append("\tTotal cost of this order: $" + TotalCost + "\n"); - strbuf.Append("\tOrder status: " + Status + "\n"); - return strbuf.ToString(); - } - } -} \ No newline at end of file diff --git a/samples/snippets/csharp/VS_Snippets_CFX/s_wcftomsmq/cs/service.cs b/samples/snippets/csharp/VS_Snippets_CFX/s_wcftomsmq/cs/service.cs deleted file mode 100644 index 38eccce9213c1..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CFX/s_wcftomsmq/cs/service.cs +++ /dev/null @@ -1,54 +0,0 @@ - -// Copyright (c) Microsoft Corporation. All Rights Reserved. - -using System; -using System.Collections.Generic; -using System.Text; -using System.Messaging; -using System.Configuration; - -namespace Microsoft.ServiceModel.Samples -{ - class Program - { - static void Main(string[] args) - { - - // Create a transaction queue using System.Messaging API - // You can also choose to not do this and instead create the - // queue using MSMQ MMC. Make sure you create a transactional queue. - - if (!MessageQueue.Exists(ConfigurationManager.AppSettings["queueName"])) - MessageQueue.Create(ConfigurationManager.AppSettings["queueName"], true); - - //Connect to the queue. - MessageQueue Queue = new MessageQueue(ConfigurationManager.AppSettings["queueName"]); - - Queue.ReceiveCompleted += new ReceiveCompletedEventHandler(ProcessOrder); - Queue.BeginReceive(); - Console.WriteLine("Order Service is running"); - Console.ReadLine(); - } - - public static void ProcessOrder(Object source,ReceiveCompletedEventArgs asyncResult) - { - try - { - // Connect to the queue. - MessageQueue Queue = (MessageQueue)source; - // End the asynchronous receive operation. - System.Messaging.Message msg = Queue.EndReceive(asyncResult.AsyncResult); - msg.Formatter = new System.Messaging.XmlMessageFormatter(new Type[] { typeof(PurchaseOrder) }); - PurchaseOrder po = (PurchaseOrder) msg.Body; - Random statusIndexer = new Random(); - po.Status = (OrderStates)statusIndexer.Next(3); - Console.WriteLine("Processing {0} ", po); - Queue.BeginReceive(); - } - catch (System.Exception ex) - { - Console.WriteLine(ex.Message); - } - } - } -} diff --git a/samples/snippets/csharp/VS_Snippets_CFX/s_ws_dualhttp/cs/client.cs b/samples/snippets/csharp/VS_Snippets_CFX/s_ws_dualhttp/cs/client.cs deleted file mode 100644 index 0328d0ae2c740..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CFX/s_ws_dualhttp/cs/client.cs +++ /dev/null @@ -1,78 +0,0 @@ - -// Copyright (c) Microsoft Corporation. All Rights Reserved. - -using System; -using System.ServiceModel; - -namespace Microsoft.ServiceModel.Samples -{ - // The service contract is defined in generatedProxy.cs, generated from the service by the svcutil tool. - - // Define class which implements callback interface of duplex contract - public class CallbackHandler : ICalculatorDuplexCallback - { - public void Equals(double result) - { - Console.WriteLine("Equals({0})", result); - } - - public void Equation(string eqn) - { - Console.WriteLine("Equation({0})", eqn); - } - } - - class Client - { - static void Main() - { - // Construct InstanceContext to handle messages on callback interface - InstanceContext instanceContext = new InstanceContext(new CallbackHandler()); - - // Create a proxy with given client endpoint configuration - CalculatorDuplexClient wcfClient = new CalculatorDuplexClient(instanceContext); - try - { - // Call the AddTo service operation. - double value = 100.00D; - wcfClient.AddTo(value); - - // Call the SubtractFrom service operation. - value = 50.00D; - wcfClient.SubtractFrom(value); - - // Call the MultiplyBy service operation. - value = 17.65D; - wcfClient.MultiplyBy(value); - - // Call the DivideBy service operation. - value = 2.00D; - wcfClient.DivideBy(value); - - // Complete equation - wcfClient.Clear(); - - // Wait for callback messages to complete before closing - System.Threading.Thread.Sleep(500); - - wcfClient.Close(); - } - catch (TimeoutException timeProblem) - { - Console.WriteLine("The service operation timed out. " + timeProblem.Message); - Console.ReadLine(); - wcfClient.Abort(); - } - catch (CommunicationException commProblem) - { - Console.WriteLine("There was a communication problem. " + commProblem.Message + commProblem.StackTrace); - Console.ReadLine(); - wcfClient.Abort(); - } - - Console.WriteLine(); - Console.WriteLine("Press to terminate client."); - Console.ReadLine(); - } - } -} diff --git a/samples/snippets/csharp/VS_Snippets_CFX/s_ws_dualhttp/cs/generatedproxy.cs b/samples/snippets/csharp/VS_Snippets_CFX/s_ws_dualhttp/cs/generatedproxy.cs deleted file mode 100644 index 869c9b94d51d1..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CFX/s_ws_dualhttp/cs/generatedproxy.cs +++ /dev/null @@ -1,112 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:2.0.50727.42 -// -// 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("System.ServiceModel", "3.0.0.0")] - [System.ServiceModel.ServiceContractAttribute(Namespace = "http://Microsoft.ServiceModel.Samples", CallbackContract = typeof(ICalculatorDuplexCallback), SessionMode=System.ServiceModel.SessionMode.Required)] - public interface ICalculatorDuplex - { - - [System.ServiceModel.OperationContractAttribute(IsOneWay = true, Action = "http://Microsoft.ServiceModel.Samples/ICalculatorDuplex/Clear")] - void Clear(); - - [System.ServiceModel.OperationContractAttribute(IsOneWay = true, Action = "http://Microsoft.ServiceModel.Samples/ICalculatorDuplex/AddTo")] - void AddTo(double n); - - [System.ServiceModel.OperationContractAttribute(IsOneWay = true, Action = "http://Microsoft.ServiceModel.Samples/ICalculatorDuplex/SubtractFrom")] - void SubtractFrom(double n); - - [System.ServiceModel.OperationContractAttribute(IsOneWay = true, Action = "http://Microsoft.ServiceModel.Samples/ICalculatorDuplex/MultiplyBy")] - void MultiplyBy(double n); - - [System.ServiceModel.OperationContractAttribute(IsOneWay = true, Action = "http://Microsoft.ServiceModel.Samples/ICalculatorDuplex/DivideBy")] - void DivideBy(double n); - } - - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")] - public interface ICalculatorDuplexCallback - { - - [System.ServiceModel.OperationContractAttribute(IsOneWay = true, Action = "http://Microsoft.ServiceModel.Samples/ICalculatorDuplex/Equals")] - void Equals(double result); - - [System.ServiceModel.OperationContractAttribute(IsOneWay = true, Action = "http://Microsoft.ServiceModel.Samples/ICalculatorDuplex/Equation")] - void Equation(string eqn); - } - - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")] - public interface ICalculatorDuplexChannel : ICalculatorDuplex, System.ServiceModel.IClientChannel - { - } - - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")] - public partial class CalculatorDuplexClient : System.ServiceModel.DuplexClientBase, ICalculatorDuplex - { - - public CalculatorDuplexClient(System.ServiceModel.InstanceContext callbackInstance) - : - base(callbackInstance) - { - } - - public CalculatorDuplexClient(System.ServiceModel.InstanceContext callbackInstance, string endpointConfigurationName) - : - base(callbackInstance, endpointConfigurationName) - { - } - - public CalculatorDuplexClient(System.ServiceModel.InstanceContext callbackInstance, string endpointConfigurationName, string remoteAddress) - : - base(callbackInstance, endpointConfigurationName, remoteAddress) - { - } - - public CalculatorDuplexClient(System.ServiceModel.InstanceContext callbackInstance, string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) - : - base(callbackInstance, endpointConfigurationName, remoteAddress) - { - } - - public CalculatorDuplexClient(System.ServiceModel.InstanceContext callbackInstance, System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) - : - base(callbackInstance, binding, remoteAddress) - { - } - - public void Clear() - { - base.Channel.Clear(); - } - - public void AddTo(double n) - { - base.Channel.AddTo(n); - } - - public void SubtractFrom(double n) - { - base.Channel.SubtractFrom(n); - } - - public void MultiplyBy(double n) - { - base.Channel.MultiplyBy(n); - } - - public void DivideBy(double n) - { - base.Channel.DivideBy(n); - } - } -} diff --git a/samples/snippets/csharp/VS_Snippets_CFX/s_wsdl_client/cs/client.cs b/samples/snippets/csharp/VS_Snippets_CFX/s_wsdl_client/cs/client.cs deleted file mode 100644 index 1898ce3841999..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CFX/s_wsdl_client/cs/client.cs +++ /dev/null @@ -1,51 +0,0 @@ - -// Copyright (c) Microsoft Corporation. All Rights Reserved. - -using System; -using System.ServiceModel; - -namespace Microsoft.ServiceModel.Samples -{ - // The service contract is defined in generatedClient.cs, generated from the service by the svcutil tool. - - // Client implementation code. - class Client - { - static void Main() - { - // Create a client. - CalculatorClient client = new CalculatorClient(); - - // Call the Add service operation. - double value1 = 100.00D; - double value2 = 15.99D; - double result = client.Add(value1, value2); - Console.WriteLine("Add({0},{1}) = {2}", value1, value2, result); - - // Call the Subtract service operation. - value1 = 145.00D; - value2 = 76.54D; - result = client.Subtract(value1, value2); - Console.WriteLine("Subtract({0},{1}) = {2}", value1, value2, result); - - // Call the Multiply service operation. - value1 = 9.00D; - value2 = 81.25D; - result = client.Multiply(value1, value2); - Console.WriteLine("Multiply({0},{1}) = {2}", value1, value2, result); - - // Call the Divide service operation. - value1 = 22.00D; - value2 = 7.00D; - result = client.Divide(value1, value2); - Console.WriteLine("Divide({0},{1}) = {2}", value1, value2, result); - - // Closing the client gracefully closes the connection and cleans up resources. - client.Close(); - - Console.WriteLine(); - Console.WriteLine("Press to terminate client."); - Console.ReadLine(); - } - } -} diff --git a/samples/snippets/csharp/VS_Snippets_CFX/s_wsdl_client/cs/generatedclient.cs b/samples/snippets/csharp/VS_Snippets_CFX/s_wsdl_client/cs/generatedclient.cs deleted file mode 100644 index 446b0848d8cff..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CFX/s_wsdl_client/cs/generatedclient.cs +++ /dev/null @@ -1,88 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:2.0.50727.42 -// -// 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("System.ServiceModel", "3.0.0.0")] - [System.ServiceModel.ServiceContractAttribute(Namespace="http://Microsoft.ServiceModel.Samples", ConfigurationName="Microsoft.ServiceModel.Samples.ICalculator")] - public interface ICalculator - { - - [System.ServiceModel.OperationContractAttribute(Action="http://Microsoft.ServiceModel.Samples/ICalculator/Add", ReplyAction="http://Microsoft.ServiceModel.Samples/ICalculator/AddResponse")] - double Add(double n1, double n2); - - [System.ServiceModel.OperationContractAttribute(Action="http://Microsoft.ServiceModel.Samples/ICalculator/Subtract", ReplyAction="http://Microsoft.ServiceModel.Samples/ICalculator/SubtractResponse")] - double Subtract(double n1, double n2); - - [System.ServiceModel.OperationContractAttribute(Action="http://Microsoft.ServiceModel.Samples/ICalculator/Multiply", ReplyAction="http://Microsoft.ServiceModel.Samples/ICalculator/MultiplyResponse")] - double Multiply(double n1, double n2); - - [System.ServiceModel.OperationContractAttribute(Action="http://Microsoft.ServiceModel.Samples/ICalculator/Divide", ReplyAction="http://Microsoft.ServiceModel.Samples/ICalculator/DivideResponse")] - double Divide(double n1, double n2); - } - - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")] - public interface ICalculatorChannel : Microsoft.ServiceModel.Samples.ICalculator, System.ServiceModel.IClientChannel - { - } - - [System.Diagnostics.DebuggerStepThroughAttribute()] - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")] - public partial class CalculatorClient : System.ServiceModel.ClientBase, Microsoft.ServiceModel.Samples.ICalculator - { - - public CalculatorClient() - { - } - - public CalculatorClient(string endpointConfigurationName) : - base(endpointConfigurationName) - { - } - - public CalculatorClient(string endpointConfigurationName, string remoteAddress) : - base(endpointConfigurationName, remoteAddress) - { - } - - public CalculatorClient(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) : - base(endpointConfigurationName, remoteAddress) - { - } - - public CalculatorClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) : - base(binding, remoteAddress) - { - } - - public double Add(double n1, double n2) - { - return base.Channel.Add(n1, n2); - } - - public double Subtract(double n1, double n2) - { - return base.Channel.Subtract(n1, n2); - } - - public double Multiply(double n1, double n2) - { - return base.Channel.Multiply(n1, n2); - } - - public double Divide(double n1, double n2) - { - return base.Channel.Divide(n1, n2); - } - } -} diff --git a/samples/snippets/csharp/VS_Snippets_CFX/sca.isinitiatingisterminating/cs/client.cs b/samples/snippets/csharp/VS_Snippets_CFX/sca.isinitiatingisterminating/cs/client.cs deleted file mode 100644 index cea3d62f3eee2..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CFX/sca.isinitiatingisterminating/cs/client.cs +++ /dev/null @@ -1,30 +0,0 @@ - -// Copyright (c) Microsoft Corporation. All Rights Reserved. - -using System; -using System.ServiceModel; - -namespace Microsoft.ServiceModel.Samples -{ - //The service contract is defined in generatedwcfClient.cs, generated from the service by the svcutil tool. - - //Client implementation code. - class Client - { - static void Main() - { - // Create a wcfClient with given client endpoint configuration - CalculatorSessionClient wcfClient = new CalculatorSessionClient(); - wcfClient.Clear(); - wcfClient.AddTo(100.0D); - wcfClient.SubtractFrom(50.0D); - wcfClient.MultiplyBy(17.65D); - wcfClient.DivideBy(2.0D); - double result = wcfClient.Equals(); - Console.WriteLine("0 + 100 - 50 * 17.65 / 2 = {0}", result); - Console.WriteLine(); - Console.WriteLine("Press to terminate client."); - Console.ReadLine(); - } - } -} diff --git a/samples/snippets/csharp/VS_Snippets_CFX/sca.isinitiatingisterminating/cs/generatedproxy.cs b/samples/snippets/csharp/VS_Snippets_CFX/sca.isinitiatingisterminating/cs/generatedproxy.cs deleted file mode 100644 index 791af3d7f43d9..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CFX/sca.isinitiatingisterminating/cs/generatedproxy.cs +++ /dev/null @@ -1,103 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:2.0.50727.42 -// -// 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("System.ServiceModel", "3.0.0.0")] - [System.ServiceModel.ServiceContractAttribute(Namespace="http://Microsoft.ServiceModel.Samples", SessionMode=System.ServiceModel.SessionMode.Required)] - public interface ICalculatorSession - { - - [System.ServiceModel.OperationContractAttribute(IsOneWay=true, Action="http://Microsoft.ServiceModel.Samples/ICalculatorSession/Clear")] - void Clear(); - - [System.ServiceModel.OperationContractAttribute(IsOneWay=true, Action="http://Microsoft.ServiceModel.Samples/ICalculatorSession/AddTo")] - void AddTo(double n); - - [System.ServiceModel.OperationContractAttribute(IsOneWay=true, Action="http://Microsoft.ServiceModel.Samples/ICalculatorSession/SubtractFrom")] - void SubtractFrom(double n); - - [System.ServiceModel.OperationContractAttribute(IsOneWay=true, Action="http://Microsoft.ServiceModel.Samples/ICalculatorSession/MultiplyBy")] - void MultiplyBy(double n); - - [System.ServiceModel.OperationContractAttribute(IsOneWay=true, Action="http://Microsoft.ServiceModel.Samples/ICalculatorSession/DivideBy")] - void DivideBy(double n); - - [System.ServiceModel.OperationContractAttribute(Action="http://Microsoft.ServiceModel.Samples/ICalculatorSession/Equals", ReplyAction="http://Microsoft.ServiceModel.Samples/ICalculatorSession/EqualsResponse")] - double Equals(); - } - - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")] - public interface ICalculatorSessionChannel : ICalculatorSession, System.ServiceModel.IClientChannel - { - } - - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")] - public partial class CalculatorSessionClient : System.ServiceModel.ClientBase, ICalculatorSession - { - - public CalculatorSessionClient() - { - } - - public CalculatorSessionClient(string endpointConfigurationName) : - base(endpointConfigurationName) - { - } - - public CalculatorSessionClient(string endpointConfigurationName, string remoteAddress) : - base(endpointConfigurationName, remoteAddress) - { - } - - public CalculatorSessionClient(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) : - base(endpointConfigurationName, remoteAddress) - { - } - - public CalculatorSessionClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) : - base(binding, remoteAddress) - { - } - - public void Clear() - { - base.Channel.Clear(); - } - - public void AddTo(double n) - { - base.Channel.AddTo(n); - } - - public void SubtractFrom(double n) - { - base.Channel.SubtractFrom(n); - } - - public void MultiplyBy(double n) - { - base.Channel.MultiplyBy(n); - } - - public void DivideBy(double n) - { - base.Channel.DivideBy(n); - } - - public double Equals() - { - return base.Channel.Equals(); - } - } -} diff --git a/samples/snippets/csharp/VS_Snippets_CFX/syndicationmapping/cs/program.cs b/samples/snippets/csharp/VS_Snippets_CFX/syndicationmapping/cs/program.cs deleted file mode 100644 index 3d01a35411e91..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CFX/syndicationmapping/cs/program.cs +++ /dev/null @@ -1,120 +0,0 @@ -using System; -using System.Collections.ObjectModel; -using System.ServiceModel; -using System.ServiceModel.Description; -using System.ServiceModel.Syndication; -using System.ServiceModel.Web; -using System.Xml; - -namespace FeedMapping -{ - class Program - { - static void Main(string[] args) - { - - //SyndicationFeed feed = new SyndicationFeed("My Feed Title", "My Feed Description", new Uri("http://MyFeedURI")); - //feed.Copyright = new TextSyndicationContent("Copyright 2007"); - //feed.Language = "EN-US"; - //feed.LastUpdatedTime = DateTime.Now; - //feed.Generator = "Sample Code"; - //feed.Id = "FeedID"; - //feed.ImageUrl = new Uri("http://server/image.jpg"); - - //SyndicationCategory category = new SyndicationCategory("MyCategory"); - //category.Label = "categoryLabel"; - //category.Name = "categoryName"; - //category.Scheme = "categoryScheme"; - //feed.Categories.Add(category); - - //SyndicationCategory category2 = new SyndicationCategory("MyCategoryTwo"); - //category2.Label = "categoryLabel"; - //category2.Name = "categoryName"; - //category2.Scheme = "categoryScheme"; - //feed.Categories.Add(category2); - - //SyndicationItem item = new SyndicationItem("Item Title", "Item Content", new Uri("http://MyItemURI")); - //item.Authors.Add(new SyndicationPerson("Jesper@Aaberg.com", "Jesper Aaberg", "http://Jesper/Aaberg")); - //item.Authors.Add(new SyndicationPerson("Syed@Abbas.com", "Syed Abbas", "http://Syed/Abbas")); - //item.Categories.Add(category); - //item.Categories.Add(category2); - //item.Contributors.Add(new SyndicationPerson("Lene@Aaling.com", "Lene Aaling", "http://Lene/Aaling")); - //item.Contributors.Add(new SyndicationPerson("Kim@Abercrombie.com", "Kim Abercrombie", "http://Kim/Abercrombie")); - //item.Copyright = new TextSyndicationContent("Copyright 2007"); - //item.Id = "ItemID"; - //item.LastUpdatedTime = DateTime.Now; - //item.PublishDate = DateTime.Today; - //item.SourceFeed = feed; - //item.Summary = new TextSyndicationContent("Item Summary"); - //feed.Items = new Collection(); - //((Collection)feed.Items).Add(item); - - //SyndicationItem htmlItem = new SyndicationItem(); - //htmlItem.Id = "htmlItemId"; - //htmlItem.LastUpdatedTime = DateTime.Now; - //htmlItem.PublishDate = DateTime.Today; - //htmlItem.SourceFeed = feed; - //htmlItem.Summary = new TextSyndicationContent("Html Item Summary"); - //htmlItem.Title = new TextSyndicationContent("Html Item Title"); - //htmlItem.Content = new TextSyndicationContent(" some html ", TextSyndicationContentKind.Html); - //((Collection)feed.Items).Add(htmlItem); - - //SyndicationItem urlItem = new SyndicationItem(); - //urlItem.Id = "urlItemId"; - //urlItem.LastUpdatedTime = DateTime.Now; - //urlItem.PublishDate = DateTime.Today; - //urlItem.SourceFeed = feed; - //urlItem.Summary = new TextSyndicationContent("URL Item Summary"); - //urlItem.Title = new TextSyndicationContent("URL Item Title"); - //urlItem.Content = new UrlSyndicationContent(new Uri("http://someUrl"), "audio"); - //((Collection)feed.Items).Add(urlItem); - - //SyndicationItem xmlItem = new SyndicationItem(); - //xmlItem.Id = "urlItemId"; - //xmlItem.LastUpdatedTime = DateTime.Now; - //xmlItem.PublishDate = DateTime.Today; - //xmlItem.SourceFeed = feed; - //xmlItem.Summary = new TextSyndicationContent("URL Item Summary"); - //XmlDocument doc = new XmlDocument(); - //XmlElement xmlElement = doc.CreateElement("MyXmlElement", "http://MyElements"); - //xmlItem.Title = new TextSyndicationContent("Xml Item Title"); - //xmlItem.Content = new XmlSyndicationContent("mytype", new SyndicationElementExtension(xmlElement)); - //((Collection)feed.Items).Add(xmlItem); - - //SyndicationItem xhtmlItem = new SyndicationItem(); - //xhtmlItem.Id = "xhtmlItemId"; - //xhtmlItem.LastUpdatedTime = DateTime.Now; - //xhtmlItem.PublishDate = DateTime.Today; - //xhtmlItem.SourceFeed = feed; - //xhtmlItem.Summary = new TextSyndicationContent("Html Item Summary"); - //xhtmlItem.Title = new TextSyndicationContent("Html Item Title"); - //xhtmlItem.Content = new TextSyndicationContent(" some xhtml ", TextSyndicationContentKind.XHtml); - //((Collection)feed.Items).Add(xhtmlItem); - - //SyndicationLink link = new SyndicationLink(new Uri("http://some/link"), "alternate", "Link Title", "text/html", 2048); - //feed.Links.Add(link); - - ///* - //// Add custom attribute - //XmlQualifiedName xqName = new XmlQualifiedName("CustomFeedAttribute"); - //feed.AttributeExtensions.Add(xqName, "value"); - - //// Add custom element - //XmlDocument doc = new XmlDocument(); - //XmlElement feedElement = doc.CreateElement("CustomFeedElement", "http://CustomFeeds"); - //feedElement.InnerText = "Feed Element Text"; - //feed.ElementExtensions.Add(feedElement); - //*/ - - //Atom10FeedFormatter atomFormatter = feed.GetAtom10Formatter(); - //Rss20FeedFormatter rssFormatter = feed.GetRss20Formatter(); - - //XmlWriter atomWriter = XmlWriter.Create("atom.xml"); - //XmlWriter rssWriter = XmlWriter.Create("rss.xml"); - //atomFormatter.WriteTo(atomWriter); - //rssFormatter.WriteTo(rssWriter); - //atomWriter.Close(); - //rssWriter.Close(); - } - } -} diff --git a/samples/snippets/csharp/VS_Snippets_CFX/ue_importmetadata/cs/service.cs b/samples/snippets/csharp/VS_Snippets_CFX/ue_importmetadata/cs/service.cs deleted file mode 100644 index e9659eaf954bd..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CFX/ue_importmetadata/cs/service.cs +++ /dev/null @@ -1,81 +0,0 @@ - -// Copyright (c) Microsoft Corporation. All Rights Reserved. - -using System; -using System.Configuration; -using System.ServiceModel; - -namespace Microsoft.ServiceModel.Samples -{ - // Define a service contract. - [ServiceContract(Namespace="http://Microsoft.ServiceModel.Samples")] - public interface ICalculator - { - [OperationContract] - double Add(double n1, double n2); - [OperationContract] - double Subtract(double n1, double n2); - [OperationContract] - double Multiply(double n1, double n2); - [OperationContract] - double Divide(double n1, double n2); - } - - // This service class implements the service contract. - // Added code to write output to the console window. - public class CalculatorService : ICalculator - { - public double Add(double n1, double n2) - { - double result = n1 + n2; - Console.WriteLine("Received Add({0},{1})", n1, n2); - Console.WriteLine("Return: {0}", result); - return result; - } - - public double Subtract(double n1, double n2) - { - double result = n1 - n2; - Console.WriteLine("Received Subtract({0},{1})", n1, n2); - Console.WriteLine("Return: {0}", result); - return result; - } - - public double Multiply(double n1, double n2) - { - double result = n1 * n2; - Console.WriteLine("Received Multiply({0},{1})", n1, n2); - Console.WriteLine("Return: {0}", result); - return result; - } - - public double Divide(double n1, double n2) - { - double result = n1 / n2; - Console.WriteLine("Received Divide({0},{1})", n1, n2); - Console.WriteLine("Return: {0}", result); - return result; - } - - // Host the service within this EXE console application. - public static void Main() - { - // Create a ServiceHost for the CalculatorService type. - using (ServiceHost serviceHost = new ServiceHost(typeof(CalculatorService))) - { - - // Open the ServiceHost to create listeners and start listening for messages. - serviceHost.Open(); - - // The service can now be accessed. - Console.WriteLine("The service is ready."); - Console.WriteLine("Press to terminate service."); - Console.WriteLine(); - Console.ReadLine(); - - // Close the ServiceHost to shut down the service. - serviceHost.Close(); - } - } - } -} diff --git a/samples/snippets/csharp/VS_Snippets_CLR/ADApplicationBase/CS/adapplicationbase.cs b/samples/snippets/csharp/VS_Snippets_CLR/ADApplicationBase/CS/adapplicationbase.cs deleted file mode 100644 index 3c466b46396a5..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CLR/ADApplicationBase/CS/adapplicationbase.cs +++ /dev/null @@ -1,32 +0,0 @@ -// -using System; - -class ADSetupInformation -{ - static void Main() - { - AppDomain root = AppDomain.CurrentDomain; - - AppDomainSetup setup = new AppDomainSetup(); - setup.ApplicationBase = - root.SetupInformation.ApplicationBase + @"MyAppSubfolder\"; - - AppDomain domain = AppDomain.CreateDomain("MyDomain", null, setup); - - Console.WriteLine("Application base of {0}:\r\n\t{1}", - root.FriendlyName, root.SetupInformation.ApplicationBase); - Console.WriteLine("Application base of {0}:\r\n\t{1}", - domain.FriendlyName, domain.SetupInformation.ApplicationBase); - - AppDomain.Unload(domain); - } -} - -/* This example produces output similar to the following: - -Application base of MyApp.exe: - C:\Program Files\MyApp\ -Application base of MyDomain: - C:\Program Files\MyApp\MyAppSubfolder\ - */ -// diff --git a/samples/snippets/csharp/VS_Snippets_CLR/AsyncDesignPattern/CS/Factorizer.cs b/samples/snippets/csharp/VS_Snippets_CLR/AsyncDesignPattern/CS/Factorizer.cs deleted file mode 100644 index 5bdc782617691..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CLR/AsyncDesignPattern/CS/Factorizer.cs +++ /dev/null @@ -1,140 +0,0 @@ -// -using System; -using System.Threading; -using System.Runtime.Remoting.Messaging; - -namespace Examples.AdvancedProgramming.AsynchronousOperations -{ - // Create a class that factors a number. - public class PrimeFactorFinder - { - public static bool Factorize( - int number, - ref int primefactor1, - ref int primefactor2) - { - primefactor1 = 1; - primefactor2 = number; - - // Factorize using a low-tech approach. - for (int i=2;i diff --git a/samples/snippets/csharp/VS_Snippets_CLR/CatchException/CS/Project.csproj b/samples/snippets/csharp/VS_Snippets_CLR/CatchException/CS/Project.csproj deleted file mode 100644 index b83f0211b39c5..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CLR/CatchException/CS/Project.csproj +++ /dev/null @@ -1,7 +0,0 @@ - - - - Library - net6.0 - - diff --git a/samples/snippets/csharp/VS_Snippets_CLR/CatchException/CS/catchexception.cs b/samples/snippets/csharp/VS_Snippets_CLR/CatchException/CS/catchexception.cs deleted file mode 100644 index cc7736bf616c3..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CLR/CatchException/CS/catchexception.cs +++ /dev/null @@ -1,30 +0,0 @@ -// -using System; - -class ExceptionTestClass -{ - public static void Main() - { - int x = 0; - try - { - int y = 100 / x; - } - catch (ArithmeticException e) - { - Console.WriteLine($"ArithmeticException Handler: {e}"); - } - catch (Exception e) - { - Console.WriteLine($"Generic Exception Handler: {e}"); - } - } -} -/* -This code example produces the following results: - -ArithmeticException Handler: System.DivideByZeroException: Attempted to divide by zero. - at ExceptionTestClass.Main() - -*/ -// diff --git a/samples/snippets/csharp/VS_Snippets_CLR/CatchException/CS/catchexception3.cs b/samples/snippets/csharp/VS_Snippets_CLR/CatchException/CS/catchexception3.cs deleted file mode 100644 index e717e69b2afd4..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CLR/CatchException/CS/catchexception3.cs +++ /dev/null @@ -1,26 +0,0 @@ -// -using System; -using System.IO; - -public class ProcessFile -{ - public static void Main() - { - try - { - StreamReader sr = File.OpenText("data.txt"); - Console.WriteLine("The first line of this file is {0}", sr.ReadLine()); - } - // - catch (FileNotFoundException e) - { - Console.WriteLine("[Data File Missing] {0}", e); - } - // - catch (Exception e) - { - Console.WriteLine("An error occurred: '{0}'", e); - } - } -} -// diff --git a/samples/snippets/csharp/VS_Snippets_CLR/CodeDomExample/CS/source.cs b/samples/snippets/csharp/VS_Snippets_CLR/CodeDomExample/CS/source.cs deleted file mode 100644 index 25e7f55ad8f4e..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CLR/CodeDomExample/CS/source.cs +++ /dev/null @@ -1,298 +0,0 @@ -// -using System; -using System.CodeDom; -using System.CodeDom.Compiler; -using System.Collections; -using System.ComponentModel; -using System.Diagnostics; -using System.Drawing; -using System.IO; -using System.Windows.Forms; -using Microsoft.CSharp; -using Microsoft.VisualBasic; -using Microsoft.JScript; - -// This example demonstrates building a Hello World program graph -// using System.CodeDom elements. It calls code generator and -// code compiler methods to build the program using CSharp, VB, or -// JScript. A Windows Forms interface is included. Note: Code -// must be compiled and linked with the Microsoft.JScript assembly. -namespace CodeDOMExample -{ - class CodeDomExample - { - // - // Build a Hello World program graph using - // System.CodeDom types. - public static CodeCompileUnit BuildHelloWorldGraph() - { - // Create a new CodeCompileUnit to contain - // the program graph. - CodeCompileUnit compileUnit = new CodeCompileUnit(); - - // Declare a new namespace called Samples. - CodeNamespace samples = new CodeNamespace("Samples"); - // Add the new namespace to the compile unit. - compileUnit.Namespaces.Add(samples); - - // Add the new namespace import for the System namespace. - samples.Imports.Add(new CodeNamespaceImport("System")); - - // Declare a new type called Class1. - CodeTypeDeclaration class1 = new CodeTypeDeclaration("Class1"); - // Add the new type to the namespace type collection. - samples.Types.Add(class1); - - // Declare a new code entry point method. - CodeEntryPointMethod start = new CodeEntryPointMethod(); - - // Create a type reference for the System.Console class. - CodeTypeReferenceExpression csSystemConsoleType = new CodeTypeReferenceExpression("System.Console"); - - // Build a Console.WriteLine statement. - CodeMethodInvokeExpression cs1 = new CodeMethodInvokeExpression( - csSystemConsoleType, "WriteLine", - new CodePrimitiveExpression("Hello World!")); - - // Add the WriteLine call to the statement collection. - start.Statements.Add(cs1); - - // Build another Console.WriteLine statement. - CodeMethodInvokeExpression cs2 = new CodeMethodInvokeExpression( - csSystemConsoleType, "WriteLine", - new CodePrimitiveExpression("Press the Enter key to continue.")); - - // Add the WriteLine call to the statement collection. - start.Statements.Add(cs2); - - // Build a call to System.Console.ReadLine. - CodeMethodInvokeExpression csReadLine = new CodeMethodInvokeExpression( - csSystemConsoleType, "ReadLine"); - - // Add the ReadLine statement. - start.Statements.Add(csReadLine); - - // Add the code entry point method to - // the Members collection of the type. - class1.Members.Add(start); - - return compileUnit; - } - // - - // - public static void GenerateCode(CodeDomProvider provider, - CodeCompileUnit compileunit) - { - // Build the source file name with the appropriate - // language extension. - String sourceFile; - if (provider.FileExtension[0] == '.') - { - sourceFile = "TestGraph" + provider.FileExtension; - } - else - { - sourceFile = "TestGraph." + provider.FileExtension; - } - - // Create an IndentedTextWriter, constructed with - // a StreamWriter to the source file. - IndentedTextWriter tw = new IndentedTextWriter(new StreamWriter(sourceFile, false), " "); - // Generate source code using the code generator. - provider.GenerateCodeFromCompileUnit(compileunit, tw, new CodeGeneratorOptions()); - // Close the output file. - tw.Close(); - } - // - - // - public static CompilerResults CompileCode(CodeDomProvider provider, - String sourceFile, - String exeFile) - { - // Configure a CompilerParameters that links System.dll - // and produces the specified executable file. - String[] referenceAssemblies = { "System.dll" }; - CompilerParameters cp = new CompilerParameters(referenceAssemblies, - exeFile, false); - // Generate an executable rather than a DLL file. - cp.GenerateExecutable = true; - - // Invoke compilation. - CompilerResults cr = provider.CompileAssemblyFromFile(cp, sourceFile); - // Return the results of compilation. - return cr; - } - // - } - - public class CodeDomExampleForm : System.Windows.Forms.Form - { - private System.Windows.Forms.Button run_button = new System.Windows.Forms.Button(); - private System.Windows.Forms.Button compile_button = new System.Windows.Forms.Button(); - private System.Windows.Forms.Button generate_button = new System.Windows.Forms.Button(); - private System.Windows.Forms.TextBox textBox1 = new System.Windows.Forms.TextBox(); - private System.Windows.Forms.ComboBox comboBox1 = new System.Windows.Forms.ComboBox(); - private System.Windows.Forms.Label label1 = new System.Windows.Forms.Label(); - - private void generate_button_Click(object sender, System.EventArgs e) - { - CodeDomProvider provider = GetCurrentProvider(); - CodeDomExample.GenerateCode(provider, CodeDomExample.BuildHelloWorldGraph()); - - // Build the source file name with the appropriate - // language extension. - String sourceFile; - if (provider.FileExtension[0] == '.') - { - sourceFile = "TestGraph" + provider.FileExtension; - } - else - { - sourceFile = "TestGraph." + provider.FileExtension; - } - - // Read in the generated source file and - // display the source text. - StreamReader sr = new StreamReader(sourceFile); - textBox1.Text = sr.ReadToEnd(); - sr.Close(); - } - - private void compile_button_Click(object sender, System.EventArgs e) - { - CodeDomProvider provider = GetCurrentProvider(); - - // Build the source file name with the appropriate - // language extension. - String sourceFile; - if (provider.FileExtension[0] == '.') - { - sourceFile = "TestGraph" + provider.FileExtension; - } - else - { - sourceFile = "TestGraph." + provider.FileExtension; - } - - // Compile the source file into an executable output file. - CompilerResults cr = CodeDomExample.CompileCode(provider, - sourceFile, - "TestGraph.exe"); - - if (cr.Errors.Count > 0) - { - // Display compilation errors. - textBox1.Text = "Errors encountered while building " + - sourceFile + " into " + cr.PathToAssembly + ": \r\n\n"; - foreach (CompilerError ce in cr.Errors) - textBox1.AppendText(ce.ToString() + "\r\n"); - run_button.Enabled = false; - } - else - { - textBox1.Text = "Source " + sourceFile + " built into " + - cr.PathToAssembly + " with no errors."; - run_button.Enabled = true; - } - } - - private void run_button_Click(object sender, - System.EventArgs e) - { - Process.Start("TestGraph.exe"); - } - - private CodeDomProvider GetCurrentProvider() - { - CodeDomProvider provider; - switch ((string)this.comboBox1.SelectedItem) - { - case "CSharp": - provider = CodeDomProvider.CreateProvider("CSharp"); - break; - case "Visual Basic": - provider = CodeDomProvider.CreateProvider("VisualBasic"); - break; - case "JScript": - provider = CodeDomProvider.CreateProvider("JScript"); - break; - default: - provider = CodeDomProvider.CreateProvider("CSharp"); - break; - } - return provider; - } - - public CodeDomExampleForm() - { - this.SuspendLayout(); - // Set properties for label1 - this.label1.Location = new System.Drawing.Point(395, 20); - this.label1.Size = new Size(180, 22); - this.label1.Text = "Select a programming language:"; - // Set properties for comboBox1 - this.comboBox1.Location = new System.Drawing.Point(560, 16); - this.comboBox1.Size = new Size(190, 23); - this.comboBox1.Name = "comboBox1"; - this.comboBox1.Items.AddRange(new string[] { "CSharp", "Visual Basic", "JScript" }); - this.comboBox1.Anchor = System.Windows.Forms.AnchorStyles.Left - | System.Windows.Forms.AnchorStyles.Right - | System.Windows.Forms.AnchorStyles.Top; - this.comboBox1.SelectedIndex = 0; - // Set properties for generate_button. - this.generate_button.Location = new System.Drawing.Point(8, 16); - this.generate_button.Name = "generate_button"; - this.generate_button.Size = new System.Drawing.Size(120, 23); - this.generate_button.Text = "Generate Code"; - this.generate_button.Click += new System.EventHandler(this.generate_button_Click); - // Set properties for compile_button. - this.compile_button.Location = new System.Drawing.Point(136, 16); - this.compile_button.Name = "compile_button"; - this.compile_button.Size = new System.Drawing.Size(120, 23); - this.compile_button.Text = "Compile"; - this.compile_button.Click += new System.EventHandler(this.compile_button_Click); - // Set properties for run_button. - this.run_button.Enabled = false; - this.run_button.Location = new System.Drawing.Point(264, 16); - this.run_button.Name = "run_button"; - this.run_button.Size = new System.Drawing.Size(120, 23); - this.run_button.Text = "Run"; - this.run_button.Click += new System.EventHandler(this.run_button_Click); - // Set properties for textBox1. - this.textBox1.Anchor = (System.Windows.Forms.AnchorStyles.Top - | System.Windows.Forms.AnchorStyles.Bottom - | System.Windows.Forms.AnchorStyles.Left - | System.Windows.Forms.AnchorStyles.Right); - this.textBox1.Location = new System.Drawing.Point(8, 48); - this.textBox1.Multiline = true; - this.textBox1.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; - this.textBox1.Name = "textBox1"; - this.textBox1.Size = new System.Drawing.Size(744, 280); - this.textBox1.Text = ""; - // Set properties for the CodeDomExampleForm. - this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); - this.ClientSize = new System.Drawing.Size(768, 340); - this.MinimumSize = new System.Drawing.Size(750, 340); - this.Controls.AddRange(new System.Windows.Forms.Control[] {this.textBox1, - this.run_button, this.compile_button, this.generate_button, - this.comboBox1, this.label1 }); - this.Name = "CodeDomExampleForm"; - this.Text = "CodeDom Hello World Example"; - this.ResumeLayout(false); - } - - protected override void Dispose(bool disposing) - { - base.Dispose(disposing); - } - - [STAThread] - static void Main() - { - Application.Run(new CodeDomExampleForm()); - } - } -} -// \ No newline at end of file diff --git a/samples/snippets/csharp/VS_Snippets_CLR/CodeDomHelloWorldSample/cs/source1.cs b/samples/snippets/csharp/VS_Snippets_CLR/CodeDomHelloWorldSample/cs/source1.cs deleted file mode 100644 index c2a55106bb2d5..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CLR/CodeDomHelloWorldSample/cs/source1.cs +++ /dev/null @@ -1,110 +0,0 @@ -// -using System; -using System.CodeDom; -using System.CodeDom.Compiler; -using System.IO; -using Microsoft.CSharp; - -public class CodeDOMSample -{ - public static void Main() - { - string sourceFile; - int dotSpot; - - CodeCompileUnit cu = new CodeCompileUnit(); - sourceFile = GenerateCSharpCode(cu); - Console.WriteLine("CS source file: {0}", sourceFile); - dotSpot = sourceFile.IndexOf('.'); - CompileCSharpCode(sourceFile, sourceFile.Substring(0, dotSpot) + ".exe"); - } - - // - public static string GenerateCSharpCode(CodeCompileUnit compileunit) - { - // Generate the code with the C# code provider. - // - CSharpCodeProvider provider = new CSharpCodeProvider(); - // - - // Build the output file name. - string sourceFile; - if (provider.FileExtension[0] == '.') - { - sourceFile = "HelloWorld" + provider.FileExtension; - } - else - { - sourceFile = "HelloWorld." + provider.FileExtension; - } - - // Create a TextWriter to a StreamWriter to the output file. - IndentedTextWriter tw = new IndentedTextWriter( - new StreamWriter(sourceFile, false), " "); - - // Generate source code using the code provider. - provider.GenerateCodeFromCompileUnit(compileunit, tw, - new CodeGeneratorOptions()); - - // Close the output file. - tw.Close(); - - return sourceFile; - } - // - - // - public static bool CompileCSharpCode(string sourceFile, - string exeFile) - { - CSharpCodeProvider provider = new CSharpCodeProvider(); - - // Build the parameters for source compilation. - CompilerParameters cp = new CompilerParameters(); - - // Add an assembly reference. - cp.ReferencedAssemblies.Add( "System.dll" ); - - // Generate an executable instead of - // a class library. - cp.GenerateExecutable = true; - - // Set the assembly file name to generate. - cp.OutputAssembly = exeFile; - - // Save the assembly as a physical file. - cp.GenerateInMemory = false; - - // Invoke compilation. - CompilerResults cr = provider.CompileAssemblyFromFile(cp, sourceFile); - - if (cr.Errors.Count > 0) - { - // Display compilation errors. - Console.WriteLine("Errors building {0} into {1}", - sourceFile, cr.PathToAssembly); - foreach(CompilerError ce in cr.Errors) - { - Console.WriteLine(" {0}", ce.ToString()); - Console.WriteLine(); - } - } - else - { - Console.WriteLine("Source {0} built into {1} successfully.", - sourceFile, cr.PathToAssembly); - } - - // Return the results of compilation. - if (cr.Errors.Count > 0) - { - return false; - } - else - { - return true; - } - } - // -} -// diff --git a/samples/snippets/csharp/VS_Snippets_CLR/CodeTryCatchFinallyExample/CS/codetrycatchfinallyexample.cs b/samples/snippets/csharp/VS_Snippets_CLR/CodeTryCatchFinallyExample/CS/codetrycatchfinallyexample.cs deleted file mode 100644 index 1b722e4176501..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CLR/CodeTryCatchFinallyExample/CS/codetrycatchfinallyexample.cs +++ /dev/null @@ -1,79 +0,0 @@ -// -using System; -using System.CodeDom; - -namespace CodeDomSamples -{ - public class CodeTryCatchFinallyExample - { - public CodeTryCatchFinallyExample() - { - // - // Declares a type to contain a try...catch block. - CodeTypeDeclaration type1 = new CodeTypeDeclaration("TryCatchTest"); - - // Defines a method that throws an exception of type System.ApplicationException. - CodeMemberMethod method1 = new CodeMemberMethod(); - method1.Name = "ThrowApplicationException"; - method1.Statements.Add( new CodeThrowExceptionStatement( - new CodeObjectCreateExpression("System.ApplicationException", new CodePrimitiveExpression("Test Application Exception")) ) ); - type1.Members.Add( method1 ); - - // Defines a constructor that calls the ThrowApplicationException method from a try block. - CodeConstructor constructor1 = new CodeConstructor(); - constructor1.Attributes = MemberAttributes.Public; - type1.Members.Add( constructor1 ); - - // Defines a try statement that calls the ThrowApplicationException method. - CodeTryCatchFinallyStatement try1 = new CodeTryCatchFinallyStatement(); - try1.TryStatements.Add( new CodeMethodInvokeExpression( new CodeThisReferenceExpression(), "ThrowApplicationException" ) ); - constructor1.Statements.Add( try1 ); - - // Defines a catch clause for exceptions of type ApplicationException. - CodeCatchClause catch1 = new CodeCatchClause("ex", new CodeTypeReference("System.ApplicationException")); - catch1.Statements.Add( new CodeCommentStatement("Handle any System.ApplicationException here.") ); - try1.CatchClauses.Add( catch1 ); - - // Defines a catch clause for any remaining unhandled exception types. - CodeCatchClause catch2 = new CodeCatchClause("ex"); - catch2.Statements.Add( new CodeCommentStatement("Handle any other exception type here.") ); - try1.CatchClauses.Add( catch2 ); - - // Defines a finally block by adding to the FinallyStatements collection. - try1.FinallyStatements.Add( new CodeCommentStatement("Handle any finally block statements.") ); - - // A C# code generator produces the following source code for the preceeding example code: - - // public class TryCatchTest - // { - // - // public TryCatchTest() - // { - // try - // { - // this.ThrowApplicationException(); - // } - // catch (System.ApplicationException ex) - // { - // // Handle any System.ApplicationException here. - // } - // catch (System.Exception ex) - // { - // // Handle any other exception type here. - // } - // finally { - // // Handle any finally block statements. - // } - // } - // - // private void ThrowApplicationException() - // { - // throw new System.ApplicationException("Test Application Exception"); - // } - // } - - // - } - } -} -// \ No newline at end of file diff --git a/samples/snippets/csharp/VS_Snippets_CLR/RegularExpressions.Examples.Email/cs/Example.cs b/samples/snippets/csharp/VS_Snippets_CLR/RegularExpressions.Examples.Email/cs/Example.cs deleted file mode 100644 index 543b22c0329b1..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CLR/RegularExpressions.Examples.Email/cs/Example.cs +++ /dev/null @@ -1,39 +0,0 @@ -// -using System; -using System.Text.RegularExpressions; - -public class RegexUtilities -{ - public static bool IsValidEmail(string strIn) - { - // Return true if strIn is in valid email format. - return Regex.IsMatch(strIn, - @"^([0-9a-zA-Z]([-\.\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})$"); - } -} -// - -// -public class Application -{ - public static void Main() - { - string[] emailAddresses = { "david.jones@proseware.com", "d.j@server1.proseware.com", - "jones@ms1.proseware.com", "j.@server1.proseware.com", - "j@proseware.com9" }; - foreach (string emailAddress in emailAddresses) - { - if (RegexUtilities.IsValidEmail(emailAddress)) - Console.WriteLine("Valid: {0}", emailAddress); - else - Console.WriteLine("Invalid: {0}", emailAddress); - } - } -} -// The example displays the following output: -// Valid: david.jones@proseware.com -// Valid: d.j@server1.proseware.com -// Valid: jones@ms1.proseware.com -// Invalid: j.@server1.proseware.com -// Invalid: j@proseware.com9 -// diff --git a/samples/snippets/csharp/VS_Snippets_CLR/RegularExpressions.Examples.Email/cs/example2.cs b/samples/snippets/csharp/VS_Snippets_CLR/RegularExpressions.Examples.Email/cs/example2.cs deleted file mode 100644 index 43f93a17979be..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CLR/RegularExpressions.Examples.Email/cs/example2.cs +++ /dev/null @@ -1,50 +0,0 @@ -// -using System; -using System.Text.RegularExpressions; - -public class RegexUtilities -{ - public static bool IsValidEmail(string strIn) - { - // Return true if strIn is in valid email format. - return Regex.IsMatch(strIn, - @"^(?("")(""[^""]+?""@)|(([0-9a-zA-Z]((\.(?!\.))|[-!#\$%&'\*\+/=\?\^`\{\}\|~\w])*)(?<=[0-9a-zA-Z])@))" + - @"(?(\[)(\[(\d{1,3}\.){3}\d{1,3}\])|(([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,6}))$"); - } -} -// - -// -public class Application -{ - public static void Main() - { - string[] emailAddresses = { "david.jones@proseware.com", "d.j@server1.proseware.com", - "jones@ms1.proseware.com", "j.@server1.proseware.com", - "j@proseware.com9", "js#internal@proseware.com", - "j_9@[129.126.118.1]", "j..s@proseware.com", - "js*@proseware.com", "js@proseware..com", - "js@proseware.com9", "j.s@server1.proseware.com" }; - foreach (string emailAddress in emailAddresses) - { - if (RegexUtilities.IsValidEmail(emailAddress)) - Console.WriteLine("Valid: {0}", emailAddress); - else - Console.WriteLine("Invalid: {0}", emailAddress); - } - } -} -// The example displays the following output: -// Valid: david.jones@proseware.com -// Valid: d.j@server1.proseware.com -// Valid: jones@ms1.proseware.com -// Invalid: j.@server1.proseware.com -// Invalid: j@proseware.com9 -// Valid: js#internal@proseware.com -// Valid: j_9@[129.126.118.1] -// Invalid: j..s@proseware.com -// Invalid: js*@proseware.com -// Invalid: js@proseware..com -// Invalid: js@proseware.com9 -// Valid: j.s@server1.proseware.com -// diff --git a/samples/snippets/csharp/VS_Snippets_CLR/RegularExpressions.Examples.Email/cs/example3.cs b/samples/snippets/csharp/VS_Snippets_CLR/RegularExpressions.Examples.Email/cs/example3.cs deleted file mode 100644 index ee041c1e92b21..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CLR/RegularExpressions.Examples.Email/cs/example3.cs +++ /dev/null @@ -1,91 +0,0 @@ -// -using System; -using System.Globalization; -using System.Text.RegularExpressions; - -public class RegexUtilities -{ - bool invalid = false; - - public bool IsValidEmail(string strIn) - { - invalid = false; - if (String.IsNullOrEmpty(strIn)) - return false; - - // Use IdnMapping class to convert Unicode domain names. - try { - strIn = Regex.Replace(strIn, @"(@)(.+)$", this.DomainMapper, - RegexOptions.None, TimeSpan.FromMilliseconds(200)); - } - catch (RegexMatchTimeoutException) { - return false; - } - - if (invalid) - return false; - - // Return true if strIn is in valid email format. - try { - return Regex.IsMatch(strIn, - @"^(?("")(""[^""]+?""@)|(([0-9a-z]((\.(?!\.))|[-!#\$%&'\*\+/=\?\^`\{\}\|~\w])*)(?<=[0-9a-z])@))" + - @"(?(\[)(\[(\d{1,3}\.){3}\d{1,3}\])|(([0-9a-z][-\w]*[0-9a-z]*\.)+[a-z0-9]{2,24}))$", - RegexOptions.IgnoreCase, TimeSpan.FromMilliseconds(250)); - } - catch (RegexMatchTimeoutException) { - return false; - } - } - - private string DomainMapper(Match match) - { - // IdnMapping class with default property values. - IdnMapping idn = new IdnMapping(); - - string domainName = match.Groups[2].Value; - try { - domainName = idn.GetAscii(domainName); - } - catch (ArgumentException) { - invalid = true; - } - return match.Groups[1].Value + domainName; - } -} -// - -// -public class Application -{ - public static void Main() - { - RegexUtilities util = new RegexUtilities(); - string[] emailAddresses = { "david.jones@proseware.com", "d.j@server1.proseware.com", - "jones@ms1.proseware.com", "j.@server1.proseware.com", - "j@proseware.com9", "js#internal@proseware.com", - "j_9@[129.126.118.1]", "j..s@proseware.com", - "js*@proseware.com", "js@proseware..com", - "js@proseware.com9", "j.s@server1.proseware.com" }; - - foreach (var emailAddress in emailAddresses) { - if (util.IsValidEmail(emailAddress)) - Console.WriteLine("Valid: {0}", emailAddress); - else - Console.WriteLine("Invalid: {0}", emailAddress); - } - } -} -// The example displays the following output: -// Valid: david.jones@proseware.com -// Valid: d.j@server1.proseware.com -// Valid: jones@ms1.proseware.com -// Invalid: j.@server1.proseware.com -// Valid: j@proseware.com9 -// Valid: js#internal@proseware.com -// Valid: j_9@[129.126.118.1] -// Invalid: j..s@proseware.com -// Invalid: js*@proseware.com -// Invalid: js@proseware..com -// Valid: js@proseware.com9 -// Valid: j.s@server1.proseware.com -// diff --git a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.basicio.textfiles/cs/source.cs b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.basicio.textfiles/cs/source.cs deleted file mode 100644 index 7a6add8235558..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.basicio.textfiles/cs/source.cs +++ /dev/null @@ -1,101 +0,0 @@ -using System; -using System.IO; -using System.Text; -using System.Collections.Generic; - -class WriteTextFiles -{ - static void Main(string[] args) - { - - // Example 1: Shows how to synchronously write to - // a text file using StreamWriter - // line by line - WriteLineByLine(); - - // Example 2: Shows how to synchronously append text to - // an existing file using StreamWriter - AppendTextSW(); - - // Example 3: Shows how to asynchronously write to - // a text file using StreamWriter - WriteTextAsync(); - - // Example 4: Shows how to synchronously write and - // append to a text file using File - WriteFile(); - } - - // Example 1: Write line by line to a new text file with StreamWriter - static void WriteLineByLine() - { - // - - // Create a string array with the lines of text - string[] lines = { "First line", "Second line", "Third line" }; - - // Set a variable to the Documents path. - string docPath = - Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); - - // Write the string array to a new file named "WriteLines.txt". - using (StreamWriter outputFile = new StreamWriter(Path.Combine(docPath,"WriteLines.txt"))) { - foreach (string line in lines) - outputFile.WriteLine(line); - } - // - } - - // Example 2: Append a line to a text file with StreamWriter - static void AppendTextSW() - { - // - - // Set a variable to the Documents path. - string docPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); - - // Append text to an existing file named "WriteLines.txt". - using (StreamWriter outputFile = new StreamWriter(Path.Combine(docPath,"WriteLines.txt"), true)) { - outputFile.WriteLine("Fourth Line"); - } - // - } - - // Example 3: Write text asynchronously with StreamWriter - static async void WriteTextAsync() - { - // - - // Set a variable to the Documents path. - string docPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); - - // Write the specified text asynchronously to a new file named "WriteTextAsync.txt". - using (StreamWriter outputFile = new StreamWriter(Path.Combine(docPath,"WriteTextAsync.txt"))) { - await outputFile.WriteAsync("This is a sentence."); - } - // - } - - // Example 4: Write and append text using File - static void WriteFile() - { - // - - // Create a string array with the lines of text - string text = "First line" + Environment.NewLine; - - // Set a variable to the Documents path. - string docPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); - - // Write the text to a new file named "WriteFile.txt". - File.WriteAllText(Path.Combine(docPath,"WriteFile.txt"), text); - - // Create a string array with the additional lines of text - string[] lines = { "New line 1", "New line 2" }; - - // Append new lines of text to the file - File.AppendAllLines(Path.Combine(docPath,"WriteFile.txt"), lines); - - // - } -} diff --git a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.basicio.textfiles/cs/source4.cs b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.basicio.textfiles/cs/source4.cs deleted file mode 100644 index ad681c69986b9..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.basicio.textfiles/cs/source4.cs +++ /dev/null @@ -1,27 +0,0 @@ -// -using System; -using System.IO; - -public class TextFromFile -{ - private const string FILE_NAME = "MyFile.txt"; - - public static void Main() - { - if (!File.Exists(FILE_NAME)) - { - Console.WriteLine("{0} does not exist.", FILE_NAME); - return; - } - using (StreamReader sr = File.OpenText(FILE_NAME)) - { - String input; - while ((input = sr.ReadLine()) != null) - { - Console.WriteLine(input); - } - Console.WriteLine ("The end of the stream has been reached."); - } - } -} -// diff --git a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.basicio.textfiles/cs/source5.cs b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.basicio.textfiles/cs/source5.cs deleted file mode 100644 index 02f5bef7a6f7a..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.basicio.textfiles/cs/source5.cs +++ /dev/null @@ -1,39 +0,0 @@ -// -using System; -using System.Text; -using System.Windows; -using System.IO; - -namespace WpfApplication -{ - public partial class MainWindow : Window - { - public MainWindow() - { - InitializeComponent(); - } - - private async void AppendButton_Click(object sender, RoutedEventArgs e) - { - // Set a variable to the My Documents path. - string mydocpath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); - - // Create a stringbuilder and write the new user input to it. - StringBuilder sb = new StringBuilder(); - - sb.AppendLine("New User Input"); - sb.AppendLine("= = = = = ="); - sb.Append(UserInputTextBox.Text); - sb.AppendLine(); - sb.AppendLine(); - - // Open a streamwriter to a new text file named "UserInputFile.txt"and write the contents of - // the stringbuilder to it. - using (StreamWriter outfile = new StreamWriter(Path.Combine(mydocpath,"UserInputFile.txt"), true)) - { - await outfile.WriteAsync(sb.ToString()); - } - } - } -} -// diff --git a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.basicio.textfiles/cs/source6.cs b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.basicio.textfiles/cs/source6.cs deleted file mode 100644 index ea33047d7c84d..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.basicio.textfiles/cs/source6.cs +++ /dev/null @@ -1,34 +0,0 @@ -// -using System; -using System.IO; -using System.Windows; - -namespace WpfApp2 -{ - /// - /// Interaction logic for MainWindow.xaml - /// - public partial class MainWindow : Window - { - public MainWindow() - { - InitializeComponent(); - } - private async void ReadFileButton_Click(object sender, RoutedEventArgs e) - { - try - { - using (StreamReader sr = new StreamReader("TestFile.txt")) - { - string line = await sr.ReadToEndAsync(); - ResultBlock.Text = line; - } - } - catch (FileNotFoundException ex) - { - ResultBlock.Text = ex.Message; - } - } - } -} -// diff --git a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.clscompliant/cs/paramarray1.cs b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.clscompliant/cs/paramarray1.cs deleted file mode 100644 index 19ec53ab253f2..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.clscompliant/cs/paramarray1.cs +++ /dev/null @@ -1,31 +0,0 @@ -// -using System; - -[assembly: CLSCompliant(true)] - -public class Group -{ - private string[] members; - - public Group(params string[] memberList) - { - members = memberList; - } - - public override string ToString() - { - return String.Join(", ", members); - } -} - -public class Example -{ - public static void Main() - { - Group gp = new Group("Matthew", "Mark", "Luke", "John"); - Console.WriteLine(gp.ToString()); - } -} -// The example displays the following output: -// Matthew, Mark, Luke, John -// diff --git a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.events.other/cs/example.cs b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.events.other/cs/example.cs deleted file mode 100644 index dc393f2004427..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.events.other/cs/example.cs +++ /dev/null @@ -1,213 +0,0 @@ -// -using System; - -namespace EventSample -{ - // Class that contains the data for - // the alarm event. Derives from System.EventArgs. - // - public class AlarmEventArgs : EventArgs - { - private bool snoozePressed; - private int nrings; - - //Constructor. - // - public AlarmEventArgs(bool snoozePressed, int nrings) - { - this.snoozePressed = snoozePressed; - this.nrings = nrings; - } - - // The NumRings property returns the number of rings - // that the alarm clock has sounded when the alarm event - // is generated. - // - public int NumRings - { - get { return nrings;} - } - - // The SnoozePressed property indicates whether the snooze - // button is pressed on the alarm when the alarm event is generated. - // - public bool SnoozePressed - { - get {return snoozePressed;} - } - - // The AlarmText property that contains the wake-up message. - // - public string AlarmText - { - get - { - if (snoozePressed) - { - return ("Wake Up!!! Snooze time is over."); - } - else - { - return ("Wake Up!"); - } - } - } - } - - // Delegate declaration. - // - public delegate void AlarmEventHandler(object sender, AlarmEventArgs e); - - // The Alarm class that raises the alarm event. - // - public class AlarmClock - { - private bool snoozePressed = false; - private int nrings = 0; - private bool stop = false; - - // The Stop property indicates whether the - // alarm should be turned off. - // - public bool Stop - { - get {return stop;} - set {stop = value;} - } - - // The SnoozePressed property indicates whether the snooze - // button is pressed on the alarm when the alarm event is generated. - // - public bool SnoozePressed - { - get {return snoozePressed;} - set {snoozePressed = value;} - } - - // The event member that is of type AlarmEventHandler. - // - public event AlarmEventHandler Alarm; - - // The protected OnAlarm method raises the event by invoking - // the delegates. The sender is always this, the current instance - // of the class. - // - protected virtual void OnAlarm(AlarmEventArgs e) - { - AlarmEventHandler handler = Alarm; - if (handler != null) - { - // Invokes the delegates. - handler(this, e); - } - } - - // This alarm clock does not have - // a user interface. - // To simulate the alarm mechanism it has a loop - // that raises the alarm event at every iteration - // with a time delay of 300 milliseconds, - // if snooze is not pressed. If snooze is pressed, - // the time delay is 1000 milliseconds. - // - public void Start() - { - for (;;) - { - nrings++; - if (stop) - { - break; - } - else - { - if (snoozePressed) - { - System.Threading.Thread.Sleep(1000); - } - else - { - System.Threading.Thread.Sleep(300); - } - AlarmEventArgs e = new AlarmEventArgs(snoozePressed, nrings); - OnAlarm(e); - } - } - } - } - - // The WakeMeUp class has a method AlarmRang that handles the - // alarm event. - // - public class WakeMeUp - { - public void AlarmRang(object sender, AlarmEventArgs e) - { - Console.WriteLine(e.AlarmText +"\n"); - - if (!(e.SnoozePressed)) - { - if (e.NumRings % 10 == 0) - { - Console.WriteLine(" Let alarm ring? Enter Y"); - Console.WriteLine(" Press Snooze? Enter N"); - Console.WriteLine(" Stop Alarm? Enter Q"); - String input = Console.ReadLine(); - - if (input.Equals("Y") ||input.Equals("y")) - { - return; - } - else if (input.Equals("N") || input.Equals("n")) - { - ((AlarmClock)sender).SnoozePressed = true; - return; - } - else - { - ((AlarmClock)sender).Stop = true; - return; - } - } - } - else - { - Console.WriteLine(" Let alarm ring? Enter Y"); - Console.WriteLine(" Stop Alarm? Enter Q"); - String input = Console.ReadLine(); - if (input.Equals("Y") || input.Equals("y")) - { - return; - } - else - { - ((AlarmClock)sender).Stop = true; - return; - } - } - } - } - - // The driver class that hooks up the event handling method of - // WakeMeUp to the alarm event of an Alarm object using a delegate. - // In a forms-based application, the driver class is the - // form. - // - public class AlarmDriver - { - public static void Main(string[] args) - { - // Instantiates the event receiver. - WakeMeUp w = new WakeMeUp(); - - // Instantiates the event source. - AlarmClock clock = new AlarmClock(); - - // Wires the AlarmRang method to the Alarm event. - clock.Alarm += new AlarmEventHandler(w.AlarmRang); - - clock.Start(); - } - } -} -// diff --git a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.events.other/cs/example2.cs b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.events.other/cs/example2.cs deleted file mode 100644 index 18b6b57d82a5f..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.events.other/cs/example2.cs +++ /dev/null @@ -1,46 +0,0 @@ -// -using System; - -public class MouseEventArgs : EventArgs -{ -} - -public class EventNameEventArgs : EventArgs -{ -} - -class EventingSnippets -{ - // - public event EventNameEventHandler EventName; - // - - // - public delegate void EventNameEventHandler(object sender, EventNameEventArgs e); - // - - // - void EventHandler(object sender, EventNameEventArgs e) {} - // - - // - void Mouse_Moved(object sender, MouseEventArgs e){} - // - - void OnSomeSignal(EventNameEventArgs e) - { - EventNameEventHandler handler = EventName; - if (handler != null) - { - // Invokes the delegates. - handler(this, e); - } - } - - public static void Main() - { - - Console.WriteLine("EventingSnippets Main()"); - } -} -// diff --git a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.events.other/cs/example4.cs b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.events.other/cs/example4.cs deleted file mode 100644 index 50dd989109f81..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.events.other/cs/example4.cs +++ /dev/null @@ -1,75 +0,0 @@ -// -// -using System; -using System.ComponentModel; -using System.Windows.Forms; -using System.Drawing; - -public class MyForm : Form -{ - private TextBox box; - private Button button; - - public MyForm() : base() - { - box = new TextBox(); - box.BackColor = System.Drawing.Color.Cyan; - box.Size = new Size(100,100); - box.Location = new Point(50,50); - box.Text = "Hello"; - - button = new Button(); - button.Location = new Point(50,100); - button.Text = "Click Me"; - - // To wire the event, create - // a delegate instance and add it to the Click event. - button.Click += new EventHandler(this.Button_Click); - Controls.Add(box); - Controls.Add(button); - } - - // The event handler. - private void Button_Click(object sender, EventArgs e) - { - box.BackColor = System.Drawing.Color.Green; - } - - // The STAThreadAttribute indicates that Windows Forms uses the - // single-threaded apartment model. - [STAThread] - public static void Main() - { - Application.Run(new MyForm()); - } -} -// - -public class SnippetForm : Form -{ - // - private Button button; - // - - // - private void Button_Click(object sender, EventArgs e) - { - //... - } - // - - public SnippetForm() : base() - { - button = new Button(); - - // - button.Click += new EventHandler(this.Button_Click); - // - } -} -#if null -// -csc /r:System.DLL /r:System.Windows.Forms.dll /r:System.Drawing.dll WinEvents.vb -// -#endif -// diff --git a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.events.other/cs/remarks.cs b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.events.other/cs/remarks.cs deleted file mode 100644 index cc3d5d17b2000..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.events.other/cs/remarks.cs +++ /dev/null @@ -1,63 +0,0 @@ -using System; - -// Code section for remarks -namespace EventRemarks -{ - public class AlarmEventArgs : EventArgs - { - } - // - public delegate void AlarmEventHandler(object sender, AlarmEventArgs e); - // - - public class AlarmClock - { - public event AlarmEventHandler Alarm; - - protected virtual void OnAlarm(AlarmEventArgs e) - { - AlarmEventHandler handler = Alarm; - if (handler != null) - { - handler(this, e); - } - } - } - - // - delegate void EventHandler(object sender, EventArgs e); - // - // - public class WakeMeUp - { - // AlarmRang has the same signature as AlarmEventHandler. - public void AlarmRang(object sender, AlarmEventArgs e) - { - //... - } - //... - } - // - - public class AlarmDriver - { - public static void Main() - { - // - // Create an instance of WakeMeUp. - WakeMeUp w = new WakeMeUp(); - - // Instantiate the event delegate. - AlarmEventHandler alhandler = new AlarmEventHandler(w.AlarmRang); - // - - // - // Instantiate the event source. - AlarmClock clock = new AlarmClock(); - - // Add the delegate instance to the event. - clock.Alarm += alhandler; - // - } - } -} diff --git a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.interop.marshaling/cs/activedir.cs b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.interop.marshaling/cs/activedir.cs deleted file mode 100644 index ab4b3e5204118..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.interop.marshaling/cs/activedir.cs +++ /dev/null @@ -1,80 +0,0 @@ -// -using System; -using System.Runtime.InteropServices; - -// -[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] -public struct DsBrowseInfo -{ - public const int MAX_PATH = 256; - - public int Size; - public IntPtr OwnerHandle; - public string Caption; - public string Title; - public string Root; - public string Path; - public int PathSize; - public int Flags; - public IntPtr Callback; - public int Param; - public int ReturnFormat; - public string UserName; - public string Password; - public string ObjectClass; - public int ObjectClassSize; -} - -internal static class NativeMethods -{ - // Declares a managed prototype for the unmanaged function. - [DllImport("dsuiext.dll", CharSet = CharSet.Unicode)] - internal static extern int DsBrowseForContainerW(ref DsBrowseInfo info); - - internal const int DSBI_ENTIREDIRECTORY = 0x00090000; - internal const int ADS_FORMAT_WINDOWS = 1; - - internal enum BrowseStatus - { - BrowseError = -1, - BrowseOk = 1, - BrowseCancel = 2 - } -} -// - -// -class App -{ - // Must be marked as STA because the default is MTA. - // DsBrowseForContainerW calls CoInitialize, which initializes the - // COM library as STA. - [STAThread] - public static void Main() - { - DsBrowseInfo dsbi = new DsBrowseInfo - { - Size = Marshal.SizeOf(typeof(DsBrowseInfo)), - PathSize = DsBrowseInfo.MAX_PATH, - Caption = "Container Selection Example", - Title = "Select a container from the list.", - ReturnFormat = NativeMethods.ADS_FORMAT_WINDOWS, - Flags = NativeMethods.DSBI_ENTIREDIRECTORY, - Root = "LDAP:", - Path = new string(new char[DsBrowseInfo.MAX_PATH]) - }; - - // Initialize remaining members... - int status = NativeMethods.DsBrowseForContainerW(ref dsbi); - if ((NativeMethods.BrowseStatus)status == NativeMethods.BrowseStatus.BrowseOk) - { - Console.WriteLine(dsbi.Path); - } - else - { - Console.WriteLine("No path returned."); - } - } -} -// -// diff --git a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.interop.marshaling/cs/buffers.cs b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.interop.marshaling/cs/buffers.cs deleted file mode 100644 index dc717cbda0e47..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.interop.marshaling/cs/buffers.cs +++ /dev/null @@ -1,33 +0,0 @@ -// -using System; -using System.Text; -using System.Runtime.InteropServices; - -// -internal static class NativeMethods -{ - [DllImport("Kernel32.dll", CharSet = CharSet.Auto)] - internal static extern int GetSystemDirectory( - StringBuilder sysDirBuffer, int size); - - [DllImport("Kernel32.dll", CharSet = CharSet.Auto)] - internal static extern IntPtr GetCommandLine(); -} -// - -// -public class App -{ - public static void Main() - { - // Call GetSystemDirectory. - StringBuilder sysDirBuffer = new StringBuilder(256); - NativeMethods.GetSystemDirectory(sysDirBuffer, sysDirBuffer.Capacity); - // ... - // Call GetCommandLine. - IntPtr cmdLineStr = NativeMethods.GetCommandLine(); - string commandLine = Marshal.PtrToStringAuto(cmdLineStr); - } -} -// -// diff --git a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.interop.marshaling/cs/comwrappers.cs b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.interop.marshaling/cs/comwrappers.cs deleted file mode 100644 index 8995623085bdb..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.interop.marshaling/cs/comwrappers.cs +++ /dev/null @@ -1,36 +0,0 @@ -// -using System; -using System.Runtime.InteropServices; - -public class Snippets -{ - public static void Main() - { - } - - // - void M1([MarshalAs(UnmanagedType.LPWStr)] string msg) - { - // ... - } - // - - // - [return: MarshalAs(UnmanagedType.LPWStr)] - public string GetMessage() - { - string msg = new string(new char[128]); - // Load message here ... - return msg; - } - // -} - -// -class MsgText -{ - [MarshalAs(UnmanagedType.LPWStr)] - public string msg = ""; -} -// -// diff --git a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.interop.marshaling/cs/gchandle.cs b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.interop.marshaling/cs/gchandle.cs deleted file mode 100644 index 1d7b1c30f1efb..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.interop.marshaling/cs/gchandle.cs +++ /dev/null @@ -1,42 +0,0 @@ -// -using System; -using System.IO; -using System.Runtime.InteropServices; - -// -public delegate bool CallBack(int handle, IntPtr param); - -internal static class NativeMethods -{ - // Passes a managed object as an LPARAM type. - // Declares a managed prototype for the unmanaged function. - [DllImport("user32.dll")] - internal static extern bool EnumWindows(CallBack cb, IntPtr param); -} -// - -// -public class App -{ - public static void Main() - { - TextWriter tw = System.Console.Out; - GCHandle gch = GCHandle.Alloc(tw); - CallBack cewp = new CallBack(CaptureEnumWindowsProc); - - // Platform invoke prevents the delegate from being garbage - // collected before the call ends. - NativeMethods.EnumWindows(cewp, (IntPtr)gch); - gch.Free(); - } - - private static bool CaptureEnumWindowsProc(int handle, IntPtr param) - { - GCHandle gch = (GCHandle)param; - TextWriter tw = (TextWriter)gch.Target; - tw.WriteLine(handle); - return true; - } -} -// -// diff --git a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.interop.marshaling/cs/handleref.cs b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.interop.marshaling/cs/handleref.cs deleted file mode 100644 index 0d69c7436bcec..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.interop.marshaling/cs/handleref.cs +++ /dev/null @@ -1,75 +0,0 @@ -// -using System; -using System.IO; -using System.Text; -using System.Runtime.InteropServices; - -// -// Declares a managed structure for the unmanaged structure. -[StructLayout(LayoutKind.Sequential)] -public struct Overlapped -{ - // ... -} - -// Declares a managed class for the unmanaged structure. -[StructLayout(LayoutKind.Sequential)] -public class Overlapped2 -{ - // ... -} - -internal static class NativeMethods -{ - // Declares managed prototypes for unmanaged functions. - // Because Overlapped is a structure, you cannot pass null as a - // parameter. Instead, declares an overloaded method. - [DllImport("Kernel32.dll")] - internal static extern bool ReadFile( - HandleRef hndRef, - StringBuilder buffer, - int numberOfBytesToRead, - out int numberOfBytesRead, - ref Overlapped flag); - - [DllImport("Kernel32.dll")] - internal static extern bool ReadFile( - HandleRef hndRef, - StringBuilder buffer, - int numberOfBytesToRead, - out int numberOfBytesRead, - IntPtr flag); // Declares an int instead of a structure reference. - - // Because Overlapped2 is a class, you can pass null as parameter. - // No overloading is needed. - [DllImport("Kernel32.dll", EntryPoint = "ReadFile")] - internal static extern bool ReadFile2( - HandleRef hndRef, - StringBuilder buffer, - int numberOfBytesToRead, - out int numberOfBytesRead, - Overlapped2 flag); -} -// - -// -public class App -{ - public static void Main() - { - FileStream fs = new FileStream("HandleRef.txt", FileMode.Open); - // Wraps the FileStream handle in HandleRef to prevent it - // from being garbage collected before the call ends. - HandleRef hr = new HandleRef(fs, fs.SafeFileHandle.DangerousGetHandle()); - StringBuilder buffer = new StringBuilder(5); - int read = 0; - // Platform invoke holds a reference to HandleRef until the call - // ends. - NativeMethods.ReadFile(hr, buffer, 5, out read, IntPtr.Zero); - Console.WriteLine($"Read {read} bytes with struct parameter: {buffer}"); - NativeMethods.ReadFile2(hr, buffer, 5, out read, null); - Console.WriteLine($"Read {read} bytes with class parameter: {buffer}"); - } -} -// -// diff --git a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.interop.marshaling/cs/openfiledlg.cs b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.interop.marshaling/cs/openfiledlg.cs deleted file mode 100644 index 56f8129dade56..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.interop.marshaling/cs/openfiledlg.cs +++ /dev/null @@ -1,64 +0,0 @@ -// -using System; -using System.Runtime.InteropServices; - -// -// Declare a class member for each structure element. -[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] -public class OpenFileName -{ - public int structSize = 0; - public IntPtr hwnd = IntPtr.Zero; - public IntPtr hinst = IntPtr.Zero; - public string filter = null; - public string custFilter = null; - public int custFilterMax = 0; - public int filterIndex = 0; - public string file = null; - public int maxFile = 0; - public string fileTitle = null; - public int maxFileTitle = 0; - public string initialDir = null; - public string title = null; - public int flags = 0; - public short fileOffset = 0; - public short fileExtMax = 0; - public string defExt = null; - public int custData = 0; - public IntPtr pHook = IntPtr.Zero; - public string template = null; -} - -internal static class NativeMethods -{ - // Declare a managed prototype for the unmanaged function. - [DllImport("Comdlg32.dll", CharSet = CharSet.Auto)] - internal static extern bool GetOpenFileName([In, Out] OpenFileName ofn); -} -// - -// -public class App -{ - public static void Main() - { - OpenFileName ofn = new OpenFileName(); - - ofn.structSize = Marshal.SizeOf(ofn); - ofn.filter = "Log files\0*.log\0Batch files\0*.bat\0"; - ofn.file = new string(new char[256]); - ofn.maxFile = ofn.file.Length; - ofn.fileTitle = new string(new char[64]); - ofn.maxFileTitle = ofn.fileTitle.Length; - ofn.initialDir = "C:\\"; - ofn.title = "Open file called using platform invoke..."; - ofn.defExt = "txt"; - - if (NativeMethods.GetOpenFileName(ofn)) - { - Console.WriteLine("Selected file with full path: {0}", ofn.file); - } - } -} -// -// diff --git a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.interop.marshaling/cs/osinfo.cs b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.interop.marshaling/cs/osinfo.cs deleted file mode 100644 index caef970690760..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.interop.marshaling/cs/osinfo.cs +++ /dev/null @@ -1,68 +0,0 @@ -// -using System; -using System.Runtime.InteropServices; - -// -[StructLayout(LayoutKind.Sequential)] -public class OSVersionInfo -{ - public int OSVersionInfoSize; - public int MajorVersion; - public int MinorVersion; - public int BuildNumber; - public int PlatformId; - - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)] - public String CSDVersion; -} - -[StructLayout(LayoutKind.Sequential)] -public struct OSVersionInfo2 -{ - public int OSVersionInfoSize; - public int MajorVersion; - public int MinorVersion; - public int BuildNumber; - public int PlatformId; - - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)] - public String CSDVersion; -} - -internal static class NativeMethods -{ - [DllImport("kernel32")] - internal static extern bool GetVersionEx([In, Out] OSVersionInfo osvi); - - [DllImport("kernel32", EntryPoint = "GetVersionEx")] - internal static extern bool GetVersionEx2(ref OSVersionInfo2 osvi); -} -// - -// -public class App -{ - public static void Main() - { - Console.WriteLine("\nPassing OSVersionInfo as a class"); - - OSVersionInfo osvi = new OSVersionInfo(); - osvi.OSVersionInfoSize = Marshal.SizeOf(osvi); - - NativeMethods.GetVersionEx(osvi); - - Console.WriteLine("Class size: {0}", osvi.OSVersionInfoSize); - Console.WriteLine("OS Version: {0}.{1}", osvi.MajorVersion, osvi.MinorVersion); - - Console.WriteLine("\nPassing OSVersionInfo as a struct"); - - OSVersionInfo2 osvi2 = new OSVersionInfo2(); - osvi2.OSVersionInfoSize = Marshal.SizeOf(osvi2); - - NativeMethods.GetVersionEx2(ref osvi2); - Console.WriteLine("Struct size: {0}", osvi2.OSVersionInfoSize); - Console.WriteLine("OS Version: {0}.{1}", osvi2.MajorVersion, osvi2.MinorVersion); - } -} -// -// diff --git a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.interop.marshaling/cs/strings.cs b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.interop.marshaling/cs/strings.cs deleted file mode 100644 index 0af440b6ed30c..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.interop.marshaling/cs/strings.cs +++ /dev/null @@ -1,73 +0,0 @@ -// -using System; -using System.Text; -using System.Runtime.InteropServices; - -// -// Declares a managed structure for each unmanaged structure. -[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] -public struct MyStrStruct -{ - public string buffer; - public int size; -} - -[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] -public struct MyStrStruct2 -{ - public string buffer; - public int size; -} - -internal class NativeMethods -{ - // Declares managed prototypes for unmanaged functions. - [DllImport("..\\LIB\\PinvokeLib.dll", CallingConvention = CallingConvention.Cdecl)] - internal static extern string TestStringAsResult(); - - [DllImport("..\\LIB\\PinvokeLib.dll", CallingConvention = CallingConvention.Cdecl)] - internal static extern void TestStringInStruct(ref MyStrStruct mss); - - [DllImport("..\\LIB\\PinvokeLib.dll", CallingConvention = CallingConvention.Cdecl)] - internal static extern void TestStringInStructAnsi(ref MyStrStruct2 mss); -} -// - -// -public class App -{ - public static void Main() - { - // String as result. - string str = NativeMethods.TestStringAsResult(); - Console.WriteLine("\nString returned: {0}", str); - - // Initializes buffer and appends something to the end so the whole - // buffer is passed to the unmanaged side. - StringBuilder buffer = new StringBuilder("content", 100); - buffer.Append((char)0); - buffer.Append('*', buffer.Capacity - 8); - - MyStrStruct mss; - mss.buffer = buffer.ToString(); - mss.size = mss.buffer.Length; - - NativeMethods.TestStringInStruct(ref mss); - Console.WriteLine("\nBuffer after Unicode function call: {0}", - mss.buffer); - - StringBuilder buffer2 = new StringBuilder("content", 100); - buffer2.Append((char)0); - buffer2.Append('*', buffer2.Capacity - 8); - - MyStrStruct2 mss2; - mss2.buffer = buffer2.ToString(); - mss2.size = mss2.buffer.Length; - - NativeMethods.TestStringInStructAnsi(ref mss2); - Console.WriteLine("\nBuffer after Ansi function call: {0}", - mss2.buffer); - } -} -// -// diff --git a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.interop.marshaling/cs/void.cs b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.interop.marshaling/cs/void.cs deleted file mode 100644 index 405f3efe5b4b1..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.interop.marshaling/cs/void.cs +++ /dev/null @@ -1,50 +0,0 @@ -// -using System; -using System.Runtime.InteropServices; - -// -internal class NativeMethods -{ - internal enum DataType - { - DT_I2 = 1, - DT_I4, - DT_R4, - DT_R8, - DT_STR - } - - // Uses AsAny when void* is expected. - [DllImport("..\\LIB\\PInvokeLib.dll")] - internal static extern void SetData(DataType t, - [MarshalAs(UnmanagedType.AsAny)] object o); - - // Uses overloading when void* is expected. - [DllImport("..\\LIB\\PInvokeLib.dll", EntryPoint = "SetData")] - internal static extern void SetData2(DataType t, ref double i); - - [DllImport("..\\LIB\\PInvokeLib.dll", EntryPoint = "SetData")] - internal static extern void SetData2(DataType t, string s); -} -// - -// -public class App -{ - public static void Main() - { - Console.WriteLine("Calling SetData using AsAny... \n"); - NativeMethods.SetData(NativeMethods.DataType.DT_I2, (short)12); - NativeMethods.SetData(NativeMethods.DataType.DT_I4, (long)12); - NativeMethods.SetData(NativeMethods.DataType.DT_R4, (float)12); - NativeMethods.SetData(NativeMethods.DataType.DT_R8, (double)12); - NativeMethods.SetData(NativeMethods.DataType.DT_STR, "abcd"); - - Console.WriteLine("\nCalling SetData using overloading... \n"); - double d = 12; - NativeMethods.SetData2(NativeMethods.DataType.DT_R8, ref d); - NativeMethods.SetData2(NativeMethods.DataType.DT_STR, "abcd"); - } -} -// -// diff --git a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portable/cs/program.cs b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portable/cs/program.cs deleted file mode 100644 index 883a7064edf9c..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portable/cs/program.cs +++ /dev/null @@ -1,93 +0,0 @@ -using System.Resources; - -// -using System; -using System.Collections.Generic; -using MyCompany.Employees; - -class Program -{ - static void Main() - { - // Get the data from some data source. - var employees = InitializeData(); - - // Display application title. - string title = UILibrary.GetTitle(); - int start = (Console.WindowWidth + title.Length) / 2; - string titlefmt = String.Format("{{0,{0}{1}", start, "}"); - Console.WriteLine(titlefmt, title); - Console.WriteLine(); - - // Retrieve resources. - string[] fields = UILibrary.GetFieldNames(); - int[] lengths = UILibrary.GetFieldLengths(); - string fmtString = String.Empty; - // Create format string for field headers and data. - for (int ctr = 0; ctr < fields.Length; ctr++) - fmtString += String.Format("{{{0},-{1}{2}{3} ", ctr, lengths[ctr], ctr >= 2 ? ":d" : "", "}"); - - // Display the headers. - Console.WriteLine(fmtString, fields); - Console.WriteLine(); - // Display the data. - foreach (var e in employees) - Console.WriteLine(fmtString, e.Item1, e.Item2, e.Item3, e.Item4); - - Console.ReadLine(); - } - - private static List> InitializeData() - { - List> employees = new List>(); - var t1 = Tuple.Create("John", "16302", new DateTime(1954, 8, 18), new DateTime(2006, 9, 8)); - employees.Add(t1); - t1 = Tuple.Create("Alice", "19745", new DateTime(1995, 5, 10), new DateTime(2012, 10, 17)); - employees.Add(t1); - return employees; - } -} -// - -namespace MyCompany.Employees -{ - public class UILibrary - { - private static ResourceManager rm; - private const int nFields = 4; - - static UILibrary() - { - rm = new ResourceManager("MyCompany.Employees.LibResources", typeof(UILibrary).Assembly); - } - - public static string GetTitle() - { - string retval = rm.GetString("Title"); - if (String.IsNullOrEmpty(retval)) - retval = ""; - - return retval; - } - - public static string[] GetFieldNames() - { - string[] fieldnames = new string[nFields]; - fieldnames[0] = rm.GetString("Name"); - fieldnames[1] = rm.GetString("ID"); - fieldnames[2] = rm.GetString("Born"); - fieldnames[3] = rm.GetString("Hired"); - return fieldnames; - } - - public static int[] GetFieldLengths() - { - int[] fieldLengths = new int[nFields]; - fieldLengths[0] = Int32.Parse(rm.GetString("NameLength")); - fieldLengths[1] = Int32.Parse(rm.GetString("IDLength")); - fieldLengths[2] = Int32.Parse(rm.GetString("BornLength")); - fieldLengths[3] = Int32.Parse(rm.GetString("HiredLength")); - return fieldLengths; - } - } -} diff --git a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portable/cs/program2.cs b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portable/cs/program2.cs deleted file mode 100644 index 20a7ea0454707..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portable/cs/program2.cs +++ /dev/null @@ -1,96 +0,0 @@ -using System.Resources; - -// -using System; -using System.Collections.Generic; -using System.Globalization; - -using MyCompany.Employees; - -class Program -{ - static void Main(string[] args) - { - - // Get the data from some data source. - var employees = InitializeData(); - - // Display application title. - string title = UILibrary.GetTitle(); - int start = (Console.WindowWidth + title.Length) / 2; - string titlefmt = String.Format("{{0,{0}{1}", start, "}"); - Console.WriteLine(titlefmt, title); - Console.WriteLine(); - - // Retrieve resources. - string[] fields = UILibrary.GetFieldNames(); - int[] lengths = UILibrary.GetFieldLengths(); - string fmtString = String.Empty; - // Create format string for field headers and data. - for (int ctr = 0; ctr < fields.Length; ctr++) - fmtString += String.Format("{{{0},-{1}{2}{3} ", ctr, lengths[ctr], ctr >= 2 ? ":d" : "", "}"); - - // Display the headers. - Console.WriteLine(fmtString, fields); - Console.WriteLine(); - // Display the data. - foreach (var e in employees) - Console.WriteLine(fmtString, e.Item1, e.Item2, e.Item3, e.Item4); - - Console.ReadLine(); - } - - private static List> InitializeData() - { - List> employees = new List>(); - var t1 = Tuple.Create("John", "16302", new DateTime(1954, 8, 18), new DateTime(2006, 9, 8)); - employees.Add(t1); - t1 = Tuple.Create("Alice", "19745", new DateTime(1995, 5, 10), new DateTime(2012, 10, 17)); - employees.Add(t1); - return employees; - } -} -// - -namespace MyCompany.Employees -{ - public class UILibrary - { - private static ResourceManager rm; - private const int nFields = 4; - - static UILibrary() - { - rm = new ResourceManager("MyCompany.Employees.LibResources", typeof(UILibrary).Assembly); - } - - public static string GetTitle() - { - string retval = rm.GetString("Title"); - if (String.IsNullOrEmpty(retval)) - retval = ""; - - return retval; - } - - public static string[] GetFieldNames() - { - string[] fieldnames = new string[nFields]; - fieldnames[0] = rm.GetString("Name"); - fieldnames[1] = rm.GetString("ID"); - fieldnames[2] = rm.GetString("Born"); - fieldnames[3] = rm.GetString("Hired"); - return fieldnames; - } - - public static int[] GetFieldLengths() - { - int[] fieldLengths = new int[nFields]; - fieldLengths[0] = Int32.Parse(rm.GetString("NameLength")); - fieldLengths[1] = Int32.Parse(rm.GetString("IDLength")); - fieldLengths[2] = Int32.Parse(rm.GetString("BornLength")); - fieldLengths[3] = Int32.Parse(rm.GetString("HiredLength")); - return fieldLengths; - } - } -} diff --git a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portable/cs/uilibrary.cs b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portable/cs/uilibrary.cs deleted file mode 100644 index dfcf4a770aab7..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portable/cs/uilibrary.cs +++ /dev/null @@ -1,167 +0,0 @@ -// -using System; -using System.Resources; -using MyCompany.Employees; - -[assembly: NeutralResourcesLanguage("en-US")] - -namespace MyCompany.Employees -{ - public class UILibrary - { - private const int nFields = 4; - - public static string GetTitle() - { - string retval = LibResources.Born; - if (String.IsNullOrEmpty(retval)) - retval = ""; - - return retval; - } - - public static string[] GetFieldNames() - { - string[] fieldnames = new string[nFields]; - fieldnames[0] = LibResources.Name; - fieldnames[1] = LibResources.ID; - fieldnames[2] = LibResources.Born; - fieldnames[3] = LibResources.Hired; - return fieldnames; - } - - public static int[] GetFieldLengths() - { - int[] fieldLengths = new int[nFields]; - fieldLengths[0] = Int32.Parse(LibResources.NameLength); - fieldLengths[1] = Int32.Parse(LibResources.IDLength); - fieldLengths[2] = Int32.Parse(LibResources.BornLength); - fieldLengths[3] = Int32.Parse(LibResources.HiredLength); - return fieldLengths; - } - } -} -// - -namespace MyCompany.Employees -{ - public class LibResources { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal LibResources() { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - public static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("MyCompany.Employees.LibResources", typeof(LibResources).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - public static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - - /// - /// Looks up a localized string similar to Birthdate. - /// - public static string Born { - get { - return ResourceManager.GetString("Born", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to 12. - /// - public static string BornLength { - get { - return ResourceManager.GetString("BornLength", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Hire Date. - /// - public static string Hired { - get { - return ResourceManager.GetString("Hired", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to 12. - /// - public static string HiredLength { - get { - return ResourceManager.GetString("HiredLength", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to ID. - /// - public static string ID { - get { - return ResourceManager.GetString("ID", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to 12. - /// - public static string IDLength { - get { - return ResourceManager.GetString("IDLength", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Name. - /// - public static string Name { - get { - return ResourceManager.GetString("Name", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to 25. - /// - public static string NameLength { - get { - return ResourceManager.GetString("NameLength", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Employee Database. - /// - public static string Title { - get { - return ResourceManager.GetString("Title", resourceCulture); - } - } - } -} diff --git a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetro/cs/app.xaml b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetro/cs/app.xaml deleted file mode 100644 index 2bd4c61d51f9c..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetro/cs/app.xaml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - diff --git a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetro/cs/app.xaml.cs b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetro/cs/app.xaml.cs deleted file mode 100644 index 482f24d5bc6ed..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetro/cs/app.xaml.cs +++ /dev/null @@ -1,70 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using Windows.ApplicationModel; -using Windows.ApplicationModel.Activation; -using Windows.Foundation; -using Windows.Foundation.Collections; -using Windows.UI.Xaml; -using Windows.UI.Xaml.Controls; -using Windows.UI.Xaml.Controls.Primitives; -using Windows.UI.Xaml.Data; -using Windows.UI.Xaml.Input; -using Windows.UI.Xaml.Media; -using Windows.UI.Xaml.Navigation; - -// The Blank Application template is documented at http://go.microsoft.com/fwlink/?LinkId=234227 - -namespace ConsumerCS -{ - /// - /// Provides application-specific behavior to supplement the default Application class. - /// - sealed partial class App : Application - { - /// - /// Initializes the singleton application object. This is the first line of authored code - /// executed, and as such is the logical equivalent of main() or WinMain(). - /// - public App() - { - this.InitializeComponent(); - this.Suspending += OnSuspending; - } - - /// - /// Invoked when the application is launched normally by the end user. Other entry points - /// will be used when the application is launched to open a specific file, to display - /// search results, and so forth. - /// - /// Details about the launch request and process. - protected override void OnLaunched(LaunchActivatedEventArgs args) - { - if (args.PreviousExecutionState == ApplicationExecutionState.Terminated) - { - //TODO: Load state from previously suspended application - } - - // Create a Frame to act navigation context and navigate to the first page - var rootFrame = new Frame(); - rootFrame.Navigate(typeof(BlankPage)); - - // Place the frame in the current Window and ensure that it is active - Window.Current.Content = rootFrame; - Window.Current.Activate(); - } - - /// - /// Invoked when application execution is being suspended. Application state is saved - /// without knowing whether the application will be terminated or resumed with the contents - /// of memory still intact. - /// - /// The source of the suspend request. - /// Details about the suspend request. - void OnSuspending(object sender, SuspendingEventArgs e) - { - //TODO: Save application state and stop any background activity - } - } -} diff --git a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetro/cs/assemblyinfo.cs b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetro/cs/assemblyinfo.cs deleted file mode 100644 index 105e28163523f..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetro/cs/assemblyinfo.cs +++ /dev/null @@ -1,29 +0,0 @@ -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("ConsumerCS")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Microsoft")] -[assembly: AssemblyProduct("ConsumerCS")] -[assembly: AssemblyCopyright("Copyright © Microsoft 2012")] -[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 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")] -[assembly: ComVisible(false)] \ No newline at end of file diff --git a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetro/cs/bindablebase.cs b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetro/cs/bindablebase.cs deleted file mode 100644 index d0ca45e6ff03e..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetro/cs/bindablebase.cs +++ /dev/null @@ -1,55 +0,0 @@ -using System; -using System.ComponentModel; -using System.Runtime.CompilerServices; -using Windows.UI.Xaml.Data; - -namespace ConsumerCS.Common -{ - /// - /// Implementation of to simplify models. - /// - [Windows.Foundation.Metadata.WebHostHidden] - public abstract class BindableBase : INotifyPropertyChanged - { - /// - /// Multicast event for property change notifications. - /// - public event PropertyChangedEventHandler PropertyChanged; - - /// - /// Checks if a property already matches a desired value. Sets the property and - /// notifies listeners only when necessary. - /// - /// Type of the property. - /// Reference to a property with both getter and setter. - /// Desired value for the property. - /// Name of the property used to notify listeners. This - /// value is optional and can be provided automatically when invoked from compilers that - /// support CallerMemberName. - /// True if the value was changed, false if the existing value matched the - /// desired value. - protected bool SetProperty(ref T storage, T value, [CallerMemberName] String propertyName = null) - { - if (object.Equals(storage, value)) return false; - - storage = value; - this.OnPropertyChanged(propertyName); - return true; - } - - /// - /// Notifies listeners that a property value has changed. - /// - /// Name of the property used to notify listeners. This - /// value is optional and can be provided automatically when invoked from compilers - /// that support . - protected void OnPropertyChanged([CallerMemberName] string propertyName = null) - { - var eventHandler = this.PropertyChanged; - if (eventHandler != null) - { - eventHandler(this, new PropertyChangedEventArgs(propertyName)); - } - } - } -} diff --git a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetro/cs/blankpage.xaml b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetro/cs/blankpage.xaml deleted file mode 100644 index 62bd56f849192..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetro/cs/blankpage.xaml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - diff --git a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetro/cs/blankpage.xaml.cs b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetro/cs/blankpage.xaml.cs deleted file mode 100644 index 60bfa3af53318..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetro/cs/blankpage.xaml.cs +++ /dev/null @@ -1,73 +0,0 @@ -// -using System; -using System.Collections.Generic; -using Windows.UI.Xaml; -using Windows.UI.Xaml.Controls; -using Windows.UI.Xaml.Controls.Primitives; -using Windows.UI.Xaml.Data; -using Windows.UI.Xaml.Input; -using Windows.UI.Xaml.Media; -using Windows.UI.Xaml.Navigation; -using MyCompany.Employees; - -namespace ConsumerCS -{ - /// - /// An empty page that can be used on its own or navigated to within a Frame. - /// - public sealed partial class BlankPage : Page - { - public BlankPage() - { - this.InitializeComponent(); - } - - /// - /// Invoked when this page is about to be displayed in a Frame. - /// - /// Event data that describes how this page was reached. The Parameter - /// property is typically used to configure the page. - protected override void OnNavigatedTo(NavigationEventArgs e) - { - Example.DisplayData(outputBlock); - } - } -} - -public class Example -{ - static public void DisplayData(Windows.UI.Xaml.Controls.TextBlock outputBlock) - { - // Get the data from some data source. - var employees = InitializeData(); - outputBlock.FontFamily = new FontFamily("Courier New"); - // Display application title. - string title = UILibrary.GetTitle(); - outputBlock.Text += title + Environment.NewLine + Environment.NewLine; - - // Retrieve resources. - string[] fields = UILibrary.GetFieldNames(); - int[] lengths = UILibrary.GetFieldLengths(); - string fmtString = String.Empty; - // Create format string for field headers and data. - for (int ctr = 0; ctr < fields.Length; ctr++) - fmtString += String.Format("{{{0},-{1}{2}{3} ", ctr, lengths[ctr], ctr >= 2 ? ":d" : "", "}"); - - // Display the headers. - outputBlock.Text += String.Format(fmtString, fields) + Environment.NewLine + Environment.NewLine; - // Display the data. - foreach (var e in employees) - outputBlock.Text += String.Format(fmtString, e.Item1, e.Item2, e.Item3, e.Item4) + Environment.NewLine; - } - - private static List> InitializeData() - { - List> employees = new List>(); - var t1 = Tuple.Create("John", "16302", new DateTime(1954, 8, 18), new DateTime(2006, 9, 8)); - employees.Add(t1); - t1 = Tuple.Create("Alice", "19745", new DateTime(1995, 5, 10), new DateTime(2012, 10, 17)); - employees.Add(t1); - return employees; - } -} -// diff --git a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetro/cs/booleannegationconverter.cs b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetro/cs/booleannegationconverter.cs deleted file mode 100644 index 13da29c124817..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetro/cs/booleannegationconverter.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; -using Windows.UI.Xaml.Data; - -namespace ConsumerCS.Common -{ - /// - /// Value converter that translates true to false and vice versa. - /// - public sealed class BooleanNegationConverter : IValueConverter - { - public object Convert(object value, Type targetType, object parameter, string language) - { - return !(value is bool && (bool)value); - } - - public object ConvertBack(object value, Type targetType, object parameter, string language) - { - return !(value is bool && (bool)value); - } - } -} diff --git a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetro/cs/booleantovisibilityconverter.cs b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetro/cs/booleantovisibilityconverter.cs deleted file mode 100644 index ac82fa47b92ec..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetro/cs/booleantovisibilityconverter.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Linq; -using System.Runtime.CompilerServices; -using Windows.Foundation; -using Windows.Foundation.Collections; -using Windows.Graphics.Display; -using Windows.UI.ViewManagement; -using Windows.UI.Xaml; -using Windows.UI.Xaml.Controls; -using Windows.UI.Xaml.Data; - -namespace ConsumerCS.Common -{ - /// - /// Value converter that translates true to and false to - /// . - /// - public sealed class BooleanToVisibilityConverter : IValueConverter - { - public object Convert(object value, Type targetType, object parameter, string language) - { - return (value is bool && (bool)value) ? Visibility.Visible : Visibility.Collapsed; - } - - public object ConvertBack(object value, Type targetType, object parameter, string language) - { - return value is Visibility && (Visibility)value == Visibility.Visible; - } - } -} diff --git a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetro/cs/layoutawarepage.cs b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetro/cs/layoutawarepage.cs deleted file mode 100644 index c747be626b117..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetro/cs/layoutawarepage.cs +++ /dev/null @@ -1,365 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Linq; -using Windows.Foundation; -using Windows.Foundation.Collections; -using Windows.UI.ViewManagement; -using Windows.UI.Xaml; -using Windows.UI.Xaml.Controls; - -namespace ConsumerCS.Common -{ - /// - /// Typical implementation of Page that provides several important conveniences: - /// application view state to visual state mapping, GoBack and GoHome event handlers, and - /// a default view model. - /// - [Windows.Foundation.Metadata.WebHostHidden] - public class LayoutAwarePage : Page - { - private List _layoutAwareControls; - private IObservableMap _defaultViewModel = new ObservableDictionary(); - private bool _useFilledStateForNarrowWindow = false; - - /// - /// Initializes a new instance of the class. - /// - public LayoutAwarePage() - { - if (Windows.ApplicationModel.DesignMode.DesignModeEnabled) return; - - // Map application view state to visual state for this page when it is part of the visual tree - this.Loaded += this.StartLayoutUpdates; - this.Unloaded += this.StopLayoutUpdates; - - // Establish the default view model as the initial DataContext - this.DataContext = _defaultViewModel; - } - - /// - /// Gets an implementation of set as the - /// page's default . This instance can be bound and surfaces - /// property change notifications making it suitable for use as a trivial view model. - /// - protected IObservableMap DefaultViewModel - { - get - { - return _defaultViewModel; - } - } - - /// - /// Gets or sets a value indicating whether visual states can be a loose interpretation - /// of the actual application view state. This is often convenient when a page layout - /// is space constrained. - /// - /// - /// The default value of false indicates that the visual state is identical to the view - /// state, meaning that Filled is only used when another application is snapped. When - /// set to true FullScreenLandscape is used to indicate that at least 1366 virtual - /// pixels of horizontal real estate are available - even if another application is - /// snapped - and Filled indicates a lesser width, even if no other application is - /// snapped. On a smaller display such as a 1024x768 panel this will result in the - /// visual state Filled whenever the device is in landscape orientation. - /// - public bool UseFilledStateForNarrowWindow - { - get - { - return _useFilledStateForNarrowWindow; - } - - set - { - _useFilledStateForNarrowWindow = value; - this.InvalidateVisualState(); - } - } - - /// - /// Invoked as an event handler to navigate backward in the page's associated - /// until it reaches the top of the navigation stack. - /// - /// Instance that triggered the event. - /// Event data describing the conditions that led to the event. - protected virtual void GoHome(object sender, RoutedEventArgs e) - { - // Use the navigation frame to return to the topmost page - if (this.Frame != null) - { - while (this.Frame.CanGoBack) this.Frame.GoBack(); - } - } - - /// - /// Invoked as an event handler to navigate backward in the page's associated - /// to go back one step on the navigation stack. - /// - /// Instance that triggered the event. - /// Event data describing the conditions that led to the - /// event. - protected virtual void GoBack(object sender, RoutedEventArgs e) - { - // Use the navigation frame to return to the previous page - if (this.Frame != null && this.Frame.CanGoBack) this.Frame.GoBack(); - } - - /// - /// Invoked as an event handler, typically on the event of a - /// within the page, to indicate that the sender should start - /// receiving visual state management changes that correspond to application view state - /// changes. - /// - /// Instance of that supports visual state - /// management corresponding to view states. - /// Event data that describes how the request was made. - /// The current view state will immediately be used to set the corresponding - /// visual state when layout updates are requested. A corresponding - /// event handler connected to - /// is strongly encouraged. Instances of automatically - /// invoke these handlers in their Loaded and Unloaded events. - /// - /// - public void StartLayoutUpdates(object sender, RoutedEventArgs e) - { - var control = sender as Control; - if (control == null) return; - if (this._layoutAwareControls == null) - { - // Start listening to view state changes when there are controls interested in updates - ApplicationView.GetForCurrentView().ViewStateChanged += this.ViewStateChanged; - Window.Current.SizeChanged += this.WindowSizeChanged; - this._layoutAwareControls = new List(); - } - this._layoutAwareControls.Add(control); - - // Set the initial visual state of the control - VisualStateManager.GoToState(control, DetermineVisualState(ApplicationView.Value), false); - } - - private void ViewStateChanged(ApplicationView sender, ApplicationViewStateChangedEventArgs e) - { - this.InvalidateVisualState(e.ViewState); - } - - private void WindowSizeChanged(object sender, Windows.UI.Core.WindowSizeChangedEventArgs e) - { - if (this._useFilledStateForNarrowWindow) this.InvalidateVisualState(); - } - - /// - /// Invoked as an event handler, typically on the event of a - /// , to indicate that the sender should start receiving visual - /// state management changes that correspond to application view state changes. - /// - /// Instance of that supports visual state - /// management corresponding to view states. - /// Event data that describes how the request was made. - /// The current view state will immediately be used to set the corresponding - /// visual state when layout updates are requested. - /// - public void StopLayoutUpdates(object sender, RoutedEventArgs e) - { - var control = sender as Control; - if (control == null || this._layoutAwareControls == null) return; - this._layoutAwareControls.Remove(control); - if (this._layoutAwareControls.Count == 0) - { - // Stop listening to view state changes when no controls are interested in updates - this._layoutAwareControls = null; - ApplicationView.GetForCurrentView().ViewStateChanged -= this.ViewStateChanged; - Window.Current.SizeChanged -= this.WindowSizeChanged; - } - } - - /// - /// Translates values into strings for visual state - /// management within the page. The default implementation uses the names of enum values. - /// Subclasses may override this method to control the mapping scheme used. - /// - /// View state for which a visual state is desired. - /// Visual state name used to drive the - /// - /// - protected virtual string DetermineVisualState(ApplicationViewState viewState) - { - if (this._useFilledStateForNarrowWindow && - (viewState == ApplicationViewState.Filled || - viewState == ApplicationViewState.FullScreenLandscape)) - { - // Allow pages to request that the Filled state be used only for landscape layouts narrower - // than 1366 virtual pixels - var windowWidth = Window.Current.Bounds.Width; - viewState = windowWidth >= 1366 ? ApplicationViewState.FullScreenLandscape : ApplicationViewState.Filled; - } - return viewState.ToString(); - } - - /// - /// Updates all controls that are listening for visual state changes with the correct - /// visual state. - /// - /// - /// Typically used in conjunction with overriding to - /// signal that a different value may be returned even though the view state has not - /// changed. - /// - /// The desired view state, or null if the current view state - /// should be used. - public void InvalidateVisualState(ApplicationViewState? viewState = null) - { - if (this._layoutAwareControls != null) - { - string visualState = DetermineVisualState(viewState == null ? ApplicationView.Value : viewState.Value); - foreach (var layoutAwareControl in this._layoutAwareControls) - { - VisualStateManager.GoToState(layoutAwareControl, visualState, false); - } - } - } - - /// - /// Implementation of IObservableMap that supports reentrancy for use as a default view - /// model. - /// - private class ObservableDictionary : IObservableMap - { - private class ObservableDictionaryChangedEventArgs : IMapChangedEventArgs - { - public ObservableDictionaryChangedEventArgs(CollectionChange change, K key) - { - this.CollectionChange = change; - this.Key = key; - } - - public CollectionChange CollectionChange { get; private set; } - public K Key { get; private set; } - } - - private Dictionary _dictionary = new Dictionary(); - public event MapChangedEventHandler MapChanged; - - private void InvokeMapChanged(CollectionChange change, K key) - { - var eventHandler = MapChanged; - if (eventHandler != null) - { - eventHandler(this, new ObservableDictionaryChangedEventArgs(CollectionChange.ItemInserted, key)); - } - } - - public void Add(K key, V value) - { - this._dictionary.Add(key, value); - this.InvokeMapChanged(CollectionChange.ItemInserted, key); - } - - public void Add(KeyValuePair item) - { - this.Add(item.Key, item.Value); - } - - public bool Remove(K key) - { - if (this._dictionary.Remove(key)) - { - this.InvokeMapChanged(CollectionChange.ItemRemoved, key); - return true; - } - return false; - } - - public bool Remove(KeyValuePair item) - { - V currentValue; - if (this._dictionary.TryGetValue(item.Key, out currentValue) && - Object.Equals(item.Value, currentValue) && this._dictionary.Remove(item.Key)) - { - this.InvokeMapChanged(CollectionChange.ItemRemoved, item.Key); - return true; - } - return false; - } - - public V this[K key] - { - get - { - return this._dictionary[key]; - } - set - { - this._dictionary[key] = value; - this.InvokeMapChanged(CollectionChange.ItemChanged, key); - } - } - - public void Clear() - { - var priorKeys = this._dictionary.Keys.ToArray(); - this._dictionary.Clear(); - foreach (var key in priorKeys) - { - this.InvokeMapChanged(CollectionChange.ItemRemoved, key); - } - } - - public ICollection Keys - { - get { return this._dictionary.Keys; } - } - - public bool ContainsKey(K key) - { - return this._dictionary.ContainsKey(key); - } - - public bool TryGetValue(K key, out V value) - { - return this._dictionary.TryGetValue(key, out value); - } - - public ICollection Values - { - get { return this._dictionary.Values; } - } - - public bool Contains(KeyValuePair item) - { - return this._dictionary.Contains(item); - } - - public int Count - { - get { return this._dictionary.Count; } - } - - public bool IsReadOnly - { - get { return false; } - } - - public IEnumerator> GetEnumerator() - { - return this._dictionary.GetEnumerator(); - } - - System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() - { - return this._dictionary.GetEnumerator(); - } - - public void CopyTo(KeyValuePair[] array, int arrayIndex) - { - int arraySize = array.Length; - foreach (var pair in this._dictionary) - { - if (arrayIndex >= arraySize) break; - array[arrayIndex++] = pair; - } - } - } - } -} diff --git a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetro/cs/logo.png b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetro/cs/logo.png deleted file mode 100644 index ebd735aa9352c..0000000000000 Binary files a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetro/cs/logo.png and /dev/null differ diff --git a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetro/cs/metroconsumercs.csproj b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetro/cs/metroconsumercs.csproj deleted file mode 100644 index 5ae60b1a62ec6..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetro/cs/metroconsumercs.csproj +++ /dev/null @@ -1,171 +0,0 @@ - - - - - Debug - AnyCPU - {089C5BB5-1ED3-4003-B2F5-230268AA325A} - AppContainerExe - Properties - MetroConsumerCS - MetroConsumerCS - en-US - 512 - {BC8A1FFA-BEE3-4634-8014-F334798102B3};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - D533CEB79E4F3DB656EE700B4C603A4C25185402 - - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE;NETFX_CORE - prompt - 4 - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE;NETFX_CORE - prompt - 4 - - - true - bin\ARM\Debug\ - DEBUG;TRACE;NETFX_CORE - ;2008 - full - ARM - false - prompt - ExpressRules.ruleset - true - - - bin\ARM\Release\ - TRACE;NETFX_CORE - true - ;2008 - pdbonly - ARM - false - prompt - ExpressRules.ruleset - true - - - true - bin\x64\Debug\ - DEBUG;TRACE;NETFX_CORE - ;2008 - full - x64 - false - prompt - ExpressRules.ruleset - true - - - bin\x64\Release\ - TRACE;NETFX_CORE - true - ;2008 - pdbonly - x64 - false - prompt - ExpressRules.ruleset - true - - - true - bin\x86\Debug\ - DEBUG;TRACE;NETFX_CORE - ;2008 - full - x86 - false - prompt - ExpressRules.ruleset - true - - - bin\x86\Release\ - TRACE;NETFX_CORE - true - ;2008 - pdbonly - x86 - false - prompt - ExpressRules.ruleset - true - - - - - - - - - App.xaml - - - BlankPage.xaml - - - - - - Designer - - - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - - - MSBuild:Compile - Designer - - - MSBuild:Compile - Designer - - - MSBuild:Compile - Designer - - - - - ..\MetroConsumer\UILibrary.dll - - - - 11.0 - - - - diff --git a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetro/cs/package.appxmanifest b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetro/cs/package.appxmanifest deleted file mode 100644 index 9a9f37219db44..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetro/cs/package.appxmanifest +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - MetroConsumerCS - ronpet - StoreLogo.png - MetroConsumerCS - - - - 6.2 - 6.2 - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetro/cs/readme.txt b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetro/cs/readme.txt deleted file mode 100644 index ec0f038d978fd..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetro/cs/readme.txt +++ /dev/null @@ -1,7 +0,0 @@ -The Common directory contains classes and XAML styles that simplify application development. - -These are not merely convenient, but are required by most Visual Studio project and item templates. -Removing, renaming, or otherwise modifying the content of these files may result in a project that -does not build, or that will not build once additional pages are added. If variations on these -classes or styles are desired it is recommended that you copy the content under a new name and -modify your private copy. diff --git a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetro/cs/richtextcolumns.cs b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetro/cs/richtextcolumns.cs deleted file mode 100644 index 563cf4528adf7..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetro/cs/richtextcolumns.cs +++ /dev/null @@ -1,210 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Windows.Foundation; -using Windows.UI.Xaml; -using Windows.UI.Xaml.Controls; -using Windows.UI.Xaml.Data; -using Windows.UI.Xaml.Documents; - -namespace ConsumerCS.Common -{ - /// - /// Wrapper for that creates as many additional overflow - /// columns as needed to fit the available content. - /// - /// - /// The following creates a collection of 400-pixel wide columns spaced 50 pixels apart - /// to contain arbitrary data-bound content: - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// Typically used in a horizontally scrolling region where an unbounded amount of - /// space allows for all needed columns to be created. When used in a vertically scrolling - /// space there will never be any additional columns. - [Windows.UI.Xaml.Markup.ContentProperty(Name = "RichTextContent")] - public sealed class RichTextColumns : Panel - { - /// - /// Identifies the dependency property. - /// - public static readonly DependencyProperty RichTextContentProperty = - DependencyProperty.Register("RichTextContent", typeof(RichTextBlock), - typeof(RichTextColumns), new PropertyMetadata(null, ResetOverflowLayout)); - - /// - /// Identifies the dependency property. - /// - public static readonly DependencyProperty ColumnTemplateProperty = - DependencyProperty.Register("ColumnTemplate", typeof(DataTemplate), - typeof(RichTextColumns), new PropertyMetadata(null, ResetOverflowLayout)); - - /// - /// Initializes a new instance of the class. - /// - public RichTextColumns() - { - this.HorizontalAlignment = HorizontalAlignment.Left; - } - - /// - /// Gets or sets the initial rich text content to be used as the first column. - /// - public RichTextBlock RichTextContent - { - get { return (RichTextBlock)GetValue(RichTextContentProperty); } - set { SetValue(RichTextContentProperty, value); } - } - - /// - /// Gets or sets the template used to create additional - /// instances. - /// - public DataTemplate ColumnTemplate - { - get { return (DataTemplate)GetValue(ColumnTemplateProperty); } - set { SetValue(ColumnTemplateProperty, value); } - } - - /// - /// Invoked when the content or overflow template is changed to recreate the column layout. - /// - /// Instance of where the change - /// occurred. - /// Event data describing the specific change. - private static void ResetOverflowLayout(DependencyObject d, DependencyPropertyChangedEventArgs e) - { - // When dramatic changes occur, rebuild the column layout from scratch - var target = d as RichTextColumns; - if (target != null) - { - target._overflowColumns = null; - target.Children.Clear(); - target.InvalidateMeasure(); - } - } - - /// - /// Lists overflow columns already created. Must maintain a 1:1 relationship with - /// instances in the collection following the initial RichTextBlock - /// child. - /// - private List _overflowColumns = null; - - /// - /// Determines whether additional overflow columns are needed and if existing columns can - /// be removed. - /// - /// The size of the space available, used to constrain the - /// number of additional columns that can be created. - /// The resulting size of the original content plus any extra columns. - protected override Size MeasureOverride(Size availableSize) - { - if (this.RichTextContent == null) return new Size(0, 0); - - // Make sure the RichTextBlock is a child, using the lack of - // a list of additional columns as a sign that this hasn't been - // done yet - if (this._overflowColumns == null) - { - Children.Add(this.RichTextContent); - this._overflowColumns = new List(); - } - - // Start by measuring the original RichTextBlock content - this.RichTextContent.Measure(availableSize); - var maxWidth = this.RichTextContent.DesiredSize.Width; - var maxHeight = this.RichTextContent.DesiredSize.Height; - var hasOverflow = this.RichTextContent.HasOverflowContent; - - // Make sure there are enough overflow columns - int overflowIndex = 0; - while (hasOverflow && maxWidth < availableSize.Width && this.ColumnTemplate != null) - { - // Use existing overflow columns until we run out, then create - // more from the supplied template - RichTextBlockOverflow overflow; - if (this._overflowColumns.Count > overflowIndex) - { - overflow = this._overflowColumns[overflowIndex]; - } - else - { - overflow = (RichTextBlockOverflow)this.ColumnTemplate.LoadContent(); - this._overflowColumns.Add(overflow); - this.Children.Add(overflow); - if (overflowIndex == 0) - { - this.RichTextContent.OverflowContentTarget = overflow; - } - else - { - this._overflowColumns[overflowIndex - 1].OverflowContentTarget = overflow; - } - } - - // Measure the new column and prepare to repeat as necessary - overflow.Measure(new Size(availableSize.Width - maxWidth, availableSize.Height)); - maxWidth += overflow.DesiredSize.Width; - maxHeight = Math.Max(maxHeight, overflow.DesiredSize.Height); - hasOverflow = overflow.HasOverflowContent; - overflowIndex++; - } - - // Disconnect extra columns from the overflow chain, remove them from our private list - // of columns, and remove them as children - if (this._overflowColumns.Count > overflowIndex) - { - if (overflowIndex == 0) - { - this.RichTextContent.OverflowContentTarget = null; - } - else - { - this._overflowColumns[overflowIndex - 1].OverflowContentTarget = null; - } - while (this._overflowColumns.Count > overflowIndex) - { - this._overflowColumns.RemoveAt(overflowIndex); - this.Children.RemoveAt(overflowIndex + 1); - } - } - - // Report final determined size - return new Size(maxWidth, maxHeight); - } - - /// - /// Arranges the original content and all extra columns. - /// - /// Defines the size of the area the children must be arranged - /// within. - /// The size of the area the children actually required. - protected override Size ArrangeOverride(Size finalSize) - { - double maxWidth = 0; - double maxHeight = 0; - foreach (var child in Children) - { - child.Arrange(new Rect(maxWidth, 0, child.DesiredSize.Width, finalSize.Height)); - maxWidth += child.DesiredSize.Width; - maxHeight = Math.Max(maxHeight, child.DesiredSize.Height); - } - return new Size(maxWidth, maxHeight); - } - } -} diff --git a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetro/cs/smalllogo.png b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetro/cs/smalllogo.png deleted file mode 100644 index 92dd1058fbfb7..0000000000000 Binary files a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetro/cs/smalllogo.png and /dev/null differ diff --git a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetro/cs/splashscreen.png b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetro/cs/splashscreen.png deleted file mode 100644 index 193187f108f50..0000000000000 Binary files a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetro/cs/splashscreen.png and /dev/null differ diff --git a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetro/cs/standardstyles.xaml b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetro/cs/standardstyles.xaml deleted file mode 100644 index d480380dbb89c..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetro/cs/standardstyles.xaml +++ /dev/null @@ -1,943 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Mouse - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetro/cs/storelogo.png b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetro/cs/storelogo.png deleted file mode 100644 index 3765186d055fb..0000000000000 Binary files a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetro/cs/storelogo.png and /dev/null differ diff --git a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetroloc/cs/app.xaml b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetroloc/cs/app.xaml deleted file mode 100644 index e18c58611b766..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetroloc/cs/app.xaml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - diff --git a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetroloc/cs/app.xaml.cs b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetroloc/cs/app.xaml.cs deleted file mode 100644 index 494329ba24185..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetroloc/cs/app.xaml.cs +++ /dev/null @@ -1,70 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using Windows.ApplicationModel; -using Windows.ApplicationModel.Activation; -using Windows.Foundation; -using Windows.Foundation.Collections; -using Windows.UI.Xaml; -using Windows.UI.Xaml.Controls; -using Windows.UI.Xaml.Controls.Primitives; -using Windows.UI.Xaml.Data; -using Windows.UI.Xaml.Input; -using Windows.UI.Xaml.Media; -using Windows.UI.Xaml.Navigation; - -// The Blank Application template is documented at http://go.microsoft.com/fwlink/?LinkId=234227 - -namespace LocConsumerCS -{ - /// - /// Provides application-specific behavior to supplement the default Application class. - /// - sealed partial class App : Application - { - /// - /// Initializes the singleton application object. This is the first line of authored code - /// executed, and as such is the logical equivalent of main() or WinMain(). - /// - public App() - { - this.InitializeComponent(); - this.Suspending += OnSuspending; - } - - /// - /// Invoked when the application is launched normally by the end user. Other entry points - /// will be used when the application is launched to open a specific file, to display - /// search results, and so forth. - /// - /// Details about the launch request and process. - protected override void OnLaunched(LaunchActivatedEventArgs args) - { - if (args.PreviousExecutionState == ApplicationExecutionState.Terminated) - { - //TODO: Load state from previously suspended application - } - - // Create a Frame to act navigation context and navigate to the first page - var rootFrame = new Frame(); - rootFrame.Navigate(typeof(BlankPage)); - - // Place the frame in the current Window and ensure that it is active - Window.Current.Content = rootFrame; - Window.Current.Activate(); - } - - /// - /// Invoked when application execution is being suspended. Application state is saved - /// without knowing whether the application will be terminated or resumed with the contents - /// of memory still intact. - /// - /// The source of the suspend request. - /// Details about the suspend request. - void OnSuspending(object sender, SuspendingEventArgs e) - { - //TODO: Save application state and stop any background activity - } - } -} diff --git a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetroloc/cs/assemblyinfo.cs b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetroloc/cs/assemblyinfo.cs deleted file mode 100644 index 54136bf6c718c..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetroloc/cs/assemblyinfo.cs +++ /dev/null @@ -1,29 +0,0 @@ -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("LocConsumerCS")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Microsoft")] -[assembly: AssemblyProduct("LocConsumerCS")] -[assembly: AssemblyCopyright("Copyright © Microsoft 2012")] -[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 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")] -[assembly: ComVisible(false)] \ No newline at end of file diff --git a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetroloc/cs/bindablebase.cs b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetroloc/cs/bindablebase.cs deleted file mode 100644 index 9c71d4d396c5a..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetroloc/cs/bindablebase.cs +++ /dev/null @@ -1,55 +0,0 @@ -using System; -using System.ComponentModel; -using System.Runtime.CompilerServices; -using Windows.UI.Xaml.Data; - -namespace LocConsumerCS.Common -{ - /// - /// Implementation of to simplify models. - /// - [Windows.Foundation.Metadata.WebHostHidden] - public abstract class BindableBase : INotifyPropertyChanged - { - /// - /// Multicast event for property change notifications. - /// - public event PropertyChangedEventHandler PropertyChanged; - - /// - /// Checks if a property already matches a desired value. Sets the property and - /// notifies listeners only when necessary. - /// - /// Type of the property. - /// Reference to a property with both getter and setter. - /// Desired value for the property. - /// Name of the property used to notify listeners. This - /// value is optional and can be provided automatically when invoked from compilers that - /// support CallerMemberName. - /// True if the value was changed, false if the existing value matched the - /// desired value. - protected bool SetProperty(ref T storage, T value, [CallerMemberName] String propertyName = null) - { - if (object.Equals(storage, value)) return false; - - storage = value; - this.OnPropertyChanged(propertyName); - return true; - } - - /// - /// Notifies listeners that a property value has changed. - /// - /// Name of the property used to notify listeners. This - /// value is optional and can be provided automatically when invoked from compilers - /// that support . - protected void OnPropertyChanged([CallerMemberName] string propertyName = null) - { - var eventHandler = this.PropertyChanged; - if (eventHandler != null) - { - eventHandler(this, new PropertyChangedEventArgs(propertyName)); - } - } - } -} diff --git a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetroloc/cs/blankpage.xaml b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetroloc/cs/blankpage.xaml deleted file mode 100644 index 36b68d561447e..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetroloc/cs/blankpage.xaml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - diff --git a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetroloc/cs/blankpage.xaml.cs b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetroloc/cs/blankpage.xaml.cs deleted file mode 100644 index 0214ee3f1be81..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetroloc/cs/blankpage.xaml.cs +++ /dev/null @@ -1,70 +0,0 @@ -// -using System; -using System.Collections.Generic; -using Windows.Globalization; -using Windows.UI.Xaml; -using Windows.UI.Xaml.Controls; -using Windows.UI.Xaml.Controls.Primitives; -using Windows.UI.Xaml.Data; -using Windows.UI.Xaml.Input; -using Windows.UI.Xaml.Media; -using Windows.UI.Xaml.Navigation; -using MyCompany.Employees; - -namespace LocConsumerCS -{ - public sealed partial class BlankPage : Page - { - public BlankPage() - { - this.InitializeComponent(); - } - - protected override void OnNavigatedTo(NavigationEventArgs e) - { - Example.Demo(outputBlock); - } - } - - public class Example - { - public static void Demo(TextBlock outputBlock) - { - // Set the application preferences. - ApplicationLanguages.PrimaryLanguageOverride = "fr-FR"; - - // Get the data from some data source. - var employees = InitializeData(); - outputBlock.FontFamily = new FontFamily("Courier New"); - // Display application title. - string title = UILibrary.GetTitle(); - outputBlock.Text += title + Environment.NewLine + Environment.NewLine; - - // Retrieve resources. - string[] fields = UILibrary.GetFieldNames(); - int[] lengths = UILibrary.GetFieldLengths(); - string fmtString = String.Empty; - // Create format string for field headers and data. - for (int ctr = 0; ctr < fields.Length; ctr++) - fmtString += String.Format("{{{0},-{1}{2}{3} ", ctr, lengths[ctr], ctr >= 2 ? ":d" : "", "}"); - - // Display the headers. - outputBlock.Text += String.Format(fmtString, fields) + Environment.NewLine + Environment.NewLine; - - // Display the data. - foreach (var e in employees) - outputBlock.Text += String.Format(fmtString, e.Item1, e.Item2, e.Item3, e.Item4) + Environment.NewLine; - } - - private static List> InitializeData() - { - List> employees = new List>(); - var t1 = Tuple.Create("John", "16302", new DateTime(1954, 8, 18), new DateTime(2006, 9, 8)); - employees.Add(t1); - t1 = Tuple.Create("Alice", "19745", new DateTime(1995, 5, 10), new DateTime(2012, 10, 17)); - employees.Add(t1); - return employees; - } - } -} -// diff --git a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetroloc/cs/booleannegationconverter.cs b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetroloc/cs/booleannegationconverter.cs deleted file mode 100644 index 4780a3fa63578..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetroloc/cs/booleannegationconverter.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; -using Windows.UI.Xaml.Data; - -namespace LocConsumerCS.Common -{ - /// - /// Value converter that translates true to false and vice versa. - /// - public sealed class BooleanNegationConverter : IValueConverter - { - public object Convert(object value, Type targetType, object parameter, string language) - { - return !(value is bool && (bool)value); - } - - public object ConvertBack(object value, Type targetType, object parameter, string language) - { - return !(value is bool && (bool)value); - } - } -} diff --git a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetroloc/cs/booleantovisibilityconverter.cs b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetroloc/cs/booleantovisibilityconverter.cs deleted file mode 100644 index 78650d8b5754b..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetroloc/cs/booleantovisibilityconverter.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Linq; -using System.Runtime.CompilerServices; -using Windows.Foundation; -using Windows.Foundation.Collections; -using Windows.Graphics.Display; -using Windows.UI.ViewManagement; -using Windows.UI.Xaml; -using Windows.UI.Xaml.Controls; -using Windows.UI.Xaml.Data; - -namespace LocConsumerCS.Common -{ - /// - /// Value converter that translates true to and false to - /// . - /// - public sealed class BooleanToVisibilityConverter : IValueConverter - { - public object Convert(object value, Type targetType, object parameter, string language) - { - return (value is bool && (bool)value) ? Visibility.Visible : Visibility.Collapsed; - } - - public object ConvertBack(object value, Type targetType, object parameter, string language) - { - return value is Visibility && (Visibility)value == Visibility.Visible; - } - } -} diff --git a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetroloc/cs/layoutawarepage.cs b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetroloc/cs/layoutawarepage.cs deleted file mode 100644 index 0383b6b081e09..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetroloc/cs/layoutawarepage.cs +++ /dev/null @@ -1,365 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Linq; -using Windows.Foundation; -using Windows.Foundation.Collections; -using Windows.UI.ViewManagement; -using Windows.UI.Xaml; -using Windows.UI.Xaml.Controls; - -namespace LocConsumerCS.Common -{ - /// - /// Typical implementation of Page that provides several important conveniences: - /// application view state to visual state mapping, GoBack and GoHome event handlers, and - /// a default view model. - /// - [Windows.Foundation.Metadata.WebHostHidden] - public class LayoutAwarePage : Page - { - private List _layoutAwareControls; - private IObservableMap _defaultViewModel = new ObservableDictionary(); - private bool _useFilledStateForNarrowWindow = false; - - /// - /// Initializes a new instance of the class. - /// - public LayoutAwarePage() - { - if (Windows.ApplicationModel.DesignMode.DesignModeEnabled) return; - - // Map application view state to visual state for this page when it is part of the visual tree - this.Loaded += this.StartLayoutUpdates; - this.Unloaded += this.StopLayoutUpdates; - - // Establish the default view model as the initial DataContext - this.DataContext = _defaultViewModel; - } - - /// - /// Gets an implementation of set as the - /// page's default . This instance can be bound and surfaces - /// property change notifications making it suitable for use as a trivial view model. - /// - protected IObservableMap DefaultViewModel - { - get - { - return _defaultViewModel; - } - } - - /// - /// Gets or sets a value indicating whether visual states can be a loose interpretation - /// of the actual application view state. This is often convenient when a page layout - /// is space constrained. - /// - /// - /// The default value of false indicates that the visual state is identical to the view - /// state, meaning that Filled is only used when another application is snapped. When - /// set to true FullScreenLandscape is used to indicate that at least 1366 virtual - /// pixels of horizontal real estate are available - even if another application is - /// snapped - and Filled indicates a lesser width, even if no other application is - /// snapped. On a smaller display such as a 1024x768 panel this will result in the - /// visual state Filled whenever the device is in landscape orientation. - /// - public bool UseFilledStateForNarrowWindow - { - get - { - return _useFilledStateForNarrowWindow; - } - - set - { - _useFilledStateForNarrowWindow = value; - this.InvalidateVisualState(); - } - } - - /// - /// Invoked as an event handler to navigate backward in the page's associated - /// until it reaches the top of the navigation stack. - /// - /// Instance that triggered the event. - /// Event data describing the conditions that led to the event. - protected virtual void GoHome(object sender, RoutedEventArgs e) - { - // Use the navigation frame to return to the topmost page - if (this.Frame != null) - { - while (this.Frame.CanGoBack) this.Frame.GoBack(); - } - } - - /// - /// Invoked as an event handler to navigate backward in the page's associated - /// to go back one step on the navigation stack. - /// - /// Instance that triggered the event. - /// Event data describing the conditions that led to the - /// event. - protected virtual void GoBack(object sender, RoutedEventArgs e) - { - // Use the navigation frame to return to the previous page - if (this.Frame != null && this.Frame.CanGoBack) this.Frame.GoBack(); - } - - /// - /// Invoked as an event handler, typically on the event of a - /// within the page, to indicate that the sender should start - /// receiving visual state management changes that correspond to application view state - /// changes. - /// - /// Instance of that supports visual state - /// management corresponding to view states. - /// Event data that describes how the request was made. - /// The current view state will immediately be used to set the corresponding - /// visual state when layout updates are requested. A corresponding - /// event handler connected to - /// is strongly encouraged. Instances of automatically - /// invoke these handlers in their Loaded and Unloaded events. - /// - /// - public void StartLayoutUpdates(object sender, RoutedEventArgs e) - { - var control = sender as Control; - if (control == null) return; - if (this._layoutAwareControls == null) - { - // Start listening to view state changes when there are controls interested in updates - ApplicationView.GetForCurrentView().ViewStateChanged += this.ViewStateChanged; - Window.Current.SizeChanged += this.WindowSizeChanged; - this._layoutAwareControls = new List(); - } - this._layoutAwareControls.Add(control); - - // Set the initial visual state of the control - VisualStateManager.GoToState(control, DetermineVisualState(ApplicationView.Value), false); - } - - private void ViewStateChanged(ApplicationView sender, ApplicationViewStateChangedEventArgs e) - { - this.InvalidateVisualState(e.ViewState); - } - - private void WindowSizeChanged(object sender, Windows.UI.Core.WindowSizeChangedEventArgs e) - { - if (this._useFilledStateForNarrowWindow) this.InvalidateVisualState(); - } - - /// - /// Invoked as an event handler, typically on the event of a - /// , to indicate that the sender should start receiving visual - /// state management changes that correspond to application view state changes. - /// - /// Instance of that supports visual state - /// management corresponding to view states. - /// Event data that describes how the request was made. - /// The current view state will immediately be used to set the corresponding - /// visual state when layout updates are requested. - /// - public void StopLayoutUpdates(object sender, RoutedEventArgs e) - { - var control = sender as Control; - if (control == null || this._layoutAwareControls == null) return; - this._layoutAwareControls.Remove(control); - if (this._layoutAwareControls.Count == 0) - { - // Stop listening to view state changes when no controls are interested in updates - this._layoutAwareControls = null; - ApplicationView.GetForCurrentView().ViewStateChanged -= this.ViewStateChanged; - Window.Current.SizeChanged -= this.WindowSizeChanged; - } - } - - /// - /// Translates values into strings for visual state - /// management within the page. The default implementation uses the names of enum values. - /// Subclasses may override this method to control the mapping scheme used. - /// - /// View state for which a visual state is desired. - /// Visual state name used to drive the - /// - /// - protected virtual string DetermineVisualState(ApplicationViewState viewState) - { - if (this._useFilledStateForNarrowWindow && - (viewState == ApplicationViewState.Filled || - viewState == ApplicationViewState.FullScreenLandscape)) - { - // Allow pages to request that the Filled state be used only for landscape layouts narrower - // than 1366 virtual pixels - var windowWidth = Window.Current.Bounds.Width; - viewState = windowWidth >= 1366 ? ApplicationViewState.FullScreenLandscape : ApplicationViewState.Filled; - } - return viewState.ToString(); - } - - /// - /// Updates all controls that are listening for visual state changes with the correct - /// visual state. - /// - /// - /// Typically used in conjunction with overriding to - /// signal that a different value may be returned even though the view state has not - /// changed. - /// - /// The desired view state, or null if the current view state - /// should be used. - public void InvalidateVisualState(ApplicationViewState? viewState = null) - { - if (this._layoutAwareControls != null) - { - string visualState = DetermineVisualState(viewState == null ? ApplicationView.Value : viewState.Value); - foreach (var layoutAwareControl in this._layoutAwareControls) - { - VisualStateManager.GoToState(layoutAwareControl, visualState, false); - } - } - } - - /// - /// Implementation of IObservableMap that supports reentrancy for use as a default view - /// model. - /// - private class ObservableDictionary : IObservableMap - { - private class ObservableDictionaryChangedEventArgs : IMapChangedEventArgs - { - public ObservableDictionaryChangedEventArgs(CollectionChange change, K key) - { - this.CollectionChange = change; - this.Key = key; - } - - public CollectionChange CollectionChange { get; private set; } - public K Key { get; private set; } - } - - private Dictionary _dictionary = new Dictionary(); - public event MapChangedEventHandler MapChanged; - - private void InvokeMapChanged(CollectionChange change, K key) - { - var eventHandler = MapChanged; - if (eventHandler != null) - { - eventHandler(this, new ObservableDictionaryChangedEventArgs(CollectionChange.ItemInserted, key)); - } - } - - public void Add(K key, V value) - { - this._dictionary.Add(key, value); - this.InvokeMapChanged(CollectionChange.ItemInserted, key); - } - - public void Add(KeyValuePair item) - { - this.Add(item.Key, item.Value); - } - - public bool Remove(K key) - { - if (this._dictionary.Remove(key)) - { - this.InvokeMapChanged(CollectionChange.ItemRemoved, key); - return true; - } - return false; - } - - public bool Remove(KeyValuePair item) - { - V currentValue; - if (this._dictionary.TryGetValue(item.Key, out currentValue) && - Object.Equals(item.Value, currentValue) && this._dictionary.Remove(item.Key)) - { - this.InvokeMapChanged(CollectionChange.ItemRemoved, item.Key); - return true; - } - return false; - } - - public V this[K key] - { - get - { - return this._dictionary[key]; - } - set - { - this._dictionary[key] = value; - this.InvokeMapChanged(CollectionChange.ItemChanged, key); - } - } - - public void Clear() - { - var priorKeys = this._dictionary.Keys.ToArray(); - this._dictionary.Clear(); - foreach (var key in priorKeys) - { - this.InvokeMapChanged(CollectionChange.ItemRemoved, key); - } - } - - public ICollection Keys - { - get { return this._dictionary.Keys; } - } - - public bool ContainsKey(K key) - { - return this._dictionary.ContainsKey(key); - } - - public bool TryGetValue(K key, out V value) - { - return this._dictionary.TryGetValue(key, out value); - } - - public ICollection Values - { - get { return this._dictionary.Values; } - } - - public bool Contains(KeyValuePair item) - { - return this._dictionary.Contains(item); - } - - public int Count - { - get { return this._dictionary.Count; } - } - - public bool IsReadOnly - { - get { return false; } - } - - public IEnumerator> GetEnumerator() - { - return this._dictionary.GetEnumerator(); - } - - System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() - { - return this._dictionary.GetEnumerator(); - } - - public void CopyTo(KeyValuePair[] array, int arrayIndex) - { - int arraySize = array.Length; - foreach (var pair in this._dictionary) - { - if (arrayIndex >= arraySize) break; - array[arrayIndex++] = pair; - } - } - } - } -} diff --git a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetroloc/cs/logo.png b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetroloc/cs/logo.png deleted file mode 100644 index ebd735aa9352c..0000000000000 Binary files a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetroloc/cs/logo.png and /dev/null differ diff --git a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetroloc/cs/metrolocconsumercs.csproj b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetroloc/cs/metrolocconsumercs.csproj deleted file mode 100644 index b3a901c44262e..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetroloc/cs/metrolocconsumercs.csproj +++ /dev/null @@ -1,175 +0,0 @@ - - - - - Debug - AnyCPU - {06900BA3-255C-4554-B5A0-78F9FE7C9094} - AppContainerExe - Properties - MetroLocConsumerCS - MetroLocConsumerCS - en-US - 512 - {BC8A1FFA-BEE3-4634-8014-F334798102B3};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - 293F5144E0326DE9A1ACD7E244D282407E975B01 - - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE;NETFX_CORE - prompt - 4 - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE;NETFX_CORE - prompt - 4 - - - true - bin\ARM\Debug\ - DEBUG;TRACE;NETFX_CORE - ;2008 - full - ARM - false - prompt - ExpressRules.ruleset - true - - - bin\ARM\Release\ - TRACE;NETFX_CORE - true - ;2008 - pdbonly - ARM - false - prompt - ExpressRules.ruleset - true - - - true - bin\x64\Debug\ - DEBUG;TRACE;NETFX_CORE - ;2008 - full - x64 - false - prompt - ExpressRules.ruleset - true - - - bin\x64\Release\ - TRACE;NETFX_CORE - true - ;2008 - pdbonly - x64 - false - prompt - ExpressRules.ruleset - true - - - true - bin\x86\Debug\ - DEBUG;TRACE;NETFX_CORE - ;2008 - full - x86 - false - prompt - ExpressRules.ruleset - true - - - bin\x86\Release\ - TRACE;NETFX_CORE - true - ;2008 - pdbonly - x86 - false - prompt - ExpressRules.ruleset - true - - - - - - - - - App.xaml - - - BlankPage.xaml - - - - - - Designer - - - - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - - - MSBuild:Compile - Designer - - - MSBuild:Compile - Designer - - - MSBuild:Compile - Designer - - - - - Resources\UILibrary.dll - - - - - - - 11.0 - - - - diff --git a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetroloc/cs/package.appxmanifest b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetroloc/cs/package.appxmanifest deleted file mode 100644 index 5e3d13b2b5787..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetroloc/cs/package.appxmanifest +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - MetroLocConsumerCS - ronpet - StoreLogo.png - MetroLocConsumerCS - - - - 6.2 - 6.2 - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetroloc/cs/richtextcolumns.cs b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetroloc/cs/richtextcolumns.cs deleted file mode 100644 index 6947e008494ad..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetroloc/cs/richtextcolumns.cs +++ /dev/null @@ -1,210 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Windows.Foundation; -using Windows.UI.Xaml; -using Windows.UI.Xaml.Controls; -using Windows.UI.Xaml.Data; -using Windows.UI.Xaml.Documents; - -namespace LocConsumerCS.Common -{ - /// - /// Wrapper for that creates as many additional overflow - /// columns as needed to fit the available content. - /// - /// - /// The following creates a collection of 400-pixel wide columns spaced 50 pixels apart - /// to contain arbitrary data-bound content: - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// Typically used in a horizontally scrolling region where an unbounded amount of - /// space allows for all needed columns to be created. When used in a vertically scrolling - /// space there will never be any additional columns. - [Windows.UI.Xaml.Markup.ContentProperty(Name = "RichTextContent")] - public sealed class RichTextColumns : Panel - { - /// - /// Identifies the dependency property. - /// - public static readonly DependencyProperty RichTextContentProperty = - DependencyProperty.Register("RichTextContent", typeof(RichTextBlock), - typeof(RichTextColumns), new PropertyMetadata(null, ResetOverflowLayout)); - - /// - /// Identifies the dependency property. - /// - public static readonly DependencyProperty ColumnTemplateProperty = - DependencyProperty.Register("ColumnTemplate", typeof(DataTemplate), - typeof(RichTextColumns), new PropertyMetadata(null, ResetOverflowLayout)); - - /// - /// Initializes a new instance of the class. - /// - public RichTextColumns() - { - this.HorizontalAlignment = HorizontalAlignment.Left; - } - - /// - /// Gets or sets the initial rich text content to be used as the first column. - /// - public RichTextBlock RichTextContent - { - get { return (RichTextBlock)GetValue(RichTextContentProperty); } - set { SetValue(RichTextContentProperty, value); } - } - - /// - /// Gets or sets the template used to create additional - /// instances. - /// - public DataTemplate ColumnTemplate - { - get { return (DataTemplate)GetValue(ColumnTemplateProperty); } - set { SetValue(ColumnTemplateProperty, value); } - } - - /// - /// Invoked when the content or overflow template is changed to recreate the column layout. - /// - /// Instance of where the change - /// occurred. - /// Event data describing the specific change. - private static void ResetOverflowLayout(DependencyObject d, DependencyPropertyChangedEventArgs e) - { - // When dramatic changes occur, rebuild the column layout from scratch - var target = d as RichTextColumns; - if (target != null) - { - target._overflowColumns = null; - target.Children.Clear(); - target.InvalidateMeasure(); - } - } - - /// - /// Lists overflow columns already created. Must maintain a 1:1 relationship with - /// instances in the collection following the initial RichTextBlock - /// child. - /// - private List _overflowColumns = null; - - /// - /// Determines whether additional overflow columns are needed and if existing columns can - /// be removed. - /// - /// The size of the space available, used to constrain the - /// number of additional columns that can be created. - /// The resulting size of the original content plus any extra columns. - protected override Size MeasureOverride(Size availableSize) - { - if (this.RichTextContent == null) return new Size(0, 0); - - // Make sure the RichTextBlock is a child, using the lack of - // a list of additional columns as a sign that this hasn't been - // done yet - if (this._overflowColumns == null) - { - Children.Add(this.RichTextContent); - this._overflowColumns = new List(); - } - - // Start by measuring the original RichTextBlock content - this.RichTextContent.Measure(availableSize); - var maxWidth = this.RichTextContent.DesiredSize.Width; - var maxHeight = this.RichTextContent.DesiredSize.Height; - var hasOverflow = this.RichTextContent.HasOverflowContent; - - // Make sure there are enough overflow columns - int overflowIndex = 0; - while (hasOverflow && maxWidth < availableSize.Width && this.ColumnTemplate != null) - { - // Use existing overflow columns until we run out, then create - // more from the supplied template - RichTextBlockOverflow overflow; - if (this._overflowColumns.Count > overflowIndex) - { - overflow = this._overflowColumns[overflowIndex]; - } - else - { - overflow = (RichTextBlockOverflow)this.ColumnTemplate.LoadContent(); - this._overflowColumns.Add(overflow); - this.Children.Add(overflow); - if (overflowIndex == 0) - { - this.RichTextContent.OverflowContentTarget = overflow; - } - else - { - this._overflowColumns[overflowIndex - 1].OverflowContentTarget = overflow; - } - } - - // Measure the new column and prepare to repeat as necessary - overflow.Measure(new Size(availableSize.Width - maxWidth, availableSize.Height)); - maxWidth += overflow.DesiredSize.Width; - maxHeight = Math.Max(maxHeight, overflow.DesiredSize.Height); - hasOverflow = overflow.HasOverflowContent; - overflowIndex++; - } - - // Disconnect extra columns from the overflow chain, remove them from our private list - // of columns, and remove them as children - if (this._overflowColumns.Count > overflowIndex) - { - if (overflowIndex == 0) - { - this.RichTextContent.OverflowContentTarget = null; - } - else - { - this._overflowColumns[overflowIndex - 1].OverflowContentTarget = null; - } - while (this._overflowColumns.Count > overflowIndex) - { - this._overflowColumns.RemoveAt(overflowIndex); - this.Children.RemoveAt(overflowIndex + 1); - } - } - - // Report final determined size - return new Size(maxWidth, maxHeight); - } - - /// - /// Arranges the original content and all extra columns. - /// - /// Defines the size of the area the children must be arranged - /// within. - /// The size of the area the children actually required. - protected override Size ArrangeOverride(Size finalSize) - { - double maxWidth = 0; - double maxHeight = 0; - foreach (var child in Children) - { - child.Arrange(new Rect(maxWidth, 0, child.DesiredSize.Width, finalSize.Height)); - maxWidth += child.DesiredSize.Width; - maxHeight = Math.Max(maxHeight, child.DesiredSize.Height); - } - return new Size(maxWidth, maxHeight); - } - } -} diff --git a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetroloc/cs/smalllogo.png b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetroloc/cs/smalllogo.png deleted file mode 100644 index 92dd1058fbfb7..0000000000000 Binary files a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetroloc/cs/smalllogo.png and /dev/null differ diff --git a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetroloc/cs/splashscreen.png b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetroloc/cs/splashscreen.png deleted file mode 100644 index 193187f108f50..0000000000000 Binary files a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetroloc/cs/splashscreen.png and /dev/null differ diff --git a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetroloc/cs/standardstyles.xaml b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetroloc/cs/standardstyles.xaml deleted file mode 100644 index d480380dbb89c..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetroloc/cs/standardstyles.xaml +++ /dev/null @@ -1,943 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Mouse - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetroloc/cs/storelogo.png b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetroloc/cs/storelogo.png deleted file mode 100644 index 3765186d055fb..0000000000000 Binary files a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.portablemetroloc/cs/storelogo.png and /dev/null differ diff --git a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.retrieving/cs/ctor1.cs b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.retrieving/cs/ctor1.cs deleted file mode 100644 index 1dd0a824c4f75..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.resources.retrieving/cs/ctor1.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; -using System.Resources; - -public class Example -{ - public static void Main() - { - CallCtor1(); - CallCtor2(); - } - - static void CallCtor1() - { - // - ResourceManager rm = new ResourceManager("MyCompany.StringResources", - typeof(Example).Assembly); - // - } - - static void CallCtor2() - { - // - ResourceManager rm = new ResourceManager(typeof(MyCompany.StringResources)); - // - } -} - -namespace MyCompany -{ - class StringResources {} -} \ No newline at end of file diff --git a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.stringreader/cs/source2.cs b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.stringreader/cs/source2.cs deleted file mode 100644 index c9bf757a2b856..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.stringreader/cs/source2.cs +++ /dev/null @@ -1,39 +0,0 @@ -// -using System; -using System.Text; -using System.Windows; -using System.IO; - -namespace WpfApplication -{ - public partial class MainWindow : Window - { - public MainWindow() - { - InitializeComponent(); - } - - private async void ReadButton_Click(object sender, RoutedEventArgs e) - { - char[] charsRead = new char[UserInput.Text.Length]; - using (StringReader reader = new StringReader(UserInput.Text)) - { - await reader.ReadAsync(charsRead, 0, UserInput.Text.Length); - } - - StringBuilder reformattedText = new StringBuilder(); - using (StringWriter writer = new StringWriter(reformattedText)) - { - foreach (char c in charsRead) - { - if (char.IsLetter(c) || char.IsWhiteSpace(c)) - { - await writer.WriteLineAsync(char.ToLower(c)); - } - } - } - Result.Text = reformattedText.ToString(); - } - } -} -// diff --git a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.strings.bestpractices/cs/explicitargs2.cs b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.strings.bestpractices/cs/explicitargs2.cs deleted file mode 100644 index 0dd2b0d0a5c9d..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.strings.bestpractices/cs/explicitargs2.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; - -// -namespace System -{ - public enum StringComparison { - CurrentCulture, - CurrentCultureIgnoreCase, - InvariantCulture, - InvariantCultureIgnoreCase, - Ordinal, - OrdinalIgnoreCase, - } -} -// diff --git a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.strings.bestpractices/cs/settings1.cs b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.strings.bestpractices/cs/settings1.cs deleted file mode 100644 index d2bf18b7d2128..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.strings.bestpractices/cs/settings1.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System; - -public class Class1 -{ - public static void Main() - { - } - - private static void SetRegistryKey() - { - // - Microsoft.Win32.RegistryKey lm = Microsoft.Win32.Registry.LocalMachine; - // Open the NETFramework key - Microsoft.Win32.RegistryKey nf = lm.CreateSubKey(@"Software\Microsoft\.NETFramework"); - // Set the value to 1. This overwrites any existing setting. - nf.SetValue("String_LegacyCompareMode", 1, - Microsoft.Win32.RegistryValueKind.DWord); - // - } - - // - private static bool IsStringLegacyCompareMode() - { - Microsoft.Win32.RegistryKey lm = Microsoft.Win32.Registry.LocalMachine; - // Open the NETFramework key - Microsoft.Win32.RegistryKey nf = lm.OpenSubKey(@"Software\Microsoft\.NETFramework"); - if (nf == null) return false; - - // Get the String_LegacyCompareMode setting. - return (bool) nf.GetValue("String_LegacyCompareMode", 0); - } - // -} diff --git a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.types.viewinfo/cs/source6.cs b/samples/snippets/csharp/VS_Snippets_CLR/conceptual.types.viewinfo/cs/source6.cs deleted file mode 100644 index 4759c0ebcbea6..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CLR/conceptual.types.viewinfo/cs/source6.cs +++ /dev/null @@ -1,29 +0,0 @@ -// -using System; -using System.Reflection; - -class Asminfo1 -{ - public static void Main() - { - Console.WriteLine ("\nReflection.MemberInfo"); - - // Get the Type and MemberInfo. - // Insert the fully qualified class name inside the quotation marks in the - // following statement. - Type MyType = Type.GetType("System.IO.BinaryReader"); - MemberInfo[] Mymemberinfoarray = MyType.GetMembers(BindingFlags.Public | - BindingFlags.NonPublic | BindingFlags.Static | - BindingFlags.Instance | BindingFlags.DeclaredOnly); - - // Get and display the DeclaringType method. - Console.Write("\nThere are {0} documentable members in ", Mymemberinfoarray.Length); - Console.Write("{0}.", MyType.FullName); - - foreach (MemberInfo Mymemberinfo in Mymemberinfoarray) - { - Console.Write("\n" + Mymemberinfo.Name); - } - } -} -// diff --git a/samples/snippets/csharp/VS_Snippets_CLR/portableclasslibrarymvvm/cs/Project.csproj b/samples/snippets/csharp/VS_Snippets_CLR/portableclasslibrarymvvm/cs/Project.csproj deleted file mode 100644 index b83f0211b39c5..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CLR/portableclasslibrarymvvm/cs/Project.csproj +++ /dev/null @@ -1,7 +0,0 @@ - - - - Library - net6.0 - - diff --git a/samples/snippets/csharp/VS_Snippets_CLR/portableclasslibrarymvvm/cs/customer.cs b/samples/snippets/csharp/VS_Snippets_CLR/portableclasslibrarymvvm/cs/customer.cs deleted file mode 100644 index c1638cb183403..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CLR/portableclasslibrarymvvm/cs/customer.cs +++ /dev/null @@ -1,27 +0,0 @@ -// -using System; - -namespace SimpleMVVM.Model -{ - public class Customer - { - public int CustomerID - { - get; - set; - } - - public string FullName - { - get; - set; - } - - public string Phone - { - get; - set; - } - } -} -// \ No newline at end of file diff --git a/samples/snippets/csharp/VS_Snippets_CLR/portableclasslibrarymvvm/cs/customerrepository.cs b/samples/snippets/csharp/VS_Snippets_CLR/portableclasslibrarymvvm/cs/customerrepository.cs deleted file mode 100644 index 6c6311e59cef0..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CLR/portableclasslibrarymvvm/cs/customerrepository.cs +++ /dev/null @@ -1,34 +0,0 @@ -// -using System; -using System.Collections.Generic; -using System.Linq; - -namespace SimpleMVVM.Model -{ - public class CustomerRepository - { - private List _customers; - - public CustomerRepository() - { - _customers = new List - { - new Customer(){ CustomerID = 1, FullName="Dana Birkby", Phone="394-555-0181"}, - new Customer(){ CustomerID = 2, FullName="Adriana Giorgi", Phone="117-555-0119"}, - new Customer(){ CustomerID = 3, FullName="Wei Yu", Phone="798-555-0118"} - }; - } - - public List GetCustomers() - { - return _customers; - } - - public void UpdateCustomer(Customer SelectedCustomer) - { - Customer customerToChange = _customers.Single(c => c.CustomerID == SelectedCustomer.CustomerID); - customerToChange = SelectedCustomer; - } - } -} -// diff --git a/samples/snippets/csharp/VS_Snippets_CLR/portableclasslibrarymvvm/cs/mainpageviewmodel.cs b/samples/snippets/csharp/VS_Snippets_CLR/portableclasslibrarymvvm/cs/mainpageviewmodel.cs deleted file mode 100644 index 097007e431662..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CLR/portableclasslibrarymvvm/cs/mainpageviewmodel.cs +++ /dev/null @@ -1,63 +0,0 @@ -// -using System; -using System.Collections.Generic; -using SimpleMVVM.Model; - -namespace SimpleMVVM.ViewModel -{ - public class CustomerViewModel : ViewModelBase - { - private List _customers; - private Customer _currentCustomer; - private CustomerRepository _repository; - - public CustomerViewModel() - { - _repository = new CustomerRepository(); - _customers = _repository.GetCustomers(); - - WireCommands(); - } - - private void WireCommands() - { - UpdateCustomerCommand = new RelayCommand(UpdateCustomer); - } - - public RelayCommand UpdateCustomerCommand - { - get; - private set; - } - - public List Customers - { - get { return _customers; } - set { _customers = value; } - } - - public Customer CurrentCustomer - { - get - { - return _currentCustomer; - } - - set - { - if (_currentCustomer != value) - { - _currentCustomer = value; - OnPropertyChanged("CurrentCustomer"); - UpdateCustomerCommand.IsEnabled = true; - } - } - } - - public void UpdateCustomer() - { - _repository.UpdateCustomer(CurrentCustomer); - } - } -} -// \ No newline at end of file diff --git a/samples/snippets/csharp/VS_Snippets_CLR/portableclasslibrarymvvm/cs/mainwindow.xaml b/samples/snippets/csharp/VS_Snippets_CLR/portableclasslibrarymvvm/cs/mainwindow.xaml deleted file mode 100644 index 8370c69314a08..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_CLR/portableclasslibrarymvvm/cs/mainwindow.xaml +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/samples/snippets/csharp/VS_Snippets_Misc/astoria_photo_streaming_client/cs/photodetailswindow.xaml.cs b/samples/snippets/csharp/VS_Snippets_Misc/astoria_photo_streaming_client/cs/photodetailswindow.xaml.cs deleted file mode 100644 index a3c328b60cebb..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_Misc/astoria_photo_streaming_client/cs/photodetailswindow.xaml.cs +++ /dev/null @@ -1,263 +0,0 @@ -//********************************************************* -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the Microsoft Public License. -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -//********************************************************* -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Shapes; - -using PhotoData; -using System.Data.Services.Client; -using System.IO; - -namespace PhotoStreamingClient -{ - /// - /// Interaction logic for PhotoDetailsWindow.xaml - /// - public partial class PhotoDetailsWindow : Window - { - private PhotoInfo photoEntity; - private DataServiceContext context; - private FileStream imageStream; - private MergeOption cachedMergeOption; - - public PhotoDetailsWindow(PhotoInfo photo, DataServiceContext context) - { - InitializeComponent(); - - this.photoEntity = photo; - this.context = context; - } - - private void Window_Loaded(object sender, RoutedEventArgs e) - { - // Display the OpenImage dialog if we are adding a new photo. - if (photoEntity.PhotoId == 0) - { - if (!SelectPhotoToSend()) - { - // Close the add photo window if a photo cannot be selected. - this.Close(); - } - } - - // Set the binding source of the root WPF object to the new entity. - LayoutRoot.DataContext = photoEntity; - } - - private void setPhoto_Click(object sender, RoutedEventArgs e) - { - // Select a photo from the local computer. - SelectPhotoToSend(); - } - - private bool SelectPhotoToSend() - { - // Create a dialog to select the image file to stream to the data service. - Microsoft.Win32.OpenFileDialog openImage = new Microsoft.Win32.OpenFileDialog(); - openImage.FileName = "image"; - openImage.DefaultExt = ".*"; - openImage.Filter = "Images File|*.jpg;*.png;*.gif;*.bmp"; - openImage.Title = "Select the image file to upload..."; - openImage.Multiselect = false; - openImage.CheckFileExists = true; - - // Reset the image stream. - imageStream = null; - - try - { - if (openImage.ShowDialog(this) == true) - { - if (photoEntity.PhotoId == 0) - { - // Set the image name from the selected file. - photoEntity.FileName = openImage.SafeFileName; - - photoEntity.DateAdded = DateTime.Today; - - // Set the content type and the file name for the slug header. - photoEntity.ContentType = - GetContentTypeFromFileName(photoEntity.FileName); - } - - photoEntity.DateModified = DateTime.Today; - - // Use a FileStream to open the existing image file. - imageStream = new FileStream(openImage.FileName, FileMode.Open); - - photoEntity.FileSize = (int)imageStream.Length; - - // Create a new image using the memory stream. - BitmapImage imageFromStream = new BitmapImage(); - imageFromStream.BeginInit(); - imageFromStream.StreamSource = imageStream; - imageFromStream.CacheOption = BitmapCacheOption.OnLoad; - imageFromStream.EndInit(); - - // Set the height and width of the image. - photoEntity.Dimensions.Height = (short?)imageFromStream.PixelHeight; - photoEntity.Dimensions.Width = (short?)imageFromStream.PixelWidth; - - // Reset to the beginning of the stream before we pass it to the service. - imageStream.Position = 0; - - // - // Set the file stream as the source of binary stream - // to send to the data service. The Slug header is the file name and - // the content type is determined from the file extension. - // A value of 'true' means that the stream is closed by the client when - // the upload is complete. - context.SetSaveStream(photoEntity, imageStream, true, - photoEntity.ContentType, photoEntity.FileName); - // - - return true; - } - else - { - MessageBox.Show("The selected file could not be opened."); - return false; - } - } - catch (IOException ex) - { - MessageBox.Show( - string.Format("The selected image file could not be opened. {0}", - ex.Message), "Operation Failed"); - - return false; - } - } - private void savePhotoDetails_Click(object sender, RoutedEventArgs e) - { - EntityDescriptor entity = null; - - try - { - if (string.IsNullOrEmpty(photoEntity.FileName)) - { - MessageBox.Show("You must first select an image file to upload."); - return; - } - - // Send the update (POST or MERGE) request to the data service and - // capture the added or updated entity in the response. - ChangeOperationResponse response = - context.SaveChanges().FirstOrDefault() as ChangeOperationResponse; - - // When we issue a POST request, the photo ID and edit-media link are not updated - // on the client (a bug), so we need to get the server values. - if (photoEntity.PhotoId == 0) - { - if (response != null) - { - entity = response.Descriptor as EntityDescriptor; - } - - // Verify that the entity was created correctly. - if (entity != null && entity.EditLink != null) - { - // Cache the current merge option (we reset to the cached - // value in the finally block). - cachedMergeOption = context.MergeOption; - - // Set the merge option so that server changes win. - context.MergeOption = MergeOption.OverwriteChanges; - - // Get the updated entity from the service. - // Note: we need Count() just to execute the query. - context.Execute(entity.EditLink).Count(); - } - } - - this.DialogResult = true; - this.Close(); - } - catch (DataServiceRequestException ex) - { - // Get the change operation result. - ChangeOperationResponse response = - ex.Response.FirstOrDefault() as ChangeOperationResponse; - - string errorMessage = string.Empty; - - // Check for a resource not found error. - if (response != null && response.StatusCode == 404) - { - // Tell the user to refresh the photos from the data service. - errorMessage = "The selected image may have been removed from the data service.\n" - + "Click the Refresh Photos button to refresh photos from the service."; - } - else - { - // Just provide the general error message. - errorMessage = string.Format("The photo data could not be updated or saved. {0}", - ex.Message); - } - - // Show the messsage box. - MessageBox.Show(errorMessage, "Operation Failed"); - - // Return false since we could not add or update the photo. - this.DialogResult = false; - return; - } - finally - { - // Reset to the cached merge option. - context.MergeOption = cachedMergeOption; - } - } - private static string GetContentTypeFromFileName(string fileName) - { - // Get the file extension from the FileName property. - string[] splitFileName = fileName.Split(new Char[] { '.' }); - - // Return the Content-Type value based on the file extension. - switch (splitFileName[splitFileName.Length - 1]) - { - case "jpeg": - return "image/jpeg"; - case "jpg": - return "image/jpeg"; - case "gif": - return "image/gif"; - case "png": - return "image/png"; - case "tiff": - return "image/tiff"; - case "bmp": - return "image/bmp"; - default: - return "application/octet-stream"; - } - } - - private void cancelDetails_Click(object sender, RoutedEventArgs e) - { - if (MessageBox.Show("If you cancel without saving you will lose any changes.", "Close this dialog?", - MessageBoxButton.OKCancel) == MessageBoxResult.OK) - { - this.DialogResult = false; - this.Close(); - } - } - } -} \ No newline at end of file diff --git a/samples/snippets/csharp/VS_Snippets_Misc/astoria_photo_streaming_client/cs/photostreamingclient.csproj b/samples/snippets/csharp/VS_Snippets_Misc/astoria_photo_streaming_client/cs/photostreamingclient.csproj deleted file mode 100644 index fd1bb33eb57c4..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_Misc/astoria_photo_streaming_client/cs/photostreamingclient.csproj +++ /dev/null @@ -1,170 +0,0 @@ - - - - Debug - AnyCPU - 9.0.30729 - 2.0 - {455EE0A5-63D5-4380-8B85-8F5BF505BEF0} - WinExe - Properties - PhotoStreamingClient - PhotoStreamingClient - v4.0 - 512 - {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - 4 - - - 3.5 - - Client - publish\ - true - Disk - false - Foreground - 7 - Days - false - false - true - 0 - 1.0.0.%2a - false - false - true - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - AllRules.ruleset - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - AllRules.ruleset - - - false - - - - - 3.5 - - - - 3.0 - - - 3.0 - - - - 3.5 - - - 3.5 - - - - - 3.0 - - - 3.0 - - - 3.0 - - - 3.0 - - - - - MSBuild:Compile - Designer - MSBuild:Compile - Designer - - - Designer - MSBuild:Compile - MSBuild:Compile - Designer - - - MSBuild:Compile - Designer - MSBuild:Compile - Designer - - - App.xaml - Code - - - - PhotoWindow.xaml - Code - - - - - PhotoDetailsWindow.xaml - - - Code - - - True - Settings.settings - True - - - - SettingsSingleFileGenerator - Settings.Designer.cs - - - - - - - - - False - .NET Framework 3.5 SP1 Client Profile - false - - - False - .NET Framework 3.5 SP1 - true - - - False - Windows Installer 3.1 - true - - - - - \ No newline at end of file diff --git a/samples/snippets/csharp/VS_Snippets_Misc/astoria_photo_streaming_client/cs/photowindow.xaml b/samples/snippets/csharp/VS_Snippets_Misc/astoria_photo_streaming_client/cs/photowindow.xaml deleted file mode 100644 index d03abd1d3a50a..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_Misc/astoria_photo_streaming_client/cs/photowindow.xaml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - diff --git a/samples/snippets/csharp/VS_Snippets_Misc/astoria_quickstart_client/cs/window1.xaml.cs b/samples/snippets/csharp/VS_Snippets_Misc/astoria_quickstart_client/cs/window1.xaml.cs deleted file mode 100644 index 747f7b297d129..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_Misc/astoria_quickstart_client/cs/window1.xaml.cs +++ /dev/null @@ -1,87 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Shapes; -// -using System.Data.Services.Client; -using NorthwindClient.Northwind; -// - -namespace NorthwindClient -{ - /// - /// Interaction logic for Window1.xaml - /// - public partial class Window1 : Window - { - public Window1() - { - InitializeComponent(); - } - // - private NorthwindEntities context; - private string customerId = "ALFKI"; - - // Replace the host server and port number with the values - // for the test server hosting your Northwind data service instance. - private Uri svcUri = new Uri("http://localhost:12345/Northwind.svc"); - - private void Window1_Loaded(object sender, RoutedEventArgs e) - { - try - { - // Instantiate the DataServiceContext. - context = new NorthwindEntities(svcUri); - - context.IgnoreMissingProperties = true; - - // Define a LINQ query that returns Orders and - // Order_Details for a specific customer. - var ordersQuery = from o in context.Orders.Expand("Order_Details") - where o.Customer.CustomerID == customerId - select o; - - // Create an DataServiceCollection based on - // execution of the LINQ query for Orders. - DataServiceCollection customerOrders = new - DataServiceCollection(ordersQuery); - - // - // Make the DataServiceCollection the binding source for the Grid. - this.orderItemsGrid.DataContext = customerOrders; - // - } - catch (Exception ex) - { - MessageBox.Show(ex.ToString()); - } - } - // - // - private void buttonSaveChanges_Click(object sender, RoutedEventArgs e) - { - try - { - // Save changes made to objects tracked by the context. - context.SaveChanges(); - } - catch (DataServiceRequestException ex) - { - MessageBox.Show(ex.ToString()); - } - } - private void buttonClose_Click(object sender, RoutedEventArgs e) - { - this.Close(); - } - // - } -} diff --git a/samples/snippets/csharp/VS_Snippets_Misc/astoria_streaming_client/cs/app.config b/samples/snippets/csharp/VS_Snippets_Misc/astoria_streaming_client/cs/app.config deleted file mode 100644 index 2f7cce784b99e..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_Misc/astoria_streaming_client/cs/app.config +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/samples/snippets/csharp/VS_Snippets_Misc/astoria_streaming_client/cs/app.xaml b/samples/snippets/csharp/VS_Snippets_Misc/astoria_streaming_client/cs/app.xaml deleted file mode 100644 index 0b0692548e383..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_Misc/astoria_streaming_client/cs/app.xaml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - diff --git a/samples/snippets/csharp/VS_Snippets_Misc/astoria_streaming_client/cs/app.xaml.cs b/samples/snippets/csharp/VS_Snippets_Misc/astoria_streaming_client/cs/app.xaml.cs deleted file mode 100644 index 2f01dbc445426..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_Misc/astoria_streaming_client/cs/app.xaml.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Configuration; -using System.Data; -using System.Linq; -using System.Windows; - -namespace NorthwindStreamingClient -{ - /// - /// Interaction logic for App.xaml - /// - public partial class App : Application - { - } -} diff --git a/samples/snippets/csharp/VS_Snippets_Misc/astoria_streaming_client/cs/customerphotowindow.xaml b/samples/snippets/csharp/VS_Snippets_Misc/astoria_streaming_client/cs/customerphotowindow.xaml deleted file mode 100644 index 46f928bfa3c97..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_Misc/astoria_streaming_client/cs/customerphotowindow.xaml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - diff --git a/samples/snippets/csharp/VS_Snippets_Misc/astoria_streaming_client/cs/customerphotowindow.xaml.cs b/samples/snippets/csharp/VS_Snippets_Misc/astoria_streaming_client/cs/customerphotowindow.xaml.cs deleted file mode 100644 index 00c8eaba86c94..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_Misc/astoria_streaming_client/cs/customerphotowindow.xaml.cs +++ /dev/null @@ -1,179 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; -using NorthwindStreamingClient.Northwind; -using System.Data.Services.Client; -using System.IO; - -namespace NorthwindStreamingClient -{ - /// - /// Interaction logic for CustomerPhotoWindow.xaml - /// - public partial class CustomerPhotoWindow : Window - { - private NorthwindEntities context; - private DataServiceCollection trackedEmployees; - private Employees currentEmployee; - - // Ideally, the service URI should be stored in the settings file. - private Uri svcUri = - new Uri("http://" + Environment.MachineName + - "/NorthwindStreaming/NorthwindStreaming.svc"); - - public CustomerPhotoWindow() - { - InitializeComponent(); - } - - private void Window_Loaded(object sender, RoutedEventArgs e) - { - // Instantiate the data service context. - context = new NorthwindEntities(svcUri); - - try - { - // Create a new collection for binding based on the LINQ query. - trackedEmployees = new DataServiceCollection(context.Employees); - - // Load all pages of the response at once. - while (trackedEmployees.Continuation != null) - { - trackedEmployees.Load( - context.Execute(trackedEmployees.Continuation.NextLinkUri)); - } - - // Bind the root StackPanel element to the collection; - // related object binding paths are defined in the XAML. - LayoutRoot.DataContext = trackedEmployees; - - if (trackedEmployees.Count == 0) - { - MessageBox.Show("Data could not be returned from the data service."); - } - - // Select the first employee in the collection. - employeesComboBox.SelectedIndex = 0; - } - catch (DataServiceQueryException ex) - { - MessageBox.Show(ex.Message); - } - catch (InvalidOperationException ex) - { - MessageBox.Show(ex.Message); - } - } - - private void employeesComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) - { - // Get the currently selected employee. - currentEmployee = - (Employees)this.employeesComboBox.SelectedItem; - - try - { - // - // Get the read stream for the Media Resource of the currently selected - // entity (Media Link Entry). - using (DataServiceStreamResponse response = - context.GetReadStream(currentEmployee, "image/bmp")) - { - // Use the returned binary stream to create a bitmap image that is - // the source of the image control. - employeeImage.Source = CreateBitmapFromStream(response.Stream); - } - // - - // - // Get the read stream URI for the Media Resource of the currently selected - // entity (Media Link Entry), and use it to create a bitmap image that is - // the source of the image control. - employeeImage.Source = new BitmapImage(context.GetReadStreamUri(currentEmployee)); - // - } - catch (DataServiceRequestException ex) - { - MessageBox.Show(ex.InnerException.Message); - } - } - - private void setImage_Click(object sender, RoutedEventArgs e) - { - // Create a dialog to select the bitmap to stream to the data service. - Microsoft.Win32.OpenFileDialog openImage = new Microsoft.Win32.OpenFileDialog(); - openImage.FileName = "image"; - openImage.DefaultExt = ".bmp"; - openImage.Filter = "Bitmap images (.bmp)|*.bmp"; - openImage.Title = "Select the image file to upload..."; - - try - { - if (openImage.ShowDialog(this) == true) - { - // - // Use the FileStream to open an existing image file. - FileStream imageStream = - new FileStream(openImage.FileName, FileMode.Open); - - // Set the file stream as the source of binary stream - // to send to the data service. Allow the context to - // close the filestream. - context.SetSaveStream(currentEmployee, - imageStream, true, "image/bmp", - string.Empty); - - // Upload the binary stream to the data service. - context.SaveChanges(); - // - - imageStream = - new FileStream(openImage.FileName, FileMode.Open); - - employeeImage.Source = CreateBitmapFromStream(imageStream); - } - } - catch (DataServiceRequestException ex) - { - MessageBox.Show(ex.InnerException.Message); - } - } - - private BitmapImage CreateBitmapFromStream(Stream stream) - { - try - { - // Create a new bitmap image using the memory stream. - BitmapImage imageFromStream = new BitmapImage(); - imageFromStream.BeginInit(); - imageFromStream.StreamSource = stream; - imageFromStream.CacheOption = BitmapCacheOption.OnLoad; - imageFromStream.EndInit(); - - // Return the bitmap. - return imageFromStream; - } - catch (Exception) - { - MessageBox.Show("The file cannot be read; " - + "make sure that it is a valid .bmp file."); - return null; - } - } - - private void closeWindow_Click(object sender, RoutedEventArgs e) - { - Close(); - } - } -} diff --git a/samples/snippets/csharp/VS_Snippets_Misc/astoria_streaming_client/cs/northwindstreamingclient.csproj b/samples/snippets/csharp/VS_Snippets_Misc/astoria_streaming_client/cs/northwindstreamingclient.csproj deleted file mode 100644 index b56487bd9ada3..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_Misc/astoria_streaming_client/cs/northwindstreamingclient.csproj +++ /dev/null @@ -1,181 +0,0 @@ - - - - Debug - AnyCPU - 9.0.30729 - 2.0 - {455EE0A5-63D5-4380-8B85-8F5BF505BEF0} - WinExe - Properties - NorthwindStreamingClient - NorthwindStreamingClient - v4.0 - 512 - {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - 4 - - - 3.5 - - false - Client - publish\ - true - Disk - false - Foreground - 7 - Days - false - false - true - 0 - 1.0.0.%2a - false - true - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - AllRules.ruleset - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - AllRules.ruleset - - - - - 3.5 - - - 3.5 - - - 3.0 - - - 3.0 - - - - 3.5 - - - 3.5 - - - - - - - - - - MSBuild:Compile - Designer - MSBuild:Compile - Designer - - - True - True - Reference.datasvcmap - - - MSBuild:Compile - Designer - MSBuild:Compile - Designer - - - App.xaml - Code - - - CustomerPhotoWindow.xaml - Code - - - - - Code - - - True - True - Resources.resx - - - True - Settings.settings - True - - - ResXFileCodeGenerator - Resources.Designer.cs - - - - SettingsSingleFileGenerator - Settings.Designer.cs - - - - - - - - - - metadata.xml - - - - - False - .NET Framework 3.5 SP1 Client Profile - false - - - False - .NET Framework 3.5 SP1 - true - - - False - Windows Installer 3.1 - true - - - - - datasvcmap - - - - - DataServiceClientGenerator - Reference.cs - - - - - \ No newline at end of file diff --git a/samples/snippets/csharp/VS_Snippets_Misc/astoria_streaming_client/cs/properties/assemblyinfo.cs b/samples/snippets/csharp/VS_Snippets_Misc/astoria_streaming_client/cs/properties/assemblyinfo.cs deleted file mode 100644 index a2bf6775d60cb..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_Misc/astoria_streaming_client/cs/properties/assemblyinfo.cs +++ /dev/null @@ -1,53 +0,0 @@ -using System.Reflection; -using System.Resources; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Windows; - -// 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("NorthwindStreamingClient")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Microsoft")] -[assembly: AssemblyProduct("NorthwindStreamingClient")] -[assembly: AssemblyCopyright("Copyright © Microsoft 2009")] -[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)] - -//In order to begin building localizable applications, set -//CultureYouAreCodingWith in your .csproj file -//inside a . For example, if you are using US english -//in your source files, set the to en-US. Then uncomment -//the NeutralResourceLanguage attribute below. Update the "en-US" in -//the line below to match the UICulture setting in the project file. - -//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] - -[assembly: ThemeInfo( - ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located - //(used if a resource is not found in the page, - // or application resource dictionaries) - ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located - //(used if a resource is not found in the page, - // app, or any theme specific resource dictionaries) -)] - -// 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")] diff --git a/samples/snippets/csharp/VS_Snippets_Misc/astoria_streaming_client/cs/properties/resources.designer.cs b/samples/snippets/csharp/VS_Snippets_Misc/astoria_streaming_client/cs/properties/resources.designer.cs deleted file mode 100644 index 267d8db7c14a0..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_Misc/astoria_streaming_client/cs/properties/resources.designer.cs +++ /dev/null @@ -1,63 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.21030.0 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace NorthwindStreamingClient.Properties { - using System; - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Resources { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Resources() { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("NorthwindStreamingClient.Properties.Resources", typeof(Resources).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - } -} diff --git a/samples/snippets/csharp/VS_Snippets_Misc/astoria_streaming_client/cs/properties/resources.resx b/samples/snippets/csharp/VS_Snippets_Misc/astoria_streaming_client/cs/properties/resources.resx deleted file mode 100644 index af7dbebbacef5..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_Misc/astoria_streaming_client/cs/properties/resources.resx +++ /dev/null @@ -1,117 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/samples/snippets/csharp/VS_Snippets_Misc/astoria_streaming_client/cs/properties/settings.designer.cs b/samples/snippets/csharp/VS_Snippets_Misc/astoria_streaming_client/cs/properties/settings.designer.cs deleted file mode 100644 index 798fadddbdb3a..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_Misc/astoria_streaming_client/cs/properties/settings.designer.cs +++ /dev/null @@ -1,26 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.21030.0 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace NorthwindStreamingClient.Properties { - - - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")] - internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { - - private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); - - public static Settings Default { - get { - return defaultInstance; - } - } - } -} diff --git a/samples/snippets/csharp/VS_Snippets_Misc/astoria_streaming_client/cs/properties/settings.settings b/samples/snippets/csharp/VS_Snippets_Misc/astoria_streaming_client/cs/properties/settings.settings deleted file mode 100644 index 033d7a5e9e226..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_Misc/astoria_streaming_client/cs/properties/settings.settings +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/samples/snippets/csharp/VS_Snippets_Misc/astoria_streaming_client/cs/service references/northwind/reference.cs b/samples/snippets/csharp/VS_Snippets_Misc/astoria_streaming_client/cs/service references/northwind/reference.cs deleted file mode 100644 index 58d363bdb6761..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_Misc/astoria_streaming_client/cs/service references/northwind/reference.cs +++ /dev/null @@ -1,512 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30306.1 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -// Original file name: -// Generation date: 3/15/2010 1:14:46 AM -namespace NorthwindStreamingClient.Northwind -{ - - /// - /// There are no comments for NorthwindEntities in the schema. - /// - public partial class NorthwindEntities : global::System.Data.Services.Client.DataServiceContext - { - /// - /// Initialize a new NorthwindEntities object. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public NorthwindEntities(global::System.Uri serviceRoot) : - base(serviceRoot) - { - this.ResolveName = new global::System.Func(this.ResolveNameFromType); - this.ResolveType = new global::System.Func(this.ResolveTypeFromName); - this.OnContextCreated(); - } - partial void OnContextCreated(); - /// - /// Since the namespace configured for this service reference - /// in Visual Studio is different from the one indicated in the - /// server schema, use type-mappers to map between the two. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - protected global::System.Type ResolveTypeFromName(string typeName) - { - if (typeName.StartsWith("NorthwindModel", global::System.StringComparison.Ordinal)) - { - return this.GetType().Assembly.GetType(string.Concat("NorthwindStreamingClient.Northwind", typeName.Substring(14)), false); - } - return null; - } - /// - /// Since the namespace configured for this service reference - /// in Visual Studio is different from the one indicated in the - /// server schema, use type-mappers to map between the two. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - protected string ResolveNameFromType(global::System.Type clientType) - { - if (clientType.Namespace.Equals("NorthwindStreamingClient.Northwind", global::System.StringComparison.Ordinal)) - { - return string.Concat("NorthwindModel.", clientType.Name); - } - return null; - } - /// - /// There are no comments for Employees in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public global::System.Data.Services.Client.DataServiceQuery Employees - { - get - { - if ((this._Employees == null)) - { - this._Employees = base.CreateQuery("Employees"); - } - return this._Employees; - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private global::System.Data.Services.Client.DataServiceQuery _Employees; - /// - /// There are no comments for Employees in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public void AddToEmployees(Employees employees) - { - base.AddObject("Employees", employees); - } - } - /// - /// There are no comments for NorthwindModel.Employees in the schema. - /// - /// - /// EmployeeID - /// - [global::System.Data.Services.Common.EntitySetAttribute("Employees")] - [global::System.Data.Services.Common.HasStreamAttribute()] - [global::System.Data.Services.Common.DataServiceKeyAttribute("EmployeeID")] - public partial class Employees : global::System.ComponentModel.INotifyPropertyChanged - { - /// - /// Create a new Employees object. - /// - /// Initial value of EmployeeID. - /// Initial value of LastName. - /// Initial value of FirstName. - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public static Employees CreateEmployees(int employeeID, string lastName, string firstName) - { - Employees employees = new Employees(); - employees.EmployeeID = employeeID; - employees.LastName = lastName; - employees.FirstName = firstName; - return employees; - } - /// - /// There are no comments for Property EmployeeID in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public int EmployeeID - { - get - { - return this._EmployeeID; - } - set - { - this.OnEmployeeIDChanging(value); - this._EmployeeID = value; - this.OnEmployeeIDChanged(); - this.OnPropertyChanged("EmployeeID"); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private int _EmployeeID; - partial void OnEmployeeIDChanging(int value); - partial void OnEmployeeIDChanged(); - /// - /// There are no comments for Property LastName in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public string LastName - { - get - { - return this._LastName; - } - set - { - this.OnLastNameChanging(value); - this._LastName = value; - this.OnLastNameChanged(); - this.OnPropertyChanged("LastName"); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private string _LastName; - partial void OnLastNameChanging(string value); - partial void OnLastNameChanged(); - /// - /// There are no comments for Property FirstName in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public string FirstName - { - get - { - return this._FirstName; - } - set - { - this.OnFirstNameChanging(value); - this._FirstName = value; - this.OnFirstNameChanged(); - this.OnPropertyChanged("FirstName"); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private string _FirstName; - partial void OnFirstNameChanging(string value); - partial void OnFirstNameChanged(); - /// - /// There are no comments for Property Title in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public string Title - { - get - { - return this._Title; - } - set - { - this.OnTitleChanging(value); - this._Title = value; - this.OnTitleChanged(); - this.OnPropertyChanged("Title"); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private string _Title; - partial void OnTitleChanging(string value); - partial void OnTitleChanged(); - /// - /// There are no comments for Property TitleOfCourtesy in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public string TitleOfCourtesy - { - get - { - return this._TitleOfCourtesy; - } - set - { - this.OnTitleOfCourtesyChanging(value); - this._TitleOfCourtesy = value; - this.OnTitleOfCourtesyChanged(); - this.OnPropertyChanged("TitleOfCourtesy"); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private string _TitleOfCourtesy; - partial void OnTitleOfCourtesyChanging(string value); - partial void OnTitleOfCourtesyChanged(); - /// - /// There are no comments for Property BirthDate in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public global::System.Nullable BirthDate - { - get - { - return this._BirthDate; - } - set - { - this.OnBirthDateChanging(value); - this._BirthDate = value; - this.OnBirthDateChanged(); - this.OnPropertyChanged("BirthDate"); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private global::System.Nullable _BirthDate; - partial void OnBirthDateChanging(global::System.Nullable value); - partial void OnBirthDateChanged(); - /// - /// There are no comments for Property HireDate in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public global::System.Nullable HireDate - { - get - { - return this._HireDate; - } - set - { - this.OnHireDateChanging(value); - this._HireDate = value; - this.OnHireDateChanged(); - this.OnPropertyChanged("HireDate"); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private global::System.Nullable _HireDate; - partial void OnHireDateChanging(global::System.Nullable value); - partial void OnHireDateChanged(); - /// - /// There are no comments for Property Address in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public string Address - { - get - { - return this._Address; - } - set - { - this.OnAddressChanging(value); - this._Address = value; - this.OnAddressChanged(); - this.OnPropertyChanged("Address"); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private string _Address; - partial void OnAddressChanging(string value); - partial void OnAddressChanged(); - /// - /// There are no comments for Property City in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public string City - { - get - { - return this._City; - } - set - { - this.OnCityChanging(value); - this._City = value; - this.OnCityChanged(); - this.OnPropertyChanged("City"); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private string _City; - partial void OnCityChanging(string value); - partial void OnCityChanged(); - /// - /// There are no comments for Property Region in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public string Region - { - get - { - return this._Region; - } - set - { - this.OnRegionChanging(value); - this._Region = value; - this.OnRegionChanged(); - this.OnPropertyChanged("Region"); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private string _Region; - partial void OnRegionChanging(string value); - partial void OnRegionChanged(); - /// - /// There are no comments for Property PostalCode in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public string PostalCode - { - get - { - return this._PostalCode; - } - set - { - this.OnPostalCodeChanging(value); - this._PostalCode = value; - this.OnPostalCodeChanged(); - this.OnPropertyChanged("PostalCode"); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private string _PostalCode; - partial void OnPostalCodeChanging(string value); - partial void OnPostalCodeChanged(); - /// - /// There are no comments for Property Country in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public string Country - { - get - { - return this._Country; - } - set - { - this.OnCountryChanging(value); - this._Country = value; - this.OnCountryChanged(); - this.OnPropertyChanged("Country"); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private string _Country; - partial void OnCountryChanging(string value); - partial void OnCountryChanged(); - /// - /// There are no comments for Property HomePhone in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public string HomePhone - { - get - { - return this._HomePhone; - } - set - { - this.OnHomePhoneChanging(value); - this._HomePhone = value; - this.OnHomePhoneChanged(); - this.OnPropertyChanged("HomePhone"); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private string _HomePhone; - partial void OnHomePhoneChanging(string value); - partial void OnHomePhoneChanged(); - /// - /// There are no comments for Property Extension in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public string Extension - { - get - { - return this._Extension; - } - set - { - this.OnExtensionChanging(value); - this._Extension = value; - this.OnExtensionChanged(); - this.OnPropertyChanged("Extension"); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private string _Extension; - partial void OnExtensionChanging(string value); - partial void OnExtensionChanged(); - /// - /// There are no comments for Property Notes in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public string Notes - { - get - { - return this._Notes; - } - set - { - this.OnNotesChanging(value); - this._Notes = value; - this.OnNotesChanged(); - this.OnPropertyChanged("Notes"); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private string _Notes; - partial void OnNotesChanging(string value); - partial void OnNotesChanged(); - /// - /// There are no comments for Property PhotoPath in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public string PhotoPath - { - get - { - return this._PhotoPath; - } - set - { - this.OnPhotoPathChanging(value); - this._PhotoPath = value; - this.OnPhotoPathChanged(); - this.OnPropertyChanged("PhotoPath"); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private string _PhotoPath; - partial void OnPhotoPathChanging(string value); - partial void OnPhotoPathChanged(); - /// - /// There are no comments for Employees1 in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public global::System.Data.Services.Client.DataServiceCollection Employees1 - { - get - { - return this._Employees1; - } - set - { - this._Employees1 = value; - this.OnPropertyChanged("Employees1"); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private global::System.Data.Services.Client.DataServiceCollection _Employees1 = new global::System.Data.Services.Client.DataServiceCollection(null, System.Data.Services.Client.TrackingMode.None); - /// - /// There are no comments for Employees2 in the schema. - /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public Employees Employees2 - { - get - { - return this._Employees2; - } - set - { - this._Employees2 = value; - this.OnPropertyChanged("Employees2"); - } - } - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - private Employees _Employees2; - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - public event global::System.ComponentModel.PropertyChangedEventHandler PropertyChanged; - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")] - protected virtual void OnPropertyChanged(string property) - { - if ((this.PropertyChanged != null)) - { - this.PropertyChanged(this, new global::System.ComponentModel.PropertyChangedEventArgs(property)); - } - } - } -} diff --git a/samples/snippets/csharp/VS_Snippets_Misc/astoria_streaming_client/cs/service references/northwind/reference.datasvcmap b/samples/snippets/csharp/VS_Snippets_Misc/astoria_streaming_client/cs/service references/northwind/reference.datasvcmap deleted file mode 100644 index 43a2698601a42..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_Misc/astoria_streaming_client/cs/service references/northwind/reference.datasvcmap +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file diff --git a/samples/snippets/csharp/VS_Snippets_Misc/astoria_streaming_client/cs/service references/northwind/service.edmx b/samples/snippets/csharp/VS_Snippets_Misc/astoria_streaming_client/cs/service references/northwind/service.edmx deleted file mode 100644 index 4847f40316058..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_Misc/astoria_streaming_client/cs/service references/northwind/service.edmx +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/samples/snippets/csharp/VS_Snippets_Misc/cancellation/cs/cancellation.cs b/samples/snippets/csharp/VS_Snippets_Misc/cancellation/cs/cancellation.cs deleted file mode 100644 index e920af17170d0..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_Misc/cancellation/cs/cancellation.cs +++ /dev/null @@ -1,54 +0,0 @@ -// How to: Cancel Threads Cooperatively - -// -using System; -using System.Threading; - -public class ServerClass -{ - public static void StaticMethod(object obj) - { - CancellationToken ct = (CancellationToken)obj; - Console.WriteLine("ServerClass.StaticMethod is running on another thread."); - - // Simulate work that can be canceled. - while (!ct.IsCancellationRequested) { - Thread.SpinWait(50000); - } - Console.WriteLine("The worker thread has been canceled. Press any key to exit."); - Console.ReadKey(true); - } -} - -public class Simple -{ - public static void Main() - { - // The Simple class controls access to the token source. - CancellationTokenSource cts = new CancellationTokenSource(); - - Console.WriteLine("Press 'C' to terminate the application...\n"); - // Allow the UI thread to capture the token source, so that it - // can issue the cancel command. - Thread t1 = new Thread(() => { if (Console.ReadKey(true).KeyChar.ToString().ToUpperInvariant() == "C") - cts.Cancel(); } ); - - // ServerClass sees only the token, not the token source. - Thread t2 = new Thread(new ParameterizedThreadStart(ServerClass.StaticMethod)); - // Start the UI thread. - - t1.Start(); - - // Start the worker thread and pass it the token. - t2.Start(cts.Token); - - t2.Join(); - cts.Dispose(); - } -} -// The example displays the following output: -// Press 'C' to terminate the application... -// -// ServerClass.StaticMethod is running on another thread. -// The worker thread has been canceled. Press any key to exit. -// diff --git a/samples/snippets/csharp/VS_Snippets_Misc/cancellation/cs/cancellationex8.cs b/samples/snippets/csharp/VS_Snippets_Misc/cancellation/cs/cancellationex8.cs deleted file mode 100644 index 6be414dbc6c6d..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_Misc/cancellation/cs/cancellationex8.cs +++ /dev/null @@ -1,65 +0,0 @@ -//How to: Cancel by Registering a Callback -// -using System; -using System.Net; -using System.Threading; -using System.Threading.Tasks; - -class CancelWithCallback -{ - - static void Main(string[] args) - { - var cts = new CancellationTokenSource(); - - // Start cancelable task. - Task t = Task.Run(() => - { - DoWork(cts.Token); - }); - - Console.WriteLine("Press 'c' to cancel."); - char ch = Console.ReadKey(true).KeyChar; - if (ch == 'c') - { - cts.Cancel(); - } - Console.WriteLine("Press any key to exit."); - Console.ReadKey(); - cts.Dispose(); - } - - static void DoWork(CancellationToken token) - { - WebClient wc = new WebClient(); - - // Create an event handler to receive the result. - wc.DownloadStringCompleted += (obj, e) => - { - // Checks status of WebClient, not external token - if (!e.Cancelled) - { - Console.WriteLine(e.Result + "\r\nPress any key."); - } - else - { - Console.WriteLine("Download was canceled."); - } - }; - - // Do not initiate download if the external token - // has already been canceled. - if (!token.IsCancellationRequested) - { - // Register the callback to a method that can unblock. - // Dispose of the CancellationTokenRegistration object - // after the callback has completed. - using (CancellationTokenRegistration ctr = token.Register(() => wc.CancelAsync())) - { - Console.WriteLine("Starting request"); - wc.DownloadStringAsync(new Uri("http://www.contoso.com")); - } - } - } -} -// diff --git a/samples/snippets/csharp/VS_Snippets_Misc/tpl/cs/continuewith.cs b/samples/snippets/csharp/VS_Snippets_Misc/tpl/cs/continuewith.cs deleted file mode 100644 index 6aba307ecddc1..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_Misc/tpl/cs/continuewith.cs +++ /dev/null @@ -1,83 +0,0 @@ -// -using System; -using System.IO; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; - -namespace ContinueWith -{ - class Continuations - { - static void Main() - { - SimpleContinuation(); - - Console.WriteLine("Press any key to exit"); - Console.ReadKey(); - } - - static void SimpleContinuation() - { - string path = @"C:\users\public\TPLTestFolder\"; - try - { - var firstTask = new Task(() => CopyDataIntoTempFolder(path)); - var secondTask = firstTask.ContinueWith((t) => CreateSummaryFile(path)); - firstTask.Start(); - } - catch (AggregateException e) - { - Console.WriteLine(e.Message); - } - } - - // A toy function to simulate a workload - static void CopyDataIntoTempFolder(string path) - { - System.IO.Directory.CreateDirectory(path); - Random rand = new Random(); - for (int x = 0; x < 50; x++) - { - byte[] bytes = new byte[1000]; - rand.NextBytes(bytes); - string filename = Path.GetRandomFileName(); - string filepath = Path.Combine(path, filename); - System.IO.File.WriteAllBytes(filepath, bytes); - } - } - - static void CreateSummaryFile(string path) - { - string[] files = System.IO.Directory.GetFiles(path); - Parallel.ForEach(files, (file) => - { - Thread.SpinWait(5000); - }); - - System.IO.File.WriteAllText(Path.Combine(path, "__SummaryFile.txt"), "did my work"); - Console.WriteLine("Done with task2"); - } - - static void SimpleContinuationWithState() - { - int[] nums = { 19, 17, 21, 4, 13, 8, 12, 7, 3, 5 }; - var f0 = new Task(() => nums.Average()); - var f1 = f0.ContinueWith(t => GetStandardDeviation(nums, t.Result)); - - f0.Start(); - Console.WriteLine("the standard deviation is {0}", f1.Result); - } - - private static double GetStandardDeviation(int[] values, double mean) - { - double d = 0.0; - foreach (var n in values) - { - d += Math.Pow(mean - n, 2); - } - return Math.Sqrt(d / (values.Length - 1)); - } - } -} -// \ No newline at end of file diff --git a/samples/snippets/csharp/VS_Snippets_Misc/tpl/cs/taskexceptions.cs b/samples/snippets/csharp/VS_Snippets_Misc/tpl/cs/taskexceptions.cs deleted file mode 100644 index 1103e5015806b..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_Misc/tpl/cs/taskexceptions.cs +++ /dev/null @@ -1,51 +0,0 @@ -// -using System; -using System.Threading.Tasks; - -public class Example -{ - public static void Main() - { - HandleExceptions(); - // RethrowAllExceptions(); - Console.Write("Press any key."); - Console.ReadKey(); - } - - static string[] GetAllFiles(string str) - { - // Should throw an AccessDenied exception on Vista. - return System.IO.Directory.GetFiles(str, "*.txt", - System.IO.SearchOption.AllDirectories); - } - - static void HandleExceptions() - { - // Assume this is a user-entered string. - string path = @"C:\"; - - // Use this line to throw UnauthorizedAccessException, which we handle. - Task task1 = Task.Factory.StartNew(() => GetAllFiles(path)); - - // Use this line to throw an exception that is not handled. - // Task task1 = Task.Factory.StartNew(() => { throw new IndexOutOfRangeException(); } ); - try { - task1.Wait(); - } - catch (AggregateException ae) { - ae.Handle((x) => - { - if (x is UnauthorizedAccessException) // This we know how to handle. - { - Console.WriteLine("You do not have permission to access all folders in this path."); - Console.WriteLine("See your network administrator or try another path."); - return true; - } - return false; // Let anything else stop the application. - }); - } - - Console.WriteLine("task1 has completed."); - } -} -// diff --git a/samples/snippets/csharp/VS_Snippets_Misc/tpl/cs/waitontasks_11.cs b/samples/snippets/csharp/VS_Snippets_Misc/tpl/cs/waitontasks_11.cs deleted file mode 100644 index 29825f8ae6a46..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_Misc/tpl/cs/waitontasks_11.cs +++ /dev/null @@ -1,79 +0,0 @@ -// - - using System; - using System.Threading; - using System.Threading.Tasks; - - class Program - { - static Random rand = new Random(); - static void Main(string[] args) - { - // Wait on a single task with no timeout specified. - Task taskA = Task.Factory.StartNew(() => DoSomeWork(10000000)); - taskA.Wait(); - Console.WriteLine("taskA has completed."); - - // Wait on a single task with a timeout specified. - Task taskB = Task.Factory.StartNew(() => DoSomeWork(10000000)); - taskB.Wait(100); //Wait for 100 ms. - - if (taskB.IsCompleted) - Console.WriteLine("taskB has completed."); - else - Console.WriteLine("Timed out before taskB completed."); - - // Wait for all tasks to complete. - Task[] tasks = new Task[10]; - for (int i = 0; i < 10; i++) - { - tasks[i] = Task.Factory.StartNew(() => DoSomeWork(10000000)); - } - Task.WaitAll(tasks); - - // Wait for first task to complete. - Task[] tasks2 = new Task[3]; - - // Try three different approaches to the problem. Take the first one. - tasks2[0] = Task.Factory.StartNew(() => TrySolution1()); - tasks2[1] = Task.Factory.StartNew(() => TrySolution2()); - tasks2[2] = Task.Factory.StartNew(() => TrySolution3()); - - int index = Task.WaitAny(tasks2); - double d = tasks2[index].Result; - Console.WriteLine("task[{0}] completed first with result of {1}.", index, d); - - Console.ReadKey(); - } - - static void DoSomeWork(int val) - { - // Pretend to do something. - Thread.SpinWait(val); - } - - static double TrySolution1() - { - int i = rand.Next(1000000); - // Simulate work by spinning - Thread.SpinWait(i); - return DateTime.Now.Millisecond; - } - static double TrySolution2() - { - int i = rand.Next(1000000); - // Simulate work by spinning - Thread.SpinWait(i); - return DateTime.Now.Millisecond; - } - static double TrySolution3() - { - int i = rand.Next(1000000); - // Simulate work by spinning - Thread.SpinWait(i); - Thread.SpinWait(1000000); - return DateTime.Now.Millisecond; - } - } - - // diff --git a/samples/snippets/csharp/VS_Snippets_Misc/tpl_cacheddownloads/cs/Project.csproj b/samples/snippets/csharp/VS_Snippets_Misc/tpl_cacheddownloads/cs/Project.csproj deleted file mode 100644 index b83f0211b39c5..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_Misc/tpl_cacheddownloads/cs/Project.csproj +++ /dev/null @@ -1,7 +0,0 @@ - - - - Library - net6.0 - - diff --git a/samples/snippets/csharp/VS_Snippets_Misc/tpl_cacheddownloads/cs/cacheddownloads.cs b/samples/snippets/csharp/VS_Snippets_Misc/tpl_cacheddownloads/cs/cacheddownloads.cs deleted file mode 100644 index 7a7079e0ba2e6..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_Misc/tpl_cacheddownloads/cs/cacheddownloads.cs +++ /dev/null @@ -1,87 +0,0 @@ -// -using System; -using System.Collections.Concurrent; -using System.Diagnostics; -using System.Linq; -using System.Net; -using System.Threading.Tasks; - -// Demonstrates how to use Task.FromResult to create a task -// that holds a pre-computed result. -class CachedDownloads -{ - // Holds the results of download operations. - static ConcurrentDictionary cachedDownloads = - new ConcurrentDictionary(); - - // Asynchronously downloads the requested resource as a string. - public static Task DownloadStringAsync(string address) - { - // First try to retrieve the content from cache. - string content; - if (cachedDownloads.TryGetValue(address, out content)) - { - return Task.FromResult(content); - } - - // If the result was not in the cache, download the - // string and add it to the cache. - return Task.Run(async () => - { - content = await new WebClient().DownloadStringTaskAsync(address); - cachedDownloads.TryAdd(address, content); - return content; - }); - } - - static void Main(string[] args) - { - // The URLs to download. - string[] urls = new string[] - { - "http://msdn.microsoft.com", - "http://www.contoso.com", - "http://www.microsoft.com" - }; - - // Used to time download operations. - Stopwatch stopwatch = new Stopwatch(); - - // Compute the time required to download the URLs. - stopwatch.Start(); - var downloads = from url in urls - select DownloadStringAsync(url); - Task.WhenAll(downloads).ContinueWith(results => - { - stopwatch.Stop(); - - // Print the number of characters download and the elapsed time. - Console.WriteLine("Retrieved {0} characters. Elapsed time was {1} ms.", - results.Result.Sum(result => result.Length), - stopwatch.ElapsedMilliseconds); - }) - .Wait(); - - // Perform the same operation a second time. The time required - // should be shorter because the results are held in the cache. - stopwatch.Restart(); - downloads = from url in urls - select DownloadStringAsync(url); - Task.WhenAll(downloads).ContinueWith(results => - { - stopwatch.Stop(); - - // Print the number of characters download and the elapsed time. - Console.WriteLine("Retrieved {0} characters. Elapsed time was {1} ms.", - results.Result.Sum(result => result.Length), - stopwatch.ElapsedMilliseconds); - }) - .Wait(); - } -} - -/* Sample output: -Retrieved 27798 characters. Elapsed time was 1045 ms. -Retrieved 27798 characters. Elapsed time was 0 ms. -*/ -// \ No newline at end of file diff --git a/samples/snippets/csharp/VS_Snippets_Misc/tpl_continuations/cs/attached1.cs b/samples/snippets/csharp/VS_Snippets_Misc/tpl_continuations/cs/attached1.cs deleted file mode 100644 index 72393b004e6b1..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_Misc/tpl_continuations/cs/attached1.cs +++ /dev/null @@ -1,39 +0,0 @@ -// -using System; -using System.Threading; -using System.Threading.Tasks; - -public class Example -{ - public static void Main() - { - var t = Task.Factory.StartNew( () => { Console.WriteLine("Running antecedent task {0}...", - Task.CurrentId); - Console.WriteLine("Launching attached child tasks..."); - for (int ctr = 1; ctr <= 5; ctr++) { - int index = ctr; - Task.Factory.StartNew( (value) => { - Console.WriteLine(" Attached child task #{0} running", - value); - Thread.Sleep(1000); - }, index, TaskCreationOptions.AttachedToParent); - } - Console.WriteLine("Finished launching attached child tasks..."); - }); - var continuation = t.ContinueWith( (antecedent) => { Console.WriteLine("Executing continuation of Task {0}", - antecedent.Id); - }); - continuation.Wait(); - } -} -// The example displays the following output: -// Running antecedent task 1... -// Launching attached child tasks... -// Finished launching attached child tasks... -// Attached child task #5 running -// Attached child task #1 running -// Attached child task #2 running -// Attached child task #3 running -// Attached child task #4 running -// Executing continuation of Task 1 -// diff --git a/samples/snippets/csharp/VS_Snippets_Misc/tpl_continuations/cs/cancellation1.cs b/samples/snippets/csharp/VS_Snippets_Misc/tpl_continuations/cs/cancellation1.cs deleted file mode 100644 index afd0e268fa44e..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_Misc/tpl_continuations/cs/cancellation1.cs +++ /dev/null @@ -1,128 +0,0 @@ -// -using System; -using System.Collections.Generic; -using System.Threading; -using System.Threading.Tasks; - -public class Example -{ - public static void Main() - { - Random rnd = new Random(); - var cts = new CancellationTokenSource(); - CancellationToken token = cts.Token; - Timer timer = new Timer(Elapsed, cts, 5000, Timeout.Infinite); - - var t = Task.Run( () => { List product33 = new List(); - for (int ctr = 1; ctr < Int16.MaxValue; ctr++) { - if (token.IsCancellationRequested) { - Console.WriteLine("\nCancellation requested in antecedent...\n"); - token.ThrowIfCancellationRequested(); - } - if (ctr % 2000 == 0) { - int delay = rnd.Next(16,501); - Thread.Sleep(delay); - } - - if (ctr % 33 == 0) - product33.Add(ctr); - } - return product33.ToArray(); - }, token); - - Task continuation = t.ContinueWith(antecedent => { Console.WriteLine("Multiples of 33:\n"); - var arr = antecedent.Result; - for (int ctr = 0; ctr < arr.Length; ctr++) - { - if (token.IsCancellationRequested) { - Console.WriteLine("\nCancellation requested in continuation...\n"); - token.ThrowIfCancellationRequested(); - } - - if (ctr % 100 == 0) { - int delay = rnd.Next(16,251); - Thread.Sleep(delay); - } - Console.Write("{0:N0}{1}", arr[ctr], - ctr != arr.Length - 1 ? ", " : ""); - if (Console.CursorLeft >= 74) - Console.WriteLine(); - } - Console.WriteLine(); - } , token); - - try { - continuation.Wait(); - } - catch (AggregateException e) { - foreach (Exception ie in e.InnerExceptions) - Console.WriteLine("{0}: {1}", ie.GetType().Name, - ie.Message); - } - finally { - cts.Dispose(); - } - - Console.WriteLine("\nAntecedent Status: {0}", t.Status); - Console.WriteLine("Continuation Status: {0}", continuation.Status); - } - - private static void Elapsed(object state) - { - CancellationTokenSource cts = state as CancellationTokenSource; - if (cts == null) return; - - cts.Cancel(); - Console.WriteLine("\nCancellation request issued...\n"); - } -} -// The example displays the following output: -// Multiples of 33: -// -// 33, 66, 99, 132, 165, 198, 231, 264, 297, 330, 363, 396, 429, 462, 495, 528, -// 561, 594, 627, 660, 693, 726, 759, 792, 825, 858, 891, 924, 957, 990, 1,023, -// 1,056, 1,089, 1,122, 1,155, 1,188, 1,221, 1,254, 1,287, 1,320, 1,353, 1,386, -// 1,419, 1,452, 1,485, 1,518, 1,551, 1,584, 1,617, 1,650, 1,683, 1,716, 1,749, -// 1,782, 1,815, 1,848, 1,881, 1,914, 1,947, 1,980, 2,013, 2,046, 2,079, 2,112, -// 2,145, 2,178, 2,211, 2,244, 2,277, 2,310, 2,343, 2,376, 2,409, 2,442, 2,475, -// 2,508, 2,541, 2,574, 2,607, 2,640, 2,673, 2,706, 2,739, 2,772, 2,805, 2,838, -// 2,871, 2,904, 2,937, 2,970, 3,003, 3,036, 3,069, 3,102, 3,135, 3,168, 3,201, -// 3,234, 3,267, 3,300, 3,333, 3,366, 3,399, 3,432, 3,465, 3,498, 3,531, 3,564, -// 3,597, 3,630, 3,663, 3,696, 3,729, 3,762, 3,795, 3,828, 3,861, 3,894, 3,927, -// 3,960, 3,993, 4,026, 4,059, 4,092, 4,125, 4,158, 4,191, 4,224, 4,257, 4,290, -// 4,323, 4,356, 4,389, 4,422, 4,455, 4,488, 4,521, 4,554, 4,587, 4,620, 4,653, -// 4,686, 4,719, 4,752, 4,785, 4,818, 4,851, 4,884, 4,917, 4,950, 4,983, 5,016, -// 5,049, 5,082, 5,115, 5,148, 5,181, 5,214, 5,247, 5,280, 5,313, 5,346, 5,379, -// 5,412, 5,445, 5,478, 5,511, 5,544, 5,577, 5,610, 5,643, 5,676, 5,709, 5,742, -// 5,775, 5,808, 5,841, 5,874, 5,907, 5,940, 5,973, 6,006, 6,039, 6,072, 6,105, -// 6,138, 6,171, 6,204, 6,237, 6,270, 6,303, 6,336, 6,369, 6,402, 6,435, 6,468, -// 6,501, 6,534, 6,567, 6,600, 6,633, 6,666, 6,699, 6,732, 6,765, 6,798, 6,831, -// 6,864, 6,897, 6,930, 6,963, 6,996, 7,029, 7,062, 7,095, 7,128, 7,161, 7,194, -// 7,227, 7,260, 7,293, 7,326, 7,359, 7,392, 7,425, 7,458, 7,491, 7,524, 7,557, -// 7,590, 7,623, 7,656, 7,689, 7,722, 7,755, 7,788, 7,821, 7,854, 7,887, 7,920, -// 7,953, 7,986, 8,019, 8,052, 8,085, 8,118, 8,151, 8,184, 8,217, 8,250, 8,283, -// 8,316, 8,349, 8,382, 8,415, 8,448, 8,481, 8,514, 8,547, 8,580, 8,613, 8,646, -// 8,679, 8,712, 8,745, 8,778, 8,811, 8,844, 8,877, 8,910, 8,943, 8,976, 9,009, -// 9,042, 9,075, 9,108, 9,141, 9,174, 9,207, 9,240, 9,273, 9,306, 9,339, 9,372, -// 9,405, 9,438, 9,471, 9,504, 9,537, 9,570, 9,603, 9,636, 9,669, 9,702, 9,735, -// 9,768, 9,801, 9,834, 9,867, 9,900, 9,933, 9,966, 9,999, 10,032, 10,065, 10,098, -// 10,131, 10,164, 10,197, 10,230, 10,263, 10,296, 10,329, 10,362, 10,395, 10,428, -// 10,461, 10,494, 10,527, 10,560, 10,593, 10,626, 10,659, 10,692, 10,725, 10,758, -// 10,791, 10,824, 10,857, 10,890, 10,923, 10,956, 10,989, 11,022, 11,055, 11,088, -// 11,121, 11,154, 11,187, 11,220, 11,253, 11,286, 11,319, 11,352, 11,385, 11,418, -// 11,451, 11,484, 11,517, 11,550, 11,583, 11,616, 11,649, 11,682, 11,715, 11,748, -// 11,781, 11,814, 11,847, 11,880, 11,913, 11,946, 11,979, 12,012, 12,045, 12,078, -// 12,111, 12,144, 12,177, 12,210, 12,243, 12,276, 12,309, 12,342, 12,375, 12,408, -// 12,441, 12,474, 12,507, 12,540, 12,573, 12,606, 12,639, 12,672, 12,705, 12,738, -// 12,771, 12,804, 12,837, 12,870, 12,903, 12,936, 12,969, 13,002, 13,035, 13,068, -// 13,101, 13,134, 13,167, 13,200, 13,233, 13,266, -// Cancellation requested in continuation... -// -// -// Cancellation request issued... -// -// TaskCanceledException: A task was canceled. -// -// Antecedent Status: RanToCompletion -// Continuation Status: Canceled -// \ No newline at end of file diff --git a/samples/snippets/csharp/VS_Snippets_Misc/tpl_continuations/cs/cancellation2.cs b/samples/snippets/csharp/VS_Snippets_Misc/tpl_continuations/cs/cancellation2.cs deleted file mode 100644 index 945c56c743453..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_Misc/tpl_continuations/cs/cancellation2.cs +++ /dev/null @@ -1,41 +0,0 @@ -// -using System; -using System.Threading; -using System.Threading.Tasks; - -public class Example -{ - public static void Main() - { - var cts = new CancellationTokenSource(); - CancellationToken token = cts.Token; - cts.Cancel(); - - var t = Task.FromCanceled(token); - var continuation = t.ContinueWith( (antecedent) => { - Console.WriteLine("The continuation is running."); - } , TaskContinuationOptions.NotOnCanceled); - try { - t.Wait(); - } - catch (AggregateException ae) { - foreach (var ie in ae.InnerExceptions) - Console.WriteLine("{0}: {1}", ie.GetType().Name, ie.Message); - - Console.WriteLine(); - } - finally { - cts.Dispose(); - } - - Console.WriteLine("Task {0}: {1:G}", t.Id, t.Status); - Console.WriteLine("Task {0}: {1:G}", continuation.Id, - continuation.Status); - } -} -// The example displays the following output: -// TaskCanceledException: A task was canceled. -// -// Task 1: Canceled -// Task 2: Canceled -// diff --git a/samples/snippets/csharp/VS_Snippets_Misc/tpl_continuations/cs/continuations.cs b/samples/snippets/csharp/VS_Snippets_Misc/tpl_continuations/cs/continuations.cs deleted file mode 100644 index eec3a90ad6a27..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_Misc/tpl_continuations/cs/continuations.cs +++ /dev/null @@ -1,58 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; - -namespace Child_Continuation -{ - class Program - { - static void Main(string[] args) - { - Console.WriteLine("Press any key to exit."); - Console.ReadKey(); - } - - static void MultiTaskContinuations() - { - CancellationTokenSource cts = new CancellationTokenSource(); - - // UI thread. Hit the right key the first time. - Task.Factory.StartNew(() => - { - Console.WriteLine("Press 'c' to cancel"); - if (Console.ReadKey().KeyChar == 'c') - cts.Cancel(); - }); - - Task[] tasks = new Task[2]; - tasks[0] = new Task(() => - { - // Do some work... - return 34; - }); - - tasks[1] = new Task(() => - { - // Do some work... - return 8; - }); - - var continuation = Task.Factory.ContinueWhenAll( - tasks, - (antecedents) => - { - int answer = antecedents[0].Result + antecedents[1].Result; - Console.WriteLine("The answer is {0}", answer); - }); - - tasks[0].Start(); - tasks[1].Start(); - continuation.Wait(); - - cts.Dispose(); - } - } -} diff --git a/samples/snippets/csharp/VS_Snippets_Misc/tpl_continuations/cs/detached1.cs b/samples/snippets/csharp/VS_Snippets_Misc/tpl_continuations/cs/detached1.cs deleted file mode 100644 index d52593a76c72f..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_Misc/tpl_continuations/cs/detached1.cs +++ /dev/null @@ -1,39 +0,0 @@ -// -using System; -using System.Threading; -using System.Threading.Tasks; - -public class Example -{ - public static void Main() - { - var t = Task.Factory.StartNew( () => { Console.WriteLine("Running antecedent task {0}...", - Task.CurrentId); - Console.WriteLine("Launching attached child tasks..."); - for (int ctr = 1; ctr <= 5; ctr++) { - int index = ctr; - Task.Factory.StartNew( (value) => { - Console.WriteLine(" Attached child task #{0} running", - value); - Thread.Sleep(1000); - }, index); - } - Console.WriteLine("Finished launching detached child tasks..."); - }, TaskCreationOptions.DenyChildAttach); - var continuation = t.ContinueWith( (antecedent) => { Console.WriteLine("Executing continuation of Task {0}", - antecedent.Id); - }); - continuation.Wait(); - } -} -// The example displays output like the following: -// Running antecedent task 1... -// Launching attached child tasks... -// Finished launching detached child tasks... -// Attached child task #1 running -// Attached child task #2 running -// Attached child task #5 running -// Attached child task #3 running -// Executing continuation of Task 1 -// Attached child task #4 running -// \ No newline at end of file diff --git a/samples/snippets/csharp/VS_Snippets_Misc/tpl_continuations/cs/exception1.cs b/samples/snippets/csharp/VS_Snippets_Misc/tpl_continuations/cs/exception1.cs deleted file mode 100644 index bbafe704c6b8d..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_Misc/tpl_continuations/cs/exception1.cs +++ /dev/null @@ -1,35 +0,0 @@ -// -using System; -using System.Threading.Tasks; - -public class Example -{ - public static void Main() - { - var task1 = Task.Run( () => { Console.WriteLine("Executing task {0}", - Task.CurrentId); - return 54; }); - var continuation = task1.ContinueWith( (antecedent) => - { Console.WriteLine("Executing continuation task {0}", - Task.CurrentId); - Console.WriteLine("Value from antecedent: {0}", - antecedent.Result); - throw new InvalidOperationException(); - } ); - - try { - task1.Wait(); - continuation.Wait(); - } - catch (AggregateException ae) { - foreach (var ex in ae.InnerExceptions) - Console.WriteLine(ex.Message); - } - } -} -// The example displays the following output: -// Executing task 1 -// Executing continuation task 2 -// Value from antecedent: 54 -// Operation is not valid due to the current state of the object. -// diff --git a/samples/snippets/csharp/VS_Snippets_Misc/tpl_continuations/cs/exception2.cs b/samples/snippets/csharp/VS_Snippets_Misc/tpl_continuations/cs/exception2.cs deleted file mode 100644 index 314e6c6b85550..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_Misc/tpl_continuations/cs/exception2.cs +++ /dev/null @@ -1,51 +0,0 @@ -// -using System; -using System.IO; -using System.Threading.Tasks; - -public class Example -{ - public static void Main() - { - var t = Task.Run( () => { string s = File.ReadAllText(@"C:\NonexistentFile.txt"); - return s; - }); - - var c = t.ContinueWith( (antecedent) => - { // Get the antecedent's exception information. - foreach (var ex in antecedent.Exception.InnerExceptions) { - if (ex is FileNotFoundException) - Console.WriteLine(ex.Message); - } - }, TaskContinuationOptions.OnlyOnFaulted); - - c.Wait(); - } -} -// The example displays the following output: -// Could not find file 'C:\NonexistentFile.txt'. -// - -public class Example2 -{ - public static void ShowTaskException() - { - var t = Task.Run( () => { string s = File.ReadAllText(@"C:\NonexistentFile.txt"); - return s; - }); - - var c = t.ContinueWith( (antecedent) => - { // Accessing Exception property catches the exception. - // Exception should not be null if OnlyOnFaulted. - // - // Determine whether an exception occurred. - if (antecedent.Exception != null) { - foreach (var ex in antecedent.Exception.InnerExceptions) { - if (ex is FileNotFoundException) - Console.WriteLine(ex.Message); - } - } - // - } ); - } -} \ No newline at end of file diff --git a/samples/snippets/csharp/VS_Snippets_Misc/tpl_continuations/cs/result1.cs b/samples/snippets/csharp/VS_Snippets_Misc/tpl_continuations/cs/result1.cs deleted file mode 100644 index 552568842f7bc..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_Misc/tpl_continuations/cs/result1.cs +++ /dev/null @@ -1,29 +0,0 @@ -// -using System; -using System.Threading.Tasks; - -public class Example -{ - public static async Task Main() - { - var t = Task.Run( () => { DateTime dat = DateTime.Now; - if (dat == DateTime.MinValue) - throw new ArgumentException("The clock is not working."); - - if (dat.Hour > 17) - return "evening"; - else if (dat.Hour > 12) - return "afternoon"; - else - return "morning"; }); - await t.ContinueWith( (antecedent) => { Console.WriteLine("Good {0}!", - antecedent.Result); - Console.WriteLine("And how are you this fine {0}?", - antecedent.Result); }, - TaskContinuationOptions.OnlyOnRanToCompletion); - } -} -// The example displays output like the following: -// Good afternoon! -// And how are you this fine afternoon? -// diff --git a/samples/snippets/csharp/VS_Snippets_Misc/tpl_continuations/cs/result2.cs b/samples/snippets/csharp/VS_Snippets_Misc/tpl_continuations/cs/result2.cs deleted file mode 100644 index edbb7dbcc5b02..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_Misc/tpl_continuations/cs/result2.cs +++ /dev/null @@ -1,33 +0,0 @@ -// -using System; -using System.Threading.Tasks; - -public class Example -{ - public static void Main() - { - var t = Task.Run( () => { DateTime dat = DateTime.Now; - if (dat == DateTime.MinValue) - throw new ArgumentException("The clock is not working."); - - if (dat.Hour > 17) - return "evening"; - else if (dat.Hour > 12) - return "afternoon"; - else - return "morning"; }); - var c = t.ContinueWith( (antecedent) => { if (t.Status == TaskStatus.RanToCompletion) { - Console.WriteLine("Good {0}!", - antecedent.Result); - Console.WriteLine("And how are you this fine {0}?", - antecedent.Result); - } - else if (t.Status == TaskStatus.Faulted) { - Console.WriteLine(t.Exception.GetBaseException().Message); - }} ); - } -} -// The example displays output like the following: -// Good afternoon! -// And how are you this fine afternoon? -// diff --git a/samples/snippets/csharp/VS_Snippets_Misc/tpl_continuations/cs/simple1.cs b/samples/snippets/csharp/VS_Snippets_Misc/tpl_continuations/cs/simple1.cs deleted file mode 100644 index f05db075942ac..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_Misc/tpl_continuations/cs/simple1.cs +++ /dev/null @@ -1,18 +0,0 @@ -// -using System; -using System.Threading.Tasks; - -public class Example -{ - public static async Task Main() - { - // Execute the antecedent. - Task taskA = Task.Run( () => DateTime.Today.DayOfWeek ); - - // Execute the continuation when the antecedent finishes. - await taskA.ContinueWith( antecedent => Console.WriteLine("Today is {0}.", antecedent.Result) ); - } -} -// The example displays output like the following output: -// Today is Monday. -// diff --git a/samples/snippets/csharp/VS_Snippets_Misc/tpl_continuations/cs/whenall1.cs b/samples/snippets/csharp/VS_Snippets_Misc/tpl_continuations/cs/whenall1.cs deleted file mode 100644 index 4591cacf8a079..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_Misc/tpl_continuations/cs/whenall1.cs +++ /dev/null @@ -1,29 +0,0 @@ -// -using System.Collections.Generic; -using System; -using System.Threading.Tasks; - -public class Example -{ - public static void Main() - { - List> tasks = new List>(); - for (int ctr = 1; ctr <= 10; ctr++) { - int baseValue = ctr; - tasks.Add(Task.Factory.StartNew( (b) => { int i = (int) b; - return i * i; }, baseValue)); - } - var continuation = Task.WhenAll(tasks); - - long sum = 0; - for (int ctr = 0; ctr <= continuation.Result.Length - 1; ctr++) { - Console.Write("{0} {1} ", continuation.Result[ctr], - ctr == continuation.Result.Length - 1 ? "=" : "+"); - sum += continuation.Result[ctr]; - } - Console.WriteLine(sum); - } -} -// The example displays the following output: -// 1 + 4 + 9 + 16 + 25 + 36 + 49 + 64 + 81 + 100 = 385 -// \ No newline at end of file diff --git a/samples/snippets/csharp/VS_Snippets_Misc/tpl_continuationstate/cs/Project.csproj b/samples/snippets/csharp/VS_Snippets_Misc/tpl_continuationstate/cs/Project.csproj deleted file mode 100644 index b83f0211b39c5..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_Misc/tpl_continuationstate/cs/Project.csproj +++ /dev/null @@ -1,7 +0,0 @@ - - - - Library - net6.0 - - diff --git a/samples/snippets/csharp/VS_Snippets_Misc/tpl_continuationstate/cs/continuationstate.cs b/samples/snippets/csharp/VS_Snippets_Misc/tpl_continuationstate/cs/continuationstate.cs deleted file mode 100644 index 9bd033890ebca..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_Misc/tpl_continuationstate/cs/continuationstate.cs +++ /dev/null @@ -1,60 +0,0 @@ -// -using System; -using System.Collections.Generic; -using System.Threading; -using System.Threading.Tasks; - -// Demonstrates how to associate state with task continuations. -class ContinuationState -{ - // Simluates a lengthy operation and returns the time at which - // the operation completed. - public static DateTime DoWork() - { - // Simulate work by suspending the current thread - // for two seconds. - Thread.Sleep(2000); - - // Return the current time. - return DateTime.Now; - } - - static void Main(string[] args) - { - // Start a root task that performs work. - Task t = Task.Run(delegate { return DoWork(); }); - - // Create a chain of continuation tasks, where each task is - // followed by another task that performs work. - List> continuations = new List>(); - for (int i = 0; i < 5; i++) - { - // Provide the current time as the state of the continuation. - t = t.ContinueWith(delegate { return DoWork(); }, DateTime.Now); - continuations.Add(t); - } - - // Wait for the last task in the chain to complete. - t.Wait(); - - // Print the creation time of each continuation (the state object) - // and the completion time (the result of that task) to the console. - foreach (var continuation in continuations) - { - DateTime start = (DateTime)continuation.AsyncState; - DateTime end = continuation.Result; - - Console.WriteLine("Task was created at {0} and finished at {1}.", - start.TimeOfDay, end.TimeOfDay); - } - } -} - -/* Sample output: -Task was created at 10:56:21.1561762 and finished at 10:56:25.1672062. -Task was created at 10:56:21.1610677 and finished at 10:56:27.1707646. -Task was created at 10:56:21.1610677 and finished at 10:56:29.1743230. -Task was created at 10:56:21.1610677 and finished at 10:56:31.1779883. -Task was created at 10:56:21.1610677 and finished at 10:56:33.1837083. -*/ -// \ No newline at end of file diff --git a/samples/snippets/csharp/VS_Snippets_Misc/tpl_continuationstate/cs/makefile b/samples/snippets/csharp/VS_Snippets_Misc/tpl_continuationstate/cs/makefile deleted file mode 100644 index f7938de7321c1..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_Misc/tpl_continuationstate/cs/makefile +++ /dev/null @@ -1,2 +0,0 @@ -ContinuationState.exe : ContinuationState.cs - csc.exe ContinuationState.cs diff --git a/samples/snippets/csharp/VS_Snippets_Misc/tpl_taskintro/cs/startnew1.cs b/samples/snippets/csharp/VS_Snippets_Misc/tpl_taskintro/cs/startnew1.cs deleted file mode 100644 index 2fceae575f65a..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_Misc/tpl_taskintro/cs/startnew1.cs +++ /dev/null @@ -1,25 +0,0 @@ -// -using System; -using System.Threading; -using System.Threading.Tasks; - -public class Example -{ - public static void Main() - { - Thread.CurrentThread.Name = "Main"; - - // Better: Create and start the task in one operation. - Task taskA = Task.Factory.StartNew(() => Console.WriteLine("Hello from taskA.")); - - // Output a message from the calling thread. - Console.WriteLine("Hello from thread '{0}'.", - Thread.CurrentThread.Name); - - taskA.Wait(); - } -} -// The example displays output like the following: -// Hello from thread 'Main'. -// Hello from taskA. -// diff --git a/samples/snippets/csharp/VS_Snippets_Network/RequestDataUsingWebRequest/cs/Project.csproj b/samples/snippets/csharp/VS_Snippets_Network/RequestDataUsingWebRequest/cs/Project.csproj deleted file mode 100644 index b83f0211b39c5..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_Network/RequestDataUsingWebRequest/cs/Project.csproj +++ /dev/null @@ -1,7 +0,0 @@ - - - - Library - net6.0 - - diff --git a/samples/snippets/csharp/VS_Snippets_Network/RequestDataUsingWebRequest/cs/WebRequestGetExample.cs b/samples/snippets/csharp/VS_Snippets_Network/RequestDataUsingWebRequest/cs/WebRequestGetExample.cs deleted file mode 100644 index 10db28f5a8d0f..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_Network/RequestDataUsingWebRequest/cs/WebRequestGetExample.cs +++ /dev/null @@ -1,38 +0,0 @@ -using System; -using System.IO; -using System.Net; - -namespace Examples.System.Net -{ - public class WebRequestGetExample - { - public static void Main() - { - // Create a request for the URL. - WebRequest request = WebRequest.Create( - "https://docs.microsoft.com"); - // If required by the server, set the credentials. - request.Credentials = CredentialCache.DefaultCredentials; - - // Get the response. - WebResponse response = request.GetResponse(); - // Display the status. - Console.WriteLine(((HttpWebResponse)response).StatusDescription); - - // Get the stream containing content returned by the server. - // The using block ensures the stream is automatically closed. - using (Stream dataStream = response.GetResponseStream()) - { - // Open the stream using a StreamReader for easy access. - StreamReader reader = new StreamReader(dataStream); - // Read the content. - string responseFromServer = reader.ReadToEnd(); - // Display the content. - Console.WriteLine(responseFromServer); - } - - // Close the response. - response.Close(); - } - } -} diff --git a/samples/snippets/csharp/VS_Snippets_Network/SendDataUsingWebRequest/cs/Project.csproj b/samples/snippets/csharp/VS_Snippets_Network/SendDataUsingWebRequest/cs/Project.csproj deleted file mode 100644 index b83f0211b39c5..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_Network/SendDataUsingWebRequest/cs/Project.csproj +++ /dev/null @@ -1,7 +0,0 @@ - - - - Library - net6.0 - - diff --git a/samples/snippets/csharp/VS_Snippets_Network/SendDataUsingWebRequest/cs/WebRequestPostExample.cs b/samples/snippets/csharp/VS_Snippets_Network/SendDataUsingWebRequest/cs/WebRequestPostExample.cs deleted file mode 100644 index f59552d221384..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_Network/SendDataUsingWebRequest/cs/WebRequestPostExample.cs +++ /dev/null @@ -1,54 +0,0 @@ -using System; -using System.IO; -using System.Net; -using System.Text; - -namespace Examples.System.Net -{ - public class WebRequestPostExample - { - public static void Main() - { - // Create a request using a URL that can receive a post. - WebRequest request = WebRequest.Create("http://www.contoso.com/PostAccepter.aspx "); - // Set the Method property of the request to POST. - request.Method = "POST"; - - // Create POST data and convert it to a byte array. - string postData = "This is a test that posts this string to a Web server."; - byte[] byteArray = Encoding.UTF8.GetBytes(postData); - - // Set the ContentType property of the WebRequest. - request.ContentType = "application/x-www-form-urlencoded"; - // Set the ContentLength property of the WebRequest. - request.ContentLength = byteArray.Length; - - // Get the request stream. - Stream dataStream = request.GetRequestStream(); - // Write the data to the request stream. - dataStream.Write(byteArray, 0, byteArray.Length); - // Close the Stream object. - dataStream.Close(); - - // Get the response. - WebResponse response = request.GetResponse(); - // Display the status. - Console.WriteLine(((HttpWebResponse)response).StatusDescription); - - // Get the stream containing content returned by the server. - // The using block ensures the stream is automatically closed. - using (dataStream = response.GetResponseStream()) - { - // Open the stream using a StreamReader for easy access. - StreamReader reader = new StreamReader(dataStream); - // Read the content. - string responseFromServer = reader.ReadToEnd(); - // Display the content. - Console.WriteLine(responseFromServer); - } - - // Close the response. - response.Close(); - } - } -} diff --git a/samples/snippets/csharp/VS_Snippets_VBCSharp/csProgGuideIndexers/CS/Indexers.cs b/samples/snippets/csharp/VS_Snippets_VBCSharp/csProgGuideIndexers/CS/Indexers.cs deleted file mode 100644 index 601d79a206c5d..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_VBCSharp/csProgGuideIndexers/CS/Indexers.cs +++ /dev/null @@ -1,154 +0,0 @@ -//using System; prefer to fully qualified all but the most extremely long references - -// -class TempRecord -{ - // Array of temperature values - private float[] temps = new float[10] { 56.2F, 56.7F, 56.5F, 56.9F, 58.8F, - 61.3F, 65.9F, 62.1F, 59.2F, 57.5F }; - - // To enable client code to validate input - // when accessing your indexer. - public int Length - { - get { return temps.Length; } - } - // Indexer declaration. - // If index is out of range, the temps array will throw the exception. - public float this[int index] - { - get - { - return temps[index]; - } - - set - { - temps[index] = value; - } - } -} - -class MainClass -{ - static void Main() - { - TempRecord tempRecord = new TempRecord(); - // Use the indexer's set accessor - tempRecord[3] = 58.3F; - tempRecord[5] = 60.1F; - - // Use the indexer's get accessor - for (int i = 0; i < 10; i++) - { - System.Console.WriteLine("Element #{0} = {1}", i, tempRecord[i]); - } - - // Keep the console window open in debug mode. - System.Console.WriteLine("Press any key to exit."); - System.Console.ReadKey(); - } -} -/* Output: - Element #0 = 56.2 - Element #1 = 56.7 - Element #2 = 56.5 - Element #3 = 58.3 - Element #4 = 58.8 - Element #5 = 60.1 - Element #6 = 65.9 - Element #7 = 62.1 - Element #8 = 59.2 - Element #9 = 57.5 - */ -// - -// -// Using a string as an indexer value -class DayCollection -{ - string[] days = { "Sun", "Mon", "Tues", "Wed", "Thurs", "Fri", "Sat" }; - - // Indexer with only a get accessor with the expression-bodied definition: - public int this[string day] => FindDayIndex(day); - - private int FindDayIndex(string day) - { - for (int j = 0; j < days.Length; j++) - { - if (days[j] == day) - { - return j; - } - } - throw new System.ArgumentOutOfRangeException( - nameof(day), - $"Day {day} is not supported. Day input must be in the form \"Sun\", \"Mon\", etc"); - } -} - -class Program -{ - static void Main() - { - var week = new DayCollection(); - System.Console.WriteLine(week["Fri"]); - - try - { - System.Console.WriteLine(week["Made-up day"]); - } - catch (System.ArgumentOutOfRangeException e) - { - System.Console.WriteLine($"Not supported input: {e.Message}"); - } - } - // Output: - // 5 - // Not supported input: Day Made-up day is not supported. Day input must be in the form "Sun", "Mon", etc (Parameter 'day') -} -// - -namespace WrapProgram -{ - // - class SampleCollection - { - // Declare an array to store the data elements. - private T[] arr = new T[100]; - - // Define the indexer, which will allow client code - // to use [] notation on the class instance itself. - // (See line 2 of code in Main below.) - public T this[int i] - { - get - { - // This indexer is very simple, and just returns or sets - // the corresponding element from the internal array. - return arr[i]; - } - set - { - arr[i] = value; - } - } - } - - // This class shows how client code uses the indexer. - class Program - { - static void Main(string[] args) - { - // Declare an instance of the SampleCollection type. - SampleCollection stringCollection = new SampleCollection(); - - // Use [] notation on the type. - stringCollection[0] = "Hello, World"; - System.Console.WriteLine(stringCollection[0]); - } - } - // Output: - // Hello, World. - // -} diff --git a/samples/snippets/csharp/VS_Snippets_VBCSharp/csProgGuideIndexers/CS/Project.csproj b/samples/snippets/csharp/VS_Snippets_VBCSharp/csProgGuideIndexers/CS/Project.csproj deleted file mode 100644 index b83f0211b39c5..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_VBCSharp/csProgGuideIndexers/CS/Project.csproj +++ /dev/null @@ -1,7 +0,0 @@ - - - - Library - net6.0 - - diff --git a/samples/snippets/csharp/VS_Snippets_VBCSharp/csProgGuideInterop/CS/ExcelAddIn.cs b/samples/snippets/csharp/VS_Snippets_VBCSharp/csProgGuideInterop/CS/ExcelAddIn.cs deleted file mode 100644 index 1e23863000659..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_VBCSharp/csProgGuideInterop/CS/ExcelAddIn.cs +++ /dev/null @@ -1,35 +0,0 @@ -// -using System.Runtime.InteropServices; - -namespace TaxTables -{ - [ClassInterface(ClassInterfaceType.AutoDual)] - public class TaxTables - { - public static double Tax(double income) - { - if (income > 0 && income <= 7000) {return (.10 * income);} - if (income > 7000 && income <= 28400) {return 700.00 + (.15 * (income - 7000));} - if (income > 28400 && income <= 68800) {return 3910.00 + (.25 * (income - 28400));} - if (income > 68800 && income <= 143500) {return 14010.00 + (.28 * (income - 68800));} - if (income > 143500 && income <= 311950) {return 34926.00 + (.33 * (income - 143500));} - if (income > 311950) {return 90514.50 + (.35 * (income - 311950));} - return 0; - } - - [ComRegisterFunctionAttribute] - public static void RegisterFunction(System.Type t) - { - Microsoft.Win32.Registry.ClassesRoot.CreateSubKey - ("CLSID\\{" + t.GUID.ToString().ToUpper() + "}\\Programmable"); - } - - [ComUnregisterFunctionAttribute] - public static void UnregisterFunction(System.Type t) - { - Microsoft.Win32.Registry.ClassesRoot.DeleteSubKey - ("CLSID\\{" + t.GUID.ToString().ToUpper() + "}\\Programmable"); - } - } -} -// diff --git a/samples/snippets/csharp/VS_Snippets_VBCSharp/csProgGuideInterop/CS/ExcelSpreadsheet.cs b/samples/snippets/csharp/VS_Snippets_VBCSharp/csProgGuideInterop/CS/ExcelSpreadsheet.cs deleted file mode 100644 index ec1e8a9c29af3..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_VBCSharp/csProgGuideInterop/CS/ExcelSpreadsheet.cs +++ /dev/null @@ -1,175 +0,0 @@ -// -using System; -using System.Reflection; -using Microsoft.Office.Interop.Excel; - -public class CreateExcelWorksheet -{ - static void Main() - { - Microsoft.Office.Interop.Excel.Application xlApp = new Microsoft.Office.Interop.Excel.Application(); - - if (xlApp == null) - { - Console.WriteLine("EXCEL could not be started. Check that your office installation and project references are correct."); - return; - } - xlApp.Visible = true; - - Workbook wb = xlApp.Workbooks.Add(XlWBATemplate.xlWBATWorksheet); - Worksheet ws = (Worksheet)wb.Worksheets[1]; - - if (ws == null) - { - Console.WriteLine("Worksheet could not be created. Check that your office installation and project references are correct."); - } - - // Select the Excel cells, in the range c1 to c7 in the worksheet. - Range aRange = ws.get_Range("C1", "C7"); - - if (aRange == null) - { - Console.WriteLine("Could not get a range. Check to be sure you have the correct versions of the office DLLs."); - } - - // Fill the cells in the C1 to C7 range of the worksheet with the number 6. - Object[] args = new Object[1]; - args[0] = 6; - aRange.GetType().InvokeMember("Value", BindingFlags.SetProperty, null, aRange, args); - - // Change the cells in the C1 to C7 range of the worksheet to the number 8. - aRange.Value2 = 8; - } -} -// - -//----------------------------------------------------------------------------- -namespace Microsoft.Office.Interop -{ - namespace Excel - { - public enum XlWBATemplate - { - xlWBATChart, - xlWBATExcel4IntlMacroSheet, - xlWBATExcel4MacroSheet, - xlWBATWorksheet - } - - //------------------------------------------------------------------------- - class Application - { - private bool _Visible; - public bool Visible - { - get{return _Visible;} - set{_Visible = value;} - } - - private Workbooks _Workbooks = new Workbooks(); - public Workbooks Workbooks - { - get{return _Workbooks;} - } - } - - //------------------------------------------------------------------------- - class Range - { - private object _Value2; - public object Value2 - { - get{return _Value2;} - set{_Value2 = value;} - } - } - - //------------------------------------------------------------------------- - class Worksheet - { - Application _Application = new Application(); - public Application Application - { - get{return _Application;} - } - - public void SaveAs(string Filename, object FileFormat, object Password, object WriteResPassword, object ReadOnlyRecommended, object CreateBackup, object AddToMru, object TextCodepage, object TextVisualLayout, object Local) - {} - - private Range _Cells = new Range(); - public Range Cells - { - get{return _Cells;} - } - - public Range get_Range(object Cell1, object Cell2) - { - return new Range(); - } - } - - //------------------------------------------------------------------------- - class Worksheets - { - public object Add(object Before, object After, object Count, object Type) - { - return new Object(); - } - - public object this[int i] - { - get - { - return new Object(); - } - } - } - - //------------------------------------------------------------------------- - class Workbook - { - private Worksheets _Worksheets = new Worksheets(); - public Worksheets Worksheets - { - get{return _Worksheets;} - } - } - - //------------------------------------------------------------------------- - class Workbooks - { - public void Close() - {} - - public Workbook Add(object Template) - { - return new Workbook(); - } - - //public GetEnumerator() System.Collections.IEnumerator - - public Workbook Open(string Filename, object UpdateLinks, object oReadOnly, object Format, object Password, object WriteResPassword, object IgnoreReadOnlyRecommended, object Origin, object Delimiter, object Editable, object Notify, object Converter, object AddToMru, object Local, object CorruptLoad) - { - return new Workbook(); - } - - Application _Application = new Application(); - public Application Application - { - get{return _Application;} - } - - public int Count - { - get{return 1;} - } - - public Workbook Item - { - get{return new Workbook();} - } - - //public Property Parent() Object - } - } -} \ No newline at end of file diff --git a/samples/snippets/csharp/VS_Snippets_VBCSharp/csProgGuideInterop/CS/WordSpell.cs b/samples/snippets/csharp/VS_Snippets_VBCSharp/csProgGuideInterop/CS/WordSpell.cs deleted file mode 100644 index bfa2daf9cc346..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_VBCSharp/csProgGuideInterop/CS/WordSpell.cs +++ /dev/null @@ -1,246 +0,0 @@ -//----------------------------------------------------------------------------- -// -using System.Reflection; -using Word = Microsoft.Office.Interop.Word; - -namespace WordSpell -{ - public partial class Form1 : System.Windows.Forms.Form - { - private System.Windows.Forms.TextBox textBox1; - private System.Windows.Forms.Button button1; - private System.Windows.Forms.Label label1; - - public Form1() // Constructor. - { - InitializeComponent(); - } - - private void button1_Click(object sender, System.EventArgs e) - { - var app = new Word.Application(); - - var errors = 0; - if (textBox1.Text.Length > 0) - { - app.Visible = false; - - // Setting these variables is comparable to passing null to the function. - // This is necessary because the C# null cannot be passed by reference. - object template = Missing.Value; - object newTemplate = Missing.Value; - object documentType = Missing.Value; - object visible = true; - - Word._Document doc1 = app.Documents.Add(ref template, ref newTemplate, ref documentType, ref visible); - doc1.Words.First.InsertBefore(textBox1.Text); - Word.ProofreadingErrors spellErrorsColl = doc1.SpellingErrors; - errors = spellErrorsColl.Count; - - object optional = Missing.Value; - - doc1.CheckSpelling( - ref optional, ref optional, ref optional, ref optional, ref optional, ref optional, - ref optional, ref optional, ref optional, ref optional, ref optional, ref optional); - - label1.Text = $"{errors} errors corrected "; - object first = 0; - object last = doc1.Characters.Count - 1; - textBox1.Text = doc1.Range(ref first, ref last).Text; - } - - object saveChanges = false; - object originalFormat = Missing.Value; - object routeDocument = Missing.Value; - - app.Quit(ref saveChanges, ref originalFormat, ref routeDocument); - } - } -} -// - -//----------------------------------------------------------------------------- -// Form1.Designer.cs -//----------------------------------------------------------------------------- -namespace Microsoft.Office.Interop -{ - namespace Word - { - - //------------------------------------------------------------------------- - class Application - { - private bool _Visible; - public bool Visible - { - get{return _Visible;} - set{_Visible = value;} - } - - private Documents _Documents = new Documents(); - public Documents Documents - { - get{return _Documents;} - } - - public void Quit(ref object SaveChanges, ref object OriginalFormat, ref object RouteDocument) - { - } - } - - //------------------------------------------------------------------------- - class Documents - { - public Document Add(ref object a, ref object b, ref object c, ref object d) - { - return new Document(); - } - } - - //------------------------------------------------------------------------- - public interface _Document - { - Words Words {get;} - ProofreadingErrors SpellingErrors {get;} - void CheckSpelling(ref object CustomDictionary, ref object IgnoreUppercase, ref object AlwaysSuggest, ref object CustomDictionary2, ref object CustomDictionary3, ref object CustomDictionary4, ref object CustomDictionary5, ref object CustomDictionary6, ref object CustomDictionary7, ref object CustomDictionary8, ref object CustomDictionary9, ref object CustomDictionary10); - Characters Characters {get;} - Range Range(ref object first, ref object last); - } - - //------------------------------------------------------------------------- - class Document : _Document - { - Words _Words = (Words) new object(); - public Words Words - { - get{ return _Words; } - } - - ProofreadingErrors _SpellingErrors = (ProofreadingErrors) new object(); - public ProofreadingErrors SpellingErrors - { - get{ return _SpellingErrors; } - } - - public void CheckSpelling(ref object CustomDictionary, ref object IgnoreUppercase, ref object AlwaysSuggest, ref object CustomDictionary2, ref object CustomDictionary3, ref object CustomDictionary4, ref object CustomDictionary5, ref object CustomDictionary6, ref object CustomDictionary7, ref object CustomDictionary8, ref object CustomDictionary9, ref object CustomDictionary10) - { - } - - Characters _Characters = (Characters) new object(); - public Characters Characters - { - get{ return _Characters; } - } - - public Range Range(ref object first, ref object last) - { - return (Range)new object(); - } - } - - //------------------------------------------------------------------------- - public interface Range - { - void InsertBefore(string Text); - string Text { set; get; } - } - - //------------------------------------------------------------------------- - public interface ProofreadingErrors - { - int Count { get; } - } - - //------------------------------------------------------------------------- - public interface Words - { - Range First {get;} - } - - //------------------------------------------------------------------------- - public interface Characters - { - int Count {get;} - } - } -} - -//----------------------------------------------------------------------------- -namespace WordSpell -{ - partial class Form1 - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components=null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.components = new System.ComponentModel.Container(); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.Text = "Form1"; - - // - this.textBox1 = new System.Windows.Forms.TextBox(); - this.button1 = new System.Windows.Forms.Button(); - this.label1 = new System.Windows.Forms.Label(); - this.SuspendLayout(); - // - // textBox1 - // - this.textBox1.Location = new System.Drawing.Point(40, 40); - this.textBox1.Multiline = true; - this.textBox1.Name = "textBox1"; - this.textBox1.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; - this.textBox1.Size = new System.Drawing.Size(344, 136); - this.textBox1.TabIndex = 0; - this.textBox1.Text = ""; - // - // button1 - // - this.button1.Location = new System.Drawing.Point(392, 40); - this.button1.Name = "button1"; - this.button1.Size = new System.Drawing.Size(96, 23); - this.button1.TabIndex = 1; - this.button1.Text = "Check Spelling"; - this.button1.Click += new System.EventHandler(this.button1_Click); - // - // label1 - // - this.label1.Location = new System.Drawing.Point(40, 24); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(336, 16); - this.label1.TabIndex = 2; - // - // Form1 - // - this.AutoScaleDimensions = new System.Drawing.SizeF(5, 13); - this.ClientSize = new System.Drawing.Size(496, 205); - this.Controls.Add(this.label1); - this.Controls.Add(this.button1); - this.Controls.Add(this.textBox1); - this.Name = "Form1"; - this.Text = "SpellCheckDemo"; - this.ResumeLayout(false); - // - } - } -} diff --git a/samples/snippets/csharp/VS_Snippets_VBCSharp/csProgGuideMain/CS/Class3.cs b/samples/snippets/csharp/VS_Snippets_VBCSharp/csProgGuideMain/CS/Class3.cs deleted file mode 100644 index 1d38b136f0081..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_VBCSharp/csProgGuideMain/CS/Class3.cs +++ /dev/null @@ -1,43 +0,0 @@ -class Test2 -{ - // - static void Main(string[] args) - // - { - } -} - -//----------------------------------------------------------------------------- -class Test3 -{ - // - static void Main() - { - //... - } - // -} - - -//----------------------------------------------------------------------------- -class Test4 -{ - // - static int Main(string[] args) - { - //... - return 0; - } - // -} - -//----------------------------------------------------------------------------- -class Test5 -{ - // - static void Main(string[] args) - { - //... - } - // -} diff --git a/samples/snippets/csharp/VS_Snippets_VBCSharp/csProgGuideMain/CS/Project.csproj b/samples/snippets/csharp/VS_Snippets_VBCSharp/csProgGuideMain/CS/Project.csproj deleted file mode 100644 index b83f0211b39c5..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_VBCSharp/csProgGuideMain/CS/Project.csproj +++ /dev/null @@ -1,7 +0,0 @@ - - - - Library - net6.0 - - diff --git a/samples/snippets/csharp/VS_Snippets_VBCSharp/csProgGuidePointers/CS/Pointers.cs b/samples/snippets/csharp/VS_Snippets_VBCSharp/csProgGuidePointers/CS/Pointers.cs deleted file mode 100644 index 050c3ac5ff0b1..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_VBCSharp/csProgGuidePointers/CS/Pointers.cs +++ /dev/null @@ -1,223 +0,0 @@ - -// -class TestCopy -{ - // The unsafe keyword allows pointers to be used in the following method. - - static unsafe void Copy(byte[] source, int sourceOffset, byte[] target, - int targetOffset, int count) - { - // If either array is not instantiated, you cannot complete the copy. - if (source == null) - { - throw new System.ArgumentException("neither array can be null.", nameof(source)); - } - if (target == null) - { - throw new System.ArgumentException("neither array can be null.", nameof(target)); - } - - // If either offset, or the number of bytes to copy, is negative, you - // cannot complete the copy. - if (sourceOffset < 0) - { - throw new System.ArgumentException("offsets and count must be non-negative.", nameof(sourceOffset)); - } - if (targetOffset < 0) - { - throw new System.ArgumentException("offsets and count must be non-negative.", nameof(targetOffset)); - } - if (count < 0) - { - throw new System.ArgumentException("offsets and count must be non-negative.", nameof(count)); - } - - // If the number of bytes from the offset to the end of the array is - // less than the number of bytes you want to copy, you cannot complete - // the copy. - if ((source.Length - sourceOffset < count) || - (target.Length - targetOffset < count)) - { - throw new System.InvalidOperationException("Cannot copy past the end of source or destination array."); - } - - // The following fixed statement pins the location of the source and - // target objects in memory so that they will not be moved by garbage - // collection. - fixed (byte* pSource = source, pTarget = target) - { - // Set the starting points in source and target for the copying. - byte* ps = pSource + sourceOffset; - byte* pt = pTarget + targetOffset; - - // Copy the specified number of bytes from source to target. - for (int i = 0; i < count; i++) - { - *pt = *ps; - pt++; - ps++; - } - } - } - - static void Main() - { - // Create two arrays of the same length. - int length = 100; - byte[] byteArray1 = new byte[length]; - byte[] byteArray2 = new byte[length]; - - // Fill byteArray1 with 0 - 99. - for (int i = 0; i < length; ++i) - { - byteArray1[i] = (byte)i; - } - - // Display the first 10 elements in byteArray1. - System.Console.WriteLine("The first 10 elements of the original are:"); - for (int i = 0; i < 10; ++i) - { - System.Console.Write(byteArray1[i] + " "); - } - System.Console.WriteLine("\n"); - - // Copy the contents of byteArray1 to byteArray2. - Copy(byteArray1, 0, byteArray2, 0, length); - - // Display the first 10 elements in the copy, byteArray2. - System.Console.WriteLine("The first 10 elements of the copy are:"); - for (int i = 0; i < 10; ++i) - { - System.Console.Write(byteArray2[i] + " "); - } - System.Console.WriteLine("\n"); - - // Copy the contents of the last 10 elements of byteArray1 to the - // beginning of byteArray2. - // The offset specifies where the copying begins in the source array. - int offset = length - 10; - Copy(byteArray1, offset, byteArray2, 0, length - offset); - - // Display the first 10 elements in the copy, byteArray2. - System.Console.WriteLine("The first 10 elements of the copy are:"); - for (int i = 0; i < 10; ++i) - { - System.Console.Write(byteArray2[i] + " "); - } - System.Console.WriteLine("\n"); - } -} -/* Output: - The first 10 elements of the original are: - 0 1 2 3 4 5 6 7 8 9 - - The first 10 elements of the copy are: - 0 1 2 3 4 5 6 7 8 9 - - The first 10 elements of the copy are: - 90 91 92 93 94 95 96 97 98 99 -*/ -// - -class TestFixed1 -{ - // - public struct MyArray - { - public char[] pathName; - private int reserved; - } - // -} - -// -namespace FixedSizeBuffers -{ - internal unsafe struct MyBuffer - { - public fixed char fixedBuffer[128]; - } - - internal unsafe class MyClass - { - public MyBuffer myBuffer = default(MyBuffer); - } - - internal class Program - { - static void Main() - { - MyClass myC = new MyClass(); - - unsafe - { - // Pin the buffer to a fixed location in memory. - fixed (char* charPtr = myC.myBuffer.fixedBuffer) - { - *charPtr = 'A'; - } - } - } - } -} -// - - -//----------------------------------------------------------------------------- -// -class TestUnsafe -{ - unsafe static void PointyMethod() - { - int i=10; - - int *p = &i; - System.Console.WriteLine("*p = " + *p); - System.Console.WriteLine("Address of p = {0:X2}\n", (int)p); - } - - static void StillPointy() - { - int i=10; - - unsafe - { - int *p = &i; - System.Console.WriteLine("*p = " + *p); - System.Console.WriteLine("Address of p = {0:X2}\n", (int)p); - } - } - - static void Main() - { - PointyMethod(); - StillPointy(); - } -} -// - -//----------------------------------------------------------------------------- -// -class TestFixed -{ - public static void PointyMethod(char[] array) - { - unsafe - { - fixed (char *p = array) - { - for (int i=0; i diff --git a/samples/snippets/csharp/VS_Snippets_VBCSharp/csProgGuidePointers/CS/Pointers.csproj b/samples/snippets/csharp/VS_Snippets_VBCSharp/csProgGuidePointers/CS/Pointers.csproj deleted file mode 100644 index bb1380fd9d95c..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_VBCSharp/csProgGuidePointers/CS/Pointers.csproj +++ /dev/null @@ -1,12 +0,0 @@ - - - - Exe - net48 - true - CsCsrefProgrammingPointers - CsCsrefProgrammingPointers - CsCsrefProgrammingPointers.Program - - - diff --git a/samples/snippets/csharp/VS_Snippets_VBCSharp/csProgGuidePointers/CS/Program.cs b/samples/snippets/csharp/VS_Snippets_VBCSharp/csProgGuidePointers/CS/Program.cs deleted file mode 100644 index 734e5f1a9bac0..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_VBCSharp/csProgGuidePointers/CS/Program.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; - -namespace CsCsrefProgrammingPointers -{ - class Program - { - static void Main(string[] args) - { - Console.WriteLine("Hi"); - Console.WriteLine(""); - - Console.WriteLine(""); - Console.WriteLine("Bye"); - } - } -} diff --git a/samples/snippets/csharp/VS_Snippets_VBCSharp/csRef30Features/CS/Project.csproj b/samples/snippets/csharp/VS_Snippets_VBCSharp/csRef30Features/CS/Project.csproj deleted file mode 100644 index b83f0211b39c5..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_VBCSharp/csRef30Features/CS/Project.csproj +++ /dev/null @@ -1,7 +0,0 @@ - - - - Library - net6.0 - - diff --git a/samples/snippets/csharp/VS_Snippets_VBCSharp/csRef30Features/CS/csref30.cs b/samples/snippets/csharp/VS_Snippets_VBCSharp/csRef30Features/CS/csref30.cs deleted file mode 100644 index af92cd2207edf..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_VBCSharp/csRef30Features/CS/csref30.cs +++ /dev/null @@ -1,645 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading; - -namespace csrefLINQExamples -{ - - class CommonMethods - { - public static List CreateStudentList() - { - List names = GetLines(@"../../../names.csv"); - List scores = GetLines(@"../../../scores.csv"); - - IEnumerable queryNamesWithIDs = - from name in names - let x = name.Split(',') - from score in scores - let s = score.Split(',') - where x[2] == s[0] - select new Student() - { - FirstName = x[0], - LastName = x[1], - ID = Convert.ToInt32(x[2]), - Year = (GradeLevel)Convert.ToInt32(x[3]), - ExamScores = (from scoreAsText in s.Skip(1) - select Convert.ToInt32(scoreAsText)). - ToList() - }; - - return queryNamesWithIDs.ToList(); - } - - // Returns a structured text file as a list of text lines - public static List GetLines(string filename) - { - List lines = new List(); - using (System.IO.StreamReader sr = new System.IO.StreamReader(filename)) - { - string s; - while ((s = sr.ReadLine()) != null) - { - // Do not add empty lines - if (s.Length > 0) - lines.Add(s); - } - } - return lines; - } - } - - public enum GradeLevel { FirstYear = 1, SecondYear, ThirdYear, FourthYear }; - public class Student - { - public string FirstName { get; set; } - public string LastName { get; set; } - public int ID { get; set; } - public GradeLevel Year; - public List ExamScores; - } - - // - class SimpleLambda - { - static void Main() - { - - // Data source. - int[] scores = { 90, 71, 82, 93, 75, 82 }; - - // The call to Count forces iteration of the source - int highScoreCount = scores.Where(n => n > 80).Count(); - - Console.WriteLine("{0} scores are greater than 80", highScoreCount); - - // Outputs: 4 scores are greater than 80 - } - } - // - - // - class SumWithLambdas - { - static void Main() - { - // Create a data source using a collection initializer - List students = CommonMethods.CreateStudentList(); - - // This query retrieves the total scores for First Year and the total for SecondYears. - // The outer Sum method requires a lambda in order to specify which numbers to add together. - var categories = - from student in students - group student by student.Year into studentGroup - select new { GradeLevel = studentGroup.Key, TotalScore = studentGroup.Sum(s => s.ExamScores.Sum()) }; - - // Execute the query. - foreach (var cat in categories) - { - Console.WriteLine("Key = {0} Sum = {1}", cat.GradeLevel, cat.TotalScore); - } - - //Keep the console window open in debug mode - Console.WriteLine("Press any key to exit."); - Console.ReadKey(); - } - /* - Outputs: - Key = SecondYear Sum = 1014 - Key = ThirdYear Sum = 964 - Key = FirstYear Sum = 1058 - Key = FourthYear Sum = 974 - */ - } - // - - // var - -//varTest removed to csrefKeywordsTypes - - // - class GroupByExample1 - { - static void Main() - { - // Create a data source - List students = CommonMethods.CreateStudentList(); - - // Implicit typing is convenient but not required - // for queries that produce groups - var query = from student in students - group student by student.LastName[0]; - - foreach (var item in query) - { - Console.WriteLine(item.Key); - foreach (var i2 in item) - { - Console.WriteLine(i2.LastName + " " + i2.FirstName); - } - } - Console.WriteLine("Press any key to exit"); - Console.ReadKey(); - } - } - /* Outputs: - T - Terry Adams - F - Fadi Fakhouri - H - Hanying Feng - Hugo Garcia - C - Cesar Garcia - Claire O'Donnell - D - Debra Garcia - S - Sven Mortensen - Svetlana Omelchenko - L - Lance Tucker - M - Michael Tucker - E - Eugene Zabokritski - */ - // - - //#5 moved to csrefKeywordsContextual#9 - - //auto-impl props - // - class LightweightCustomer - { - public double TotalPurchases { get; set; } - public string Name { get; private set; } // read-only - public int CustomerID { get; private set; } // read-only - } - // - - //lightweight class - // - public class Contact - { - public string Name { get; set; } - public string Address { get; set; } - public int ContactNumber { get; set; } - public int ID { get; private set; } // readonly - } - // - - //Return Subsets of Element Properties - - // - class AnonymousTypes - { - static void Main(string[] args) - { - // Create a data source. - List students = CommonMethods.CreateStudentList(); - - // Create the query. var is required because - // the query produces a sequence of anonymous types. - var queryHighScores = - from student in students - where student.ExamScores[0] > 95 - select new { student.FirstName, student.LastName }; - - // Execute the query. - foreach (var student in queryHighScores) - { - // The anonymous type's properties were not named. Therefore - // they have the same names as the Student properties. - Console.WriteLine(student.FirstName + ", " + student.LastName); - } - } - } - /* Output: - Adams, Terry - Fakhouri, Fadi - Garcia, Cesar - Omelchenko, Svetlana - Zabokritski, Eugene - */ - // - - class ImplicitTyping - { // How to use implicitly typed locals - // - - static void Main(string[] args) - { - // Create the data source - List students = CommonMethods.CreateStudentList(); - - // Create the query. var is required because - // the query produces a sequence of anonymous types. - var studentQuery = - from student in students - where student.FirstName[0] == 'S' - select new { student.FirstName, student.LastName }; - - // Execute the query. - foreach (var student in studentQuery) - { - Console.WriteLine("First = {0}, Last = {1}", student.FirstName, student.LastName); - } - } - // - - static void QueryMethod(List students) - { - //how to use implicitly typed locals #2 - // - var queryID = - from student in students - where student.ID > 111 - select student.LastName; - - foreach (string str in queryID) - { - Console.WriteLine(str); - } - // - } - } - - class StudentName - { - public string FirstName { get; set; } - public string LastName { get; set; } - public int ID { get; set; } - } - - class CollInit - { - //how to init a dictionary with coll initializer - // - Dictionary students = new Dictionary() - { - { 111, new StudentName {FirstName="Sachin", LastName="Karnik", ID=211}}, - { 112, new StudentName {FirstName="Dina", LastName="Salimzianova", ID=317, }}, - { 113, new StudentName {FirstName="Andy", LastName="Ruth", ID=198, }} - }; - // - } - - class ObjInit - { - //How to: Initialize Objects without Calling a Constructor (C# Programming Guide) - // - - StudentName student = new StudentName - { - FirstName = "Craig", - LastName = "Playstead", - ID = 116 - }; - // - - //How to: Initialize Objects without Calling a Constructor #2 (C# Programming Guide) - // - List students = new List() - { - new StudentName {FirstName="Craig", LastName="Playstead", ID=116}, - new StudentName {FirstName="Shu", LastName="Ito", ID=112, }, - new StudentName {FirstName="Stefan", LastName="Rißling", ID=113, }, - new StudentName {FirstName="Rajesh", LastName="Rotti", ID=114, } - }; - // - } - - // Implicitly Typed Arrays example 1 - // - class ImplicitlyTypedArraySample - { - static void Main() - { - var a = new[] { 1, 10, 100, 1000 }; // int[] - var b = new[] { "hello", null, "world" }; // string[] - - // single-dimension jagged array - var c = new[] - { - new[]{1,2,3,4}, - new[]{5,6,7,8} - }; - - // jagged array of strings - var d = new[] - { - new[]{"Luca", "Mads", "Luke", "Dinesh"}, - new[]{"Karen", "Suma", "Frances"} - }; - } - } - // - - // Implicitly Typed Arrays examples 2 - class ImplicitArraySample2 - { - static void Method() - { - // - var contacts = new[] - { - new { - Name = " Eugene Zabokritski", - PhoneNumbers = new[] { "206-555-0108", "425-555-0001" } - }, - new { - Name = " Hanying Feng", - PhoneNumbers = new[] { "650-555-0199" } - } - }; - // - } - } - - //Object and collection intializers - class ObjCollInitializers - { - // - private class Cat - { - // Auto-implemented properties - public int Age { get; set; } - public string Name { get; set; } - } - - static void MethodA() - { - // Object initializer - Cat cat = new Cat { Age = 10, Name = "Sylvester" }; - } - // - - class Product - { - public string ProductName { get; set; } - public decimal UnitPrice { get; set; } - } - - void MethodB() - { - List products = new List(); - - // - var productInfos = - from p in products - select new { p.ProductName, p.UnitPrice }; - // - - // - List cats = new List - { - new Cat(){ Name="Sylvester", Age=8 }, - new Cat(){ Name="Whiskers", Age=2}, - new Cat() { Name="Sasha", Age=14} - }; - // - - // - List moreCats = new List - { - new Cat(){ Name="Furrytail", Age=5 }, - new Cat(){ Name="Peaches", Age=4}, - null - }; - // - } - } - - //Implicitly Typed Local Variables Conceptual Topic - class ImplicitlyTypedLocals - { - // compilation hack - class Customer - { - public string City { get; set; } - } - static List customers = new List(); - - // - static void Main() - { - // i is compiled as an int - var i = 5; - - // s is compiled as a string - var s = "Hello"; - - // a is compiled as int[] - var a = new[] { 0, 1, 2 }; - - // expr is compiled as IEnumerable - var expr = - from c in customers - where c.City == "London" - select c; - - // anon is compiled as an anonymous type - var anon = new { Name = "Terry", Age = 34 }; - - // list is compiled as List - var list = new List(); - } - // - } - - // - class ImplicitlyTypedLocals2 - { - static void Main() - { - string[] words = { "aPPLE", "BlUeBeRrY", "cHeRry" }; - - // If a query variable has been initialized with var, - // then you must also use var in the foreach statement. - var upperLowerWords = - from w in words - select new { Upper = w.ToUpper(), Lower = w.ToLower() }; - - // Execute the query - foreach (var ul in upperLowerWords) - { - Console.WriteLine("Uppercase: {0}, Lowercase: {1}", ul.Upper, ul.Lower); - } - } - } - /* Outputs: - Uppercase: APPLE, Lowercase: apple - Uppercase: BLUEBERRY, Lowercase: blueberry - Uppercase: CHERRY, Lowercase: cherry - */ - // - - // - class AnonymousMethodTest - { - delegate void testDelegate(string s); - static void M(string s) - { - Console.WriteLine(s); - } - - static void Main(string[] args) - { - // Original delegate syntax required - // initialization with a named method. - testDelegate testdelA = new testDelegate(M); - - // C# 2.0: A delegate can be initialized with - // inline code, called an "anonymous method." - testDelegate testDelB = delegate(string s) { Console.WriteLine(s); }; - - // C# 3.0. A delegate can be initialized with - // a lambda expression. - testDelegate testDelC = (x) => { Console.WriteLine(x); }; - - // Invoke the delegates. - testdelA("Hello. My name is M and I write lines."); - testDelC("That's nothing. I'm anonymous and "); - testDelC("I'm a famous author."); - - // Keep console window open in debug mode. - Console.WriteLine("Press any key to exit."); - Console.ReadKey(); - } - } - /* Output: - Hello. My name is M and I write lines. - That's nothing. I'm anonymous and - I'm a famous author. - Press any key to exit. - */ - // - - // - class Test2 - { - Func f; - - bool M(Func func, int i) - { - - int local = i; - Console.WriteLine(func(local)); - Thread.Sleep(5300); - return func(local); - } - static void Main() - { - Test2 app = new Test2(); - bool b = app.M(x => x % 2 == 0, DateTime.Now.Second); - - //bool b2 = app.M(x => x + - - Console.WriteLine(b.ToString()); - - Console.ReadKey(); - } - } - // - - //reserving numbers 67-79 for anonymous methods - - // - class MQ - { - IEnumerable QueryMethod1(ref int[] ints) - { - var intsToStrings = from i in ints - where i > 4 - select i.ToString(); - return intsToStrings; - } - - static void Main() - { - MQ app = new MQ(); - - int[] nums = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; - - var myQuery = app.QueryMethod1(ref nums); - - //execute myQuery - foreach (string s in myQuery) - { - Console.WriteLine(s); - } - - //modify myQuery - myQuery = (from str in myQuery - orderby str descending - select str). - Take(3); - - // Executing myQuery after more - // composition - Console.WriteLine("After modification:"); - foreach (string s in myQuery) - { - Console.WriteLine(s); - } - - // Keep console window open in debug mode. - Console.WriteLine("Press any key to exit."); - Console.ReadKey(); - } - } - // - - class CSHarp30 - { - - // - class Product2 - { - public string Color { get; set; } - public string Price { get; set; } - } - - // - // - class Product3 - { - public string Color { get; set; } - public string Price { get; set; } - } - // - // - class Product4 - { - public string Color { get; set; } - public string Price { get; set; } - } - // - // - class Product5 - { - public string Color { get; set; } - public string Price { get; set; } - } - // - // - class Product6 - { - public string Color { get; set; } - public string Price { get; set; } - } - // - // - class Product7 - { - public string Color { get; set; } - public string Price { get; set; } - } - // - } -} diff --git a/samples/snippets/csharp/VS_Snippets_VBCSharp/csasyncmethod/cs/app.xaml b/samples/snippets/csharp/VS_Snippets_VBCSharp/csasyncmethod/cs/app.xaml deleted file mode 100644 index cab3dbe1cc318..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_VBCSharp/csasyncmethod/cs/app.xaml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - diff --git a/samples/snippets/csharp/VS_Snippets_VBCSharp/csasyncmethod/cs/app.xaml.cs b/samples/snippets/csharp/VS_Snippets_VBCSharp/csasyncmethod/cs/app.xaml.cs deleted file mode 100644 index c576ec6c00474..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_VBCSharp/csasyncmethod/cs/app.xaml.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Configuration; -using System.Data; -using System.Linq; -using System.Threading.Tasks; -using System.Windows; - -namespace AsyncMethodCS -{ - /// - /// Interaction logic for App.xaml - /// - public partial class App : Application - { - } -} diff --git a/samples/snippets/csharp/VS_Snippets_VBCSharp/csasyncmethod/cs/asyncmethodcs.csproj b/samples/snippets/csharp/VS_Snippets_VBCSharp/csasyncmethod/cs/asyncmethodcs.csproj deleted file mode 100644 index 0a532a88e3af2..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_VBCSharp/csasyncmethod/cs/asyncmethodcs.csproj +++ /dev/null @@ -1,11 +0,0 @@ - - - - WinExe - net48 - true - AsyncMethodCS - AsyncMethodCS - - - diff --git a/samples/snippets/csharp/VS_Snippets_VBCSharp/csasyncmethod/cs/mainwindow.xaml b/samples/snippets/csharp/VS_Snippets_VBCSharp/csasyncmethod/cs/mainwindow.xaml deleted file mode 100644 index 5fa9638764a7a..0000000000000 --- a/samples/snippets/csharp/VS_Snippets_VBCSharp/csasyncmethod/cs/mainwindow.xaml +++ /dev/null @@ -1,9 +0,0 @@ - - -