Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Mar 30, 2019. It is now read-only.
/SharpDXPublic archive

Commita046bb8

Browse files
committed
Added IFormattable to FourCC to provide customised string representation when building Media Foundation GUIDs.
1 parentbe1c541 commita046bb8

File tree

2 files changed

+45
-2
lines changed

2 files changed

+45
-2
lines changed

‎Source/SharpDX.MediaFoundation/VideoFormatGuids.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public static partial class VideoFormatGuids
1515
/// <returns>Media foundation unique ID</returns>
1616
publicstaticGuidFromFourCC(SharpDX.Multimedia.FourCCfourCC)
1717
{
18-
returnnewGuid(string.Concat(fourCC.ToString(),"-0000-0010-8000-00aa00389b71"));
18+
returnnewGuid(string.Concat(fourCC.ToString("I",null),"-0000-0010-8000-00aa00389b71"));
1919
}
2020
}
2121
}

‎Source/SharpDX/Multimedia/FourCC.cs‎

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
1919
// THE SOFTWARE.
2020
usingSystem;
21+
usingSystem.Globalization;
2122
usingSystem.Runtime.InteropServices;
2223

2324
namespaceSharpDX.Multimedia
@@ -26,7 +27,7 @@ namespace SharpDX.Multimedia
2627
/// A FourCC descriptor.
2728
/// </summary>
2829
[StructLayout(LayoutKind.Sequential,Size=4)]
29-
publicstructFourCC:IEquatable<FourCC>
30+
publicstructFourCC:IEquatable<FourCC>,IFormattable
3031
{
3132
/// <summary>
3233
/// Empty FourCC.
@@ -175,6 +176,48 @@ public override int GetHashCode()
175176
return(int)value;
176177
}
177178

179+
/// <summary>
180+
/// Provides a custom string representation of the FourCC descriptor.
181+
/// </summary>
182+
/// <remarks>
183+
/// The general format "G" is equivalent to the parameterless.
184+
/// <see cref="FourCC.ToString()"/>. The special format "I" returns a
185+
/// string representation which can be used to construct a Media
186+
/// Foundation format GUID. It is equivalent to "X08".
187+
/// </remarks>
188+
/// <param name="format">The format descriptor, which can be "G" (empty
189+
/// or <c>null</c> is equivalent to "G"), "I" or any valid standard
190+
/// number format.</param>
191+
/// <param name="formatProvider">The format provider for formatting
192+
/// numbers.</param>
193+
/// <returns>The requested string representation.</returns>
194+
/// <exception cref="System.FormatException">In case of
195+
/// <paramref name="format"/> is not "G", "I" or a valid number
196+
/// format.</exception>
197+
publicstringToString(stringformat,IFormatProviderformatProvider)
198+
{
199+
if(string.IsNullOrEmpty(format))
200+
{
201+
format="G";
202+
}
203+
if(formatProvider==null)
204+
{
205+
formatProvider=CultureInfo.CurrentCulture;
206+
}
207+
208+
switch(format.ToUpperInvariant())
209+
{
210+
case"G":
211+
returnthis.ToString();
212+
213+
case"I":
214+
returnthis.value.ToString("X08",formatProvider);
215+
216+
default:
217+
returnthis.value.ToString(format,formatProvider);
218+
}
219+
}
220+
178221
publicstaticbooloperator==(FourCCleft,FourCCright)
179222
{
180223
returnleft.Equals(right);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp