Exemple #1
0
        private TEntity NewTEntity(StorageItemsList storageList, Type type)
        {
            System.Reflection.ConstructorInfo _constructor = type.GetConstructor(new Type[0]);
            Debug.Assert(_constructor != null, String.Format("Cannot get constructor for the type {0}", type.Name));
            TEntity _ret = (TEntity)_constructor.Invoke(new object[0]);

            Debug.Assert(_ret != null, String.Format("Cannot invoke constructor for the type {0}", type.Name));
            AssignValues2Entity(storageList, _ret);
            return(_ret);
        }
 internal EntityListItemsCollection(DataContext dataContext, SPCList list)
 {
     this.m_list                    = list;
     this.m_DataContext             = dataContext;
     m_DerivedTypes                 = typeof(TEntity).GetDerivedTypes();
     m_EntityPropertiesDictionary   = new Dictionary <string, Dictionary <string, StorageItem> >();
     m_ListItemPropertiesDictionary = new Dictionary <string, StorageItemsList>();
     foreach (var _typeidx in m_DerivedTypes)
     {
         StorageItemsList _si = StorageItem.CreateStorageDescription(_typeidx.Value, true);
         m_EntityPropertiesDictionary.Add(_typeidx.Key, _si.Values.ToDictionary <StorageItem, string>(storageItem => storageItem.PropertyName));
         m_ListItemPropertiesDictionary.Add(_typeidx.Key, _si);
     }
 }
Exemple #3
0
 private void AssignValues2Entity(StorageItemsList storageList, TEntity _entity)
 {
     Index = MyListItem.Id;
     foreach (StorageItem _storage in storageList.Values)
     {
         if (_storage.IsReverseLookup())
         {
             _storage.AssignReverseLookupValues2Entity(m_DataContext, _entity, Index);
             continue;
         }
         if (!MyListItem.FieldValues.ContainsKey(_storage.SPFieldName))
         {
             throw new ArgumentOutOfRangeException(String.Format("Cannot get value from SharePoint for the field {0}", _storage.SPFieldName));
         }
         object Value = MyListItem.FieldValues[_storage.SPFieldName];
         _storage.AssignValue2Entity(m_DataContext, _entity, Value);
     }
 }
        /// <summary>
        /// Compares the content of the selected storages.
        /// </summary>
        /// <typeparam name="TSP">The type of the TSP.</typeparam>
        /// <typeparam name="TSQL">The type of the TSQL.</typeparam>
        /// <param name="mapping">The mapping.</param>
        /// <exception cref="System.ApplicationException">
        /// </exception>
        public static void CompareSelectedStoragesContent <TSP, TSQL>(Dictionary <string, string> mapping)
        {
            //Get SP stage info
            StorageItemsList _storageListSP = Linq2SP.StorageItem.CreateStorageDescription(typeof(TSP), false);
            //Get SQL stage info
            Dictionary <string, Link2SQL.SQLStorageItem> _storageListSQLDictionary = Link2SQL.SQLStorageItem.CreateStorageDescription(typeof(TSQL), mapping);

            //Assert.AreEqual<int>(_storageSPDictionary.Count, _storageListSQL.Count, String.Format("Storage length of {0} must be equal, if not loss of data may occur", typeof(TSP).Name));
            foreach (string _item in _storageListSQLDictionary.Keys)
            {
                if (!_storageListSP.ContainsKey(_item))
                {
                    throw new ApplicationException(String.Format("Storage SP of {1} does not contain property {0}", _item, typeof(TSP).Name));
                }
            }
            foreach (string _item in _storageListSP.Keys)
            {
                if (!_storageListSQLDictionary.ContainsKey(_item))
                {
                    throw new ApplicationException(String.Format("Storage SQL of {1} does not contain property {0}", _item, typeof(TSQL).Name));
                }
            }
        }
Exemple #5
0
 /// <summary>
 /// Assigns the values to entity.
 /// </summary>
 /// <param name="storageList">The storage dictionary containing field name and <see cref="StorageItem" /> pairs.</param>
 /// <exception cref="System.NotImplementedException">Only ColumnAttribute is supported.
 /// or
 /// IsLookupId must be true for lookup field.
 /// </exception>
 internal void AssignValues2Entity(StorageItemsList storageList)
 {
     AssignValues2Entity(storageList, this.TEntityGetter);
 }
Exemple #6
0
 internal TEntityWrapper(DataContext dataContext, ListItem listItem, Type type, StorageItemsList storageList, PropertyChangedEventHandler handler)
     : this(dataContext)
 {
     if (listItem == null)
     {
         throw new ArgumentNullException("listItem");
     }
     MyListItem                = listItem;
     ContentTypeID             = listItem.GetContentTypeID();
     this.TEntityGetter        = NewTEntity(storageList, type);
     TEntityGetter.EntityState = EntityState.Unchanged;
     TEntityGetter.OriginalValues.Clear();
     TEntityGetter.PropertyChanged += handler;
 }