public object Deserialize<T>(Mediachase.Ibn.Core.Business.EntityObject entity) { if(entity.PrimaryKeyId != null) { McCalAddress mcCalAddress = Resource as McCalAddress; if (mcCalAddress != null) { mcCalAddress.MetaObjectId = entity.PrimaryKeyId.Value; } } foreach (EntityObjectProperty entityProp in entity.Properties) { iCal2EntityMapping.MappingResult mapRes = iCal2EntityMapping.EntityProp2iCalProp<T>(entityProp.Name); if (entityProp.Value == null || mapRes == null) continue; if (mapRes.Name.StartsWith("X-")) { Resource.AddParameter(mapRes.Name, entityProp.Value.ToString()); continue; } switch (mapRes.Name) { case "Authority": Resource.Scheme = Uri.UriSchemeMailto; Resource.Authority = entityProp.Value.ToString(); break; } } return Resource; }
public object Deserialize <T>(Mediachase.Ibn.Core.Business.EntityObject entity) { if (entity.PrimaryKeyId != null) { InnerEvent.UID = new Text(entity.PrimaryKeyId.Value.ToString()); } foreach (EntityObjectProperty entityProp in entity.Properties) { iCal2EntityMapping.MappingResult mapRes = iCal2EntityMapping.EntityProp2iCalProp <T>(entityProp.Name); //Пропускаем пустые свойства if (entityProp.Value == null || mapRes == null) { continue; } if (mapRes.Name.StartsWith("X-")) { InnerEvent.AddProperty(mapRes.Name, entityProp.Value.ToString()); continue; } switch (mapRes.Name) { case "CATEGORIES": InnerEvent.Categories = new TextCollection[] { new TextCollection(entityProp.Value.ToString()) }; break; case "DTSTART": InnerEvent.DTStart = (DateTime)entityProp.Value; break; case "DTEND": InnerEvent.DTEnd = (DateTime)entityProp.Value; break; case "DTSTART.TZID": case "DTEND.TZID": if (entityProp.Name == CalendarEventEntity.FieldEndTimeZoneOffset) { InnerEvent.DTEnd.AddParameter(mapRes.Name, entityProp.Value.ToString()); } else { InnerEvent.DTStart.AddParameter(mapRes.Name, entityProp.Value.ToString()); } break; case "PRIORITY": InnerEvent.Priority = new Integer((int)entityProp.Value); break; case "CLASS": InnerEvent.Class = new Text(entityProp.Value.ToString()); break; case "SUMMARY": InnerEvent.Summary = new Text(entityProp.Value.ToString()); break; case "LOCATION": InnerEvent.Location = new Text(entityProp.Value.ToString()); break; case "DESCRIPTION": InnerEvent.Description = new Text(entityProp.Value.ToString()); break; case "RECURRENCE-ID": InnerEvent.Recurrence_ID = new iCalDateTime(entityProp.Value.ToString()); break; } } return(InnerEvent); }