Exemple #1
0
        internal void AddToCollection <WPOType>(WPOType obj)
            where WPOType : WPOBaseObject
        {
            PropertyInfo collectionProperty = GetType().GetProperties().SingleOrDefault(prop => prop.PropertyType == typeof(WPOCollection <WPOType>));

            if (collectionProperty != null)
            {
                var collection = (WPOCollection <WPOType>)GetPropertyValue(collectionProperty);
                if (collection == null)
                {
                    collection = new WPOCollection <WPOType>();
                }

                if (!collection.Contains(obj))
                {
                    collection.Add(obj);
                    collectionProperty.SetValue(this, collection);
                }
            }
        }
Exemple #2
0
 public WPOCollection <WpoObject> Cast <WpoObject>(WPOCollection <WPOBaseObject> collection)
 {
     return(new WPOCollection <WpoObject>(collection.Cast <WpoObject>()));
 }