Пример #1
0
 public void ArrayUtility_Convert_1()
 {
     int[]   source = { 1, 2, 3 };
     short[] target = ArrayUtility.Convert <int, short>(source);
     Assert.AreEqual(source.Length, target.Length);
     for (int i = 0; i < source.Length; i++)
     {
         Assert.IsTrue
         (
             (short)source[i] == target[i]
         );
     }
 }
        private void AddRowsButton_Click(object sender, EventArgs e)
        {
            int count = 0;

            if (NumberOfNewRowsField.Validate())
            {
                count = (int)NumberOfNewRowsField.Value;
            }

            Person[] persons = new Person[count];
            for (int i = 0; i < count; i++)
            {
                persons[i] = Person.CreateObject(Guid.NewGuid());
            }

            ChildrenList.AddRows((IBusinessObjectWithIdentity[])ArrayUtility.Convert(persons, typeof(IBusinessObjectWithIdentity)));
        }
Пример #3
0
        /// <summary>
        ///   Queries <see cref="IBusinessObjectReferenceProperty.SearchAvailableObjects"/> for the
        ///   <see cref="IBusinessObjectWithIdentity"/> objects to be displayed in edit mode and sets the list with the
        ///   objects returned by the query.
        /// </summary>
        /// <remarks>
        ///   <para>
        ///     Uses the <see cref="Select"/> statement to query the <see cref="BocReferenceValueBase.Property"/>'s
        ///     <see cref="IBusinessObjectReferenceProperty.SearchAvailableObjects"/> method for the list contents.
        ///   </para><para>
        ///     Only populates the list if <see cref="EnableSelectStatement"/> is not <see langword="false"/>.
        ///     Otherwise the list will be left empty.
        ///   </para>
        /// </remarks>
        protected void PopulateBusinessObjectList()
        {
            if (!IsSelectStatementEnabled)
            {
                return;
            }

            if (Property == null)
            {
                return;
            }

            IBusinessObject[] businessObjects = null;

            //  Get all matching business objects
            if (DataSource != null)
            {
                businessObjects = Property.SearchAvailableObjects(DataSource.BusinessObject, new DefaultSearchArguments(_select));
            }

            RefreshBusinessObjectList(ArrayUtility.Convert <IBusinessObject, IBusinessObjectWithIdentity> (businessObjects));
        }
Пример #4
0
 public T[] ToArray()
 {
     return(ArrayUtility.Convert(this));
 }
 public PropertyBase[] ToArray()
 {
     return(ArrayUtility.Convert(_innerCollection));
 }
        private void Page_Load(object sender, EventArgs e)
        {
            var personID = new Guid(((ViewPersonDetailsWxeFunction)CurrentFunction).ID);

            Person person = Person.GetObject(personID);

#pragma warning disable 219 // unused variable
            Person partner;
            if (person != null)
            {
                partner = person.Partner;
            }
#pragma warning restore 219

            CurrentObject.BusinessObject = (IBusinessObjectWithIdentity)person;
            CurrentObject.LoadValues(IsPostBack);

            if (!IsPostBack)
            {
                IBusinessObjectWithIdentity[] objects = (IBusinessObjectWithIdentity[])ArrayUtility.Convert(
                    XmlReflectionBusinessObjectStorageProvider.Current.GetObjects(typeof(Person)), typeof(IBusinessObjectWithIdentity));
                PartnerField.SetBusinessObjectList(objects);
            }
        }
        private void Page_Load(object sender, EventArgs e)
        {
            Guid   personID = new Guid(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1);
            Person person   = Person.GetObject(personID);
            Person partner;

            if (person == null)
            {
                person             = Person.CreateObject(personID);
                person.FirstName   = "Hugo";
                person.LastName    = "Meier";
                person.DateOfBirth = new DateTime(1959, 4, 15);
                person.Height      = 179;
                person.Income      = 2000;

                partner           = person.Partner = Person.CreateObject();
                partner.FirstName = "Sepp";
                partner.LastName  = "Forcher";
            }
            else
            {
                partner = person.Partner;
            }

            CurrentObject.BusinessObject = (IBusinessObject)person;
            CurrentObject.LoadValues(IsPostBack);

            if (!IsPostBack)
            {
                IBusinessObjectWithIdentity[] objects = (IBusinessObjectWithIdentity[])ArrayUtility.Convert(
                    XmlReflectionBusinessObjectStorageProvider.Current.GetObjects(typeof(Person)), typeof(IBusinessObjectWithIdentity));
                ReferenceField.SetBusinessObjectList(objects);
            }
        }
Пример #8
0
        override protected void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            Person person = (Person)CurrentObject.BusinessObject;

            if (!IsPostBack)
            {
                IBusinessObjectWithIdentity[] objects = (IBusinessObjectWithIdentity[])ArrayUtility.Convert(
                    XmlReflectionBusinessObjectStorageProvider.Current.GetObjects(typeof(Person)), typeof(IBusinessObjectWithIdentity));
                UnboundPartnerField.SetBusinessObjectList(objects);
                DisabledUnboundPartnerField.SetBusinessObjectList(objects);
            }

            UnboundPartnerField.Property = (IBusinessObjectReferenceProperty)CurrentObject.BusinessObjectClass.GetPropertyDefinition("Partner");
            //UnboundPartnerField.LoadUnboundValue (person.Partner, IsPostBack);
            UnboundReadOnlyPartnerField.Property = (IBusinessObjectReferenceProperty)CurrentObject.BusinessObjectClass.GetPropertyDefinition("Partner");
            UnboundReadOnlyPartnerField.LoadUnboundValue((IBusinessObjectWithIdentity)person.Partner, IsPostBack);
            DisabledUnboundPartnerField.Property = (IBusinessObjectReferenceProperty)CurrentObject.BusinessObjectClass.GetPropertyDefinition("Partner");
            DisabledUnboundPartnerField.LoadUnboundValue((IBusinessObjectWithIdentity)person.Partner, IsPostBack);
            DisabledUnboundReadOnlyPartnerField.Property = (IBusinessObjectReferenceProperty)CurrentObject.BusinessObjectClass.GetPropertyDefinition("Partner");
            DisabledUnboundReadOnlyPartnerField.LoadUnboundValue((IBusinessObjectWithIdentity)person.Partner, IsPostBack);

            if (!IsPostBack)
            {
                if (Page is ISmartNavigablePage)
                {
                    ((ISmartNavigablePage)Page).SetFocus(PartnerField);
                }
            }
        }
 public void TestConvertWithNull()
 {
     Assert.That(ArrayUtility.Convert <object, string> (null), Is.Null);
 }
 public void TestConvert()
 {
     object[] o1  = { "a", "b", "c", "d" };
     string[] res = ArrayUtility.Convert <object, string> (o1);
     Assert.That(string.Concat(res), Is.EqualTo("abcd"));
 }