Beispiel #1
0
        private void CopyRIList(IObservableList sourceList, IObservableList targetList, List <GuidMapper> guidMappingList, bool setNewGUID)
        {
            for (int i = 0; i < sourceList.Count; i++)
            {
                object item = sourceList[i];
                if (item is RepositoryItemBase)
                {
                    RepositoryItemBase RI = CopyRIObject(item as RepositoryItemBase, guidMappingList, setNewGUID);
                    if (setNewGUID)
                    {
                        GuidMapper mapping = new GuidMapper();
                        mapping.Original = RI.Guid;
                        RI.Guid          = Guid.NewGuid();
                        mapping.newGuid  = RI.Guid;
                        guidMappingList.Add(mapping);

                        if ((item as RepositoryItemBase).IsSharedRepositoryInstance && (item as RepositoryItemBase).ParentGuid == Guid.Empty)
                        {
                            RI.ParentGuid = mapping.Original;
                        }
                    }
                    targetList.Add(RI);
                }
                else
                {
                    targetList.Add(item);
                }
            }
        }
Beispiel #2
0
 private void CopyRIList(IObservableList sourceList, IObservableList targetList, List <GuidMapper> guidMappingList, bool setNewGUID)
 {
     foreach (object item in sourceList)
     {
         if (item is RepositoryItemBase)
         {
             RepositoryItemBase RI = CopyRIObject(item as RepositoryItemBase, guidMappingList, setNewGUID);
             if (setNewGUID)
             {
                 GuidMapper mapping = new GuidMapper();
                 mapping.Original = RI.Guid;
                 RI.Guid          = Guid.NewGuid();
                 mapping.newGuid  = RI.Guid;
                 guidMappingList.Add(mapping);
             }
             targetList.Add(RI);
         }
         else
         {
             targetList.Add(item);
         }
     }
 }
Beispiel #3
0
        private void UpdateRepoItemGuids(RepositoryItemBase item, List <GuidMapper> guidMappingList)
        {
            foreach (FieldInfo PI in item.GetType().GetFields())
            {
                var token = PI.GetCustomAttribute(typeof(IsSerializedForLocalRepositoryAttribute));
                if (token == null)
                {
                    continue;
                }

                // we drill down to ObservableList
                if (typeof(IObservableList).IsAssignableFrom(PI.FieldType))
                {
                    IObservableList obj = (IObservableList)PI.GetValue(item);
                    if (obj == null)
                    {
                        return;
                    }
                    List <object> items = ((IObservableList)obj).ListItems;

                    if ((items != null) && (items.Count > 0) && (items[0].GetType().IsSubclassOf(typeof(RepositoryItemBase))))
                    {
                        foreach (RepositoryItemBase ri in items.Cast <RepositoryItemBase>())
                        {
                            GuidMapper mapping = new GuidMapper();
                            mapping.Original = ri.Guid;
                            ri.Guid          = Guid.NewGuid();
                            mapping.newGuid  = ri.Guid;

                            guidMappingList.Add(mapping);

                            UpdateRepoItemGuids(ri, guidMappingList);
                        }
                    }
                }
            }
        }