Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ FromType()

static VertexDeclaration Microsoft.Xna.Framework.Graphics.VertexDeclaration.FromType ( Type vertexType)
inlinestaticpackage

Definition at line 140 of file VertexDeclaration.cs.

141 {
142 if (vertexType == null)
143 {
144 throw new ArgumentNullException("vertexType", FrameworkResources.NullNotAllowed);
145 }
146 if (!vertexType.IsValueType)
147 {
148 throw new ArgumentException(string.Format(args: new object[1] { vertexType }, provider: CultureInfo.CurrentCulture, format: FrameworkResources.VertexTypeNotValueType));
149 }
150 if (!(Activator.CreateInstance(vertexType) is IVertexType { VertexDeclaration: var vertexDeclaration }))
151 {
152 throw new ArgumentException(string.Format(args: new object[1] { vertexType }, provider: CultureInfo.CurrentCulture, format: FrameworkResources.VertexTypeNotIVertexType));
153 }
154 if (vertexDeclaration == null)
155 {
156 throw new InvalidOperationException(string.Format(args: new object[1] { vertexType }, provider: CultureInfo.CurrentCulture, format: FrameworkResources.VertexTypeNullDeclaration));
157 }
158 if (Marshal.SizeOf(vertexType) != vertexDeclaration._vertexStride)
159 {
160 throw new InvalidOperationException(string.Format(args: new object[1] { vertexType }, provider: CultureInfo.CurrentCulture, format: FrameworkResources.VertexTypeWrongSize));
161 }
162 return vertexDeclaration;
163 }
static ? object CreateInstance([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors|DynamicallyAccessedMemberTypes.NonPublicConstructors)] Type type, BindingFlags bindingAttr, Binder? binder, object?[]? args, CultureInfo? culture)
Definition Activator.cs:17
static CultureInfo CurrentCulture
static int SizeOf(object structure)
Definition Marshal.cs:697
bool IsValueType
Definition Type.cs:234

References System.Activator.CreateInstance(), System.Globalization.CultureInfo.CurrentCulture, System.Globalization.Format, System.format, System.Type.IsValueType, Microsoft.Xna.Framework.FrameworkResources.NullNotAllowed, System.Runtime.InteropServices.Marshal.SizeOf(), Microsoft.Xna.Framework.FrameworkResources.VertexTypeNotIVertexType, Microsoft.Xna.Framework.FrameworkResources.VertexTypeNotValueType, Microsoft.Xna.Framework.FrameworkResources.VertexTypeNullDeclaration, and Microsoft.Xna.Framework.FrameworkResources.VertexTypeWrongSize.

Referenced by Microsoft.Xna.Framework.Graphics.DynamicVertexBuffer.DynamicVertexBuffer(), and Microsoft.Xna.Framework.Graphics.VertexBuffer.VertexBuffer().