Book a Demo

Author Topic: Set initial value of a property  (Read 2856 times)

eaeio

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Set initial value of a property
« on: March 03, 2011, 12:05:38 am »
Sample code below.  Say I want to set the value of 2 different properties.  using the sample code below.  I am unable to do this because it ends up setting ALL the properties to the last value set (1001).  I may be looking at the wrong place.

private void test2(EA.Repository Repository)
        {
            EA.Element element = Repository.GetElementByGuid("{9F605559-A9AF-45d2-8FB1-5EECF51DFC25}");
            foreach (EA.CustomProperty prop in element.CustomProperties)
            {
                Repository.WriteOutput(ID, prop.Name + prop.Value, -1);
                if (prop.Name == "default")
                {
                    prop.Value = "1000";
                }
            }
            EA.Element element2 = Repository.GetElementByGuid("{F0B6DB5E-BFA4-4aa7-887A-29A92111E62E}");
            foreach (EA.CustomProperty prop in element2.CustomProperties)
            {
                Repository.WriteOutput(ID, prop.Name + prop.Value, -1);
                if (prop.Name == "default")
                {
                    prop.Value = "1001";
                }
            }
        }