当前位置: 首页>>代码示例>>C#>>正文


C# IPackage.ReplaceResource方法代码示例

本文整理汇总了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();
            }
        }
开发者ID:Robobeurre,项目名称:NRaas,代码行数:27,代码来源:IMAGImporter.cs

示例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();
            }
        }
开发者ID:Robobeurre,项目名称:NRaas,代码行数:22,代码来源:TextImporter.cs

示例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;
        }
开发者ID:Robobeurre,项目名称:NRaas,代码行数:36,代码来源:STBLImporter.cs

示例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);
        }
开发者ID:Kuree,项目名称:Sims4Tools,代码行数:16,代码来源:MainForm.cs

示例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;
        }
开发者ID:Robobeurre,项目名称:NRaas,代码行数:26,代码来源:ListItem.cs


注:本文中的IPackage.ReplaceResource方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。