/// <summary> /// Получает объект типа McEvent из дерева связанных EntityObject (EntityObjectHierarchy) /// </summary> /// <param name="entityHierarchy">The entity hierarchy.</param> /// <returns></returns> public static McEvent GetMcEventFromEntityObjectHierarchy(EntityObjectHierarchy entityHierarchy) { McEvent retVal = new McEvent(); McSerializerFactory factory = new McSerializerFactory(); IEntitySerializable serializer = factory.Create <IEntitySerializable>(retVal); retVal = (McEvent)serializer.Deserialize <CalendarEventEntity>(entityHierarchy.InnerEntity); foreach (EntityObjectHierarchy child in entityHierarchy.Childrens) { if (child.InnerEntity.MetaClassName == CalendarEventRecurrenceEntity.ClassName) { McRecurrencePattern rPattern = new McRecurrencePattern(); retVal.AddChild(rPattern); serializer = factory.Create <IEntitySerializable>(rPattern); if (serializer != null) { rPattern = (McRecurrencePattern)serializer.Deserialize <CalendarEventRecurrenceEntity>(child.InnerEntity); retVal.RRule = new RecurrencePattern[] { rPattern }; } } else if (child.InnerEntity.MetaClassName == CalendarEventResourceEntity.ClassName) { McCalAddress resource = new McCalAddress(); retVal.AddChild(resource); serializer = factory.Create <IEntitySerializable>(resource); if (serializer != null) { resource = (McCalAddress)serializer.Deserialize <CalendarEventResourceEntity>(child.InnerEntity); retVal.AddChild(resource); if (((CalendarEventResourceEntity)child.InnerEntity).ResourceEventOrganizator) { retVal.Organizer = resource; } else { List <Cal_Address> oldVals = new List <Cal_Address>(); if (retVal.Attendee != null) { oldVals.AddRange(retVal.Attendee); } oldVals.Add(resource); retVal.Attendee = oldVals.ToArray(); } } } else if (child.InnerEntity.MetaClassName == CalendarEventEntity.ClassName) { McEvent exception = GetMcEventFromEntityObjectHierarchy(child); if (exception != null) { retVal.AddReccurenceException(exception); } } } return(retVal); }
public void AddReccurenceException(McEvent eventException) { if (_recurrenceException.Contains(eventException)) { return; } _recurrenceException.Add(eventException); }
public void AddReccurenceException(McEvent eventException) { if (_recurrenceException.Contains(eventException)) return; _recurrenceException.Add(eventException); }
/// <summary> /// Получает объект типа McEvent из дерева связанных EntityObject (EntityObjectHierarchy) /// </summary> /// <param name="entityHierarchy">The entity hierarchy.</param> /// <returns></returns> public static McEvent GetMcEventFromEntityObjectHierarchy(EntityObjectHierarchy entityHierarchy) { McEvent retVal = new McEvent(); McSerializerFactory factory = new McSerializerFactory(); IEntitySerializable serializer = factory.Create<IEntitySerializable>(retVal); retVal = (McEvent)serializer.Deserialize<CalendarEventEntity>(entityHierarchy.InnerEntity); foreach (EntityObjectHierarchy child in entityHierarchy.Childrens) { if (child.InnerEntity.MetaClassName == CalendarEventRecurrenceEntity.ClassName) { McRecurrencePattern rPattern = new McRecurrencePattern(); retVal.AddChild(rPattern); serializer = factory.Create<IEntitySerializable>(rPattern); if (serializer != null) { rPattern = (McRecurrencePattern)serializer.Deserialize<CalendarEventRecurrenceEntity>(child.InnerEntity); retVal.RRule = new RecurrencePattern[] { rPattern }; } } else if (child.InnerEntity.MetaClassName == CalendarEventResourceEntity.ClassName) { McCalAddress resource = new McCalAddress(); retVal.AddChild(resource); serializer = factory.Create<IEntitySerializable>(resource); if(serializer != null) { resource = (McCalAddress)serializer.Deserialize<CalendarEventResourceEntity>(child.InnerEntity); retVal.AddChild(resource); if(((CalendarEventResourceEntity)child.InnerEntity).ResourceEventOrganizator) { retVal.Organizer = resource; } else { List<Cal_Address> oldVals = new List<Cal_Address>(); if (retVal.Attendee != null) { oldVals.AddRange(retVal.Attendee); } oldVals.Add(resource); retVal.Attendee = oldVals.ToArray(); } } } else if (child.InnerEntity.MetaClassName == CalendarEventEntity.ClassName) { McEvent exception = GetMcEventFromEntityObjectHierarchy(child); if (exception != null) { retVal.AddReccurenceException(exception); } } } return retVal; }