示例#1
0
        private bool Equals(SST other)
        {
            var areBothNonPartial = string.IsNullOrEmpty(PartialClassIdentifier) &&
                                    string.IsNullOrEmpty(other.PartialClassIdentifier);
            var pciEq = areBothNonPartial || string.Equals(PartialClassIdentifier, other.PartialClassIdentifier);

            return(EnclosingType.Equals(other.EnclosingType) &&
                   pciEq && Fields.Equals(other.Fields) &&
                   Properties.Equals(other.Properties) && Methods.Equals(other.Methods) && Events.Equals(other.Events) &&
                   Delegates.Equals(other.Delegates));
        }
示例#2
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = EnclosingType.GetHashCode();
         if (!string.IsNullOrEmpty(PartialClassIdentifier))
         {
             hashCode = (hashCode * 397) ^ PartialClassIdentifier.GetHashCode();
         }
         hashCode = (hashCode * 397) ^ Fields.GetHashCode();
         hashCode = (hashCode * 397) ^ Properties.GetHashCode();
         hashCode = (hashCode * 397) ^ Methods.GetHashCode();
         hashCode = (hashCode * 397) ^ Events.GetHashCode();
         hashCode = (hashCode * 397) ^ Delegates.GetHashCode();
         return(hashCode);
     }
 }
示例#3
0
        /// <summary>
        ///   Initializes a new instance of the <see cref = "AnonymousMethodInfo" /> class.
        /// </summary>
        /// <param name = "anonymousMethod">An anonymous method.</param>
        public AnonymousMethodInfo(MethodInfo anonymousMethod)
        {
            if (anonymousMethod == null)
            {
                throw new ArgumentNullException(nameof(anonymousMethod));
            }
            this.anonymousMethod = anonymousMethod;

            var declaringType = this.anonymousMethod.DeclaringType;

            var methodName = this.anonymousMethod.Name;
            var indexOfGt  = methodName.IndexOf(">", StringComparison.OrdinalIgnoreCase);

            if (indexOfGt < 0)
            {
                EnclosingType       = declaringType;
                EnclosingMethodName = this.anonymousMethod.Name;
                return;
            }

            EnclosingMethodName = methodName.Substring(0, indexOfGt).TrimStart('<');

            if (declaringType.IsCompilerGenerated() &&
                (declaringType
                 ?.DeclaringType
                 ?.IsGenericTypeDefinition ?? false))
            {
                EnclosingType = declaringType
                                .DeclaringType
                                ?.MakeGenericType(declaringType.GenericTypeArguments);
            }
            else
            {
                EnclosingType = declaringType;
            }

            while (EnclosingType?.DeclaringType != null &&
                   EnclosingType.IsCompilerGenerated())
            {
                EnclosingType = EnclosingType.DeclaringType;
            }
        }
示例#4
0
 public override string ToString()
 {
     return(EnclosingType.ToString(false) + "." + Method.ToString());
 }