Browse Source

fix http://community.sharpdevelop.net/forums/p/15639/39951.aspx#39951

project (and thus the target framework) was improperly detected for newly generated resource files (not yet written to disk).
pull/6/merge
Siegfried Pammer 14 years ago
parent
commit
9260c46613
  1. 14
      src/AddIns/DisplayBindings/FormsDesigner/Project/Src/Services/ResourceStore.cs

14
src/AddIns/DisplayBindings/FormsDesigner/Project/Src/Services/ResourceStore.cs

@ -37,7 +37,7 @@ namespace ICSharpCode.FormsDesigner.Services
{ {
ResourceStorage storage; ResourceStorage storage;
if (!resources.TryGetValue(culture.Name, out storage)) { if (!resources.TryGetValue(culture.Name, out storage)) {
storage = resources[culture.Name] = new ResourceStorage(culture.Name); storage = resources[culture.Name] = new ResourceStorage(culture.Name, viewContent.PrimaryFileName);
string fileName = CalcResourceFileName(viewContent.PrimaryFileName, culture.Name); string fileName = CalcResourceFileName(viewContent.PrimaryFileName, culture.Name);
CreateOpenedFileForStorage(storage, fileName, File.Exists(fileName)); CreateOpenedFileForStorage(storage, fileName, File.Exists(fileName));
} }
@ -108,12 +108,14 @@ namespace ICSharpCode.FormsDesigner.Services
IResourceWriter writer; IResourceWriter writer;
byte[] buffer; byte[] buffer;
readonly string cultureName; readonly string cultureName;
string parentDesignerSourceFileName;
internal OpenedFile OpenedFile; internal OpenedFile OpenedFile;
internal bool IsNewFile; internal bool IsNewFile;
public ResourceStorage(string cultureName) public ResourceStorage(string cultureName, string parentDesignerSourceFileName)
{ {
this.cultureName = cultureName; this.cultureName = cultureName;
this.parentDesignerSourceFileName = parentDesignerSourceFileName;
} }
public void Dispose() public void Dispose()
@ -204,7 +206,7 @@ namespace ICSharpCode.FormsDesigner.Services
public IResourceWriter GetWriter() public IResourceWriter GetWriter()
{ {
this.stream = new MemoryStream(); this.stream = new MemoryStream();
this.writer = CreateResourceWriter(this.stream, OpenedFile.FileName); this.writer = CreateResourceWriter(this.stream, GetResourceType(OpenedFile.FileName), parentDesignerSourceFileName);
return this.writer; return this.writer;
} }
@ -335,12 +337,12 @@ namespace ICSharpCode.FormsDesigner.Services
return new ResXResourceReader(stream); return new ResXResourceReader(stream);
} }
internal static IResourceWriter CreateResourceWriter(Stream stream, string fileName) internal static IResourceWriter CreateResourceWriter(Stream stream, ResourceType type, string parentDesignerSourceFileName)
{ {
if (GetResourceType(fileName) == ResourceType.Resources) { if (type == ResourceType.Resources) {
return new ResourceWriter(stream); return new ResourceWriter(stream);
} }
return new ResXResourceWriter(stream, t => ResXConverter.ConvertTypeName(t, fileName)); return new ResXResourceWriter(stream, t => ResXConverter.ConvertTypeName(t, parentDesignerSourceFileName));
} }
internal static ResourceType GetResourceType(string fileName) internal static ResourceType GetResourceType(string fileName)

Loading…
Cancel
Save