// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) using System; using System.Collections.Generic; using System.Diagnostics; using System.Text; namespace Tango.Scripting.Editors.Utils { /// /// An immutable stack. /// /// Using 'foreach' on the stack will return the items from top to bottom (in the order they would be popped). /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1711:IdentifiersShouldNotHaveIncorrectSuffix")] [Serializable] public sealed class ImmutableStack : IEnumerable { /// /// Gets the empty stack instance. /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", Justification = "ImmutableStack is immutable")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1000:DoNotDeclareStaticMembersOnGenericTypes")] public static readonly ImmutableStack Empty = new ImmutableStack(); readonly T value; readonly ImmutableStack next; private ImmutableStack() { } private ImmutableStack(T value, ImmutableStack next) { this.value = value; this.next = next; } /// /// Pushes an item on the stack. This does not modify the stack itself, but returns a new /// one with the value pushed. /// public ImmutableStack Push(T item) { return new ImmutableStack(item, this); } /// /// Gets the item on the top of the stack. /// /// The stack is empty. public T Peek() { if (IsEmpty) throw new InvalidOperationException("Operation not valid on empty stack."); return value; } internal T UnsafePeek() { Debug.Assert(!IsEmpty); return value; } /// /// Gets the stack with the top item removed. /// /// The stack is empty. public ImmutableStack Pop() { if (IsEmpty) throw new InvalidOperationException("Operation not valid on empty stack."); return next; } /// /// Gets if this stack is empty. /// public bool IsEmpty { get { return next == null; } } /// /// Gets an enumerator that iterates through the stack top-to-bottom. /// public IEnumerator GetEnumerator() { ImmutableStack t = this; while (!t.IsEmpty) { yield return t.value; t = t.next; } } System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { return this.GetEnumerator(); } /// public override string ToString() { StringBuilder b = new StringBuilder("[Stack"); foreach (T val in this) { b.Append(' '); b.Append(val); } b.Append(']'); return b.ToString(); } } }
<?xml version="1.0" encoding="utf-8"?>

<!-- For more information on using web.config transformation visit https://go.microsoft.com/fwlink/?LinkId=125889 -->

<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
  <!--
    In the example below, the "SetAttributes" transform will change the value of 
    "connectionString" to use "ReleaseSQLServer" only when the "Match" locator 
    finds an attribute "name" that has a value of "MyDB".
    
    <connectionStrings>
      <add name="MyDB" 
        connectionString="Data Source=ReleaseSQLServer;Initial Catalog=MyReleaseDB;Integrated Security=True" 
        xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
    </connectionStrings>
  -->

  <appSettings>
    <add key="ServerAddress" value="localhost\SQLEXPRESS" />
  </appSettings>
  
  <system.web>
    <!--
      In the example below, the "Replace" transform will replace the entire 
      <customErrors> section of your web.config file.
      Note that because there is only one customErrors section under the 
      <system.web> node, there is no need to use the "xdt:Locator" attribute.
      
      <customErrors defaultRedirect="GenericError.htm"
        mode="RemoteOnly" xdt:Transform="Replace">
        <error statusCode="500" redirect="InternalError.htm"/>
      </customErrors>
    -->
  </system.web>
</configuration>