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


C# LoggerResult.Warning方法代码示例

本文整理汇总了C#中LoggerResult.Warning方法的典型用法代码示例。如果您正苦于以下问题:C# LoggerResult.Warning方法的具体用法?C# LoggerResult.Warning怎么用?C# LoggerResult.Warning使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在LoggerResult的用法示例。


在下文中一共展示了LoggerResult.Warning方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Save

        /// <summary>
        /// Saves all packages and assets.
        /// </summary>
        /// <param name="log">The <see cref="LoggerResult"/> in which to report result.</param>
        public void Save(LoggerResult log, PackageSaveParameters saveParameters = null)
        {
            bool packagesSaved = false;

            //var clock = Stopwatch.StartNew();
            using (var profile = Profiler.Begin(PackageSessionProfilingKeys.Saving))
            {
                try
                {
                    saveParameters = saveParameters ?? PackageSaveParameters.Default();
                    var assetsOrPackagesToRemove = BuildAssetsOrPackagesToRemove();

                    // Compute packages that have been renamed
                    // TODO: Disable for now, as not sure if we want to delete a previous package
                    //foreach (var package in packagesCopy)
                    //{
                    //    var newPackage = packages.Find(package.Id);
                    //    if (newPackage != null && package.PackagePath != null && newPackage.PackagePath != package.PackagePath)
                    //    {
                    //        assetsOrPackagesToRemove[package.PackagePath] = package;
                    //    }
                    //}

                    // Depending on saveParameters, select the list of source file operations to do
                    List<SourceFileOperation> sourceFileOperations;
                    switch (saveParameters.SaveSourceFileOperations)
                    {
                        case PackageSaveSourceFileOperations.All:
                            sourceFileOperations = BuildSourceFileOperations(assetsOrPackagesToRemove);
                            break;
                        case PackageSaveSourceFileOperations.ReversibleOnly:
                            sourceFileOperations = BuildSourceFileOperations(assetsOrPackagesToRemove).Where(x => !x.Irreversible).ToList();
                            break;
                        case PackageSaveSourceFileOperations.None:
                            sourceFileOperations = new List<SourceFileOperation>();
                            break;
                        default:
                            throw new ArgumentOutOfRangeException();
                    }

                    // If package are not modified, return immediately
                    if (!CheckModifiedPackages() && assetsOrPackagesToRemove.Count == 0 && sourceFileOperations.Count == 0)
                    {
                        return;
                    }

                    // Suspend tracking when saving as we don't want to receive
                    // all notification events
                    if (dependencies != null)
                    {
                        dependencies.BeginSavingSession();
                    }

                    // Return immediately if there is any error
                    if (log.HasErrors)
                    {
                        return;
                    }

                    // Perform source file operations
                    foreach (var sourceFileOperation in sourceFileOperations)
                    {
                        switch (sourceFileOperation.Type)
                        {
                            case SourceFileOperationType.Move:
                                try
                                {
                                    // Move target already exists: try to copy and then delete
                                    if (File.Exists(sourceFileOperation.Destination))
                                    {
                                        // Use upper try/catch
                                        File.Copy(sourceFileOperation.Source, sourceFileOperation.Destination, true);

                                        // Try to delete source
                                        try
                                        {
                                            File.Delete(sourceFileOperation.Source);
                                        }
                                        catch (Exception ex)
                                        {
                                            // File locked?
                                            log.Warning(sourceFileOperation.AssetItem.Package, sourceFileOperation.AssetItem.ToReference(), AssetMessageCode.AssetCannotDelete, ex, sourceFileOperation.Source);
                                        }
                                    }
                                    else
                                    {
                                        try
                                        {
                                            File.Move(sourceFileOperation.Source, sourceFileOperation.Destination);
                                        }
                                        catch (Exception ex)
                                        {
                                            // Could not Move, revert back to a Copy instead
                                            // Use upper try/catch
                                            File.Copy(sourceFileOperation.Source, sourceFileOperation.Destination, true);
                                            log.Warning(sourceFileOperation.AssetItem.Package, sourceFileOperation.AssetItem.ToReference(), AssetMessageCode.AssetCannotDelete, ex,
//.........这里部分代码省略.........
开发者ID:h78hy78yhoi8j,项目名称:xenko,代码行数:101,代码来源:PackageSession.cs

示例2: CheckDependencies

        /// <summary>
        /// Checks the package.
        /// </summary>
        /// <returns>LoggerResult.</returns>
        public LoggerResult CheckDependencies()
        {
            var log = new LoggerResult();

            // Can only check dependencies if we are inside a session
            if (package.Session == null)
            {
                return log;
            }

            // If ProjetcPath is null, the package was not saved.
            if (Parameters.ConvertUPathTo == UPathType.Relative && package.FullPath == null)
            {
                log.Error(package, null, AssetMessageCode.PackageFilePathNotSet);
                return log;
            }

            // 1. Check all store package references
            foreach (var packageDependency in package.Meta.Dependencies)
            {
                // Try to find the package reference
                var subPackage = package.Session.Packages.Find(packageDependency);
                if (subPackage == null)
                {
                    if (packageDependency.Name == PackageStore.Instance.DefaultPackageName)
                    {
                        log.Warning(package, null, AssetMessageCode.PackageDependencyModified, packageDependency, PackageStore.Instance.DefaultPackageMinVersion);
                        packageDependency.Version = PackageStore.Instance.DefaultPackageMinVersion;
                        package.IsDirty = true;
                    }
                    else
                    {
                        log.Error(package, null, AssetMessageCode.PackageNotFound, packageDependency);
                    }
                }
            }

            // 2. Check all local package references
            foreach (var packageReference in package.LocalDependencies)
            {
                // Try to find the package reference
                var newSubPackage = package.Session.Packages.Find(packageReference.Id);
                if (newSubPackage == null)
                {
                    log.Error(package, null, AssetMessageCode.PackageNotFound, packageReference.Location);
                    continue;
                }

                if (newSubPackage.FullPath == null || newSubPackage.IsSystem)
                {
                    continue;
                }

                // If package was found, check that the path is correctly setup
                var pathToSubPackage = Parameters.ConvertUPathTo == UPathType.Relative ? newSubPackage.FullPath.MakeRelative(package.RootDirectory) : newSubPackage.FullPath;
                if (packageReference.Location != pathToSubPackage)
                {
                    // Modify package path to be relative if different
                    packageReference.Location = pathToSubPackage;

                    if (Parameters.SetDirtyFlagOnAssetWhenFixingUFile)
                    {
                        package.IsDirty = true;
                    }
                }
            }

            // TODO: Check profiles

            return log;
        }
开发者ID:Powerino73,项目名称:paradox,代码行数:75,代码来源:PackageAnalysis.cs


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