/// <summary> /// Updates the field. /// </summary> /// <param name='f'> /// F. /// </param> /// <exception cref='ArgumentNullException'> /// Is thrown when an argument passed to a method is invalid because it is <see langword="null" /> . /// </exception> public void UpdateField(AssetFieldEntry f) { if(f==null) throw new ArgumentNullException(); int i = 0; foreach (AssetFieldEntry d in FieldList){ if( d.Name.Equals(f.Name)){ FieldList.SetValue(f,i); return; } i++; } //if we got this far then we will add the field - and as these are tiny, just resize the array Array.Resize<AssetFieldEntry>(ref fields, fields.Length +1); FieldList.SetValue(f,fields.Length-1); }
public void testAssetSummary() { AssetSummary o = new AssetSummary(); DateTime create = DateTime.Now; o.CreateDate = create.ToString(); o.CreatedBy = "createbytest"; o.Id = "idtest"; o.Language = "langtest"; DateTime lastmod = DateTime.Now; o.LastModifiedDate = lastmod.ToString(); o.LastModifier = "lastmod"; o.Name = "nametes"; o.Path = "/tsh/"; DateTime pubdate = DateTime.Now; o.PublishDate = pubdate.ToString(); o.Revision = "testrev"; o.Type = "testtype"; AssetFieldEntry f1 = new AssetFieldEntry("name1","val1"); AssetFieldEntry f2 = new AssetFieldEntry("name2","val2"); // o.Fields.Add(f1.Name,f1); // o.Fields.Add(f2.Name,f2); Assert.AreEqual(create.ToString(),o.CreateDate); Assert.AreEqual("createbytest",o.CreatedBy); Assert.AreEqual("idtest",o.Id); Assert.AreEqual("langtest",o.Language); Assert.AreEqual(lastmod.ToString(),o.LastModifiedDate); Assert.AreEqual("lastmod",o.LastModifier); Assert.AreEqual("nametes",o.Name); Assert.AreEqual("/tsh/",o.Path); Assert.AreEqual(pubdate.ToString(), o.PublishDate); Assert.AreEqual("testrev",o.Revision); Assert.AreEqual("testtype",o.Type); // Assert.AreEqual(2, o.Fields.Count); }
/// <summary> /// Initializes a new instance of the <see cref="Percussion.CM1.API.Content.Model.AssetFields"/> class. /// </summary> public AssetFields() { FieldList = new AssetFieldEntry[]{}; }