internal PSEtwUserTrace(string traceName, bool includeVerboseEtwProperties) { _propertyExtractor = new PropertyExtractor(includeVerboseEtwProperties); _trace = new UserTrace(traceName); _cts = new CancellationTokenSource(); Reset(); }
public void AuthenticateInvalidCreds() { String props = PropertyExtractor.GetProperties(typeof(AgencyUserRole)); RegisteredUser user = RegisteredUser.Authenticate(5, "*****@*****.**", "371444D0", false, false); Assert.IsNull(user); }
public void For_Extract_When_ExpressionIsNull_Then_ExceptionIsThrown() { // Arrange: Expression <Func <TestPerson, string> > expression = null; // Act & Assert: var extractor = new PropertyExtractor <TestPerson>(); Assert.Throws <ArgumentNullException>(() => extractor.Extract(expression)); }
public void FillProps() { TestObject to = new TestObject(); to.p1 = 10; to.p2 = "ab"; Assert.AreEqual(to.p1.ToString(), PropertyExtractor.Extract("p1", to)); Assert.AreEqual(to.p2.ToString(), PropertyExtractor.Extract("p2", to)); }
public void FillNestedProps() { TestObject to = new TestObject(); to.nested = new TestObject.NestedObject(); to.nested.p3 = 20; to.nested.p4 = "cd"; Assert.AreEqual(to.nested.p3.ToString(), PropertyExtractor.Extract("nested.p3", to)); Assert.AreEqual(to.nested.p4.ToString(), PropertyExtractor.Extract("nested.p4", to)); }
public void For_Extract_When_ExpressionIsPropertyInfo_Then_ItIsReturned() { // Arrange: var testPerson = new TestPerson(); Expression <Func <TestPerson, string> > expression = person => person.AnyProperty; // Act: var extractor = new PropertyExtractor <TestPerson>(); var result = extractor.Extract(expression); // Assert: result.MemberType.Should().Be(MemberTypes.Property); }
public void For_Extract_When_ExpressionIsNotMemberExpression_Then_ExceptionIsThrown() { // Arrange: var testPerson = new TestPerson { AnyProperty = "PersonName" }; Expression <Func <TestPerson, int> > expression = person => person.AnyMethod(); // Act: var extractor = new PropertyExtractor <TestPerson>(); var exception = Assert.Throws <ArgumentException>(() => extractor.Extract(expression)); // Assert: exception.Message.Should().Contain("must be member expression"); }
public AsyncPropertyValidator <TProp> SetupAsync <TProp>(Expression <Func <TObject, TProp> > expression) { var memberInfo = PropertyExtractor.Extract(expression); if (PropertyValidators.TryGetValue(memberInfo.Name, out var propertyValidator)) { if (propertyValidator is AsyncPropertyValidator <TProp> asyncPropertyValidator) { return(asyncPropertyValidator); } throw new InvalidOperationException("Member already has assigned synchronous validator"); } var newPropertyValidator = new AsyncPropertyValidator <TProp>(memberInfo); PropertyValidators.Add(memberInfo.Name, newPropertyValidator); return(newPropertyValidator); }
internal List <TResult> LoadTo <TResult>(Expression predicate, int skip, int?limit, List <SortOrder> sortOrders, List <QueryHint> hints, Expression selector) { Func <Dictionary <PropertyInfo, object>, TResult> generator; var propertyExtractor = new PropertyExtractor(); var properties = propertyExtractor.Extract <TResult>(selector, out generator); var mapper = this.m_mapper; var predicateDoc = mapper.GetPredicate(predicate); var fieldsDoc = this.m_mapper.GetFields(properties); var sortDoc = mapper.GetSortOrders(sortOrders); var collection = mapper.GetCollection(this.Database); var mongoCursor = collection.Find(predicateDoc).SetFields(fieldsDoc).SetSortOrder(sortDoc).SetSkip(skip); if (limit.HasValue) { mongoCursor = mongoCursor.SetLimit(limit.Value); } var hintsDoc = (hints != null && hints.Count > 0) ? mapper.GetHints(hints) : null; if (hintsDoc != null) { mongoCursor.SetHint(hintsDoc); } this.Log.WriteQuery(collection, predicateDoc, fieldsDoc, sortDoc, hintsDoc, skip, limit); var docList = mongoCursor.ToList(); var result = new List <TResult>(docList.Count); foreach (var doc in docList) { var values = mapper.GetValues(properties, doc); result.Add(generator(values)); } return(result); }
public ViewModel() { SelectedConfiguration = "Debug"; SelectedPlatform = "AnyCPU"; model = new PropertyExtractor(SelectedConfiguration, SelectedPlatform); }
public void Setup() { bool verbose = true; extractor = new PropertyExtractor("TestData", "Debug", "AnyCPU", verbose); }
static void Main(string[] args) { var timer = new Stopwatch(); timer.Start(); if (args.Length != 4) { Console.WriteLine("RefactorConsole <input_dir> <property_sheet> <config> <platform>"); return; } string inputDir = args[0]; if (!Directory.Exists(inputDir)) { Console.WriteLine("Input directory doesn't exist: {0}", inputDir); return; } string propSheet = args[1]; if (!File.Exists(propSheet)) { Console.WriteLine("Input property sheet file doesn't exist: {0}", propSheet); return; } string config = args[2]; string platform = args[3]; bool verbose = true; var refactor = new PropertyExtractor(inputDir, config, platform, verbose); refactor.PropertySheetPath = propSheet; timer.Stop(); Console.WriteLine("{0} files", refactor.CountFoundFiles); Console.WriteLine("{0} files valid", refactor.Count); Utils.WL(ConsoleColor.DarkYellow, String.Format("Elapsed Time: {0}\n", timer.Elapsed)); Console.WriteLine("Change configuration property"); timer.Restart(); refactor.SetGlobalProperty("Configuration", "Release"); timer.Stop(); Utils.WL(ConsoleColor.DarkYellow, String.Format("Elapsed Time: {0}\n", timer.Elapsed)); Console.WriteLine("Moving a property"); timer.Restart(); refactor.Move("OutputPath", "$(BuildDir)"); timer.Stop(); Utils.WL(ConsoleColor.DarkYellow, String.Format("Elapsed Time: {0}\n", timer.Elapsed)); Console.WriteLine("Change configuration property"); timer.Restart(); refactor.SetGlobalProperty("Configuration", "Debug"); timer.Stop(); Utils.WL(ConsoleColor.DarkYellow, String.Format("Elapsed Time: {0}\n", timer.Elapsed)); Console.WriteLine("Moving a property"); timer.Restart(); refactor.Move("OutputPath", "$(BuildDir)"); timer.Stop(); Utils.WL(ConsoleColor.DarkYellow, String.Format("Elapsed Time: {0}\n", timer.Elapsed)); Console.WriteLine("Removing a random property"); timer.Restart(); refactor.Remove("Optimize"); refactor.Move("ProjectType", "local"); timer.Stop(); Utils.WL(ConsoleColor.DarkYellow, String.Format("Elapsed Time: {0}\n", timer.Elapsed)); Console.WriteLine("Saving the files"); timer.Restart(); refactor.SaveAll(); timer.Stop(); Utils.WL(ConsoleColor.DarkYellow, String.Format("Elapsed Time: {0}\n", timer.Elapsed)); Console.WriteLine("Print Found Properties"); timer.Restart(); refactor.PrintFoundProperties(); timer.Stop(); Utils.WL(ConsoleColor.DarkYellow, String.Format("Elapsed Time: {0}\n", timer.Elapsed)); }