예제 #1
0
 protected void CheckValidFrameworkElement(ICommonType frameworkElementType, FrameworkElementPatchingType frameworkElementPatchingType, params (string PropertyName, string FieldName)[] expectedGroups)
예제 #2
0
 public abstract PatchResult Patch(ICommonAssembly assembly, ICommonType frameworkElementType, FrameworkElementPatchingType patchingType);
예제 #3
0
        public override PatchResult Patch(ICommonAssembly assembly, ICommonType frameworkElementType, FrameworkElementPatchingType patchingType)
        {
            log.Info("Patching dependency groups...");

            var propertyGroups = dependencyGrouperService.GetGroups(assembly, frameworkElementType, patchingType);

            if (!propertyGroups.Any())
            {
                log.Info("Not found dependency groups");
                return(PatchResult.Continue);
            }

            log.Debug("Dependency groups found:", propertyGroups.Select(group => $"Property: '{group.Property.Name}', dependency field: '{group.Field?.Name}'"));

            foreach (var group in propertyGroups)
            {
                log.Info($"Patch group: property: '{group.Property.Name}', dependency field: '{group.Field?.Name}'...");
                PatchGroup(assembly, frameworkElementType, group);
                log.Info("Group was patched");
            }

            log.Info("Dependency groups was patched");
            return(PatchResult.Continue);
        }
        public DependencyGroup[] GetGroups(ICommonAssembly assembly, ICommonType frameworkElementType, FrameworkElementPatchingType patchingType)
        {
            var dependencyPropertyType = assembly.GetCommonType(KnownTypeNames.DependencyProperty, true);

            CheckFrameworkElement(frameworkElementType, dependencyPropertyType);

            var patchingProperties = GetPatchingProperties(frameworkElementType, patchingType);

            CheckPatchingPropertyNames(patchingProperties);

            var patchingDependencyGroups = GetPatchingDependencyGroups(patchingProperties, frameworkElementType);

            CheckPatchingPropertyGroups(patchingDependencyGroups, dependencyPropertyType);

            return(patchingDependencyGroups.Select(group => new DependencyGroup(group.Fields.SingleOrDefault(), group.Property)).ToArray());
        }
 private ICommonProperty[] GetPatchingProperties(IHasProperties frameworkElementType, FrameworkElementPatchingType patchingType)
 {
     return(frameworkElementType.Properties
            .Where(property => property.NotContainsAttribute <NotPatchingPropertyAttribute>() &&
                   (!applicationPatcherWpfConfiguration.SkipConnectingByNameIfNameIsInvalid || nameRulesService.IsNameValid(property.Name, UseNameRulesFor.DependencyProperty)) && (
                       patchingType == FrameworkElementPatchingType.All ||
                       property.ContainsAttribute <PatchingPropertyAttribute>() ||
                       property.ContainsAttribute <ConnectPropertyToFieldAttribute>()))
            .ToArray());
 }
 public PatchingFrameworkElementAttribute(FrameworkElementPatchingType patchingType = FrameworkElementPatchingType.All)
 {
     PatchingType = patchingType;
 }