Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / wpf / src / Core / CSharp / System / Windows / Media / Imaging / InplaceBitmapMetadataWriter.cs / 1 / InplaceBitmapMetadataWriter.cs
//------------------------------------------------------------------------------
// Microsoft Avalon
// Copyright (c) Microsoft Corporation, All Rights Reserved
//
// File: InPlaceBitmapMetadataWriter.cs
//
//-----------------------------------------------------------------------------
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel;
using System.ComponentModel.Design.Serialization;
using System.Reflection;
using MS.Internal;
using MS.Win32.PresentationCore;
using System.Diagnostics;
using System.Globalization;
using System.Runtime.InteropServices;
using System.Xml;
using System.IO;
using System.Security;
using System.Security.Permissions;
using System.Windows.Media.Imaging;
using System.Windows.Threading;
using System.Text;
using MS.Internal.PresentationCore; // SecurityHelper
namespace System.Windows.Media.Imaging
{
#region InPlaceBitmapMetadataWriter
///
/// Metadata Class for BitmapImage.
///
sealed public partial class InPlaceBitmapMetadataWriter : BitmapMetadata
{
#region Constructors
///
///
///
private InPlaceBitmapMetadataWriter()
{
}
///
///
///
///
/// Critical - Accesses critical resources
///
[SecurityCritical]
internal InPlaceBitmapMetadataWriter(
SafeMILHandle /* IWICFastMetadataEncoder */ fmeHandle,
SafeMILHandle /* IWICMetadataQueryWriter */ metadataHandle,
object syncObject
) : base(metadataHandle, false, false, syncObject)
{
_fmeHandle = fmeHandle;
}
///
///
///
///
/// Critical - Accesses unmanaged code
/// TreatAsSafe - inputs are verified or safe
///
[SecurityCritical, SecurityTreatAsSafe]
static internal InPlaceBitmapMetadataWriter CreateFromFrameDecode(BitmapSourceSafeMILHandle frameHandle, object syncObject)
{
Invariant.Assert(frameHandle != null);
SafeMILHandle /* IWICFastMetadataEncoder */ fmeHandle = null;
SafeMILHandle /* IWICMetadataQueryWriter */ metadataHandle = null;
using (FactoryMaker factoryMaker = new FactoryMaker())
{
lock (syncObject)
{
HRESULT.Check(UnsafeNativeMethods.WICImagingFactory.CreateFastMetadataEncoderFromFrameDecode(
factoryMaker.ImagingFactoryPtr,
frameHandle,
out fmeHandle));
}
}
HRESULT.Check(UnsafeNativeMethods.WICFastMetadataEncoder.GetMetadataQueryWriter(
fmeHandle,
out metadataHandle));
return new InPlaceBitmapMetadataWriter(fmeHandle, metadataHandle, syncObject);
}
///
///
///
///
/// Critical - Accesses unmanaged code
/// TreatAsSafe - inputs are verified or safe
///
[SecurityCritical, SecurityTreatAsSafe]
static internal InPlaceBitmapMetadataWriter CreateFromDecoder(SafeMILHandle decoderHandle, object syncObject)
{
Invariant.Assert(decoderHandle != null);
SafeMILHandle /* IWICFastMetadataEncoder */ fmeHandle = null;
SafeMILHandle /* IWICMetadataQueryWriter */ metadataHandle = null;
using (FactoryMaker factoryMaker = new FactoryMaker())
{
lock (syncObject)
{
HRESULT.Check(UnsafeNativeMethods.WICImagingFactory.CreateFastMetadataEncoderFromDecoder(
factoryMaker.ImagingFactoryPtr,
decoderHandle,
out fmeHandle));
}
}
HRESULT.Check(UnsafeNativeMethods.WICFastMetadataEncoder.GetMetadataQueryWriter(
fmeHandle,
out metadataHandle));
return new InPlaceBitmapMetadataWriter(fmeHandle, metadataHandle, syncObject);
}
///
///
///
///
/// Critical - Accesses unmanaged code
/// PublicOK - inputs are verified or safe
///
[SecurityCritical ]
public bool TrySave()
{
int hr;
Invariant.Assert(_fmeHandle != null);
lock (SyncObject)
{
hr = UnsafeNativeMethods.WICFastMetadataEncoder.Commit(_fmeHandle);
}
return HRESULT.Succeeded(hr);
}
#endregion
#region Freezable
///
/// Shadows inherited Copy() with a strongly typed
/// version for convenience.
///
public new InPlaceBitmapMetadataWriter Clone()
{
return (InPlaceBitmapMetadataWriter)base.Clone();
}
///
/// Implementation of Freezable.CreateInstanceCore .
///
/// The new Freezable.
protected override Freezable CreateInstanceCore()
{
throw new InvalidOperationException(SR.Get(SRID.Image_InplaceMetadataNoCopy));
}
///
/// Implementation of Freezable.CloneCore .
///
protected override void CloneCore(Freezable sourceFreezable)
{
throw new InvalidOperationException(SR.Get(SRID.Image_InplaceMetadataNoCopy));
}
///
/// Implementation of Freezable.CloneCurrentValueCore .
///
protected override void CloneCurrentValueCore(Freezable sourceFreezable)
{
throw new InvalidOperationException(SR.Get(SRID.Image_InplaceMetadataNoCopy));
}
///
/// Implementation of Freezable.GetAsFrozenCore .
///
protected override void GetAsFrozenCore(Freezable sourceFreezable)
{
throw new InvalidOperationException(SR.Get(SRID.Image_InplaceMetadataNoCopy));
}
///
/// Implementation of Freezable.GetCurrentValueAsFrozenCore .
///
protected override void GetCurrentValueAsFrozenCore(Freezable sourceFreezable)
{
throw new InvalidOperationException(SR.Get(SRID.Image_InplaceMetadataNoCopy));
}
#endregion
///
/// Critical - pointer to an unmanaged object that methods are called on.
///
[SecurityCritical]
private SafeMILHandle _fmeHandle;
}
#endregion
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------------
// Microsoft Avalon
// Copyright (c) Microsoft Corporation, All Rights Reserved
//
// File: InPlaceBitmapMetadataWriter.cs
//
//-----------------------------------------------------------------------------
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel;
using System.ComponentModel.Design.Serialization;
using System.Reflection;
using MS.Internal;
using MS.Win32.PresentationCore;
using System.Diagnostics;
using System.Globalization;
using System.Runtime.InteropServices;
using System.Xml;
using System.IO;
using System.Security;
using System.Security.Permissions;
using System.Windows.Media.Imaging;
using System.Windows.Threading;
using System.Text;
using MS.Internal.PresentationCore; // SecurityHelper
namespace System.Windows.Media.Imaging
{
#region InPlaceBitmapMetadataWriter
///
/// Metadata Class for BitmapImage.
///
sealed public partial class InPlaceBitmapMetadataWriter : BitmapMetadata
{
#region Constructors
///
///
///
private InPlaceBitmapMetadataWriter()
{
}
///
///
///
///
/// Critical - Accesses critical resources
///
[SecurityCritical]
internal InPlaceBitmapMetadataWriter(
SafeMILHandle /* IWICFastMetadataEncoder */ fmeHandle,
SafeMILHandle /* IWICMetadataQueryWriter */ metadataHandle,
object syncObject
) : base(metadataHandle, false, false, syncObject)
{
_fmeHandle = fmeHandle;
}
///
///
///
///
/// Critical - Accesses unmanaged code
/// TreatAsSafe - inputs are verified or safe
///
[SecurityCritical, SecurityTreatAsSafe]
static internal InPlaceBitmapMetadataWriter CreateFromFrameDecode(BitmapSourceSafeMILHandle frameHandle, object syncObject)
{
Invariant.Assert(frameHandle != null);
SafeMILHandle /* IWICFastMetadataEncoder */ fmeHandle = null;
SafeMILHandle /* IWICMetadataQueryWriter */ metadataHandle = null;
using (FactoryMaker factoryMaker = new FactoryMaker())
{
lock (syncObject)
{
HRESULT.Check(UnsafeNativeMethods.WICImagingFactory.CreateFastMetadataEncoderFromFrameDecode(
factoryMaker.ImagingFactoryPtr,
frameHandle,
out fmeHandle));
}
}
HRESULT.Check(UnsafeNativeMethods.WICFastMetadataEncoder.GetMetadataQueryWriter(
fmeHandle,
out metadataHandle));
return new InPlaceBitmapMetadataWriter(fmeHandle, metadataHandle, syncObject);
}
///
///
///
///
/// Critical - Accesses unmanaged code
/// TreatAsSafe - inputs are verified or safe
///
[SecurityCritical, SecurityTreatAsSafe]
static internal InPlaceBitmapMetadataWriter CreateFromDecoder(SafeMILHandle decoderHandle, object syncObject)
{
Invariant.Assert(decoderHandle != null);
SafeMILHandle /* IWICFastMetadataEncoder */ fmeHandle = null;
SafeMILHandle /* IWICMetadataQueryWriter */ metadataHandle = null;
using (FactoryMaker factoryMaker = new FactoryMaker())
{
lock (syncObject)
{
HRESULT.Check(UnsafeNativeMethods.WICImagingFactory.CreateFastMetadataEncoderFromDecoder(
factoryMaker.ImagingFactoryPtr,
decoderHandle,
out fmeHandle));
}
}
HRESULT.Check(UnsafeNativeMethods.WICFastMetadataEncoder.GetMetadataQueryWriter(
fmeHandle,
out metadataHandle));
return new InPlaceBitmapMetadataWriter(fmeHandle, metadataHandle, syncObject);
}
///
///
///
///
/// Critical - Accesses unmanaged code
/// PublicOK - inputs are verified or safe
///
[SecurityCritical ]
public bool TrySave()
{
int hr;
Invariant.Assert(_fmeHandle != null);
lock (SyncObject)
{
hr = UnsafeNativeMethods.WICFastMetadataEncoder.Commit(_fmeHandle);
}
return HRESULT.Succeeded(hr);
}
#endregion
#region Freezable
///
/// Shadows inherited Copy() with a strongly typed
/// version for convenience.
///
public new InPlaceBitmapMetadataWriter Clone()
{
return (InPlaceBitmapMetadataWriter)base.Clone();
}
///
/// Implementation of Freezable.CreateInstanceCore .
///
/// The new Freezable.
protected override Freezable CreateInstanceCore()
{
throw new InvalidOperationException(SR.Get(SRID.Image_InplaceMetadataNoCopy));
}
///
/// Implementation of Freezable.CloneCore .
///
protected override void CloneCore(Freezable sourceFreezable)
{
throw new InvalidOperationException(SR.Get(SRID.Image_InplaceMetadataNoCopy));
}
///
/// Implementation of Freezable.CloneCurrentValueCore .
///
protected override void CloneCurrentValueCore(Freezable sourceFreezable)
{
throw new InvalidOperationException(SR.Get(SRID.Image_InplaceMetadataNoCopy));
}
///
/// Implementation of Freezable.GetAsFrozenCore .
///
protected override void GetAsFrozenCore(Freezable sourceFreezable)
{
throw new InvalidOperationException(SR.Get(SRID.Image_InplaceMetadataNoCopy));
}
///
/// Implementation of Freezable.GetCurrentValueAsFrozenCore .
///
protected override void GetCurrentValueAsFrozenCore(Freezable sourceFreezable)
{
throw new InvalidOperationException(SR.Get(SRID.Image_InplaceMetadataNoCopy));
}
#endregion
///
/// Critical - pointer to an unmanaged object that methods are called on.
///
[SecurityCritical]
private SafeMILHandle _fmeHandle;
}
#endregion
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- BamlResourceContent.cs
- SelectorItemAutomationPeer.cs
- Currency.cs
- MatrixTransform3D.cs
- Byte.cs
- WsdlServiceChannelBuilder.cs
- CardSpaceSelector.cs
- odbcmetadatacollectionnames.cs
- Lease.cs
- PasswordDeriveBytes.cs
- KeyTimeConverter.cs
- WhileDesigner.cs
- LexicalChunk.cs
- Native.cs
- JsonFormatWriterGenerator.cs
- LinkLabelLinkClickedEvent.cs
- EventLogException.cs
- UserNameSecurityTokenProvider.cs
- ChannelFactory.cs
- SQLDateTimeStorage.cs
- DataServiceRequest.cs
- XmlSerializationGeneratedCode.cs
- ActiveDocumentEvent.cs
- CharConverter.cs
- GenericNameHandler.cs
- WbemException.cs
- MarkedHighlightComponent.cs
- ConsoleEntryPoint.cs
- PrivateUnsafeNativeCompoundFileMethods.cs
- FileUpload.cs
- MemberPathMap.cs
- ValueUnavailableException.cs
- Activity.cs
- Ops.cs
- ProjectionQueryOptionExpression.cs
- StyleSelector.cs
- SystemIcmpV6Statistics.cs
- RootNamespaceAttribute.cs
- Table.cs
- CodePrimitiveExpression.cs
- XmlDocumentFragment.cs
- MethodImplAttribute.cs
- XPathNodePointer.cs
- ConnectionOrientedTransportElement.cs
- Stacktrace.cs
- CellRelation.cs
- KeysConverter.cs
- ResumeStoryboard.cs
- PersonalizationEntry.cs
- XAMLParseException.cs
- Activity.cs
- DynamicRendererThreadManager.cs
- DefinitionUpdate.cs
- VerticalConnector.xaml.cs
- KeyedCollection.cs
- MethodBuilderInstantiation.cs
- SqlMethodTransformer.cs
- HttpListenerPrefixCollection.cs
- PointUtil.cs
- CollectionDataContractAttribute.cs
- GifBitmapEncoder.cs
- MenuItemCollection.cs
- WebPartHeaderCloseVerb.cs
- XmlNavigatorStack.cs
- UmAlQuraCalendar.cs
- ChangesetResponse.cs
- PointLight.cs
- MonikerSyntaxException.cs
- FixUpCollection.cs
- Rectangle.cs
- BinaryCommonClasses.cs
- RequestTimeoutManager.cs
- ByteConverter.cs
- BuildProvider.cs
- ScriptingSectionGroup.cs
- DataTableReader.cs
- ProxyHelper.cs
- ScriptServiceAttribute.cs
- ZipFileInfo.cs
- NavigatorInput.cs
- DeviceFiltersSection.cs
- TemplateBindingExpression.cs
- _ServiceNameStore.cs
- ContainerControlDesigner.cs
- MetafileHeaderWmf.cs
- DependencyPropertyDescriptor.cs
- DefaultPropertiesToSend.cs
- CssStyleCollection.cs
- ImmutableCollection.cs
- DeferredReference.cs
- Utilities.cs
- SurrogateEncoder.cs
- RegexCharClass.cs
- RegexMatch.cs
- ClientScriptManager.cs
- XsltException.cs
- PaintValueEventArgs.cs
- DataObjectAttribute.cs
- SmiEventSink.cs
- datacache.cs