/// <summary> /// Adds an xref to the set. /// </summary> public void Add(Xref xref) { // TODO(someday): not currently enforcing set behavior; start by adding .equals to // Xref, then check Contains before allowing Add. (Should probably complain // loudly if item already exists, since we're not expecting that.) mRefs.Add(xref); }
public async Task PrepareAssets(DocsSiteRouter router) { foreach (var(path, contentItem) in _uiBundle.GetContentItems(new Path[] { "**/*.js", "**/*.css", "**/*.png", "**/*.jpg", "**/*.gif" })) { var xref = new Xref(_uiBundle.Version, _uiBundle.Id, path); Path route = router.GenerateRoute(xref) ?? throw new InvalidOperationException($"Could not generate route for '{xref}'."); await using var inputStream = await contentItem.File.OpenRead(); await _output.GetOrCreateDirectory(route.GetDirectoryPath()); var outputFile = await _output.GetOrCreateFile(route); var outputStream = await outputFile.OpenWrite(); await inputStream.CopyToAsync(outputStream); } }
public Xref GetXrefById(int id) { Xref xref = databasePlaceholder.Get(id); if (xref == null) { throw new HttpResponseException(HttpStatusCode.NotFound); } return(xref); }
public Section?GetSectionByXref(Xref xref, Section context) { if (xref.Version == null) { xref = xref.WithVersion(context.Version); } if (xref.SectionId == null) { xref = xref.WithSectionId(context.Id); } return(GetSectionByXref(xref)); }
public string?GenerateRoute(Xref xref) { var targetSection = Site.GetSectionByXref(xref, Section); if (targetSection == null) { throw new InvalidOperationException($"Section NotFound: {xref}"); } Path path = xref.Path; if (path.GetExtension() == ".md") { path = path.ChangeExtension(".html"); } return(targetSection.Version + "/" + targetSection.Path / path); }
private async Task <PipeReader> Resolver(Site site, Section section, Xref xref) { var targetSection = site.GetSectionByXref(xref, section); if (targetSection == null) { throw new InvalidOperationException($"Could not resolve include. Could not resolve section '{xref}'."); } var targetItem = targetSection .GetContentItem(xref.Path); if (targetItem == null) { throw new InvalidOperationException( $"Could not resolve include. Could not resolve content item '{xref}'."); } var stream = await targetItem.File.OpenRead(); if (xref.Query.Any()) { if (xref.Query.TryGetValue("s", out var symbolName)) { using var reader = new StreamReader(stream); var text = await reader.ReadToEndAsync(); var syntaxTree = CSharpSyntaxTree.ParseText(text); var compilation = syntaxTree.GetCompilationUnitRoot(); var sourceCode = GetSourceText(compilation, symbolName); var pipe = new Pipe(); pipe.Writer.Write(Encoding.UTF8.GetBytes(sourceCode.Text)); await pipe.Writer.FlushAsync(); await pipe.Writer.CompleteAsync(); return(pipe.Reader); } } return(PipeReader.Create(stream)); }
//todo: should probably move this to Site public Xref FullyQualify(Xref xref) { var targetSection = Site.GetSectionByXref(xref, Section); if (targetSection == null) { throw new InvalidOperationException($"NotFound: {xref}"); } var targetItem = targetSection.GetContentItem(xref.Path); if (targetItem == null) { throw new InvalidOperationException($"NotFound: {xref}"); } return(xref .WithSectionId(targetSection.Id) .WithVersion(targetSection.Version)); }
internal IPdfObject ResolveReference(PdfReference reference) { PdfCrossReference indirectObj = Xref.Get(reference.ObjectNumber, reference.Generation); if (indirectObj == null) { return(null); } if (!indirectObj.Loaded) { Parser.ParseIndirectObjectDefinition(indirectObj); } IPdfObject obj = indirectObj.Object; if (obj is PdfReference) { return(ResolveReference(obj as PdfReference)); } return(obj); }
// main routine to generate cross-reference. // If no command line parameters, standard input is used. // Otherwise, files in command line are used. public static void Main(string[] args) { Xref p; if (args.Length == 0) { p = new Xref(Console.In); p.GenerateCrossReference( ); return; } for (int i = 0; i < args.Length; i++) { TextReader f = null; try { f = new StreamReader(args[i]); Console.WriteLine(args[i] + ": "); p = new Xref(f); p.GenerateCrossReference( ); } catch (IOException e) { Console.Error.WriteLine(e + args[i]); } finally { if (f != null) { f.Close( ); } } } }
public static void Init() { closeQuickMenu = typeof(QuickMenu).GetMethods() .Where(mb => mb.Name.StartsWith("Method_Public_Void_Boolean_") && mb.Name.Length <= 29 && !mb.Name.Contains("PDM") && Xref.CheckUsed(mb, "Method_Public_Void_Int32_Boolean_")).First(); openQuickMenu = typeof(QuickMenu).GetMethods() .Where(mb => mb.Name.StartsWith("Method_Public_Void_Boolean_") && mb.Name.Length <= 29 && mb.GetParameters().Any(pi => pi.HasDefaultValue == false)).First(); setMenuIndex = typeof(QuickMenu).GetMethods() .Where(mb => mb.Name.StartsWith("Method_Public_Void_Int32_") && mb.Name.Length <= 27 && Xref.CheckUsed(mb, "Method_Public_Void_Boolean_")).First(); QuickMenuContextualDisplayEnum = typeof(QuickMenuContextualDisplay).GetNestedTypes() .Where(type => type.Name.StartsWith("Enum")).First(); QuickMenuContexualDisplayMethod = typeof(QuickMenuContextualDisplay).GetMethod($"Method_Public_Void_{QuickMenuContextualDisplayEnum.Name}_0"); InstanceHistoryMod.Instance.Harmony.Patch(openQuickMenu, null, new HarmonyMethod(typeof(UIManager).GetMethod(nameof(OnQuickMenuOpen)))); InstanceHistoryMod.Instance.Harmony.Patch(closeQuickMenu, null, new HarmonyMethod(typeof(UIManager).GetMethod(nameof(OnQuickMenuClose)))); }
/// <summary> /// Creates a new PdfObjectRef object with the documents generation Id and next (unique) object Id. /// </summary> public virtual PdfObjectRef NewObjectRef() { Xref.Add(-1L); return(new PdfObjectRef(CurrentGenerationId, Xref.Count)); }
public override void Init() { OpenInWorldMenuButton = (MelonPreferences_Entry <bool>)MelonPreferences.CreateEntry("UserInfoExtensionsSettings", nameof(OpenInWorldMenuButton), false, "Show\"Open User World in World Menu\" button"); UserInfoExtensionsMod.userDetailsMenu.AddSimpleButton("Open User World in World Menu", OpenUserWorldInWorldMenu, new Action <GameObject>((gameObject) => { openInWorldMenuButtonGameObject = gameObject; gameObject.SetActive(OpenInWorldMenuButton.Value); })); UserInfoExtensionsMod.menu.AddSimpleButton("Open User World in World Menu", OpenUserWorldInWorldMenu); setUpWorldInfo = typeof(PageWorldInfo).GetMethods() .Where(mb => mb.Name.StartsWith("Method_Public_Void_ApiWorld_ApiWorldInstance_Boolean_Boolean_") && !mb.Name.Contains("_PDM_") && Xref.CheckMethod(mb, "NEW INSTANCE")).First(); }
public PdfCrossReference AddObject(IPdfObject obj) { return(Xref.AddEntry(obj)); }
public IEnumerable <PdfCrossReference> GetObjects() { return(Xref.GetIndirectObjects()); }