public override PatchResult Patch(ICommonAssembly assembly)
        {
            log.Info("Patching view model types...");

            var selectingType = assembly.GetReflectionAttribute <SelectingViewModelAttribute>()?.SelectingType
                                ?? applicationPatcherWpfConfiguration.DefaultViewModelSelectingType;

            log.Info($"View model selecting type: '{selectingType}'");

            var viewModelBaseType = assembly.GetCommonType(KnownTypeNames.ViewModelBase, true).Load();

            CheckAssembly(assembly, viewModelBaseType);

            var viewModelTypes = assembly.GetInheritanceCommonTypesFromThisAssembly(viewModelBaseType).ToArray();

            if (!viewModelTypes.Any())
            {
                log.Info("Not found view model types");
                return(PatchResult.Continue);
            }

            log.Debug("View model types found:", viewModelTypes.Select(viewModel => viewModel.FullName).OrderBy(fullName => fullName));

            var patchingViewModelTypes = viewModelTypes
                                         .Where(viewModelType => viewModelType.NotContainsReflectionAttribute <NotPatchingViewModelAttribute>() &&
                                                (selectingType == ViewModelSelectingType.All || viewModelType.ContainsReflectionAttribute <PatchingViewModelAttribute>()))
                                         .ToArray();

            if (!patchingViewModelTypes.Any())
            {
                log.Info("Not found patching view model types");
                return(PatchResult.Continue);
            }

            log.Debug("Patching view model types:", patchingViewModelTypes.Select(viewModel => viewModel.FullName).OrderBy(fullName => fullName));

            foreach (var viewModelType in patchingViewModelTypes)
            {
                log.Info($"Patching type '{viewModelType.FullName}'...");

                if (PatchViewModel(assembly, viewModelBaseType, viewModelType) == PatchResult.Cancel)
                {
                    return(PatchResult.Cancel);
                }

                log.Info($"Type '{viewModelType.FullName}' was patched");
            }

            log.Info("View model types was patched");
            return(PatchResult.Continue);
        }
        public override PatchResult Patch(ICommonAssembly assembly)
        {
            log.Info("Patching framework element types...");

            var selectingType = assembly.GetReflectionAttribute <SelectingFrameworkElementAttribute>()?.SelectingType
                                ?? applicationPatcherWpfConfiguration.DefaultFrameworkElementSelectingType;

            log.Info($"Framework element selecting type: '{selectingType}'");

            var frameworkElementBaseType = assembly.GetCommonType(KnownTypeNames.FrameworkElement, true).Load();

            CheckAssembly(assembly, frameworkElementBaseType);

            var frameworkElementTypes = assembly.GetInheritanceCommonTypesFromThisAssembly(frameworkElementBaseType).ToArray();

            if (!frameworkElementTypes.Any())
            {
                log.Info("Not found framework element types");
                return(PatchResult.Continue);
            }

            log.Debug("Framework element types found:", frameworkElementTypes.Select(frameworkElement => frameworkElement.FullName).OrderBy(fullName => fullName));

            var patchingFrameworkElementTypes = frameworkElementTypes
                                                .Where(frameworkElementType => frameworkElementType.NotContainsReflectionAttribute <NotPatchingFrameworkElementAttribute>() &&
                                                       (selectingType == FrameworkElementSelectingType.All || frameworkElementType.ContainsReflectionAttribute <PatchingFrameworkElementAttribute>()))
                                                .ToArray();

            if (!patchingFrameworkElementTypes.Any())
            {
                log.Info("Not found patching framework element types");
                return(PatchResult.Continue);
            }

            log.Debug("Patching framework element types:", patchingFrameworkElementTypes.Select(frameworkElement => frameworkElement.FullName).OrderBy(fullName => fullName));

            foreach (var frameworkElementType in patchingFrameworkElementTypes)
            {
                log.Info($"Patching type '{frameworkElementType.FullName}'...");

                if (PatchFrameworkElement(assembly, frameworkElementType) == PatchResult.Cancel)
                {
                    return(PatchResult.Cancel);
                }

                log.Info($"Type '{frameworkElementType.FullName}' was patched");
            }

            log.Info("Framework element types was patched");
            return(PatchResult.Continue);
        }
 public static TAttribute GetReflectionAttribute <TAttribute>(this ICommonAssembly commonAssembly, bool throwExceptionIfNotFound = false) where TAttribute : Attribute
 {
     return((TAttribute)commonAssembly.GetReflectionAttribute(typeof(TAttribute), throwExceptionIfNotFound));
 }
 public static bool TryGetReflectionAttribute <TAttribute>(this ICommonAssembly commonAssembly, out TAttribute foundAttribute) where TAttribute : Attribute
 {
     return((foundAttribute = commonAssembly.GetReflectionAttribute <TAttribute>()) != null);
 }