本文整理汇总了C#中IStream.Commit方法的典型用法代码示例。如果您正苦于以下问题:C# IStream.Commit方法的具体用法?C# IStream.Commit怎么用?C# IStream.Commit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IStream
的用法示例。
在下文中一共展示了IStream.Commit方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SaveUIState
/// <include file='doc\WindowPane.uex' path='docs/doc[@for="WindowPane.IVsUIElementPane.SaveUIElementState"]/*' />
/// <internalonly/>
/// <devdoc>
/// IVsUIElementPane implementation.
/// </devdoc>
int IVsUIElementPane.SaveUIElementState(IStream pstream)
{
Stream stateStream;
int hresult = SaveUIState(out stateStream);
if (ErrorHandler.Succeeded(hresult))
{
// Make sure the returned stream (if any) is properly disposed even if it's not readable or is empty
using (stateStream)
{
// If a stream was returned and is readable and have anything to read from it
if (stateStream != null && stateStream.CanRead && stateStream.Length > 0)
{
using (BinaryReader reader = new BinaryReader(stateStream))
{
byte[] bytes = new byte[stateStream.Length];
stateStream.Position = 0;
reader.Read(bytes, 0, bytes.Length);
uint written = 0;
pstream.Write(bytes, (uint)bytes.Length, out written);
pstream.Commit((uint)STGC.STGC_DEFAULT);
}
}
}
}
return hresult;
}