public IReadOnlyList <TItem> GetOrAdd(TKey key, Func <TKey, IEnumerable <TItem> > getFunc)
 {
     int index = Primary.GetOrAdd(key, k =>
     {
         var rawList = getFunc(k);
         lock (Primary)
         {
             int[] itemListByIndex = rawList.Select(item =>
             {
                 if (!ItemDict.TryGetValue(item, out int itemIndex))
                 {
                     itemIndex = ItemList.Count;
                     ItemList.Add(item);
                     ItemDict[item] = itemIndex;
                 }
                 return(itemIndex);
             }).ToArray();
             var intArray = new IntArray(itemListByIndex);
             if (!ListDict.TryGetValue(intArray, out int listIndex))
             {
                 lock (ListList)
                 {
                     listIndex = ListList.Count;
                     ListList.Add(itemListByIndex.Select(ii => ItemList[ii]).ToArray());
                 }
                 ListDict[intArray] = listIndex;
             }
             return(listIndex);
         }
Example #2
0
 private void BtnAdd_Click(object sender, RoutedEventArgs e)
 {
     if ((int)cmbListName.SelectedValue > 0 && !string.IsNullOrEmpty(txtName.Text) && !string.IsNullOrEmpty(dtDeatLine.Text))
     {
         var result = Db.CreateToDo((int)cmbListName.SelectedValue, txtName.Text, txtDesc.Text, Convert.ToDateTime(dtDeatLine.Text));
         if (result.Completed)
         {
             MessageBox.Show("Successful");
             //Utils.GoBack(this);
             if (State.LastAction == ACTION.AddToDoFromToDoList)
             {
                 ListToDo t = new ListToDo(State.LastListId);
                 t.Show();
             }
             else if (State.LastAction == ACTION.AddToDoFromListList)
             {
                 ListList l = new ListList();
                 l.Show();
             }
             else
             {
                 IndexToDo i = new IndexToDo();
                 i.Show();
             }
             this.Close();
         }
     }
     else
     {
         MessageBox.Show("You must entry more info!");
     }
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            // The following code gets the client context and Title property by using TokenHelper.
            // To access other properties, you may need to request permissions on the host web.

            var contextToken = TokenHelper.GetContextTokenFromRequest(Page.Request);
            var hostWeb      = Page.Request["SPHostUrl"];

            using (var clientContext = TokenHelper.GetClientContextWithContextToken(hostWeb, contextToken, Request.Url.Authority))
            {
                //Load the properties for the web object.
                Web web = clientContext.Web;
                clientContext.Load(web);
                clientContext.ExecuteQuery();

                //Get the site name.
                var siteName = web.Title;

                //Get the current user.
                clientContext.Load(web.CurrentUser);
                clientContext.ExecuteQuery();
                var currentUser = clientContext.Web.CurrentUser.LoginName;

                //Load the lists from the Web object.
                ListCollection lists = web.Lists;
                clientContext.Load <ListCollection>(lists);
                clientContext.ExecuteQuery();

                //Load the current users from the Web object.
                UserCollection users = web.SiteUsers;
                clientContext.Load <UserCollection>(users);
                clientContext.ExecuteQuery();

                List <string> listOfUsers = new List <string>();
                List <string> listOfLists = new List <string>();


                foreach (User siteUser in users)
                {
                    listOfUsers.Add(siteUser.LoginName);
                }


                foreach (List list in lists)
                {
                    listOfLists.Add(list.Title);
                }

                WebTitleLabel.Text = siteName + " " + web.Url;

                AppWebLabel.Text = Page.Request["SPAppWebUrl"];

                CurrentUserLabel.Text = currentUser;
                UserList.DataSource   = listOfUsers;
                UserList.DataBind();
                ListList.DataSource = listOfLists;
                ListList.DataBind();
            }
        }
        private void LblGoToListsBtn_MouseDown(object sender, MouseButtonEventArgs e)
        {
            Utils.MarkTravel(this);
            ListList w = new ListList();

            w.Show();
            this.Close();
        }
Example #5
0
        public ListList <string> ListListOfString4()
        {
            var list = new ListList <string>();

            for (var i = 0; i < Size; i++)
            {
                list.Add("abc");
            }

            return(list);
        }
Example #6
0
        public ListList <int> ListListOfInt()
        {
            var list = new ListList <int>();

            for (var i = 0; i < Size; i++)
            {
                list.Add(i);
            }

            return(list);
        }
        protected void CSOM_Click(object sender, EventArgs e)
        {
            string commandAccessToken = ((LinkButton)sender).CommandArgument;

            RetrieveWithCSOM(commandAccessToken);
            WebTitleLabel.Text    = siteName;
            CurrentUserLabel.Text = currentUser;
            UserList.DataSource   = listOfUsers;
            UserList.DataBind();
            ListList.DataSource = listOfLists;
            ListList.DataBind();
        }