示例#1
0
 protected PsfContentRegexpViewModel(string regularExpression)
 {
     this.regularExpression = new ChangeableProperty <string>(regularExpression);
     this.regularExpression.ValueChanged += this.RegularExpressionOnValueChanged;
     this.SetValuesFromRegularExpression(regularExpression);
     this.AddChild(this.regularExpression);
 }
示例#2
0
        public override void Commit()
        {
            if (this.Path.IsTouched)
            {
                this.model.Path = this.Path.CurrentValue;
            }

            if (this.Name.IsTouched)
            {
                this.model.Name = this.Name.CurrentValue;
            }

            if (this.Icon.IsTouched)
            {
                this.model.Icon = this.Icon.CurrentValue;
            }

            if (this.AsAdmin.IsTouched)
            {
                this.model.AsAdmin = this.AsAdmin.CurrentValue;
            }

            if (this.Arguments.IsTouched)
            {
                this.model.Arguments = this.Arguments.CurrentValue;
            }

            base.Commit();
        }
示例#3
0
        public PsfContentProcessTraceViewModel(string processRegularExpression, string fixupName, PsfTraceFixupConfig traceFixup) : base(processRegularExpression, fixupName)
        {
            this.breakOn     = new ChangeableProperty <TraceLevel>(traceFixup.BreakOn);
            this.traceMethod = new ChangeableProperty <string>(traceFixup.TraceMethod);
            this.TraceLevel  = new PsfContentTraceLevelViewModel(traceFixup.TraceLevels);

            this.AddChildren(this.breakOn, this.traceMethod, this.TraceLevel);
        }
示例#4
0
        public PsfContentTraceLevelViewModel(PsfTraceFixupLevels levels)
        {
            this.defaultLevel            = new ChangeableProperty <TraceLevel>(levels.Default);
            this.filesystemLevel         = new ChangeableProperty <TraceLevel>(levels.Filesystem);
            this.registryLevel           = new ChangeableProperty <TraceLevel>(levels.Registry);
            this.processAndThreadLevel   = new ChangeableProperty <TraceLevel>(levels.ProcessAndThread);
            this.dynamicLinkLibraryLevel = new ChangeableProperty <TraceLevel>(levels.DynamicLinkLibrary);

            this.AddChildren(this.defaultLevel, this.filesystemLevel, this.registryLevel, this.processAndThreadLevel, this.dynamicLinkLibraryLevel);
        }
示例#5
0
        public PsfContentRuleRedirectionViewModel(IEnumerable <PsfContentFileRedirectionViewModel> include, IEnumerable <PsfContentFileRedirectionViewModel> exclude, string redirectBase, bool isReadOnly)
        {
            this.targetRedirection = new ChangeableProperty <string>(redirectBase);
            this.isReadOnly        = new ChangeableProperty <bool>(isReadOnly);

            this.Include = new ChangeableCollection <PsfContentFileRedirectionViewModel>(include);
            this.Exclude = new ChangeableCollection <PsfContentFileRedirectionViewModel>(exclude);

            this.Include.Commit();
            this.Exclude.Commit();

            this.AddChildren(this.Include, this.Exclude, this.isReadOnly, this.targetRedirection);
        }
        private PsfContentFolderRedirectionViewModel(PsfContentFolderRelationTo relation, string knownDir, string baseDir, IEnumerable <PsfContentRuleRedirectionViewModel> rules)
        {
            this.knownDir   = new ChangeableProperty <string>(knownDir);
            this.baseDir    = new ChangeableProperty <string>(baseDir);
            this.relationTo = new ChangeableProperty <PsfContentFolderRelationTo>(relation);

            this.Rules = new ChangeableCollection <PsfContentRuleRedirectionViewModel>(rules.OrderBy(r => r.Exclude.Any() ? 1 : 0));
            this.Rules.Commit();
            this.AddChildren(this.Rules, this.knownDir, this.relationTo, this.baseDir);

            this.knownDir.ValueChanged   += this.DirectoryOnValueChanged;
            this.baseDir.ValueChanged    += this.DirectoryOnValueChanged;
            this.relationTo.ValueChanged += this.DirectoryOnValueChanged;
        }
