private void LoadChildNodesCollection(IStorePropertyBag[] rows, int startIndex)
 {
     for (int i = startIndex; i < rows.Length; i++)
     {
         IStorePropertyBag storePropertyBag = rows[i];
         if (CalendarGroup.IsCalendarSection(storePropertyBag) && CalendarGroup.IsFolderTreeData(storePropertyBag) && CalendarGroup.IsCalendarGroupEntry(storePropertyBag))
         {
             byte[] valueOrDefault = storePropertyBag.GetValueOrDefault <byte[]>(FolderTreeDataSchema.ParentGroupClassId, null);
             if (valueOrDefault == null || valueOrDefault.Length != 16)
             {
                 ExTraceGlobals.StorageTracer.TraceDebug <int>(0L, "Found CalendarGroupEntry with invalid parent group id. ArrayLength: {0}", (valueOrDefault == null) ? -1 : valueOrDefault.Length);
             }
             else
             {
                 Guid g = new Guid(valueOrDefault);
                 if (this.groupClassId.Equals(g))
                 {
                     CalendarGroupEntryInfo calendarGroupEntryInfoFromRow = CalendarGroupEntry.GetCalendarGroupEntryInfoFromRow(storePropertyBag);
                     if (calendarGroupEntryInfoFromRow != null)
                     {
                         this.children.Add(calendarGroupEntryInfoFromRow);
                     }
                 }
             }
         }
     }
     this.hasLoadedCalendarsCollection = true;
 }
        private static void AddCalendarToList(IStorePropertyBag row, Dictionary <Guid, CalendarGroupInfo> guidToGroupMapping, Dictionary <StoreObjectId, LocalCalendarGroupEntryInfo> calendarIdToGroupEntryMapping, CalendarGroupInfoList calendarGroups)
        {
            CalendarGroupEntryInfo calendarGroupEntryInfoFromRow = CalendarGroupEntry.GetCalendarGroupEntryInfoFromRow(row);

            if (calendarGroupEntryInfoFromRow == null)
            {
                return;
            }
            CalendarGroupInfo calendarGroupInfo;

            if (!guidToGroupMapping.TryGetValue(calendarGroupEntryInfoFromRow.ParentGroupClassId, out calendarGroupInfo))
            {
                ExTraceGlobals.StorageTracer.TraceDebug <string, Guid, VersionedId>(0L, "Found a calendar group entry with an invalid parent id. CalendarName: {0}, ParentId: {1}, ItemId: {2}", calendarGroupEntryInfoFromRow.CalendarName, calendarGroupEntryInfoFromRow.ParentGroupClassId, calendarGroupEntryInfoFromRow.Id);
                return;
            }
            LocalCalendarGroupEntryInfo localCalendarGroupEntryInfo = calendarGroupEntryInfoFromRow as LocalCalendarGroupEntryInfo;

            if (calendarGroupEntryInfoFromRow != null && calendarGroupEntryInfoFromRow.CalendarId != null && calendarGroupEntryInfoFromRow.CalendarId.IsPublicFolderType())
            {
                foreach (CalendarGroupEntryInfo calendarGroupEntryInfo in calendarGroupInfo.Calendars)
                {
                    if (calendarGroupEntryInfo.CalendarId != null && calendarGroupEntryInfo.CalendarId.Equals(calendarGroupEntryInfoFromRow.CalendarId))
                    {
                        return;
                    }
                }
            }
            if (localCalendarGroupEntryInfo != null)
            {
                LocalCalendarGroupEntryInfo localCalendarGroupEntryInfo2;
                if (calendarIdToGroupEntryMapping.TryGetValue(localCalendarGroupEntryInfo.CalendarId, out localCalendarGroupEntryInfo2))
                {
                    if (localCalendarGroupEntryInfo2.LastModifiedTime.CompareTo(localCalendarGroupEntryInfo.LastModifiedTime) > 0)
                    {
                        calendarGroups.DuplicateNodes.Add(localCalendarGroupEntryInfo);
                        return;
                    }
                    calendarGroups.DuplicateNodes.Add(localCalendarGroupEntryInfo2);
                    guidToGroupMapping[localCalendarGroupEntryInfo2.ParentGroupClassId].Calendars.Remove(localCalendarGroupEntryInfo2);
                    calendarIdToGroupEntryMapping[localCalendarGroupEntryInfo.CalendarId] = localCalendarGroupEntryInfo;
                }
                else
                {
                    calendarIdToGroupEntryMapping.Add(localCalendarGroupEntryInfo.CalendarId, localCalendarGroupEntryInfo);
                }
            }
            calendarGroupInfo.Calendars.Add(calendarGroupEntryInfoFromRow);
        }