public Interceptors([NotNull] PropertyAccessorWeaver weaver, [NotNull] TypeReference classDefinition, [CanBeNull] Interceptors baseTypeInterceptors) { _weaver = weaver; // ReSharper disable once AssignNullToNotNullAttribute ClassDefinition = classDefinition.Resolve(); _baseTypeInterceptors = baseTypeInterceptors; // ReSharper disable once PossibleNullReferenceException var allMethods = ClassDefinition.Methods; if (allMethods == null) { return; } var getInterceptors = allMethods.Where(m => m?.CustomAttributes?.GetAttribute(AttributeNames.GetInterceptor) != null).ToArray(); if (getInterceptors.Length > 1) { throw new WeavingException($"Multiple [GetInterceptor] attributed methods found in class {classDefinition}.", getInterceptors[1]); } _getInterceptor = getInterceptors.FirstOrDefault(); var setInterceptors = allMethods.Where(m => m?.CustomAttributes?.GetAttribute(AttributeNames.SetInterceptor) != null).ToArray(); if (setInterceptors.Length > 1) { throw new WeavingException($"Multiple [SetInterceptor] attributed methods found in class {classDefinition}.", setInterceptors[1]); } _setInterceptor = setInterceptors.FirstOrDefault(); VerifyInterceptors(); }
public Interceptors(PropertyAccessorWeaver weaver, TypeReference classDefinition, Interceptors?baseTypeInterceptors) { _weaver = weaver; ClassDefinition = classDefinition.Resolve(); _baseTypeInterceptors = baseTypeInterceptors; var allMethods = ClassDefinition.Methods; if (allMethods == null) { return; } var getInterceptors = allMethods.Where(m => m?.CustomAttributes?.GetAttribute(AttributeNames.GetInterceptor) != null).ToArray(); if (getInterceptors.Length > 1) { throw new WeavingException($"Multiple [GetInterceptor] attributed methods found in class {classDefinition}.", getInterceptors[1]); } _getInterceptor = getInterceptors.FirstOrDefault(); var setInterceptors = allMethods.Where(m => m?.CustomAttributes?.GetAttribute(AttributeNames.SetInterceptor) != null).ToArray(); if (setInterceptors.Length > 1) { throw new WeavingException($"Multiple [SetInterceptor] attributed methods found in class {classDefinition}.", setInterceptors[1]); } _setInterceptor = setInterceptors.FirstOrDefault(); VerifyInterceptors(); }
public ClassWeaver([NotNull] PropertyAccessorWeaver weaver, [NotNull] TypeDefinition classDefinition) { _weaver = weaver; _classDefinition = classDefinition; _logger = _weaver._logger; }