本文整理汇总了C#中IContext.WriteWarning方法的典型用法代码示例。如果您正苦于以下问题:C# IContext.WriteWarning方法的具体用法?C# IContext.WriteWarning怎么用?C# IContext.WriteWarning使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IContext
的用法示例。
在下文中一共展示了IContext.WriteWarning方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetNodeChildren
public override IEnumerable<INodeFactory> GetNodeChildren( IContext context )
{
XDocument document = GetODataDocument( context );
var entries = GetEntries( document );
var entryFactories = new List<INodeFactory>();
foreach( var entry in entries )
{
var id = entry.Descendants(Names.Id).First().Value;
entryFactories.Add( new ODataEntryNodeFactory(new Uri( id ), _metadata, entry) );
}
var next = GetNextResultSetURI(document);
if( null != next && ! context.Force )
{
context.WriteWarning(
String.Format(
@"The OData collection at URI [{0}] has returned a partial result set.
Specify the -force parameter to retrieve the complete result set, or narrow your query using the -filter parameter.
For more information on filtering, type:
get-help about_OData_Query",
BaseUri
)
);
}
// resolve all <link rel="next" /> when -force is supplied
if( context.Force )
{
while( null != next )
{
var xdoc = XDocumentManager.Get(next);
entries = GetEntries(xdoc);
foreach (var entry in entries)
{
var id = entry.Descendants(Names.Id).First().Value;
entryFactories.Add(new ODataEntryNodeFactory(new Uri(id), _metadata, entry));
}
next = GetNextResultSetURI(xdoc);
}
}
return entryFactories;
}
示例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);
}