コード例 #1
0
        private bool EqualsEvent(IEventSignature x, IEventSignature y)
        {
            if (x == y)
            {
                return(true);
            }

            if (x == null || y == null)
            {
                return(false);
            }

            if (x.Name != y.Name)
            {
                return(false);
            }

            if (!EqualsType(x.EventType, y.EventType))
            {
                return(false);
            }

            if (!EqualsType(x.Owner, y.Owner))
            {
                return(false);
            }

            return(true);
        }
コード例 #2
0
        protected bool Equals(IEventSignature x, IEventSignature y, bool canIgnoreOwner)
        {
            if (x == y)
            {
                return(true);
            }

            if (x == null || y == null)
            {
                return(false);
            }

            if (x.Name != y.Name)
            {
                return(false);
            }

            if (!Equals(x.EventType, y.EventType, false))
            {
                return(false);
            }

            if (!canIgnoreOwner || (_flags & SignatureComparisonFlags.IgnoreMemberOwner) != SignatureComparisonFlags.IgnoreMemberOwner)
            {
                if (!Equals(x.Owner, y.Owner, canIgnoreOwner))
                {
                    return(false);
                }
            }

            return(true);
        }
コード例 #3
0
        private void WriteEvent(ref int pos, IEventSignature e)
        {
            _blob.Write(ref pos, (byte)SignatureType.Event);
            WriteString(ref pos, e.Name);

            var  owner      = e.Owner;
            bool writeOwner = (owner != null);

            _blob.Write(ref pos, (bool)writeOwner);

            int addLength = 4;

            if (writeOwner)
            {
                addLength += 4;
            }

            _blob.Length += addLength;

            if (writeOwner)
            {
                WriteReferenced(ref pos, owner);
            }

            WriteReferenced(ref pos, e.EventType);
        }
コード例 #4
0
        public static string ToString(this IEventSignature eventSig, IModule module = null, SignaturePrintingFlags flags = SignaturePrintingFlags.None)
        {
            var printer = new SignaturePrinter(flags);

            printer.PrintEvent(eventSig, module);

            return(printer.ToString());
        }
コード例 #5
0
        internal bool Equals(IEventSignature x, IEventSignature y)
        {
            if (x.Name != y.Name)
            {
                return(false);
            }

            if (!EqualsType(x.EventType, y.EventType))
            {
                return(false);
            }

            return(true);
        }
コード例 #6
0
        public IEvent Resolve(IEventSignature eventSig, ICodeNode context, bool throwOnFailure = false)
        {
            var e = ResolveEvent(eventSig, context.Module, context);

            if (e == null)
            {
                if (throwOnFailure)
                {
                    throw new ResolveReferenceException(string.Format(SR.EventResolveError, eventSig.ToString()));
                }

                return(null);
            }

            return(e);
        }
コード例 #7
0
        protected int GetHashCode(IEventSignature obj, bool canIgnoreOwner)
        {
            int hashCode = 0x10000;

            if (obj.Name != null)
            {
                hashCode ^= obj.Name.GetHashCode();
            }

            if (!canIgnoreOwner || (_flags & SignatureComparisonFlags.IgnoreMemberOwner) != SignatureComparisonFlags.IgnoreMemberOwner)
            {
                var owner = obj.Owner;
                if (owner != null)
                {
                    hashCode ^= GetHashCode(owner, canIgnoreOwner);
                }
            }

            return(hashCode);
        }
コード例 #8
0
        public void PrintEvent(IEventSignature eventSig, IModule module)
        {
            if ((_flags & SignaturePrintingFlags.IgnoreMemberOwner) != SignaturePrintingFlags.IgnoreMemberOwner)
            {
                var owner = eventSig.Owner;
                if (owner != null)
                {
                    PrintType(owner, module);
                }
                else
                {
                    _builder.Append(CodeModelUtils.GlobalTypeName);
                }

                _builder.Append("::");
            }

            PrintIdentifier(eventSig.Name);
            _builder.Append(" : ");
            PrintType(eventSig.EventType, module, false);
        }
コード例 #9
0
        protected IEvent ResolveEvent(IEventSignature eventSig, IModule context, ICodeNode genericContext)
        {
            var ownerType = ResolveType(eventSig.Owner, context, genericContext);

            if (ownerType == null)
            {
                return(null);
            }

            var comparer = new ResolveSignatureComparer(context, ownerType.Module);

            // Find
            foreach (var e in ownerType.Events)
            {
                if (comparer.Equals(eventSig, e.DeclaringEvent))
                {
                    return(e);
                }
            }

            return(null);
        }
コード例 #10
0
 public static IEvent Resolve(this IEventSignature eventSig, ICodeNode context, bool throwOnFailure = false)
 {
     return(context.AssemblyManager.Resolve(eventSig, context, throwOnFailure));
 }
コード例 #11
0
 public int GetHashCode(IEventSignature obj)
 {
     return(GetHashCode(obj, true));
 }
コード例 #12
0
 public bool Equals(IEventSignature x, IEventSignature y)
 {
     return(Equals(x, y, true));
 }