예제 #1
0
        /// <summary>
        /// This callback is receiving hash calculated from asset source file. If the source hash is changing from what
        /// we had previously stored, we can emit a <see cref="AssetFileChangedType.SourceUpdated" /> event.
        /// </summary>
        /// <param name="sourceFile">The source file.</param>
        /// <param name="hash">The object identifier hash calculated from this source file.</param>
        private void SourceImportFileHashCallback(UFile sourceFile, ObjectId hash)
        {
            lock (ThisLock)
            {
                HashSet <AssetId> items;
                if (!mapSourceFilesToAssets.TryGetValue(sourceFile, out items))
                {
                    return;
                }

                currentHashes[sourceFile] = hash;

                var message = new List <SourceFileChangedData>();
                foreach (var itemId in items)
                {
                    TrackedAsset trackedAsset;
                    if (trackedAssets.TryGetValue(itemId, out trackedAsset))
                    {
                        bool needUpdate = trackedAsset.DependsOnSource(sourceFile);
                        var  data       = new SourceFileChangedData(SourceFileChangeType.SourceFile, trackedAsset.AssetId, new[] { sourceFile }, needUpdate);
                        message.Add(data);
                    }
                }
                if (message.Count > 0)
                {
                    SourceFileChanged.Post(message);
                }
            }
        }
예제 #2
0
        public FileDescriptor(string filePath, SourceFileChanged fileChangedCallback, TraceDataSource dataSource)
        {
            if (string.IsNullOrEmpty(filePath))
            {
                throw new ArgumentException();
            }
            this.dataSource = dataSource;
            FileStream fileStream = Utilities.CreateFileStreamHelper(filePath);

            this.filePath = filePath;
            fileLength    = fileStream.Length;
            xmlUtil       = new XmlUtils(null);
            try
            {
                FileSectorIndicator(fileStream);
            }
            catch (LogFileException ex)
            {
                fileStream.Close();
                throw ex;
            }
            this.fileStream = fileStream;
            if (fileChangedCallback != null)
            {
                sourceFileChangedCallback = (SourceFileChanged)Delegate.Combine(sourceFileChangedCallback, fileChangedCallback);
            }
        }