Exemplo n.º 1
0
        internal static S GetCollectionAsValidType <S, T>(IDirectedConnectedNodeCollection <T> collection) where S : class, IDirectedConnectedNodeCollection <T>
        {
            if (collection == null)
            {
                return(null);
            }

            var typedCollection = collection as S;

            if (typedCollection == null)
            {
                throw new InvalidCastException($"Given collection is not a '{typeof(S)}' collection. Collection Type is actually: '{collection.GetType()}'");
            }

            return(typedCollection);
        }