示例#7
0
        public void BasicTest()
        {
            bool eventChangingFired;
            bool eventChangedFired;

            EventHandler <ValueChangingEventArgs> handlerChanging = (sender, args) => { eventChangingFired = true; };
            EventHandler <ValueChangedEventArgs>  handlerChanged  = (sender, args) => { eventChangedFired = true; };

            eventChangingFired = false;
            eventChangedFired  = false;
            var change1 = new ChangeableProperty <bool>(true);

            change1.ValueChanging += handlerChanging;
            change1.ValueChanged  += handlerChanged;
            Assert.IsTrue(change1.OriginalValue);
            Assert.IsTrue(change1.CurrentValue);
            Assert.IsFalse(change1.IsDirty);
            Assert.IsFalse(change1.IsTouched);
            Assert.IsFalse(eventChangingFired);
            Assert.IsFalse(eventChangedFired);

            // Changing to the same value should do nothing
            eventChangingFired   = false;
            change1.CurrentValue = true;
            Assert.IsTrue(change1.OriginalValue);
            Assert.IsTrue(change1.CurrentValue);
            Assert.IsFalse(change1.IsDirty);
            Assert.IsFalse(change1.IsTouched);
            Assert.IsFalse(eventChangingFired);
            Assert.IsFalse(eventChangedFired);

            eventChangingFired   = false;
            change1.CurrentValue = false;
            Assert.IsTrue(change1.OriginalValue);
            Assert.IsFalse(change1.CurrentValue);
            Assert.IsTrue(change1.IsDirty);
            Assert.IsTrue(change1.IsTouched);
            Assert.IsTrue(eventChangingFired);

            eventChangingFired   = false;
            change1.CurrentValue = true;
            Assert.IsTrue(change1.OriginalValue);
            Assert.IsTrue(change1.CurrentValue);
            Assert.IsFalse(change1.IsDirty);
            Assert.IsTrue(change1.IsTouched);
            Assert.IsTrue(eventChangingFired);
            Assert.IsTrue(eventChangingFired);
        }
示例#8
0
        public void TestCommit()
        {
            var change1 = new ChangeableProperty <bool>(false);

            change1.CurrentValue = true;
            Assert.IsFalse(change1.OriginalValue);
            Assert.IsTrue(change1.CurrentValue);
            Assert.IsTrue(change1.IsDirty);
            Assert.IsTrue(change1.IsTouched);

            change1.Commit();
            Assert.IsTrue(change1.OriginalValue);
            Assert.IsTrue(change1.CurrentValue);
            Assert.IsFalse(change1.IsDirty);
            Assert.IsFalse(change1.IsTouched);
        }
示例#9
0
        public void TestTouching()
        {
            var change1 = new ChangeableProperty <bool>(true);

            Assert.IsFalse(change1.IsTouched);

            change1.Touch();
            Assert.IsTrue(change1.IsTouched);

            change1.Touch();
            Assert.IsTrue(change1.IsTouched);

            change1.Reset(ValueResetType.Soft);
            Assert.IsTrue(change1.IsTouched);

            change1.Reset(ValueResetType.Hard);
            Assert.IsFalse(change1.IsTouched);
        }
示例#10
0
        protected PsfContentProcessViewModel(string processRegularExpression, string fixupName) : base(processRegularExpression)
        {
            Bitness bitness;

            if (fixupName.IndexOf("64", StringComparison.Ordinal) != -1)
            {
                bitness = Bitness.x64;
            }
            else if (fixupName.IndexOf("32", StringComparison.Ordinal) != -1 || fixupName.IndexOf("86", StringComparison.Ordinal) != -1)
            {
                bitness = Bitness.x86;
            }
            else
            {
                bitness = Bitness.Unknown;
            }

            this.is64Bit = new ChangeableProperty <Bitness>(bitness);
            this.AddChildren(this.is64Bit);
        }
