本文整理汇总了C#中IPackage.ReplaceResource方法的典型用法代码示例。如果您正苦于以下问题:C# IPackage.ReplaceResource方法的具体用法?C# IPackage.ReplaceResource怎么用?C# IPackage.ReplaceResource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPackage
的用法示例。
在下文中一共展示了IPackage.ReplaceResource方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Import
public override bool Import(string filename, IPackage package)
{
ImageResource.ImageResource resource = CreateResource(package) as ImageResource.ImageResource;
FileStream fileStream = new FileStream(filename, FileMode.Open, FileAccess.Read);
try
{
using (BinaryReader stream = new BinaryReader(fileStream))
{
resource.Stream.Position = 0;
resource.Stream.SetLength(stream.BaseStream.Length);
resource.Stream.Write(stream.ReadBytes((int)stream.BaseStream.Length), 0, (int)stream.BaseStream.Length);
}
package.ReplaceResource(mEntry, resource);
return true;
}
catch (Exception ex)
{
MainForm.IssueError(ex, "Import failed.");
return false;
}
finally
{
fileStream.Close();
}
}
示例2: Import
public override bool Import(string filename, IPackage package)
{
TextResource.TextResource resource = CreateResource(package) as TextResource.TextResource;
FileStream stream = new FileStream(filename, FileMode.Open, FileAccess.Read);
try
{
resource.TextFileReader = new StreamReader(stream);
package.ReplaceResource(mEntry, resource);
return true;
}
catch (Exception ex)
{
MainForm.IssueError(ex, "Import failed.");
return false;
}
finally
{
stream.Close();
}
}
示例3: Import
public bool Import(Dictionary<ulong, Lookup> elements, IPackage package)
{
StblResource.StblResource resource = CreateResource(package) as StblResource.StblResource;
resource.Clear();
string instance = mEntry["Instance"];
bool keyLoad = false;
if (instance.StartsWith("0x17"))
{
keyLoad = true;
}
foreach (KeyValuePair<ulong, Lookup> element in elements)
{
if (keyLoad)
{
string value = element.Value.mKey;
if (element.Value.mSpace)
{
value = "PackerSpace|" + value;
}
resource.Add(element.Key, value);
}
else
{
resource.Add(element.Key, element.Value.mText);
}
}
package.ReplaceResource(mEntry, resource);
return true;
}
示例4: exportResourceToPackage
private void exportResourceToPackage(IPackage tgtpkg, IResourceIndexEntry srcrie, bool replace)
{
IResourceIndexEntry rie = tgtpkg.Find(x => ((IResourceKey)srcrie).Equals(x));
if (rie != null)
{
if (!replace) return;
tgtpkg.DeleteResource(rie);
}
rie = tgtpkg.AddResource(srcrie, null, true);
if (rie == null) return;
rie.Compressed = srcrie.Compressed;
IResource srcres = s4pi.WrapperDealer.WrapperDealer.GetResource(0, CurrentPackage, srcrie, true);//Don't need wrapper
tgtpkg.ReplaceResource(rie, srcres);
}
示例5: AddNew
public bool AddNew(ulong instance, IPackage package, bool autoSet)
{
mPackage = package;
string filename = GetFilename(autoSet, true);
if (string.IsNullOrEmpty(filename)) return false;
string name = CreateInstance(filename, ref instance);
if (instance == 0) return false;
Set (mPackage.AddResource(new AResource.TGIBlock(0, null, (uint)Type, 0, instance), null, false), mPackage);
if (mEntry == null) return false;
if (File.Exists(filename))
{
Filename = filename;
}
else
{
mPackage.ReplaceResource(mEntry, ResourceHandlers.CreateResource(mEntry, mPackage));
}
Name = name;
return true;
}