|
| 1 | +// Copyright 2019 Florian Gather <[email protected]> |
| 2 | +// Copyright 2019 Fritz Brandhuber <[email protected]> |
| 3 | +// Copyright 2020 Pavel Fischer <[email protected]> |
| 4 | +// |
| 5 | +// SPDX-License-Identifier: Apache-2.0 |
| 6 | + |
| 7 | +using System.Collections.Generic; |
| 8 | +using System.Linq; |
| 9 | +using ArchUnitNET.Domain.Dependencies; |
| 10 | + |
| 11 | +namespace ArchUnitNET.Domain |
| 12 | +{ |
| 13 | + public class UnavailableType : IType |
| 14 | + { |
| 15 | + public UnavailableType(IType type) |
| 16 | + { |
| 17 | + Type = type; |
| 18 | + } |
| 19 | + |
| 20 | + private IType Type { get; } |
| 21 | + public string Name => Type.Name; |
| 22 | + public string FullName => Type.FullName; |
| 23 | + |
| 24 | + public Visibility Visibility => Type.Visibility; |
| 25 | + public bool IsNested => Type.IsNested; |
| 26 | + public bool IsGeneric => Type.IsGeneric; |
| 27 | + public bool IsGenericParameter => Type.IsGenericParameter; |
| 28 | + public bool IsStub => true; |
| 29 | + public bool IsCompilerGenerated => Type.IsCompilerGenerated; |
| 30 | + |
| 31 | + public Namespace Namespace => Type.Namespace; |
| 32 | + public Assembly Assembly => Type.Assembly; |
| 33 | + |
| 34 | + public IEnumerable<Attribute> Attributes => |
| 35 | + AttributeInstances.Select(instance => instance.Type); |
| 36 | + public List<AttributeInstance> AttributeInstances => Type.AttributeInstances; |
| 37 | + |
| 38 | + public List<ITypeDependency> Dependencies => Type.Dependencies; |
| 39 | + public List<ITypeDependency> BackwardsDependencies => Type.BackwardsDependencies; |
| 40 | + public IEnumerable<IType> ImplementedInterfaces => Type.ImplementedInterfaces; |
| 41 | + |
| 42 | + public MemberList Members => Type.Members; |
| 43 | + public List<GenericParameter> GenericParameters => Type.GenericParameters; |
| 44 | + |
| 45 | + public override string ToString() |
| 46 | + { |
| 47 | + return FullName; |
| 48 | + } |
| 49 | + |
| 50 | + private bool Equals(Struct other) |
| 51 | + { |
| 52 | + return Equals(Type, other.Type); |
| 53 | + } |
| 54 | + |
| 55 | + public override bool Equals(object obj) |
| 56 | + { |
| 57 | + if (ReferenceEquals(null, obj)) |
| 58 | + { |
| 59 | + return false; |
| 60 | + } |
| 61 | + |
| 62 | + if (ReferenceEquals(this, obj)) |
| 63 | + { |
| 64 | + return true; |
| 65 | + } |
| 66 | + |
| 67 | + return obj.GetType() == GetType() && Equals((Struct)obj); |
| 68 | + } |
| 69 | + |
| 70 | + public override int GetHashCode() |
| 71 | + { |
| 72 | + return Type != null ? Type.GetHashCode() : 0; |
| 73 | + } |
| 74 | + } |
| 75 | +} |
0 commit comments