示例#11
0
        public void TestCancelling()
        {
            EventHandler <ValueChangingEventArgs> cancelHandler = (sender, args) => { args.Cancel = true; };
            var change1 = new ChangeableProperty <bool>(false);

            // Since our handler cancels the change, there should be no difference to the previous result.
            change1.ValueChanging += cancelHandler;
            change1.CurrentValue   = true;
            Assert.IsFalse(change1.OriginalValue);
            Assert.IsFalse(change1.CurrentValue);
            Assert.IsFalse(change1.IsDirty);
            Assert.IsFalse(change1.IsTouched);

            change1.ValueChanging -= cancelHandler;
            change1.CurrentValue   = true;
            Assert.IsFalse(change1.OriginalValue);
            Assert.IsTrue(change1.CurrentValue);
            Assert.IsTrue(change1.IsDirty);
            Assert.IsTrue(change1.IsTouched);
        }
示例#12
0
        public void TestReset()
        {
            var change1 = new ChangeableProperty <bool>(false);

            change1.CurrentValue = true;
            Assert.IsFalse(change1.OriginalValue, "Original value must not be changed.");
            Assert.IsTrue(change1.CurrentValue);
            Assert.IsTrue(change1.IsDirty);
            Assert.IsTrue(change1.IsTouched);

            change1.Reset();
            Assert.IsFalse(change1.OriginalValue, "Original value must not be changed by reset methods.");
            Assert.IsFalse(change1.CurrentValue);
            Assert.IsFalse(change1.IsDirty);
            Assert.IsFalse(change1.IsTouched);

            var change2 = new ChangeableProperty <bool>(false);

            change2.Reset(); // calling reset without changing the value
            Assert.IsFalse(change2.OriginalValue);
            Assert.IsFalse(change2.CurrentValue);
            Assert.IsFalse(change2.IsDirty);
            Assert.IsFalse(change2.IsTouched);

            change2.CurrentValue = true;
            change2.Reset(ValueResetType.Soft);
            Assert.IsFalse(change2.OriginalValue, "Original value must not be changed by reset methods.");
            Assert.IsFalse(change2.CurrentValue, "Current value must be reset to the base value after calling reset.");
            Assert.IsFalse(change2.IsDirty, "IsDirty must be False after calling reset.");
            Assert.IsTrue(change2.IsTouched, "When resetting using soft mode, the IsTouched flag must be not changed.");

            change2.CurrentValue = true;
            change2.Reset(ValueResetType.Hard);
            Assert.IsFalse(change2.OriginalValue, "Original value must not be changed by reset methods.");
            Assert.IsFalse(change2.CurrentValue, "Current value must be reset to the base value after calling reset.");
            Assert.IsFalse(change2.IsDirty, "IsDirty must be False after calling reset.");
            Assert.IsFalse(change2.IsTouched, "When resetting using hard mode, the IsTouched flag must be always false.");
        }
示例#13
0
        public PsfContentRuleRedirectionViewModel(IEnumerable <string> include, IEnumerable <string> exclude, string redirectBase, bool isReadOnly)
        {
            this.targetRedirection = new ChangeableProperty <string>(redirectBase);
            this.isReadOnly        = new ChangeableProperty <bool>(isReadOnly);

            this.Include = new ChangeableCollection <PsfContentFileRedirectionViewModel>();
            this.Exclude = new ChangeableCollection <PsfContentFileRedirectionViewModel>();

            foreach (var item in include)
            {
                this.Include.Add(new PsfContentFileRedirectionViewModel(item));
            }

            foreach (var item in exclude)
            {
                this.Exclude.Add(new PsfContentFileRedirectionViewModel(item, true));
            }

            this.Include.Commit();
            this.Exclude.Commit();

            this.AddChildren(this.Include, this.Exclude, this.isReadOnly, this.targetRedirection);
        }
