当前位置: 首页>>代码示例>>C#>>正文


C# List.AddItem方法代码示例

本文整理汇总了C#中List.AddItem方法的典型用法代码示例。如果您正苦于以下问题:C# List.AddItem方法的具体用法?C# List.AddItem怎么用?C# List.AddItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在List的用法示例。


在下文中一共展示了List.AddItem方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Ping

 static void Ping(List pings)
 {
     var ping = pings.AddItem(new ListItemCreationInformation());
     ping["Title"] = DateTime.Now.ToUniversalTime();
     ping.Update();
     pings.Context.ExecuteQuery();
 }
开发者ID:ronnieholm,项目名称:SPSearchIndexLiveliness,代码行数:7,代码来源:Program.cs

示例2: TestNonRecursiveFiltering

		public virtual void TestNonRecursiveFiltering()
		{
			ObjectInserter odi = db.NewObjectInserter();
			ObjectId aSth = odi.Insert(Constants.OBJ_BLOB, Sharpen.Runtime.GetBytesForString(
				"a.sth"));
			ObjectId aTxt = odi.Insert(Constants.OBJ_BLOB, Sharpen.Runtime.GetBytesForString(
				"a.txt"));
			DirCache dc = db.ReadDirCache();
			DirCacheBuilder builder = dc.Builder();
			DirCacheEntry aSthEntry = new DirCacheEntry("a.sth");
			aSthEntry.FileMode = FileMode.REGULAR_FILE;
			aSthEntry.SetObjectId(aSth);
			DirCacheEntry aTxtEntry = new DirCacheEntry("a.txt");
			aTxtEntry.FileMode = FileMode.REGULAR_FILE;
			aTxtEntry.SetObjectId(aTxt);
			builder.Add(aSthEntry);
			builder.Add(aTxtEntry);
			builder.Finish();
			ObjectId treeId = dc.WriteTree(odi);
			odi.Flush();
			TreeWalk tw = new TreeWalk(db);
			tw.Filter = PathSuffixFilter.Create(".txt");
			tw.AddTree(treeId);
			IList<string> paths = new List<string>();
			while (tw.Next())
			{
				paths.AddItem(tw.PathString);
			}
			IList<string> expected = new List<string>();
			expected.AddItem("a.txt");
			NUnit.Framework.Assert.AreEqual(expected, paths);
		}
开发者ID:LunarLanding,项目名称:ngit,代码行数:32,代码来源:PathSuffixFilterTestCase.cs

示例3: AddDeaultData

        public void AddDeaultData(ClientContext context, List list)
        {
            for (int i = 1; i <= 5; i++)
            {
                // Add a list item
                var itemInfo = new ListItemCreationInformation
                {
                    LeafName = string.Format("List Item {0}", i)
                };
                var item = list.AddItem(itemInfo);
                item["My_x0020_Number1"] = 100 + i;
                item["My_x0020_Number2"] = i;
                item.Update();
            }

            context.ExecuteQuery();
        }
开发者ID:mehrosu,项目名称:SPOEmulators,代码行数:17,代码来源:ProvisioningEngine.cs

示例4: AddItem

 /// <summary>
 /// Adds list item in specified list.
 /// </summary>
 /// <param name="clientContext">Client context</param>
 /// <param name="list">Name of the list</param>
 /// <param name="columns">List of column names</param>
 /// <param name="values">Values for corresponding columns</param>
 /// <returns>String stating success flag</returns>
 public static bool AddItem(ClientContext clientContext, List list, IList<string> columns, IList<object> values)
 {
     bool result = false;
     if (null != clientContext && null != list && null != columns && null != values && columns.Count == values.Count)
     {
         // Add the Matter URL in list
         ListItemCreationInformation listItemCreateInfo = new ListItemCreationInformation();
         ListItem newListItem = list.AddItem(listItemCreateInfo);
         int position = 0;
         foreach (string column in columns)
         {
             newListItem[column] = values[position++];
         }
         ///// Update the list
         newListItem.Update();
         clientContext.ExecuteQuery();
         result = true;
     }
     return result;
 }
