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


C# IContext.WriteError方法代码示例

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


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

示例1: GetPackage

        public PackageDescriptor GetPackage(string path, IContext context, ProgressRecord progress)
        {
            path = path.ToLowerInvariant();
            if (!_cache.ContainsKey(path))
            {
                var events = new NullEvents();
                context.WriteDebug("Loading " + path);
                if (null != progress)
                {
                    progress.CurrentOperation = path;
                    context.WriteProgress(progress);
                }

                try
                {
                    var package = _drive.Application.LoadPackage(path, events, true);
                    var descriptor = new PackageDescriptor(package, path);
                    _cache.Add(path, descriptor);
                }
                catch(Exception e)
                {
                    /*if (!context.Force)
                    {
                        throw;
                    }*/

                    _cache.Add( path, null );
                    var errorRecord = new ErrorRecord( e, "PackageCache.GetPackage", ErrorCategory.ReadError, path);
                    context.WriteError( errorRecord );
                }
                finally
                {
                    context.WriteDebug(events.ToString());
                    context.WriteDebug("Done loading " + path);
                }
            }
            return _cache[path];
        }
开发者ID:beefarino,项目名称:bips,代码行数:38,代码来源:PackageCache.cs

示例2: RemoveItem

        public void RemoveItem(IContext context, string path, bool recurse)
        {
            if (_project.Kind == Constants.vsProjectKindMisc)
            {
                context.WriteWarning(
                    String.Format(
                        "Project {0} cannot be removed since it's of the 'Miscellaneous Files' type",
                        Name
                        ));
                return;
            }

            if (context.Force)
            {
                try
                {
                    _project.Delete();
                    return;
                }
                catch
                {
                }
                try
                {
                    
                    
                    var projPath = _project.FullName; 
                    _project.DTE.Solution.Remove(_project);
                    
                    if( ! String.IsNullOrEmpty( projPath) && 
                        ( Directory.Exists( projPath ) || File.Exists(projPath)))
                    {
                        if (! (_project is SolutionFolder) )
                        {
                            projPath = Path.GetDirectoryName(projPath);
                        }
                        Directory.Delete(projPath, true);
                    }

                }
                catch( Exception e )
                {
                    context.WriteWarning(
                        String.Format(
                            "An exception was raised while deleting project {0}.\r\n{1}",
                            Name, e.ToString()
                        ));
                }

                return;               
            }

            var solutionService = Locator.GetService<SVsSolution>() as IVsSolution;
            if (null == solutionService)
            {
                context.WriteError(
                    new ErrorRecord(
                        new ServiceUnavailableException(typeof(IVsSolution)),
                        "StudioShell.ServiceUnavailable",
                        ErrorCategory.ResourceUnavailable,
                        GetNodeValue()
                        )
                    );
                return;
            }

            IVsHierarchy heirarchy;
            solutionService.GetProjectOfUniqueName(_project.UniqueName, out heirarchy);
            if (null == heirarchy)
            {
                context.WriteWarning("The project " + _project.Name +
                                     " could not be removed: the IVsSolution service failed to locate the project by its unique name. ");
                return;
            }

            solutionService.CloseSolutionElement((uint)__VSSLNCLOSEOPTIONS.SLNCLOSEOPT_UnloadProject, heirarchy, 0);
        }
开发者ID:wangchunlei,项目名称:MyGit,代码行数:77,代码来源:ProjectNodeFactory.cs

示例3: WriteNotSupportedItemTypeError

 private void WriteNotSupportedItemTypeError(string thisCodeItemTypeName, IContext context, string itemTypeName,
                                             string path)
 {
     context.WriteError(
         new ErrorRecord(
             new CodeModelNodeDoesNotSupportItemTypeException(thisCodeItemTypeName, itemTypeName),
             "StudioShell.NewItem.InvalidItemType",
             ErrorCategory.InvalidArgument,
             path
             ));
 }
开发者ID:wangchunlei,项目名称:MyGit,代码行数:11,代码来源:FileCodeModelNodeFactory.cs

示例4: NewItem

        public IPathNode NewItem(IContext context, string path, string itemTypeName, object newItemValue)
        {
            if( null == _codeModelNodeFactory )
            {
                context.WriteError( 
                    new ErrorRecord( 
                        new NotSupportedException(
                            "The node at [" + path + "] does not support file code model operations"    
                        ), 
                        "StudioShell.CodeModel.NewItem",
                        ErrorCategory.InvalidOperation, 
                        path)
                        );
                return null;
            }

            return _codeModelNodeFactory.NewItem(context, path, itemTypeName, newItemValue);
        }
开发者ID:wangchunlei,项目名称:MyGit,代码行数:18,代码来源:ProjectItemCodeModelNodeFactory.cs

示例5: CopyItem

        public IPathNode CopyItem(IContext context, string path, string copyPath, IPathNode destinationContainer,
                                  bool recurse)
        {
            ProjectItems destinationItems = null;
            ShellProject destinationProject = destinationContainer.Item as ShellProject;
            ShellProjectItem destinationItem = destinationContainer.Item as ShellProjectItem;

            if (null == destinationProject)
            {
                var containerKinds = new[]
                                         {
                                             Constants.vsProjectItemKindPhysicalFolder,
                                             Constants.vsProjectItemsKindSolutionItems,
                                             Constants.vsProjectItemKindSubProject,
                                             Constants.vsProjectItemKindVirtualFolder,
                                         };

                if (null == destinationItem || !containerKinds.Contains(destinationItem.Kind))
                {
                    throw new InvalidOperationException(
                        "Project items can only be moved or copied into a project node, a project folder, or solution folder.");
                }

                destinationItems = destinationItem.AsProjectItem().ProjectItems;
                destinationProject = destinationItem.ContainingProject;
            }
            else
            {
                destinationItems = destinationProject.AsProject().ProjectItems;
            }

            ShellProject sourceProject = new ShellProject(_item.ContainingProject);

            bool isWithinProject = sourceProject.UniqueName == destinationProject.UniqueName;

            if (String.IsNullOrEmpty(copyPath))
            {
                if (isWithinProject)
                {
                    copyPath = "Copy of " + path;
                }
                else
                {
                    copyPath = path;
                }
            }

            ProjectItem newItem = null;
            CopyItemContext copyContext = null;
            var events = ((Events2) _item.DTE.Events);
            copyContext = new CopyItemContext(_item, copyPath, destinationItems, isWithinProject, recurse);

            events.ProjectItemsEvents.ItemAdded += copyContext.OnItemAdded;
            Exception error = null;
            AddItemCopy(copyContext, out error);

            events.ProjectItemsEvents.ItemAdded -= copyContext.OnItemAdded;
            if (null != error)
            {
                context.WriteError(new ErrorRecord(
                                       new CopyOrMoveItemInternalException(path, copyContext.CopyPath, error),
                                       "StudioShell.CopyItem.Internal", ErrorCategory.WriteError, path));
                return null;
            }
            return new PathNode(ShellObjectFactory.CreateFromProjectItem(newItem), copyPath, false);
        }
开发者ID:wangchunlei,项目名称:MyGit,代码行数:66,代码来源:ProjectItemNodeFactoryBase.cs


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