示例#14
0
        public void TestReferenceTypes()
        {
            var object1 = new object();
            var object2 = new object();

            var change1 = new ChangeableProperty <object>(object1);

            Assert.AreEqual(object1, change1.CurrentValue);
            Assert.AreEqual(object1, change1.OriginalValue);
            Assert.IsFalse(change1.IsDirty);
            Assert.IsFalse(change1.IsTouched);

            change1.CurrentValue = object2;
            Assert.AreEqual(object2, change1.CurrentValue);
            Assert.AreEqual(object1, change1.OriginalValue);
            Assert.IsTrue(change1.IsDirty);
            Assert.IsTrue(change1.IsTouched);

            change1.CurrentValue = object1;
            Assert.AreEqual(object1, change1.CurrentValue);
            Assert.AreEqual(object1, change1.OriginalValue);
            Assert.IsFalse(change1.IsDirty);
            Assert.IsTrue(change1.IsTouched);
        }
示例#15
0
 public PsfContentProcessCustomViewModel(string processRegularExpression, string fixupName, CustomPsfFixupConfig customFixup) : base(processRegularExpression, fixupName)
 {
     this.json = new ChangeableProperty <string>(customFixup.Json);
     this.AddChild(this.json);
     this.Header = Regex.Replace(fixupName, @"[x_]*(?:64|86|32)?(?:\.dll)?$", string.Empty).ToUpperInvariant();
 }
示例#16
0
        public void ChangeableContainerTest()
        {
            var prop1 = new ChangeableProperty <string>("initial");
            var prop2 = new ChangeableProperty <string>("initial");

            var container = new ChangeableContainer(prop1, prop2);

            Assert.IsFalse(prop1.IsTouched);
            Assert.IsFalse(prop2.IsTouched);
            Assert.IsFalse(container.IsTouched);
            Assert.IsFalse(prop1.IsDirty);
            Assert.IsFalse(prop2.IsDirty);
            Assert.IsFalse(container.IsDirty);

            prop1.CurrentValue = "other";
            Assert.IsTrue(prop1.IsTouched);
            Assert.IsFalse(prop2.IsTouched);
            Assert.IsTrue(container.IsTouched);
            Assert.IsTrue(prop1.IsDirty);
            Assert.IsFalse(prop2.IsDirty);
            Assert.IsTrue(container.IsDirty);

            prop1.CurrentValue = "initial";
            Assert.IsTrue(prop1.IsTouched);
            Assert.IsFalse(prop2.IsTouched);
            Assert.IsTrue(container.IsTouched);
            Assert.IsFalse(prop1.IsDirty);
            Assert.IsFalse(prop2.IsDirty);
            Assert.IsFalse(container.IsDirty);

            prop1.Reset(ValueResetType.Hard);
            Assert.IsFalse(prop1.IsTouched);
            Assert.IsFalse(prop2.IsTouched);
            Assert.IsFalse(container.IsTouched);
            Assert.IsFalse(prop1.IsDirty);
            Assert.IsFalse(prop2.IsDirty);
            Assert.IsFalse(container.IsDirty);

            prop2.CurrentValue = "second";
            Assert.IsFalse(prop1.IsTouched);
            Assert.IsTrue(prop2.IsTouched);
            Assert.IsTrue(container.IsTouched);
            Assert.IsFalse(prop1.IsDirty);
            Assert.IsTrue(prop2.IsDirty);
            Assert.IsTrue(container.IsDirty);

            container.Reset(ValueResetType.Hard);
            Assert.IsFalse(prop1.IsTouched);
            Assert.IsFalse(prop2.IsTouched);
            Assert.IsFalse(container.IsTouched);
            Assert.IsFalse(prop1.IsDirty);
            Assert.IsFalse(prop2.IsDirty);
            Assert.IsFalse(container.IsDirty);

            prop2.CurrentValue = "second";
            container.Commit();
            Assert.IsFalse(prop1.IsTouched);
            Assert.IsFalse(prop2.IsTouched);
            Assert.IsFalse(container.IsTouched);
            Assert.IsFalse(prop1.IsDirty);
            Assert.IsFalse(prop2.IsDirty);
            Assert.IsFalse(container.IsDirty);
        }