public static void WriteObsoleteAttribute(CodeWriter code, IServiceElementInfo element)
 {
     if (element.IsObsolete())
     {
         code.WriteLine("[Obsolete]");
     }
 }
Beispiel #2
0
 public static void WriteObsoleteAttribute(CodeWriter code, IServiceElementInfo element)
 {
     if (element.IsObsolete())
     {
         string message = element.TryGetObsoleteMessage();
         code.WriteLine(message != null ? $"[Obsolete({CreateString(message)})]" : "[Obsolete]");
     }
 }
Beispiel #3
0
        /// <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]);
 }
Beispiel #6
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);
 }
Beispiel #8
0
 private void WriteSummaryAndAttributes(CodeWriter code, IServiceElementInfo info)
 {
     WriteSummary(code, info.Summary);
     WriteAttributes(code, info.Attributes);
 }
Beispiel #9
0
 private static bool?GetObsoleteOrNull(IServiceElementInfo info)
 {
     return(info.IsObsolete() ? true : default(bool?));
 }
Beispiel #10
0
 private static string GetSummaryOrNull(IServiceElementInfo info)
 {
     return(info.Summary.Length == 0 ? null : info.Summary);
 }
Beispiel #11
0
 private static string TryGetCSharpName(IServiceElementInfo element)
 {
     return(element?.TryGetAttribute("csharp")?.Parameters.SingleOrDefault(x => x.Name == "name")?.Value);
 }
Beispiel #12
0
 /// <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"));
 }
Beispiel #13
0
 /// <summary>
 /// Returns true if the element has the 'obsolete' attribute.
 /// </summary>
 public static bool IsObsolete(this IServiceElementInfo element)
 {
     return(element.TryGetObsoleteAttribute() != null);
 }
Beispiel #14
0
 private static ServiceAttributeInfo TryGetObsoleteAttribute(this IServiceElementInfo element)
 {
     return(element.TryGetAttribute("obsolete"));
 }