Exemplo n.º 1
0
 public static void UpdateTypeMap(TypeMap typeMap)
 {
     DocIdFormatter.TypeMap    = typeMap;
     SlashdocFormatter.TypeMap = typeMap;
     foreach (var f in TypeFormatters.Union(MemberFormatters))
     {
         f.TypeMap = typeMap;
     }
 }
        /// <inheritdoc />
        public override string ToString()
        {
            var startTime = StartTime != null?TypeFormatters.ToString(StartTime.Value, "o") : null;

            var endTime = EndTime != null?TypeFormatters.ToString(EndTime.Value, "o") : null;

            var duration = TypeFormatters.ToString(Duration, "P");

            switch (startTime, endTime, duration)
            {
Exemplo n.º 3
0
        internal static QueryBody CreateQueryBody(string query, TimeSpan?timeSpan)
        {
            var queryBody = new QueryBody(query);

            if (timeSpan != null)
            {
                queryBody.Timespan = TypeFormatters.ToString(timeSpan.Value, "P");
            }

            return(queryBody);
        }
Exemplo n.º 4
0
        public static void AddFormatter(string langId)
        {
            langId = langId.ToLower();
            var map = MDocUpdater.Instance.TypeMap;

            switch (langId)
            {
            case Consts.DocIdLowCase:
                TypeFormatters.Add(DocIdFormatter);
                MemberFormatters.Add(DocIdFormatter);
                break;

            case Consts.VbNetLowCase:
                TypeFormatters.Add(new VBMemberFormatter(map));
                MemberFormatters.Add(new VBMemberFormatter(map));
                break;

            case Consts.CppCliLowCase:
                TypeFormatters.Add(new CppMemberFormatter(map));
                MemberFormatters.Add(new CppFullMemberFormatter(map));
                break;

            case Consts.CppCxLowCase:
                TypeFormatters.Add(new CppCxMemberFormatter(map));
                MemberFormatters.Add(new CppCxFullMemberFormatter(map));
                break;

            case Consts.CppWinRtLowCase:
                TypeFormatters.Add(new CppWinRtMemberFormatter(map));
                MemberFormatters.Add(new CppWinRtFullMemberFormatter(map));
                AdditionalAttributeFormatters.Add(new CppWinRtAttributeFormatter());
                break;

            case Consts.FSharpLowCase:
            case "fsharp":
                TypeFormatters.Add(new FSharpMemberFormatter(map));
                MemberFormatters.Add(new FSharpFullMemberFormatter(map));
                AdditionalAttributeFormatters.Add(new FSharpAttributeFormatter());
                break;

            case Consts.JavascriptLowCase:
                TypeFormatters.Add(new JsMemberFormatter(map));
                MemberFormatters.Add(new JsMemberFormatter(map));
                break;

            default:
                throw new ArgumentException("Unsupported formatter id '" + langId + "'.");
            }
        }
Exemplo n.º 5
0
        internal static QueryBody CreateQueryBody(string query, TimeSpan?timeSpan, LogsQueryOptions options, out string prefer)
        {
            var queryBody = new QueryBody(query);

            if (timeSpan != null)
            {
                queryBody.Timespan = TypeFormatters.ToString(timeSpan.Value, "P");
            }

            prefer = null;

            if (options?.Timeout is TimeSpan timeout)
            {
                prefer = "wait=" + (int)timeout.TotalSeconds;
            }

            if (options?.IncludeStatistics == true)
            {
                prefer += " include-statistics=true";
            }

            return(queryBody);
        }
Exemplo n.º 6
0
 public void AddTypeFormatter <T>(Func <object, ActionContext, string> formatter)
 {
     TypeFormatters.Add(typeof(T), formatter);
 }
Exemplo n.º 7
0
 private static string GetTimespan(DateTimeOffset startTime, DateTimeOffset endTime)
 {
     return($"{TypeFormatters.ToString(startTime, "o")}/{TypeFormatters.ToString(endTime, "o")}");
 }
 public static void WriteNullStringValue(this Utf8JsonWriter writer, string propertyName, DateTimeOffset?value, string format) =>
 writer.WriteNullObjectValue(propertyName, value != null ? TypeFormatters.ToString(value.Value, format) : null);