private void depthBtn_Click(object sender, RoutedEventArgs e) { ushort depth = 0; if (!ushort.TryParse(depthTxtBox.Text, out depth) || depth > 10) { MessageBox.Show("Select depth between 0 and 10"); return; } depthBtn.IsEnabled = false; canvas.Children.Clear(); List <CommonAlgorithms.Numerical.Line> result = new List <CommonAlgorithms.Numerical.Line>(); Recursive.DrawKochCurve(depth, new CommonAlgorithms.Numerical.Point(30, 50), 0, 500, result); foreach (var line in result) { var l = new System.Windows.Shapes.Line(); l.X1 = line.p1.X; l.Y1 = line.p1.Y; l.X2 = line.p2.X; l.Y2 = line.p2.Y; l.Stroke = Brushes.Red; l.StrokeThickness = 1; canvas.Children.Add(l); } depthBtn.IsEnabled = true; }
public void GetUrl(int scheduleID) { try { Stopwatch sw = new Stopwatch(); sw.Start(); DataSource.Where(x => x.ThreadID == scheduleID).FirstOrDefault().Status = ScheduleStatus.Running; Recursive rr = new Recursive(Source); rr.ThreadID = scheduleID; rr.DataCollection = DataSource; rr.GetFile(TargetPath); DataSource.Where(x => x.ThreadID == scheduleID).FirstOrDefault().Status = ScheduleStatus.Done; sw.Stop(); messageQueue.Enqueue(new QueueModel() { Message = $"{DataSource.Where(x => x.ThreadID == scheduleID).FirstOrDefault().Schedule}\r\n下載更新成功。共花費時間{sw.Elapsed}", Type = QueueModel.TypeDatail.Success }); } catch (Exception ie) { DataSource.Where(x => x.ThreadID == scheduleID).FirstOrDefault().Status = ScheduleStatus.Error; messageQueue.Enqueue(new QueueModel() { Message = $"{DataSource.Where(x => x.ThreadID == scheduleID).FirstOrDefault().Schedule}\r\n下載更新失敗。\r\n{ie.Message}\r\n{ie.StackTrace}", Type = QueueModel.TypeDatail.Fail }); } }
protected override void Execute(CodeActivityContext context) { string folder = Folder.Get(context); bool recursive = Recursive.Get(context); string combinedXPOFile = CombinedXPOFile.Get(context); bool includeSystemObjects = IncludeSystemObjects.Get(context); bool includeNonSystemObjects = IncludeNonSystemObjects.Get(context); if (!System.IO.Directory.Exists(System.IO.Path.GetDirectoryName(combinedXPOFile))) { System.IO.Directory.CreateDirectory(System.IO.Path.GetDirectoryName(combinedXPOFile)); } if (includeNonSystemObjects && includeSystemObjects) { CodeCrib.AX.Client.CombineXPOs.Combine(folder, recursive, combinedXPOFile, Client.CombineXPOs.IncludeObjects.AllObjects); } else if (includeNonSystemObjects && !includeSystemObjects) { CodeCrib.AX.Client.CombineXPOs.Combine(folder, recursive, combinedXPOFile, Client.CombineXPOs.IncludeObjects.ExcludeSystemObjects); } else if (!includeNonSystemObjects && includeSystemObjects) { CodeCrib.AX.Client.CombineXPOs.Combine(folder, recursive, combinedXPOFile, Client.CombineXPOs.IncludeObjects.SystemObjectsOnly); } // else neither }
public void Main() { var command = "?"; if (Pull) { command = "pull"; } else if (Push) { command = "push"; } else if (Show) { command = "show"; } Console.WriteLine($"command: '{command}'"); Console.WriteLine($"code: {Code}"); Console.WriteLine($"amount: {Amount}"); Console.WriteLine($"attribute targets: {AttributeTargets}"); Console.WriteLine($"text: '{Text}'"); Console.WriteLine($"recursive: {Recursive.ToString().ToLower()}"); Console.WriteLine($"array: {Array.ToString(", ")}"); }
public override int GetHashCode() { var hashCode = 862207841; hashCode = (hashCode * -1521134295) + EqualityComparer <string> .Default.GetHashCode(BasePath); foreach (var excludedDirectory in ExcludedDirectories) { hashCode = (hashCode * -1521134295) + EqualityComparer <string> .Default.GetHashCode( excludedDirectory); } foreach (var fileExtension in FileExtensions) { hashCode = (hashCode * -1521134295) + EqualityComparer <string> .Default.GetHashCode( fileExtension); } hashCode = (hashCode * -1521134295) + Recursive.GetHashCode(); hashCode = (hashCode * -1521134295) + DifferenceType.GetHashCode(); hashCode = (hashCode * -1521134295) + MaxDurationDifferenceSeconds.GetHashCode(); hashCode = (hashCode * -1521134295) + MaxDurationDifferencePercent.GetHashCode(); hashCode = (hashCode * -1521134295) + MaxImageCompares.GetHashCode(); hashCode = (hashCode * -1521134295) + MaxDifferentImages.GetHashCode(); hashCode = (hashCode * -1521134295) + MaxImageDifferencePercent.GetHashCode(); return(hashCode); }
/// <summary> /// When implemented in a derived class, performs the execution of the activity. /// </summary> /// <param name="context">The execution context under which the activity executes.</param> protected override void Execute(CodeActivityContext context) { var attributeName = AttributeName.Get(context); var attributeValue = AttributeValue.Get(context); var createAttributeIfNotExists = CreateAttributeIfNotExists.Get(context); var directoryToSearch = DirectoryToSearch.Get(context); var fileNamesToSearch = FileNamesToSearch.Get(context); var commandLog = new CodeActivityContextCommandLog(context); var recursive = Recursive.Get(context); var writeVerboseLogMessages = WriteVerboseLogMessages.Get(context); var command = new SetAssemblyAttributeInFilesCommand { AttributeName = attributeName, AttributeValue = attributeValue, CreateAttributeIfNotExists = createAttributeIfNotExists, DirectoryToSearch = directoryToSearch, FileNamesToSearch = fileNamesToSearch, CommandLog = commandLog, Recursive = recursive, WriteVerboseLogMessages = writeVerboseLogMessages }; var successful = command.Execute(); if (false == successful) { commandLog.Error("The SetAssemblyAttributeInFiles activity failed."); } }
void Start() { var w0 = Tuple1.a('3'); Debug.Log(w0.value); var w2 = w0.add("5"); Debug.Log(w2._1 + w2._2); var r0 = Recursive.a(3); Debug.Log(r0.value); var r1 = r0.wrap(); Debug.Log(r1.value.value); var r2 = r1.wrap(); Debug.Log(r2.value.value.value); var r21 = r0.wrap2(3); Debug.Log(r21.value._1 + r21.value._2); var r22 = r21.wrap2(5); Debug.Log(r22.value._1._1 + r22.value._1._2 + r22.value._2); }
private void genBtn_Click(object sender, RoutedEventArgs e) { ushort n = 0; if (!ushort.TryParse(depthTxtBox.Text, out n) || n > 10) { MessageBox.Show("Choose a number between 0 to 10"); return; } var p1 = new CommonAlgorithms.Numerical.Point(300, 50); var p2 = new CommonAlgorithms.Numerical.Point(50, 550); var p3 = new CommonAlgorithms.Numerical.Point(550, 550); Triangle t = new Triangle(p1, p2, p3); List <Triangle> result = new List <Triangle>((int)System.Math.Pow(3D, (double)n)); this.Dispatcher.Invoke(() => genBtn.IsEnabled = false, System.Windows.Threading.DispatcherPriority.Render); this.Dispatcher.Invoke(() => canvas.Children.Clear(), System.Windows.Threading.DispatcherPriority.Render); Recursive.DrawFractalTriangles(t, n, result); foreach (var triangle in result) { Polyline polyline = new Polyline(); polyline.Points.Add(new System.Windows.Point(triangle.p1.X, triangle.p1.Y)); polyline.Points.Add(new System.Windows.Point(triangle.p2.X, triangle.p2.Y)); polyline.Points.Add(new System.Windows.Point(triangle.p3.X, triangle.p3.Y)); polyline.Fill = Brushes.Black; polyline.Stroke = Brushes.Black; polyline.StrokeThickness = 1; canvas.Children.Add(polyline); } genBtn.IsEnabled = true; }
/// <summary> /// Gets the command-line arguments to use when launching the process that executes the restore. /// </summary> /// <returns>An <see cref="IEnumerable{String}" /> containing the command-line arguments that need to separated by spaces and surrounded by quotes.</returns> internal IEnumerable <string> GetCommandLineArguments() { #if IS_CORECLR // The full path to the executable for dotnet core yield return(Path.Combine(ThisAssemblyLazy.Value.DirectoryName, Path.ChangeExtension(ThisAssemblyLazy.Value.Name, ".Console.dll"))); #endif var options = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase) { ["GenerateRestoreGraphFile"] = true.ToString(), [nameof(Recursive)] = Recursive.ToString(), [nameof(RestoreGraphOutputPath)] = RestoreGraphOutputPath, }; // Semicolon delimited list of options yield return(string.Join(";", options.Select(i => $"{i.Key}={i.Value}"))); // Full path to MSBuild.exe or MSBuild.dll #if IS_CORECLR yield return(Path.Combine(MSBuildBinPath, "MSBuild.dll")); #else yield return(Path.Combine(MSBuildBinPath, "MSBuild.exe")); #endif // Full path to the entry project. If its a solution file, it will be the full path to solution, otherwise SolutionPath is either empty // or is the value "*Undefined*" and ProjectFullPath is set instead. yield return(IsSolutionPathDefined ? SolutionPath : ProjectFullPath); // Semicolon delimited list of MSBuild global properties var globalProperties = GetGlobalProperties().Select(i => $"{i.Key}={i.Value}").Concat(new string[] { $"OriginalMSBuildStartupDirectory={MSBuildStartupDirectory}" }); yield return(string.Join(";", globalProperties)); }
public static Func <T0, T1, TR> Y <T0, T1, TR>( Func <Func <T0, T1, TR>, Func <T0, T1, TR> > f) { Recursive <T0, T1, TR> rec = r => (a0, a1) => f(r(r))(a0, a1); return(rec(rec)); }
public void SelfReferencingType() { var input = new Recursive(); var script = CSScriptSerializer.Serialize(input); var output = CSScriptSerializer.Deserialize <Recursive>(script); Assert.Equal(input.Self, output.Self); }
public _(Recursive parent, IObserver <TSource> observer) : base(observer) { _source = parent._source; _scheduler = parent.Scheduler; _currentPrependNode = parent._prepends; _appends = parent._appends; }
/// <summary> /// A simple "Fixed Point Combinator" implementation http://en.wikipedia.org/wiki/Y_combinator /// </summary> /// <typeparam name="T">Argument type</typeparam> /// <typeparam name="R">Result type</typeparam> /// <param name="f"></param> /// <returns></returns> /// <example> /// <![CDATA[ /// // Anonymous and recursive reverse string function /// Func<string, string> reverse = Y<string, string>( /// f => /// s => /// (string.IsNullOrEmpty(s) || s.Length == 1) /// ? s /// : f(s.Substring(1)) + s[0]); /// ]]> /// </example> public static Func <T, R> Y <T, R> (Func <Func <T, R>, Func <T, R> > f) { Recursive <T, R> rec = r => a => f(r(r)) (a); return(rec(rec)); }
public void Fibonacci_WhenPositiveNumber_ResultFibonacci() { // Arrange // Act var result = Recursive.Fibonacci(10); // Assert Assert.Equal(55, result); }
public void Fibonacci_WhenOne_ResultOne() { // Arrange // Act var result = Recursive.Fibonacci(1); // Assert Assert.Equal(1, result); }
public void Fibonacci_WhenZero_ResultZero() { // Arrange // Act var result = Recursive.Fibonacci(0); // Assert Assert.Equal(0, result); }
public void WriteXml(XmlWriter writer) { writer.WriteStartElement("Source"); writer.WriteAttributeString("ID", ID.ToString()); writer.WriteAttributeString("Path", Path); writer.WriteAttributeString("Recursive", Recursive.ToString(CultureInfo.InvariantCulture)); writer.WriteAttributeString("Filter", Filter); writer.WriteAttributeString("Inclusive", Inclusive.ToString(CultureInfo.InvariantCulture)); writer.WriteEndElement(); }
public void Factorial_WhenZero_ResultOne() { // Arrange // Act var result = Recursive.Factorial(0); // Assert Assert.Equal(1, result); }
public static void OnTotalChildCountChanged(object sender, DependencyPropertyChangedEventArgs e) { TextBox txt = sender as TextBox; if (txt != null) { var children = Recursive.GetAllChildren(txt); txt.Text = children.Count().ToString(); } }
public void Factorial_WhenPositiveNumber_ResultFactorial() { // Arrange // Act var result = Recursive.Factorial(5); // Assert Assert.Equal(120, result); }
public void ErrorsOutOnRecursive() { Recursive parent = new Recursive(); Recursive child = new Recursive(); parent.Other = child; child.Other = parent; var constraint = Constraints.PropertyCompareConstraint(child); Assert.That(constraint.Matches(child), Is.False); }
public void Recurse() { var r1 = new Recursive(1, new Recursive(2, new Recursive(4)), new Recursive(3)); var recursives = r1.Recurse(r => r.Recursives).ToArray(); Assert.IsTrue(recursives.Select(x => x.Value).SequenceEqual(new[] { 1, 2, 4, 3 })); }
public void RecursiveObjectsAreClonable() { var foo = new Recursive <int>(); foo.RecursiveValue = foo; foo.ExtraValue = 42; var bar = Cloning.Clone(foo); Assert.Equal(42, bar.ExtraValue); Assert.True(ReferenceEquals(bar, bar.RecursiveValue)); }
public void TestRecursivePopulationThreeLevel() { var r1 = new Recursive(1, new Recursive(2, new Recursive(4)), new Recursive(3)); var recursives = r1.Recurse(r => r.Recursives).ToArray(); Assert.AreEqual(4, recursives.Length); Assert.IsTrue(recursives.Select(x => x.Value).SequenceEqual(new[] { 1, 2, 4, 3 })); }
public void Cmmdc_WhenPositiveNumbers_ResultCMMDC() { // Arrange const int x = 12; const int y = 18; // Act var result = Recursive.Cmmdc(x, y); // Assert Assert.Equal(6, result); }
public void Cmmdc_WhenZero_ResultX() { // Arrange const int x = 10; const int y = 0; // Act var result = Recursive.Cmmdc(x, y); // Assert Assert.Equal(x, result); }
public override int GetHashCode() { unchecked { var hashCode = Filters?.GetHashCode() ?? 0; hashCode = (hashCode * 397) ^ AutoAddFiles.GetHashCode(); hashCode = (hashCode * 397) ^ AutoDeleteFiles.GetHashCode(); hashCode = (hashCode * 397) ^ Recursive.GetHashCode(); hashCode = (hashCode * 397) ^ (WatchDirectory?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ (SyncDirectory?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ (Delay.GetHashCode()); return(hashCode); } }
private void HighlightEligibleUnderCursor(CursorState cursorState) { var selectedEntity = cursorState.SelectedEntity; if (lastEntitSelected != null) { Recursive.ApplyActionRecursively(lastEntitSelected.GameObject.transform, ResetOutline); } if (selectedEntity != null) { Recursive.ApplyActionRecursively(selectedEntity.GameObject.transform, AddOutline); } lastEntitSelected = selectedEntity; }
public void Create_ObjectStringEqualRecursive_Expression() { // arrange var value = new ObjectValueNode( new ObjectFieldNode("nested", new ObjectValueNode( new ObjectFieldNode("nested", new ObjectValueNode( new ObjectFieldNode("bar", new StringValueNode("a") ) ) ) ) ) ); var fooType = CreateType(new FilterInputType <Recursive>()); // act var filter = new QueryableFilterVisitor( fooType, typeof(Recursive), TypeConversion.Default, true); filter.Visit(value, null); Func <Recursive, bool> func = filter.CreateFilter <Recursive>().Compile(); var a = new Recursive { Nested = new Recursive { Nested = new Recursive { Bar = "a" } } }; Assert.True(func(a)); var b = new Recursive { Nested = new Recursive { Nested = new Recursive { Bar = "b" } } }; Assert.False(func(b)); }
public void RecurseWhile() { var r1 = new Recursive(1, new Recursive(2, new Recursive(4), new Recursive(5)), new Recursive(3, new Recursive(6), new Recursive(7))); var recursives = r1.RecurseWhile(r => r.Recursives, r => r.Value % 2 == 1).ToArray(); Assert.IsTrue(recursives.Select(x => x.Value).SequenceEqual(new[] { 1, 3, 7 })); }
public void RecurseSelect() { var r1 = new Recursive(1, new Recursive(2, new Recursive(4)), new Recursive(3)); var values = r1.RecurseSelect(r => r.Recursives, x => x.Value).ToArray(); Assert.IsTrue(values.SequenceEqual(new[] { 1, 2, 4, 3 })); }
public void Nesting() { var value = new Recursive(); var value2 = new Recursive(); var nestedValue = new Recursive() { Terminal = "test" }; var nestedValue2 = new Recursive() { Terminal = "test" }; value.Recurse = nestedValue; value2.Recurse = nestedValue2; Assert.IsTrue(value.Equals(value2)); Assert.AreEqual(value.GetHashCode(), value2.GetHashCode()); }