public static bool TryFormatJObjectExtensions <T>(T entityToFormat, ExtensionManifestDirectory extensionManifestDirectory, out IList <JToken> tokens) where T : IExtensibleEntity { tokens = default; if (entityToFormat == null) { return(false); } var results = new List <JToken>(); foreach (var extensionEntity in entityToFormat.Extensions) { if (!extensionManifestDirectory.TryGetExtensionManifestByExtensionType(extensionEntity.GetType(), out var extensionManifest)) { continue; } if (extensionManifest.TryFormatJObjectExtension(extensionEntity, extensionManifestDirectory, out var extensionElements)) { results.AddRange(extensionElements); } } if (!results.Any()) { return(false); } tokens = results; return(true); }
public static void ParseXElementExtensions <T>(XElement parentElement, ExtensionManifestDirectory extensionManifestDirectory, T entityToExtend) where T : IExtensibleEntity { if (parentElement == null) { throw new ArgumentNullException(nameof(parentElement)); } if (extensionManifestDirectory == null) { throw new ArgumentNullException(nameof(extensionManifestDirectory)); } if (entityToExtend == null) { throw new ArgumentNullException(nameof(entityToExtend)); } foreach (var extensionManifest in extensionManifestDirectory) { if (extensionManifest.TryParseXElementExtension(parentElement, extensionManifestDirectory, out var extension)) { entityToExtend.Extensions.Add(extension); } } }
public abstract bool TryFormatJObjectExtension(IExtensionEntity extensionToFormat, ExtensionManifestDirectory extensionManifestDirectory, out IList <JToken> tokens);
public abstract bool TryParseJObjectExtension(JObject parentObject, ExtensionManifestDirectory extensionManifestDirectory, out IExtensionEntity extension);
public abstract bool TryFormatXElementExtension(IExtensionEntity extensionToFormat, XNamespaceAliasSet namespaceAliases, ExtensionManifestDirectory extensionManifestDirectory, out IList <XElement> elements);
public abstract bool TryParseXElementExtension(XElement parentElement, ExtensionManifestDirectory extensionManifestDirectory, out IExtensionEntity extension);
public static bool TryFormatXElementExtensions <T>(T entityToFormat, XNamespaceAliasSet namespaceAliases, ExtensionManifestDirectory extensionManifestDirectory, out IList <XElement> elements) where T : IExtensibleEntity { elements = default; if (entityToFormat == null) { return(false); } var results = new List <XElement>(); foreach (var extensionEntity in entityToFormat.Extensions) { if (!extensionManifestDirectory.TryGetExtensionManifestByExtensionType(extensionEntity.GetType(), out var extensionManifest)) { continue; } if (extensionManifest.TryFormatXElementExtension(extensionEntity, namespaceAliases, extensionManifestDirectory, out var extensionElements)) { results.AddRange(extensionElements); } } if (!results.Any()) { return(false); } elements = results; return(true); }