public ResourceDataBase(IResourceFile file, string name, string value, string comment) { this.file = file; this.name = name; this.xmlValue = value; this.comment = comment; }
public TextParser(TextReader reader, IResourceFile resourceFile, string basePath) { this.reader = reader; this.resourceFile = resourceFile; this.basePath = basePath; this.nextChar = reader.Read(); }
public void CheckFileFormat(IResourceFile file) { if (!file.ContentType.Equals("video/mp4", StringComparison.OrdinalIgnoreCase)) { throw new UnsupportedFileFormatException(); } }
public IList<Managed> Load(Stream stream, string defaultName, IResourceFile resourceFile, string basePath) { IList<Managed> items = managedCollectionFactory(); using (var source = new StreamReader(stream)) { var parser = new TextParser(source, resourceFile, basePath); for (;;) { var lexem = parser.Lexem; if (lexem == null) { return items; } object serializer = textDeserializerFactory(Hash.Get(lexem)); if (serializer != null) { items.Add(((ITextDeserializer)serializer).Parse(parser, defaultName)); continue; } parser.UnknownLexemError(); } } }
public List <ResourceDataBase> GetItemsNotExistingInCulture(VSCulture culture) { List <ResourceDataBase> notExisting = new List <ResourceDataBase>(); foreach (IResourceFile file in files) { foreach (ResourceDataBase data in file.Data.Values) { if (data.ResxFile.FileGroup.Files.ContainsKey(culture.Culture)) { IResourceFile culturedFile = data.ResxFile.FileGroup.Files[culture.Culture]; if (!culturedFile.Data.ContainsKey(data.Name)) { notExisting.Add(data); } } else { notExisting.Add(data); } } } return(notExisting); }
public void GetResourceAsync(string path, BKAction <UnityEngine.Object> onComplete) { if (assetList.ContainsKey(path)) { onComplete((assetList[path].RefTarget() as UnityEngine.Object)); return; } var ab = GetAssetBundle(path); if (ab == null) { onComplete(null); return; } IResourceFile file = resourceTable.GetResourceFile(path); if (file == null) { BundleToAsset(path, file, ab, ab); onComplete(ab); return; } CoroutineMgr.StartCoroutine(DoGetResourceAsync(file, ab, onComplete)); }
private IResourceFile GetResourceItem(string fileName) { IResourceFile resourceItem = null; this._embeddedResourceItems.TryGetValue(GetResourceItemKey(fileName), out resourceItem); return(resourceItem); }
public T GetResource <T>(string path) where T : UnityEngine.Object { if (assetList.ContainsKey(path)) { return((T)(assetList[path].RefTarget())); } var ab = GetAssetBundle(path); if (ab == null) { return(default(T)); } IResourceFile file = resourceTable.GetResourceFile(path); if (file == null) { BundleToAsset(path, file, ab, ab); return((T)Convert.ChangeType(ab, typeof(T))); } else { var obj = ab.LoadAsset <T>(file.idInPack); BundleToAsset(path, file, ab, obj); return(obj); } }
public void GetResourceAsync <T>(string path, BKAction <T> onComplete) where T : UnityEngine.Object { if (assetList.ContainsKey(path)) { onComplete((T)(assetList[path].RefTarget())); return; } var ab = GetAssetBundle(path); if (ab == null) { onComplete(default(T)); return; } IResourceFile file = resourceTable.GetResourceFile(path); if (file == null) { BundleToAsset(path, file, ab, ab); onComplete((T)Convert.ChangeType(ab, typeof(T))); return; } CoroutineMgr.StartCoroutine(DoGetResourceAsync <T>(file, ab, onComplete)); }
private PageModuleTypeFileLocation CreateTemplateFile(IResourceFile file) { var templateFile = new PageModuleTypeFileLocation(); templateFile.Path = file.VirtualPath; templateFile.FileName = Path.GetFileNameWithoutExtension(file.VirtualPath); var templatePath = Path.Combine(Path.GetDirectoryName(file.VirtualPath), TEMPLATES_FOLDER_NAME); var templateDirectory = _resourceLocator.GetDirectory(templatePath); if (templateDirectory != null) { templateFile.Templates = FilterViewFiles(templateDirectory) .GroupBy(t => t.Name, (k, v) => v.FirstOrDefault()) // De-dup .Select(t => new PageModuleTypeTemplateFileLocation() { FileName = Path.GetFileNameWithoutExtension(t.VirtualPath), Path = t.VirtualPath }) .ToDictionary(t => t.FileName); } else { templateFile.Templates = new Dictionary <string, PageModuleTypeTemplateFileLocation>(); } return(templateFile); }
private ResourceUploadResult UploadResource(IResourceFile file, ResourceType resourceType) { if (file == null || file.Length == 0) { throw new UploadResourceException("null file"); } RawUploadResult uploadResult; var uploadParams = new RawUploadParams(); switch (resourceType) { case ResourceType.Image: uploadParams = new ImageUploadParams(); break; case ResourceType.Video: uploadParams = new VideoUploadParams(); break; } using (var stream = file.OpenReadStream()) { uploadParams.File = new FileDescription(file.FileName, stream); uploadResult = _cloudinary.Upload(uploadParams); } if (uploadResult.Error != null) { throw new UploadResourceException(uploadResult.Error.Message); } return(new ResourceUploadResult(uploadResult.PublicId, uploadResult.SecureUrl.AbsoluteUri)); }
public ResourceDataBase(IResourceFile file, string name, string value, string comment) { this.file = file; this.name = name; this.xmlValue = cleanValue(value); this.comment = comment; }
public void LoadFile(IResourceFile file) { XPathNodeIterator nodes = nav.Select("/resxClient/project/resourceFile[@FileName = '" + file.ID + "']"); if (nodes.MoveNext()) { LoadFile(file, nodes.Current); } }
public override ResourceUploadResult Add(IResourceFile file) { _fileName = $"{Guid.NewGuid().ToString()}{file.FileExtension}"; using var stream = new FileStream(FileFullPath, FileMode.Create); file.CopyTo(stream); return(new ResourceUploadResult(_fileName, FileUrl)); }
protected void LoadFile(IResourceFile file, XPathNavigator nav) { if (file == null) { throw new ArgumentNullException("file"); } file.LoadSettings(nav); }
public ResGroup(IResourceManager resourceManager, IResourceFile resourceFile, IComponentContext context) { this.resourceManager = resourceManager; this.resourceFile = resourceFile; this.context = context; //TODO: make public properties read-only this.externalResources = context.Resolve<IList<IResourceFile>>(); this.embeddedResources = context.Resolve<IList<Managed>>(); }
IEnumerator DoGetResourceAsync(IResourceFile file, AssetBundle ab, BKAction <UnityEngine.Object> onComplete) { var req = ab.LoadAssetAsync(file.idInPack, GetResourceType(file.type)); yield return(req); var obj = req.asset; BundleToAsset(file.srcFile, file, ab, obj); onComplete(obj); }
/// <summary> /// Processes the file part. /// This helps recursively create our directory structure. /// </summary> /// <param name="resourceName">Name of the file.</param> /// <param name="parts">The parts.</param> /// <param name="folder">The folder.</param> /// <exception cref="System.Collections.Generic.KeyNotFoundException"></exception> private void ProcessFilePart(string resourceName, IEnumerable <string> parts, ResourceFolder folder) { resourceName = resourceName.Replace("\\", "/"); if (parts.Count() == 1) { IResourceFile item = null; this._embeddedResourceItems.TryGetValue(GetResourceItemKey(resourceName), out item); var embeddedResourceFile = item as ResourceFile; if (embeddedResourceFile == null && !resourceName.EndsWith(".resx", StringComparison.OrdinalIgnoreCase)) { System.Diagnostics.Trace.TraceWarning("Could not find an embedded file {0} yet it was defined in embedded project file.", resourceName); } if (item != null) { folder.AddFile(item); // we can only infer the virtual path once we know the file location. embeddedResourceFile.VirtualPath = "~/" + resourceName; embeddedResourceFile.FileName = parts.First(); } } else if (parts.Count() > 1) { var originalPart = parts.First(); var firstPart = originalPart .Replace("-", "_"); // this is a MSBuild convention, folder paths cannot contain a -, they are converted to _ at build time. // File names can contain dashes on the other hand... go figure. var nextParts = parts.Skip(1); var childFolder = folder.Folders .OfType <ResourceFolder>() .FirstOrDefault(x => x.Name.Equals(firstPart, StringComparison.OrdinalIgnoreCase)); if (childFolder == null) { var virtualPath = (folder.VirtualPath ?? "~") + "/" + originalPart; childFolder = new ResourceFolder() { Name = firstPart, VirtualPath = virtualPath }; folder.AddFolder(childFolder); } this.ProcessFilePart(resourceName, nextParts, childFolder); } }
private PageTemplateFile MapPageTemplateFile(IResourceFile file) { var fileName = Path.ChangeExtension(file.Name, null).TrimStart(new char[] { '_', '-' }); var templateFile = new PageTemplateFile() { FileName = fileName, FullPath = file.VirtualPath }; return(templateFile); }
IEnumerator DoGetResourceAsync <T>(IResourceFile file, AssetBundle ab, BKAction <T> onComplete) where T : UnityEngine.Object { var req = ab.LoadAssetAsync <T>(file.idInPack); yield return(req); var obj = (T)req.asset; BundleToAsset(file.srcFile, file, ab, obj); onComplete(obj); }
public void SaveFile(IResourceFile file) { XmlElement element = (XmlElement)xml.SelectSingleNode("/resxClient/project/resourceFile[@FileName = '" + file.ID + "']"); if (element == null) { element = xml.CreateElement("resourceFile"); element.SetAttribute("FileName", file.ID); xml.DocumentElement.FirstChild.AppendChild(element); } file.SaveSettings(element); }
public void SetResourceData(string key, string value, CultureInfo culture) { if (!Files.ContainsKey(culture)) { IResourceFile file = CreateNewFile(culture); file.CreateResourceData(key, value); } else { Files[culture].SetResourceData(key, value); } }
public T[] GetAllResources <T>(string path) where T : UnityEngine.Object { IResourceFile file = resourceTable.GetResourceFile(path); if (file != null && file.singleDirectResource && assetList.ContainsKey(file.srcFile)) { return(new T[] { (T)assetList[file.srcFile].RefTarget() }); } var ab = GetAssetBundle(path); return(ab == null ? null : (T[])ab.LoadAllAssets()); }
public UnityEngine.Object[] GetAllResources(string path) { IResourceFile file = resourceTable.GetResourceFile(path); if (file != null && file.singleDirectResource && assetList.ContainsKey(file.srcFile)) { return(new UnityEngine.Object[] { assetList[file.srcFile].RefTarget() as UnityEngine.Object }); } var ab = GetAssetBundle(path); return(ab == null ? null : ab.LoadAllAssets()); }
public void SetResourceDataComment(string key, string comment, CultureInfo culture) { if (!Files.ContainsKey(culture)) { IResourceFile file = CreateNewFile(culture); file.CreateResourceDataComment(key, comment); } else { Files[culture].SetResourceDataComment(key, comment); } }
public IList<IResourceFileItem> Read(string filePath, IResourceFile resourceFile) { IList<IResourceFileItem> items = this.context.Resolve<IList<IResourceFileItem>>(); var t = new Texture { BasePath = Path.GetDirectoryName(filePath), Name = Path.GetFileNameWithoutExtension(filePath), Image = LoadBitmap(filePath) }; items.Add(new ResourceFileItem(Texture.TypeHash, t)); return items; }
internal void AddResourceFileToProjectFile(IResourceFile file, VSProjectFileTypes filetype) { try { if (file.FileGroup.Files.Count > 0) { if (projectXml == null) { projectXml = new XmlDocument(); projectXml.Load(GetProjectFilePath()); namespaceManager = new XmlNamespaceManager(projectXml.NameTable); namespaceManager.AddNamespace("n", defaultnamespace); } string filename = getProjectRelativeFileName(file); var node = projectXml.SelectSingleNode(String.Format("/n:Project/n:ItemGroup/n:{1}[@Include = '{0}']", filename, filetype), namespaceManager); if (node == null) { foreach (var otherfile in file.FileGroup.Files.Values) { filename = getProjectRelativeFileName(otherfile); node = projectXml.SelectSingleNode(String.Format("/n:Project/n:ItemGroup[n:{1}/@Include = '{0}']", filename, filetype), namespaceManager); if (node != null) { break; } } if (node == null) { log4net.ILog log = log4net.LogManager.GetLogger(typeof(VSProject)); log.WarnFormat("Resource file '{0}' could not be added to project '{1}', because no existing file found in project.", file.File.Name, file.FileGroup.Container.Project.Name); } else { var embeddedResource = projectXml.CreateElement(filetype.ToString(), defaultnamespace); embeddedResource.SetAttribute("Include", getProjectRelativeFileName(file)); node.AppendChild(embeddedResource); } } } } catch (Exception e) { log4net.ILog log = log4net.LogManager.GetLogger(typeof(VSProject)); log.Error("Resource file could not be added to the project.", e); } }
public byte[] GetContent(ISerializedFile file) { IResourceFile res = file.Collection.FindResourceFile(Path); if (res == null) { return(null); } byte[] data = new byte[Size]; res.Stream.Position = Offset; res.Stream.ReadBuffer(data, 0, data.Length); return(data); }
public void ChangeCulture(IResourceFile file, CultureInfo culture) { if (file == null) { throw new ArgumentNullException("file"); } if (this.Files.ContainsKey(file.Culture)) { this.Files.Remove(file.Culture); } this.Files.Add(culture, file); }
public void LoadFile(IResourceFile file) { if (file == null) { throw new ArgumentNullException("file"); } XPathNodeIterator nodes = nav.Select("/resxClient/project/resourceFile[@FileName = '" + file.ID + "']"); if (nodes.MoveNext()) { LoadFile(file, nodes.Current); } }
public async Task CheckOrganizationMaximumStorage(IResourceFile file, CancellationToken token) { var subscription = await _subscriptionManager.GetOrganizationSubscriptionPlan(token); var currentStorage = await _subscriptionManager.GetOrganizationCurrentStorage(token); if (DoesFileSizeExceedMaximumStorageAllowed(file, currentStorage, subscription)) { throw new FileExceedsTotalMaximumStorageException(); } if (DoesFileSizeExceedMaximumFileSizeAllowed(file, subscription)) { throw new FileExceedsMaximumFileSizeException(); } }
void cbCultureInfos_SelectedIndexChanged(object sender, EventArgs e) { Main.setToolbarStatusText(Properties.Resources.ChangingCulture); var node = (ResourceFileTreeNode)this.treeView.SelectedNode; IResourceFile file = (node).File; file.Culture = CultureInfo.GetCultureInfo(((CulturesComboBoxItem)this.cbCultureInfos.SelectedItem).Name); file.FileGroup.Container.Project.ResxProjectFile.SaveFile(file); file.FileGroup.Container.Project.ResxProjectFile.Save(); node.Refresh(); Main.CurrentSolution.RemoveUnusedCultures(); refreshAnalysis(); Main.setToolbarStatusText(Properties.Resources.ChangingCultureCompleted, 4000); }
public void SaveFile(IResourceFile file) { if (file == null) { throw new ArgumentNullException("file"); } XmlElement element = (XmlElement)xml.SelectSingleNode("/resxClient/project/resourceFile[@FileName = '" + file.ID + "']"); if (element == null) { element = xml.CreateElement("resourceFile"); element.SetAttribute("FileName", file.ID); xml.DocumentElement.FirstChild.AppendChild(element); } file.SaveSettings(element); }
public void GetAllResourcesAsync <T>(string path, BKAction <T[]> onComplete) where T : UnityEngine.Object { IResourceFile file = resourceTable.GetResourceFile(path); if (file != null && file.singleDirectResource && assetList.ContainsKey(file.srcFile)) { onComplete(new T[] { (T)assetList[file.srcFile].RefTarget() }); return; } var ab = GetAssetBundle(path); if (ab == null) { return; } CoroutineMgr.StartCoroutine(DoGetAllResourcesAsync <T>(ab, onComplete)); }
public UnityEngine.Object GetResource(string path) { if (assetList.ContainsKey(path)) { return(assetList[path].RefTarget() as UnityEngine.Object); } var ab = GetAssetBundle(path); if (ab == null) { return(null); } IResourceFile file = resourceTable.GetResourceFile(path); var obj = file == null ? ab : ab.LoadAsset(file.idInPack, GetResourceType(file.type)); BundleToAsset(path, file, ab, obj); return(obj); }
private void BundleToAsset(string path, IResourceFile file, AssetBundle ab, UnityEngine.Object asset) { if (file != null && file.singleDirectResource && !file.beDependent && asset != null && (!assetBundleList.ContainsKey(file.targetFile) || !assetBundleList[file.targetFile].cache)) { var cref = new CountableRef(asset); cref.RefTarget(); assetList.Add(file.srcFile, cref); ab.Unload(false); assetBundleList.Remove(file.targetFile); } else { if (assetBundleList.ContainsKey(path) && asset != null) { assetBundleList[path].RefTarget(); } } }
public void Add(IResourceFile file) { if (file.Culture != null) { files.Add(file.Culture, file); } else { container.Project.UnassignedFiles.Add(file); } file.SetFileGroup(this); if (file.Culture != null) { foreach (ResourceDataBase data in file.Data.Values) { data.Reference(); } } }
public byte[] GetContent(ISerializedFile file) { IResourceFile res = file.Collection.FindResourceFile(Source); if (res == null) { return(null); } if (Size == 0) { return(null); } byte[] data = new byte[Size]; using (PartialStream resStream = new PartialStream(res.Stream, res.Offset, res.Size)) { resStream.Position = Offset; resStream.ReadBuffer(data, 0, data.Length); } return(data); }
public IList<IResourceFileItem> Read(string filePath, IResourceFile resourceFile) { var items = this.context.Resolve<IList<IResourceFileItem>>(); using (var fileStream = File.OpenRead(filePath)) { var resources = this.Load(fileStream, Path.GetDirectoryName(Path.GetFullPath(filePath)), resourceFile); foreach (var resource in resources) { items.Add(new ResourceFileItem(resource.ClassHashCode, resource)); } } return items; }
public ResourceDataBase(IResourceFile file) { this.file = file; }
public ResourceDataBase(IResourceFile file, string name) { this.file = file; this.name = name; }
public void LoadFile(IResourceFile file, XPathNavigator nav) { file.LoadSettings(nav); }
public void ChangeCulture(IResourceFile file, CultureInfo culture) { if (this.Files.ContainsKey(file.Culture)) this.Files.Remove(file.Culture); this.Files.Add(culture, file); }
public IList<IResourceFileItem> Read(string filePath, IResourceFile resourceFile) { var items = itemsCollectionFactory(); using (var fileStream = File.OpenRead(filePath)) { var resources = this.Load( fileStream, Path.GetFileNameWithoutExtension(filePath), resourceFile, Path.GetDirectoryName(Path.GetFullPath(filePath))); foreach (var resource in resources) { items.Add(new ResourceFileItem(resource.ClassHashCode, resource)); } } return items; }
public void ProvideResource(uint type, uint nameHash, object item, IResourceFile source) { var consumeResource = (ResourceItem)this.EnsureItem(type, nameHash); consumeResource.Provide(item, source); }
public IList<Managed> Load(Stream stream, string basePath, IResourceFile resourceFile) { using (var source = new BinaryReader(stream)) { var parser = new BinaryParser(source, basePath, resourceFile); return this.ParseGroupBin(parser); } }
internal void AddResourceFileToProjectFile(IResourceFile file, VSProjectFileTypes filetype) { try { if (file.FileGroup.Files.Count > 0) { if (projectXml == null) { projectXml = new XmlDocument(); projectXml.Load(GetProjectFilePath()); namespaceManager = new XmlNamespaceManager(projectXml.NameTable); namespaceManager.AddNamespace("n", defaultnamespace); } string filename = getProjectRelativeFileName(file); var node = projectXml.SelectSingleNode(String.Format("/n:Project/n:ItemGroup/n:{1}[@Include = '{0}']", filename, filetype), namespaceManager); if (node == null) { foreach (var otherfile in file.FileGroup.Files.Values) { filename = getProjectRelativeFileName(otherfile); node = projectXml.SelectSingleNode(String.Format("/n:Project/n:ItemGroup[n:{1}/@Include = '{0}']", filename, filetype), namespaceManager); if (node != null) break; } if (node == null) { log4net.ILog log = log4net.LogManager.GetLogger(typeof(VSProject)); log.WarnFormat("Resource file '{0}' could not be added to project '{1}', because no existing file found in project.", file.File.Name, file.FileGroup.Container.Project.Name); } else { var embeddedResource = projectXml.CreateElement(filetype.ToString(), defaultnamespace); embeddedResource.SetAttribute("Include", getProjectRelativeFileName(file)); node.AppendChild(embeddedResource); } } } } catch (Exception e) { log4net.ILog log = log4net.LogManager.GetLogger(typeof(VSProject)); log.Error("Resource file could not be added to the project.", e); } }
private string getProjectRelativeFileName(IResourceFile file) { var s1 = Path.Combine(file.FileGroup.Container.Project.Solution.SolutionDirectory.FullName, file.FileGroup.Container.Project.Directory.FullName); return file.File.FullName.Substring(s1.Length); }
public void RetractResource(uint type, uint nameHash, object item, IResourceFile source) { var consumeResource = (ResourceItem)this.EnsureItem(type, nameHash); consumeResource.Retract(item, source); this.TryToRemoveResource(consumeResource); }
public void Retract(object value, IResourceFile sourceFile) { if (!this.values.Remove(new ResourceItemSource(value, sourceFile))) { throw new ApplicationException("Can't retract resource - it wasn't provided"); } this.RaisePropertyChanged("Value"); }
public void AddFile(IResourceFile file) { this._files.Add(file); }
/// <summary> /// Initializes a new instance of the <see cref="EmbeddedFile" /> class. /// </summary> /// <param name="virtualPath">The virtual path to the resource represented by this instance.</param> /// <param name="resourcesFile">The embedded resource file.</param> public EmbeddedFile(string virtualPath, IResourceFile resourcesFile) : base(virtualPath.StartsWith("~", StringComparison.OrdinalIgnoreCase) ? virtualPath : "~" + virtualPath) { this._resourcesFile = resourcesFile; }
public ResourceFileTreeNode(IResourceFile f) { this.file = f; setText(); }
public ResourceItemSource(object value, IResourceFile source) { this.value = value; this.source = source; }
public BinaryParser(BinaryReader source, string basePath, IResourceFile resourceFile) { this.source = source; this.basePath = basePath; this.resourceFile = resourceFile; }
public void Provide(object value, IResourceFile sourceFile) { if (value == null) { throw new ArgumentNullException("value is null"); } if (sourceFile == null) { throw new ArgumentNullException("sourceFile is null"); } this.values.Add(new ResourceItemSource(value, sourceFile)); this.RaisePropertyChanged("Value"); }
public void LoadFile(string filename) { this.CloseFile(); this.resourceFile = this.resourceManager.EnsureFile(filename); this.resourceFile.Open(); this.dataContext.Value = this.resourceFile.Items; this.history.Clear(); }
public void CloseFile() { if (this.resourceFile != null) { this.resourceFile.Close(); this.dataContext.Value = null; this.resourceFile = null; } }