Code development platform for open source projects from the European Union institutions :large_blue_circle: EU Login authentication by SMS has been phased out. To see alternatives please check here

Skip to content
Snippets Groups Projects
Select Git revision
  • 111190be2eef963295cdb61b20ba016d9fd8bc05
  • development default
  • bugfix/EDELIVERY-14172-domismp-accepts-requests-with-wrong-domain-header-value
  • EDELIVERY-15372-upgrade-libraries-and-plugins-and-update-httpclient-to-httpclient5
  • EDELIVERY-15377-migrate-to-angular-20
  • feature/EDELIVERY-15382-rest-api-jwt-authentication-for-dynamic-discovery-client
  • bugfix/EDELIVERY-14196-select-domain-select-resource-dropdown-should-be-order-alphabetically
  • feature/EDELIVERY-12753-sml-integration-migration-to-different-smp
  • feature/EDELIVERY-13757-extend-session-dialog-should-have-an-active-counter
  • EDELIVERY-15144-sql-update
  • bugfix/EDELIVERY-14326-ui-edit-resource-filters
  • feature/EDELIVERY-15144-domismp-system-notification-generalize-time-expiration-alerts
  • bugfix/EDELIVERY-15102-alert-is-not-appearing-when-adding-duplicated-certificate
  • bugfix/EDELIVERY-15203-small-left-grid-shows-no-data-found-for-1-2-seconds-before-loading-the-data
  • EDELIVERY-15219-search-filter-with-understore-char-does-not-work
  • bugfix/EDELIVERY-15226-certificates-error-when-trying-to-delete-certificates
  • bugfix/EDELIVERY-15224-error-when-trying-to-update-info-from-profile-page
  • bugfix/EDELIVERY-15225-emails-are-not-sent-in-domismp
  • release/5.1.x
  • feature/EDELIVERY-12746-external-secret-sharing-services-as-vaults
  • EDELIVERY-15229-upgrade-libraries-and-plugins
  • 5.1.1
  • 5.1
  • 5.1-TEST
  • 5.1-RC1
  • 5.0.1
  • 5.0
  • 5.0-RC1
  • 4.2
  • 4.2-RC1
  • 4.1.2
  • 4.1.1
  • 4.1.0
  • 4.1.0-RC1
  • 4.0.0
  • 4.0.0-RC1
  • 3.0.2
  • 3.0.1
  • 3.0.0
39 results

credential-dialog.component.ts

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    SwitchExtension.cs 2.65 KiB
    /*
    * Copyright 2015 European Union
    *
    * Licensed under the EUPL (the "Licence");
    * You may not use this work except in compliance with the Licence.
    * You may obtain a copy of the Licence at:
    *
    * http://ec.europa.eu/idabc/eupl5
    *
    * Unless required by applicable law or agreed to in writing, software 
    * distributed under the Licence is distributed on an "AS IS" basis,
    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    * See the Licence for the specific language governing permissions and 
    * limitations under the Licence.
    */
    
    using System;
    using System.Diagnostics;
    
    namespace TUGraz.VectoCore.Utils
    {
    	/// <summary>
    	/// Extension Methods for Creating a Switch-Case Construct on Types.
    	/// </summary>
    	/// <remarks>
    	/// Adapted for VECTO. Created by Virtlink. Original source code on GitHub: <see href="https://gist.github.com/Virtlink/8722649"/>.
    	/// </remarks>
    	public static class SwitchExtension
    	{
    		/// <summary>
    		/// Switches on the type.
    		/// With ".Case" you can define single alternatives (only the first suitable case will be executed).
    		/// With ".If" you can define multiple type-conditionals (every suitable if will be executed)
    		/// </summary>
    		/// <typeparam name="T"></typeparam>
    		/// <param name="self">The self.</param>
    		/// <returns></returns>
    		[DebuggerHidden]
    		public static Switch<T> Switch<T>(this T self)
    		{
    			return new Switch<T>(self);
    		}
    	}
    
    	public class Switch<T>
    	{
    		private readonly T _value;
    		private bool _handled;
    
    		[DebuggerHidden]
    		internal Switch(T value)
    		{
    			_value = value;
    			_handled = false;
    		}
    
    		[DebuggerHidden]
    		public Switch<T> Case<TFilter>(Action action) where TFilter : T
    		{
    			return Case<TFilter>(_ => action());
    		}
    
    		[DebuggerHidden]
    		public Switch<T> Case<TFilter>() where TFilter : T
    		{
    			return Case<TFilter>(() => {});
    		}
    
    
    		[DebuggerHidden]
    		public Switch<T> Case<TFilter>(Action<TFilter> action) where TFilter : T
    		{
    			if (!_handled && _value.GetType() == typeof(TFilter)) {
    				action((TFilter)_value);
    				_handled = true;
    			}
    			return this;
    		}
    
    		/// <summary>
    		/// Does the action if the type is fullfilled and continues the evaluation.
    		/// </summary>
    		/// <typeparam name="TFilter">The type of the filter.</typeparam>
    		/// <param name="action">The action.</param>
    		/// <returns></returns>
    		[DebuggerHidden]
    		public Switch<T> If<TFilter>(Action<TFilter> action) where TFilter : class
    		{
    			if (_value is TFilter) {
    				action(_value as TFilter);
    			}
    			return this;
    		}
    
    		[DebuggerHidden]
    		public void Default(Action action)
    		{
    			Default(_ => action());
    		}
    
    		[DebuggerHidden]
    		public void Default(Action<T> action)
    		{
    			if (!_handled) {
    				action(_value);
    			}
    		}
    	}
    }