Exemplo n.º 1
0
 public ResourceDataBase(IResourceFile file, string name, string value, string comment)
 {
     this.file = file;
     this.name = name;
     this.xmlValue = value;
     this.comment = comment;
 }
Exemplo n.º 2
0
		public TextParser(TextReader reader, IResourceFile resourceFile, string basePath)
		{
			this.reader = reader;
			this.resourceFile = resourceFile;
			this.basePath = basePath;
			this.nextChar = reader.Read();
		}
Exemplo n.º 3
0
 public void CheckFileFormat(IResourceFile file)
 {
     if (!file.ContentType.Equals("video/mp4", StringComparison.OrdinalIgnoreCase))
     {
         throw new UnsupportedFileFormatException();
     }
 }
Exemplo n.º 4
0
		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();
				}
			}
		}
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 6
0
        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);
        }
Exemplo n.º 8
0
        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);
            }
        }
Exemplo n.º 9
0
        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);
        }
Exemplo n.º 11
0
        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));
        }
Exemplo n.º 12
0
 public ResourceDataBase(IResourceFile file, string name, string value, string comment)
 {
     this.file     = file;
     this.name     = name;
     this.xmlValue = cleanValue(value);
     this.comment  = comment;
 }
Exemplo n.º 13
0
 public void LoadFile(IResourceFile file)
 {
     XPathNodeIterator nodes = nav.Select("/resxClient/project/resourceFile[@FileName = '" + file.ID + "']");
     if (nodes.MoveNext())
     {
         LoadFile(file, nodes.Current);
     }
 }
Exemplo n.º 14
0
        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));
        }
Exemplo n.º 15
0
        protected void LoadFile(IResourceFile file, XPathNavigator nav)
        {
            if (file == null)
            {
                throw new ArgumentNullException("file");
            }

            file.LoadSettings(nav);
        }
Exemplo n.º 16
0
		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>>();
		}
Exemplo n.º 17
0
        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);
            }
        }
Exemplo n.º 19
0
        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);
        }
Exemplo n.º 20
0
        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);
        }
Exemplo n.º 21
0
        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);
        }
Exemplo n.º 22
0
        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);
            }
        }
Exemplo n.º 23
0
        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());
        }
Exemplo n.º 24
0
        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());
        }
Exemplo n.º 25
0
        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);
            }
        }
Exemplo n.º 26
0
		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;
		}
Exemplo n.º 27
0
        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);
            }
        }
Exemplo n.º 28
0
        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);
        }
Exemplo n.º 29
0
        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);
        }
Exemplo n.º 30
0
        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);
            }
        }
Exemplo n.º 31
0
        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();
            }
        }
Exemplo n.º 32
0
        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);
        }
Exemplo n.º 33
0
        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);
        }
Exemplo n.º 34
0
        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));
        }
Exemplo n.º 35
0
        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);
        }
Exemplo n.º 36
0
 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();
         }
     }
 }
Exemplo n.º 37
0
        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();
                }
            }
        }
Exemplo n.º 38
0
        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);
        }
Exemplo n.º 39
0
		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;
		}
Exemplo n.º 40
0
 public ResourceDataBase(IResourceFile file)
 {
     this.file = file;
 }
Exemplo n.º 41
0
 public ResourceDataBase(IResourceFile file, string name)
 {
     this.file = file;
     this.name = name;
 }
Exemplo n.º 42
0
 public void LoadFile(IResourceFile file, XPathNavigator nav)
 {
     file.LoadSettings(nav);
 }
Exemplo n.º 43
0
        public void ChangeCulture(IResourceFile file, CultureInfo culture)
        {
            if (this.Files.ContainsKey(file.Culture))
                this.Files.Remove(file.Culture);

            this.Files.Add(culture, file);
        }
Exemplo n.º 44
0
		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;
		}
Exemplo n.º 45
0
		public void ProvideResource(uint type, uint nameHash, object item, IResourceFile source)
		{
			var consumeResource = (ResourceItem)this.EnsureItem(type, nameHash);
			consumeResource.Provide(item, source);
		}
Exemplo n.º 46
0
		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);
			}
		}
Exemplo n.º 47
0
        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);
            }
        }
Exemplo n.º 48
0
 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);
 }
Exemplo n.º 49
0
		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);
		}
Exemplo n.º 50
0
		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;
 }
Exemplo n.º 53
0
        public ResourceFileTreeNode(IResourceFile f)
        {
            this.file = f;

            setText();
        }
Exemplo n.º 54
0
		public ResourceItemSource(object value, IResourceFile source)
		{
			this.value = value;
			this.source = source;
		}
Exemplo n.º 55
0
		public BinaryParser(BinaryReader source, string basePath, IResourceFile resourceFile)
		{
			this.source = source;
			this.basePath = basePath;
			this.resourceFile = resourceFile;
		}
Exemplo n.º 56
0
		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");
		}
Exemplo n.º 57
0
		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();
		}
Exemplo n.º 58
0
		public void CloseFile()
		{
			if (this.resourceFile != null)
			{
				this.resourceFile.Close();
				this.dataContext.Value = null;
				this.resourceFile = null;
			}
		}