public static void AssertActivityDescriptor(this WfClientActivityDescriptor cad, WfClientActivityDescriptor sad) { cad.AreSame(sad); Assert.AreEqual(cad.ActivityType, sad.ActivityType); cad.Condition.AreSame(sad.Condition); cad.Variables.AssertCollection(sad.Variables); cad.Resources.AssertResources(sad.Resources); cad.EnterEventReceivers.AssertResources(sad.EnterEventReceivers); cad.LeaveEventReceivers.AssertResources(sad.LeaveEventReceivers); cad.ToTransitions.AssertCollection(sad.ToTransitions); cad.ToTransitions.ForEach(ct => ct.IsValid()); sad.ToTransitions.ForEach(st => st.IsValid()); cad.GetFromTransitions().AssertCollection(sad.GetFromTransitions()); cad.GetFromTransitions().ForEach(ct => ct.IsValid()); sad.GetFromTransitions().ForEach(st => st.IsValid()); cad.RelativeLinks.AssertRelativeLinks(sad.RelativeLinks); }
/// <summary> /// Is the given method an implementation (implicit or explicit) of the given interface method. /// </summary> /// <param name="method">The method to investigate</param> /// <param name="iMethod">The interface method.</param> public static bool IsImplementationOf(this MethodDefinition method, MethodDefinition iMethod) { // Try explicit first var resolver = new GenericsResolver(method.DeclaringType); if (method.IsExplicitImplementation()) { return method.Overrides.Any(x => x.GetElementMethod().AreSameIncludingDeclaringType(iMethod, resolver.Resolve)); } // Private methods cannot be an implicit implementation if (method.IsPrivate) return false; // Try implicit if (method.AreSame(iMethod, resolver.Resolve)) { // If the declaring class also has an explicit implementation of the method we have no match. // Otherwise we have a match. return !method.DeclaringType.HasExplicitImplementationOf(iMethod); } return false; }
/// <summary> /// Determines if the directory directly contains the other directory or file. /// </summary> public static bool ContainsDirectly(this DirectoryInfo dir, FileSystemInfo other) { if (dir == null) throw new ArgumentNullException("dir"); if (other == null) throw new ArgumentNullException("other"); return dir.AreSame(other.GetParentDirectory()); }
public static void AssertProcessDescriptor(this WfClientProcessDescriptor cpd, WfClientProcessDescriptor spd) { cpd.AreSame(spd); cpd.Activities.AssertActivityDescriptorCollection(spd.Activities); if (cpd.InitialActivity != null) Assert.AreEqual(cpd.InitialActivity.Key, spd.InitialActivity.Key); if (cpd.CompletedActivity != null) Assert.AreEqual(cpd.CompletedActivity.Key, spd.CompletedActivity.Key); cpd.RelativeLinks.AssertRelativeLinks(spd.RelativeLinks); }
/// <summary> /// Are method reference a and b the same or both null? /// Note! Declaring type is not taken into account! /// </summary> public static bool AreSameOrNull(this MethodReference a, MethodReference b, Func<GenericParameter, TypeReference> genericParamResolver) { if ((a == null) && (b == null)) { return true; } if ((a == null) || (b == null)) { return false; } return a.AreSame(b, genericParamResolver); }
/// <summary> /// Are type a and b the same? /// </summary> public static bool AreSameIncludingScope(this TypeReference a, TypeReference b, Func<GenericParameter, TypeReference> genericParamResolver) { return a.AreSame(b, genericParamResolver) && a.Scope.AreSame(b.Scope); }
/// <summary> /// Are method reference a and b the same? /// Note! Declaring type IS taken into account! /// </summary> public static bool AreSameIncludingDeclaringType(this MethodReference a, MethodReference b, Func<GenericParameter, TypeReference> genericParamResolver) { return a.AreSame(b, genericParamResolver) && a.DeclaringType.GetElementType().AreSame(b.DeclaringType.GetElementType(), genericParamResolver); }