/// <inheritdoc/> // Called by the base class to write the start of the file (i.e. everything up to the body of the Instantiator class). protected override void WriteFileStart(CodeBuilder builder) { // A sorted set to hold the namespaces that the generated code will use. The set is maintained in sorted order. var namespaces = new SortedSet<string>(); if (Info.UsesCanvas) { namespaces.Add("Microsoft.Graphics.Canvas"); } if (Info.UsesCanvasEffects) { namespaces.Add("Microsoft.Graphics.Canvas.Effects"); } if (Info.UsesCanvasGeometry) { namespaces.Add("Microsoft.Graphics.Canvas.Geometry"); } if (Info.UsesNamespaceWindowsUIXamlMedia) { namespaces.Add("System.ComponentModel"); namespaces.Add("System.Runtime.InteropServices.WindowsRuntime"); namespaces.Add("Windows.Foundation"); namespaces.Add("Windows.UI.Xaml.Media"); } if (Info.GenerateDependencyObject) { namespaces.Add("Windows.UI.Xaml"); } if (Info.UsesStreams) { namespaces.Add("System.IO"); } namespaces.Add("System"); namespaces.Add("System.Numerics"); namespaces.Add("Windows.UI"); namespaces.Add("Windows.UI.Composition"); // Write out each namespace using. foreach (var n in namespaces) { builder.WriteLine($"using {n};"); } builder.WriteLine(); builder.WriteLine($"namespace {Info.Namespace}"); builder.OpenScope(); // Write a description of the source as comments. foreach (var line in GetSourceDescriptionLines()) { builder.WritePreformattedCommentLine(line); } // If the composition has LoadedImageSurface, write a class that implements the IDynamicAnimatedVisualSource interface. // Otherwise, implement the IAnimatedVisualSource interface. if (Info.LoadedImageSurfaces.Count > 0) { WriteIDynamicAnimatedVisualSource(builder, Info); } else { WriteIAnimatedVisualSource(builder, Info); } builder.CloseScope(); builder.WriteLine(); }