public static void WriteObsoleteAttribute(CodeWriter code, IServiceElementInfo element) { if (element.IsObsolete()) { code.WriteLine("[Obsolete]"); } }
public static void WriteObsoleteAttribute(CodeWriter code, IServiceElementInfo element) { if (element.IsObsolete()) { string message = element.TryGetObsoleteMessage(); code.WriteLine(message != null ? $"[Obsolete({CreateString(message)})]" : "[Obsolete]"); } }
/// <summary> /// Returns the attribute with the specified name. /// </summary> /// <remarks>Throws a ServiceDefinitionException if the attribute is duplicated.</remarks> public static ServiceAttributeInfo TryGetAttribute(this IServiceElementInfo element, string name) { var attributes = element?.Attributes; if (attributes == null) { return(null); } var matchingAttributes = attributes.Where(x => x.Name == name).ToList(); if (matchingAttributes.Count > 1) { throw new ServiceDefinitionException($"'{name}' attribute is duplicated.", matchingAttributes[1].Position); } return(matchingAttributes.FirstOrDefault()); }
public static ServiceAttributeInfo TryGetHttpAttribute(this IServiceElementInfo element) { return(element.TryGetAttribute("http")); }
public static IReadOnlyList <ServiceAttributeParameterInfo> GetHttpParameters(this IServiceElementInfo element) { return(element.TryGetAttribute("http")?.Parameters ?? new ServiceAttributeParameterInfo[0]); }
private static void WriteJSDoc(CodeWriter code, IServiceElementInfo element) { WriteJSDoc(code, element.Summary, isObsolete: element.IsObsolete(), obsoleteMessage: element.TryGetObsoleteMessage()); }
private static string TryGetJavaScriptName(IServiceElementInfo element) { return(element?.TryGetAttribute("javascript")?.Parameters.SingleOrDefault(x => x.Name == "name")?.Value); }
private void WriteSummaryAndAttributes(CodeWriter code, IServiceElementInfo info) { WriteSummary(code, info.Summary); WriteAttributes(code, info.Attributes); }
private static bool?GetObsoleteOrNull(IServiceElementInfo info) { return(info.IsObsolete() ? true : default(bool?)); }
private static string GetSummaryOrNull(IServiceElementInfo info) { return(info.Summary.Length == 0 ? null : info.Summary); }
private static string TryGetCSharpName(IServiceElementInfo element) { return(element?.TryGetAttribute("csharp")?.Parameters.SingleOrDefault(x => x.Name == "name")?.Value); }
/// <summary> /// Returns the obsolete message for an element with the 'obsolete' attribute. /// </summary> /// <remarks>Use <see cref="IsObsolete"/> to determine if the element is obsolete.</remarks> public static string TryGetObsoleteMessage(this IServiceElementInfo element) { return(element.TryGetObsoleteAttribute()?.TryGetParameterValue("message")); }
/// <summary> /// Returns true if the element has the 'obsolete' attribute. /// </summary> public static bool IsObsolete(this IServiceElementInfo element) { return(element.TryGetObsoleteAttribute() != null); }
private static ServiceAttributeInfo TryGetObsoleteAttribute(this IServiceElementInfo element) { return(element.TryGetAttribute("obsolete")); }