Ejemplo n.º 1
0
        // REVIEW: named ValueTuple would be more readable
        private static Tuple <string, Dictionary <string, HTMLElement> > BuildTemplateAndParams(
            RenderElem <HTMLElement>[] tokens)
        {
            var innerHtmlTemplate = "";
            var controls          = new Dictionary <string, HTMLElement>();

            foreach (var t in tokens)
            {
                if (t.Iview != null)
                {
                    var id = UniqueIdGenerator.Generate();
                    innerHtmlTemplate += string.Format("<div id='{0}'></div>", id);
                    controls.Add(id.ToString(), t.Iview.Widget);
                    Logger.Debug(typeof(FormCanvasExtensions), "BuildTemplateAndParams() iview={0} with id={1}", t, id);
                    continue;
                }

                if (t.NativeItm != null)
                {
                    var id = UniqueIdGenerator.Generate();
                    innerHtmlTemplate += string.Format("<div id='{0}'></div>", id);
                    controls.Add(id.ToString(), t.NativeItm);
                    Logger.Debug(typeof(FormCanvasExtensions), "BuildTemplateAndParams() NativeItm={0} with id={1}", t, id);
                    continue;
                }

                innerHtmlTemplate += t.Token;
                Logger.Debug(typeof(FormCanvasExtensions), "BuildTemplateAndParams() literal={0}", t);
            }

            return(new Tuple <string, Dictionary <string, HTMLElement> >(innerHtmlTemplate, controls));
        }
Ejemplo n.º 2
0
 private TooltipOper Immediate(string classToRemove, string classToAdd)
 {
     Logger.Debug(GetType(), "scheduling Immediate oper");
     return(new TooltipOper {
         OperationId = UniqueIdGenerator.Generate(),
         DurationMs = 1, //shortest possible time (but not in the same thread so that transitions are applied)
         ClassToRemove = classToRemove,
         ClassToAdd = classToAdd
     });
 }
Ejemplo n.º 3
0
 private TooltipOper Lasting(string classToRemove, string classToAdd, int milisec)
 {
     Logger.Debug(GetType(), "scheduling Lasting oper");
     return(new TooltipOper {
         OperationId = UniqueIdGenerator.Generate(),
         DurationMs = milisec,
         ClassToRemove = classToRemove,
         ClassToAdd = classToAdd
     });
 }
Ejemplo n.º 4
0
        public void Generate_UniqueCodes_1_million_UniqueIdGenerator()
        {
            var codes = new HashSet <string>();

            for (int x = 0; x < million; x++)
            {
                var guid = UniqueIdGenerator.Generate(8);
                Console.Write($"{guid}, ");

                if (!codes.Add(guid))
                {
                    Assert.Fail("duplicate found");
                }
            }
        }
Ejemplo n.º 5
0
        public async Task InvokeAsync(HttpContext context)
        {
            // try to fetch user trace id from cookies
            // if no such cookie, create a new one
            if (!context.Request.Cookies.TryGetValue(UserTraceCookieName, out var userTraceIdCookieValue) || !PublicId.TryParse(userTraceIdCookieValue, out var temp))
            {
                long?userTraceId = UniqueIdGenerator.Generate();

                context.Response.Cookies.Append(
                    UserTraceCookieName,
                    userTraceId.Value.ToPublicId(),
                    new CookieOptions
                {
                    SameSite    = SameSiteMode.None,
                    IsEssential = true,
                    MaxAge      = TimeSpan.FromDays(365)
                });
            }

            await _next(context);
        }