public ActionResult Save(Bam.Net.Services.DataReplication.Data.Dao.DataProperty[] values) { try { DataPropertyCollection saver = new DataPropertyCollection(); saver.AddRange(values); saver.Save(); return(Json(new { Success = true, Message = "", Dao = "" })); } catch (Exception ex) { return(GetErrorResult(ex)); } }
public void ThrowsOnDuplicateName() { DataPropertyCollection propList = new DataPropertyCollection(); propList.Add("Name", "some value"); Expect.Throws(() => { propList.Add("Name", "bad bad"); }, (ex) => { OutLineFormat("{0}", ConsoleColor.Yellow, ex.Message); }, "Should have thrown exception"); }
public void ToAndFromDataPropertyCollection() { TestMonkey value = new TestMonkey { Monkey = "Yay", HasTail = false }; DataPropertyCollection dpc = value.ToDataPropertyCollection(); Expect.AreEqual(value.Monkey, dpc.Value <string>("Monkey")); Expect.IsFalse(dpc.Value <bool>("HasTail")); TestMonkey valueAgain = dpc.ToInstance <TestMonkey>(); Expect.AreEqual(valueAgain.Monkey, value.Monkey); Expect.AreEqual(valueAgain.HasTail, value.HasTail); }
public void CanSerializeAndDeserializeDataPropertyList() { DataPropertyCollection propList = new DataPropertyCollection(); propList.Add("Prop1", true); propList.Add("Prop2", false); propList.Add("Name", "Banana"); byte[] serialized = propList.ToBinaryBytes(); DataPropertyCollection deserialized = serialized.FromBinaryBytes <DataPropertyCollection>(); Expect.AreEqual(3, deserialized.Count); Expect.IsTrue(deserialized.Value <bool>("Prop1")); Expect.IsFalse(deserialized.Value <bool>("Prop2")); Expect.AreEqual("Banana", deserialized.Value <string>("Name")); }
// implement execute method public override int Execute(params string[] parameters) { // current document Document doc = Application.ActiveDocument; // display message StringBuilder message = new StringBuilder(); // SearchBox form SearchBox sb = new SearchBox(); // show form sb.ShowDialog(); // assign Id value int Id = 0; try { // convert sb return value string to int Id = Convert.ToInt32(sb.ReturnValue); } catch { } // create search object Search search = new Search(); // selection to search search.Selection.SelectAll(); // create SearchCondition by InternalName of Category & Property // to find the specific item by its ID SearchCondition condition = SearchCondition.HasPropertyByName("LcRevitData_Element", "LcRevitPropertyElementId").EqualValue(new VariantData(Id)); /* * // create SearchCondition by DisplayName of Category & Property * // to find the specific item by its ID * SearchCondition condition = SearchCondition.HasPropertyByDisplayName("Element", * "Id").EqualValue(new VariantData(Id)); */ // SearchCondition to applied during search search.SearchConditions.Add(condition); // collect model item (if found) ModelItem item = search.FindFirst(doc, false); // item found if (item != null) { // make selection doc.CurrentSelection.Add(item); // get modelitem's Element category by display name method PropertyCategory elementCategory = item.PropertyCategories. FindCategoryByDisplayName("Element"); // all properties of Element category DataPropertyCollection dataProperties = elementCategory.Properties; // display properties count message.Append(String.Format("[{0}] ModelItem's Element Category has {1} Properties.\n", Id.ToString(), dataProperties.Count)); // index int index = 1; // iterate properties foreach (DataProperty dp in elementCategory.Properties) { // append to display "Property Display Name & Property Value(includes DataType)" message.Append(String.Format("{0}. {1} => {2}\n", index, dp.DisplayName, dp.Value)); // index increment index += 1; } // display message wf.MessageBox.Show(message.ToString(), "Element Category"); } // return value return(0); }
public void CanSerializeAndDeserializeDataPropertyList() { DataPropertyCollection list = new DataPropertyCollection(); list.Prop("Monkey", true); }