开发者ID:MatthewSammut,项目名称:mattercenter,代码行数:28,代码来源:Lists.cs

示例5: ProcessInbox

        internal override void ProcessInbox(RevisionList inbox)
        {
            if (Status == ReplicationStatus.Offline) {
                Log.V(TAG, "Offline, so skipping inbox process");
                return;
            }

            if(_requests.Count > ManagerOptions.Default.MaxOpenHttpConnections) {
                Task.Delay(1000).ContinueWith(t => ProcessInbox(inbox), CancellationToken.None, TaskContinuationOptions.None, WorkExecutor.Scheduler);
                return;
            }

            SafeAddToChangesCount(inbox.Count);
            // Generate a set of doc/rev IDs in the JSON format that _revs_diff wants:
            // <http://wiki.apache.org/couchdb/HttpPostRevsDiff>
            var diffs = new Dictionary<String, IList<String>>();
            foreach (var rev in inbox) {
                var docID = rev.GetDocId();
                var revs = diffs.Get(docID);
                if (revs == null) {
                    revs = new List<String>();
                    diffs[docID] = revs;
                }
                revs.AddItem(rev.GetRevId());
                AddPending(rev);
            }

            // Call _revs_diff on the target db:
            Log.D(TAG, "posting to /_revs_diff: {0}", String.Join(Environment.NewLine, new[] { Manager.GetObjectMapper().WriteValueAsString(diffs) }));

            SendAsyncRequest(HttpMethod.Post, "/_revs_diff", diffs, (response, e) =>
            {
                try {
                    var results = response.AsDictionary<string, object>();

                    Log.D(TAG, "/_revs_diff response: {0}\r\n{1}", response, results);

                    if (e != null) {
                        LastError = e;
                        RevisionFailed();
                    } else {
                        if (results.Count != 0)  {
                            // Go through the list of local changes again, selecting the ones the destination server
                            // said were missing and mapping them to a JSON dictionary in the form _bulk_docs wants:
                            var docsToSend = new List<object> ();
                            var revsToSend = new RevisionList();
                            foreach (var rev in inbox) {
                                // Is this revision in the server's 'missing' list?
                                IDictionary<string, object> properties = null;
                                var revResults = results.Get(rev.GetDocId()).AsDictionary<string, object>(); 
                                if (revResults == null) {
                                    SafeIncrementCompletedChangesCount();
                                    continue;
                                }

                                var revs = revResults.Get("missing").AsList<string>();
                                if (revs == null || !revs.Any( id => id.Equals(rev.GetRevId(), StringComparison.OrdinalIgnoreCase))) {
                                    RemovePending(rev);
                                    SafeIncrementCompletedChangesCount();
                                    continue;
                                }

                                // Get the revision's properties:
                                var contentOptions = DocumentContentOptions.IncludeAttachments;
                                if (!_dontSendMultipart && RevisionBodyTransformationFunction == null)
                                {
                                    contentOptions |= DocumentContentOptions.BigAttachmentsFollow;
                                }


                                RevisionInternal loadedRev;
                                try {
                                    loadedRev = LocalDatabase.LoadRevisionBody (rev);
                                    properties = new Dictionary<string, object>(rev.GetProperties());
                                } catch (CouchbaseLiteException e1) {
                                    Log.W(TAG, string.Format("{0} Couldn't get local contents of {1}", rev, this), e1);
                                    RevisionFailed();
                                    continue;
                                }

                                var populatedRev = TransformRevision(loadedRev);
                                IList<string> possibleAncestors = null;
                                if (revResults.ContainsKey("possible_ancestors")) {
                                    possibleAncestors = revResults["possible_ancestors"].AsList<string>();
                                }

                                properties = new Dictionary<string, object>(populatedRev.GetProperties());
                                var history = LocalDatabase.GetRevisionHistory(populatedRev, possibleAncestors);
                                properties["_revisions"] = Database.MakeRevisionHistoryDict(history);
                                populatedRev.SetProperties(properties);

                                // Strip any attachments already known to the target db:
                                if (properties.ContainsKey("_attachments")) {
                                    // Look for the latest common ancestor and stuf out older attachments:
                                    var minRevPos = FindCommonAncestor(populatedRev, possibleAncestors);
                                    Status status = new Status();
                                    if(!LocalDatabase.ExpandAttachments(populatedRev, minRevPos + 1, !_dontSendMultipart, false, status)) {
                                        Log.W(TAG, "Error expanding attachments!");
                                        RevisionFailed();
                                        continue;
//.........这里部分代码省略.........
开发者ID:naveen190781,项目名称:couchbase-lite-net,代码行数:101,代码来源:Pusher.cs

示例6: MigrateContent_List

        private static void MigrateContent_List(ClientContext clientContext, List listToBeReplaced, List newList)
        {
            try
            {
                ListItemCollection sourceListItems = listToBeReplaced.GetItems(CamlQuery.CreateAllItemsQuery());
                FieldCollection sourceListFields = listToBeReplaced.Fields;

                clientContext.Load(sourceListItems, sListItems => sListItems.IncludeWithDefaultProperties(li => li.AttachmentFiles));
                clientContext.Load(sourceListFields);
                clientContext.ExecuteQuery();

                var sourceItemEnumerator = sourceListItems.GetEnumerator();
                while (sourceItemEnumerator.MoveNext())
                {
                    var sourceItem = sourceItemEnumerator.Current;
                    ListItemCreationInformation itemCreateInfo = new ListItemCreationInformation();
                    ListItem targetItem = newList.AddItem(itemCreateInfo);
                    object sourceModifiedDate = null;
                    object sourceModifiledBy = null;

                    foreach (Field sourceListField in sourceListFields)
                    {
                        try
                        {
                            //[START]Copy all except Attachments,ReadOnlyField,ContentType
                            if (!sourceListField.ReadOnlyField && sourceListField.InternalName != "Attachments" && sourceListField.InternalName != "ContentType" && null != sourceItem[sourceListField.InternalName])
                            {
                                //[START] Calendar and Event List
                                if (listToBeReplaced.BaseTemplate.ToString().Equals("106"))
                                {
                                    if (sourceListField.InternalName.Equals("EndDate"))
                                    {
                                        continue;
                                    }
                                    else if (sourceListField.InternalName.Equals("EventDate"))
                                    {
                                        targetItem[sourceListField.InternalName] = sourceItem[sourceListField.InternalName];
                                        targetItem["EndDate"] = sourceItem["EndDate"];
                                        targetItem.Update();
                                        clientContext.ExecuteQuery();
                                        //[START] [Load "Target Items" After Update, to avoid Version Conflict]
                                        targetItem = newList.GetItemById(targetItem.Id);
                                        clientContext.Load(targetItem);
                                        clientContext.ExecuteQuery();
                                        //[END] [Load "Target Items" After Update, to avoid Version Conflict]
                                    }
                                    else if (ContainsField(newList, sourceListField.InternalName))
                                    {
                                        targetItem[sourceListField.InternalName] = sourceItem[sourceListField.InternalName];
                                        targetItem.Update();
                                        clientContext.ExecuteQuery();
                                        //[START] [Load "Target Items" After Update, to avoid Version Conflict]
                                        targetItem = newList.GetItemById(targetItem.Id);
                                        clientContext.Load(targetItem);
                                        clientContext.ExecuteQuery();
                                        //[END] [Load "Target Items" After Update, to avoid Version Conflict]
                                    }
                                }
                                //[END] Calendar and Event List
                                else
                                {
                                    if (ContainsField(newList, sourceListField.InternalName))
                                    {
                                        targetItem[sourceListField.InternalName] = sourceItem[sourceListField.InternalName];
                                        targetItem.Update();
                                        clientContext.ExecuteQuery();
                                        //[START] [Load "Target Items" After Update, to avoid Version Conflict]
                                        targetItem = newList.GetItemById(targetItem.Id);
                                        clientContext.Load(targetItem);
                                        clientContext.ExecuteQuery();
                                        //[END] [Load "Target Items" After Update, to avoid Version Conflict]
                                    }
                                }
                            }
                            //[END]Copy all except Attachments, ReadOnlyField, ContentType

                            //Created, Author Field
                            if (sourceItem.FieldValues.Keys.Contains(sourceListField.InternalName))
                            {
                                //Created By
                                if (sourceListField.InternalName.Equals("Author"))
                                {
                                    //newList.Fields.GetByInternalNameOrTitle("Author").ReadOnlyField = false;
                                    if (ContainsField(newList, sourceListField.InternalName))
                                    {
                                        targetItem[sourceListField.InternalName] = sourceItem[sourceListField.InternalName];
                                        targetItem.Update();
                                        clientContext.ExecuteQuery();
                                    }
                                }
                                //Created Date
                                if (sourceListField.InternalName.Equals("Created"))
                                {
                                    //newList.Fields.GetByInternalNameOrTitle("Created").ReadOnlyField = false;
                                    if (ContainsField(newList, sourceListField.InternalName))
                                    {
                                        targetItem[sourceListField.InternalName] = sourceItem[sourceListField.InternalName];
                                        targetItem.Update();
                                        clientContext.ExecuteQuery();
                                    }
//.........这里部分代码省略.........
开发者ID:OfficeDev,项目名称:PnP-Transformation,代码行数:101,代码来源:ListMigrationHelper.cs

示例7: AddNewListItem

        private static void AddNewListItem(CsvRecord record, List spList, ClientContext clientContext)
        {
            //Instantiate dictionary to temporarily store field values
            Dictionary<string, object> itemFieldValues = new Dictionary<string, object>();
            //Use reflection to iterate through the record's properties
            PropertyInfo[] properties = typeof(CsvRecord).GetProperties();
            foreach (PropertyInfo property in properties)
            {
                //Get property value
                object propValue = property.GetValue(record, null);
                //Only set field if the property has a value
                if (!String.IsNullOrEmpty(propValue.ToString()))
                {
                    //Get site column that matches the property name
                    //ASSUMPTION: Your property names match the internal names of the corresponding site columns
                    Field matchingField = spList.Fields.GetByInternalNameOrTitle(property.Name);
                    clientContext.Load(matchingField);
                    clientContext.ExecuteQuery();

                    //Switch on the field type
                    switch (matchingField.FieldTypeKind)
                    {
                        case FieldType.User:
                            FieldUserValue userFieldValue = GetUserFieldValue(propValue.ToString(), clientContext);
                            if (userFieldValue != null)
                                itemFieldValues.Add(matchingField.InternalName, userFieldValue);
                            else
                                throw new Exception("User field value could not be added: " + propValue.ToString());
                            break;
                        case FieldType.Lookup:
                            FieldLookupValue lookupFieldValue = GetLookupFieldValue(propValue.ToString(),
                                ConfigurationManager.AppSettings["LookupListName"].ToString(),
                                clientContext);
                            if (lookupFieldValue != null)
                                itemFieldValues.Add(matchingField.InternalName, lookupFieldValue);
                            else
                                throw new Exception("Lookup field value could not be added: " + propValue.ToString());
                            break;
                        case FieldType.Invalid:
                            switch (matchingField.TypeAsString)
                            {
                                case "TaxonomyFieldType":
                                    TaxonomyFieldValue taxFieldValue = GetTaxonomyFieldValue(propValue.ToString(), matchingField, clientContext);
                                    if (taxFieldValue != null)
                                        itemFieldValues.Add(matchingField.InternalName, taxFieldValue);
                                    else
                                        throw new Exception("Taxonomy field value could not be added: " + propValue.ToString());
                                    break;
                                default:
                                    //Code for publishing site columns not implemented
                                    continue;
                            }
                            break;
                        default:
                            itemFieldValues.Add(matchingField.InternalName, propValue);
                            break;
                    }
                }
            }

            //Add new item to list
            ListItemCreationInformation creationInfo = new ListItemCreationInformation();
            ListItem oListItem = spList.AddItem(creationInfo);

            foreach (KeyValuePair<string, object> itemFieldValue in itemFieldValues)
            {
                //Set each field value
                oListItem[itemFieldValue.Key] = itemFieldValue.Value;
            }
            //Persist changes
            oListItem.Update();
            clientContext.ExecuteQuery();
        }
开发者ID:ALCBerry87,项目名称:SPO-Import-List-CSV,代码行数:73,代码来源:Program.cs

示例8: Test005_PutGetStringList

 public virtual void Test005_PutGetStringList()
 {
     Config c = new Config();
     List<string> values = new List<string>();
     values.AddItem("value1");
     values.AddItem("value2");
     c.SetStringList("my", null, "somename", values);
     object[] expArr = Sharpen.Collections.ToArray(values);
     string[] actArr = c.GetStringList("my", null, "somename");
     NUnit.Framework.Assert.IsTrue(Arrays.Equals(expArr, actArr));
     string expText = "[my]\n\tsomename = value1\n\tsomename = value2\n";
     NUnit.Framework.Assert.AreEqual(expText, c.ToText());
 }
开发者ID:kenji-tan,项目名称:ngit,代码行数:13,代码来源:ConfigTest.cs

示例9: GetPossibleAncestorRevisionIDs

        public IList<String> GetPossibleAncestorRevisionIDs(RevisionInternal rev, int limit, ref Boolean hasAttachment)
        {
            var matchingRevs = new List<String>();
            var generation = rev.GetGeneration();
            if (generation <= 1)
            {
                return null;
            }

            var docNumericID = GetDocNumericID(rev.GetDocId());
            if (docNumericID <= 0)
            {
                return null;
            }

            var sqlLimit = limit > 0 ? limit : -1;

            // SQL uses -1, not 0, to denote 'no limit'
            var sql = @"SELECT revid, sequence FROM revs WHERE doc_id=? and revid < ? and deleted=0 and json not null"
                  + " ORDER BY sequence DESC LIMIT ?";
            var args = new [] { Convert.ToString(docNumericID), generation + "-", sqlLimit.ToString() };
            Cursor cursor = null;
            try
            {
                cursor = StorageEngine.RawQuery(sql, args);
                cursor.MoveToNext();

                if (!cursor.IsAfterLast())
                {
                    if (matchingRevs.Count == 0)
                    {
                        hasAttachment = SequenceHasAttachments(cursor.GetLong(1));
                    }
                    matchingRevs.AddItem(cursor.GetString(0));
                }
            }
            catch (SQLException e)
            {
                Log.E(Database.Tag, "Error getting all revisions of document", e);
            }
            finally
            {
                if (cursor != null)
                {
                    cursor.Close();
                }
            }
            return matchingRevs;
        }
开发者ID:FireflyLogic,项目名称:couchbase-lite-net,代码行数:49,代码来源:Database.cs

示例10: Header

		public Header(IDictionary<string, IList<string>> map) : this()
		{
			// initialize fields
			foreach (KeyValuePair<string, IList<string>> next in map.EntrySet())
			{
				string key = next.Key;
				IList<string> value = next.Value;
				List<string> linkedList = new List<string>();
				foreach (string element in value)
				{
					linkedList.AddItem(element);
					props.AddItem(key);
					props.AddItem(element);
				}
				keyTable.Put(key, linkedList);
			}
		}
开发者ID:Redth,项目名称:couchbase-lite-net,代码行数:17,代码来源:URLConnection.cs

示例11: CreateSampleReport

        private void CreateSampleReport(ClientContext clientContext, List list)
        {
            Trace.WriteLine("Creating sample report template");
            var template = new
            {
                engine = "jsrender",
                content = System.IO.File.ReadAllText(Path.Combine(AssemblyDirectory, "SampleReport", "SampleReport.html")),
                helpers = System.IO.File.ReadAllText(Path.Combine(AssemblyDirectory, "SampleReport", "SampleHelpers.js")),
                script = new
                {
                    content = System.IO.File.ReadAllText(Path.Combine(AssemblyDirectory, "SampleReport", "SampleScript.js")),
                }
            };

            ListItem listItem = list.AddItem(new ListItemCreationInformation());
            listItem["Title"] = "Sample report";
            listItem["Template"] = JsonConvert.SerializeObject(template);
            listItem["Description"] = "This is sample report. You can print it using [Render jsreport] button from detail form. To edit it use [Open editor] button on edit form";
            listItem.Update();
            clientContext.ExecuteQuery();
            Trace.WriteLine("Sample report template created");
        }
开发者ID:ricardocarneiro,项目名称:sharepoint-2,代码行数:22,代码来源:RemoteEventReceiver.svc.cs

示例12: ExtractChapterTOCFrameData

 private IList<ID3v2ChapterTOCFrameData> ExtractChapterTOCFrameData(string id)
 {
     ID3v2FrameSet frameSet = frameSets.Get(id);
     if (frameSet != null)
     {
         IList<ID3v2ChapterTOCFrameData> chapterData = new List<ID3v2ChapterTOCFrameData>();
         IList<ID3v2Frame> frames = frameSet.GetFrames();
         foreach (ID3v2Frame frame in frames)
         {
             ID3v2ChapterTOCFrameData frameData;
             try
             {
                 frameData = new ID3v2ChapterTOCFrameData(UseFrameUnsynchronisation(), frame.GetData
                     ());
                 chapterData.AddItem(frameData);
             }
             catch (InvalidDataException)
             {
             }
         }
         // do nothing
         return chapterData;
     }
     return null;
 }
开发者ID:selivonchyk,项目名称:mp3net,代码行数:25,代码来源:AbstractID3v2Tag.cs

示例13: EnsureListItem

        private ListItem EnsureListItem(List list, ListItemDefinition listItemModel)
        {
            var context = list.Context;

            // TODO, lazy to query
            var items = list.GetItems(CamlQuery.CreateAllItemsQuery());

            context.Load(items);
            context.ExecuteQuery();

            // BIG TODO, don't tell me, I know that
            var currentItem = items.FirstOrDefault(i => i["Title"] != null &&
                    (i["Title"].ToString() == listItemModel.Title));

            InvokeOnModelEvent(this, new ModelEventArgs
            {
                CurrentModelNode = null,
                Model = null,
                EventType = ModelEventType.OnProvisioning,
                Object = currentItem,
                ObjectType = typeof(ListItem),
                ObjectDefinition = listItemModel,
                ModelHost = list
            });

            if (currentItem == null)
            {
                var newItem = list.AddItem(new ListItemCreationInformation());

                newItem["Title"] = listItemModel.Title;

                InvokeOnModelEvent(this, new ModelEventArgs
                {
                    CurrentModelNode = null,
                    Model = null,
                    EventType = ModelEventType.OnProvisioned,
                    Object = newItem,
                    ObjectType = typeof(ListItem),
                    ObjectDefinition = listItemModel,
                    ModelHost = list
                });

                newItem.Update();

                context.ExecuteQuery();

                return newItem;
            }
            else
            {
                currentItem["Title"] = listItemModel.Title;

                InvokeOnModelEvent(this, new ModelEventArgs
                {
                    CurrentModelNode = null,
                    Model = null,
                    EventType = ModelEventType.OnProvisioned,
                    Object = currentItem,
                    ObjectType = typeof(ListItem),
                    ObjectDefinition = listItemModel,
                    ModelHost = list
                });

                currentItem.Update();

                context.ExecuteQuery();

                return currentItem;
            }
        }
开发者ID:nklychnikov,项目名称:spmeta2,代码行数:70,代码来源:ListItemModelHandler.cs

示例14: CreateBriefcaseIfNotExists

 /// <summary>
 /// Check for the list item named Matter Center Briefcase already exists, if not then only create new folder
 /// </summary>
 /// <param name="clientContext">SP client context</param>
 /// <param name="list">Name of the list</param>
 /// <param name="usersMySite">My Site URL of the user</param>
 internal static void CreateBriefcaseIfNotExists(ClientContext clientContext, List list, string usersMySite)
 {
     CamlQuery briefcaseQuery = new CamlQuery();
     briefcaseQuery.ViewXml = string.Format(CultureInfo.InvariantCulture, ServiceConstantStrings.BriefcaseFolderQuery, ServiceConstantStrings.LegalBriefcaseFolder);
     ListItemCollection briefcases = list.GetItems(briefcaseQuery);
     clientContext.Load(briefcases, listItems => listItems.Include(item => item.DisplayName));
     clientContext.ExecuteQuery();
     ListItem listItem = briefcases.Where(item => item.DisplayName == ServiceConstantStrings.LegalBriefcaseFolder).FirstOrDefault();
     if (null == listItem)      // Check for Matter Center Briefcase folder exists, if not then create
     {
         ListItemCreationInformation newItem = new ListItemCreationInformation();
         newItem.FolderUrl = string.Concat(usersMySite, ServiceConstantStrings.OneDriveDocumentLibraryTitle);
         newItem.LeafName = ServiceConstantStrings.LegalBriefcaseFolder;
         newItem.UnderlyingObjectType = FileSystemObjectType.Folder;
         listItem = list.AddItem(newItem);
         listItem.Update();
         clientContext.Load(listItem, field => field.DisplayName);
         clientContext.ExecuteQuery();
     }
 }
开发者ID:MatthewSammut,项目名称:mattercenter,代码行数:26,代码来源:BriefcaseContentTypeHelperFunctions.cs

示例15: PopulateListWithTestData

        private void PopulateListWithTestData()
        {
            _clientContext = new ClientContext("http://jakesharepointsaturday.sharepoint.com/TeamSite");

            Web site = _clientContext.Web;
            _list = site.Lists.GetByTitle("Death Star Inventory 2");

            for (int j = 0; j < 20; j++)
            {
                for (int i = 0; i < 100; i++)
                {
                    var newItemInfo = new ListItemCreationInformation() { LeafName = string.Format("TIE Fighter #{0}", i + (j * 100)) };
                    ListItem newItem = _list.AddItem(newItemInfo);
                    _clientContext.Load(newItem);
                    newItem["Item_x0020_Type"] = "TIE Fighter";
                    newItem["Fire_x0020_Power"] = 1;
                    newItem.Update();
                }
                _clientContext.ExecuteQueryAsync(SuccessCallback, FailedCallback);
            }

            for (int j = 0; j < 10; j++)
            {
                for (int i = 0; i < 100; i++)
                {
                    var newItemInfo = new ListItemCreationInformation() { LeafName = string.Format("Turbo Laser Battery #{0}", i + (j * 100)) };
                    ListItem newItem = _list.AddItem(newItemInfo);
                    _clientContext.Load(newItem);
                    newItem["Item_x0020_Type"] = "Turbo Laser";
                    newItem["Fire_x0020_Power"] = 4;
                    newItem.Update();
                }
                _clientContext.ExecuteQueryAsync(SuccessCallback, FailedCallback);
            }
        }
开发者ID:bkama,项目名称:presentations,代码行数:35,代码来源:MainPage.xaml.cs


注:本文中的List.AddItem方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。