/// <summary> /// Exports a set of resource types into the portable object file. /// </summary> /// <param name="provider">The provider.</param> /// <param name="objects">The objects.</param> /// <returns>The PO file.</returns> public virtual File Export(ResourceProvider provider, ResourceObjectProviderBase objects = null) { var culture = Culture ?? CultureInfo.InstalledUICulture; var originalContext = new LocalizationContext(EmptyResourceProvider.Instance, CultureInfo.InvariantCulture, new ResourceObjectProvider()); var translatedContext = new LocalizationContext(new GettextResourceProvider(provider), culture, objects); var list = new List<Entry>(); var stringType = typeof (string); CachedResourceObjectProvider.RemoveAllCachedObjects(); foreach (var type in _types) { var original = originalContext.GetResourceObject(type); var translated = translatedContext.GetResourceObject(type); var set = type.FullName; var comments = GetComments(type.GetCustomAttributes<POCommentAttribute>()); list.AddRange(ResourceObjectProviderBase.EnumerateFields(type).Where(x => x.FieldType == stringType).Select(field => new Entry { Context = string.Format("{0}.{1}", set, field.Name), OriginalText = (string) field.GetValue(original), TranslatedText = (string) field.GetValue(translated), Comments = GetComments(field.GetCustomAttributes<POCommentAttribute>(), comments) })); list.AddRange(ResourceObjectProviderBase.EnumerateProperties(type).Where(x => x.PropertyType == stringType).Select(property => new Entry { Context = string.Format("{0}.{1}", set, property.Name), OriginalText = (string)property.GetValue(original, null), TranslatedText = (string)property.GetValue(original, null), Comments = GetComments(property.GetCustomAttributes<POCommentAttribute>(), comments) })); } CachedResourceObjectProvider.RemoveAllCachedObjects(); return new File(Name, culture.Name, list); }