private PropertyDescriptorCollection ReadProperties(ITypeDescriptorContext context, object realComponent, Attribute[] attributes, object realObject, string name) { PropertyDescriptorCollection remappedProperties; PropertyDescriptorCollection realProperties = DescriptorUtils.GetAllProperties(context, realObject, attributes); remappedProperties = DescriptorUtils.RemapComponent(realProperties, realComponent, realObject, name, new ChildTypeConverter()); return(remappedProperties); }
/// <summary> /// Constructor /// </summary> /// <param name="device">Direct3D11 Device</param> /// <param name="maxFaceCount">Maximum body count</param> public DynamicRgbSpaceFaceStructuredBuffer(Device device, int maxFaceCount) { if (device == null) { throw new ArgumentNullException("device"); } var desc = DescriptorUtils.DynamicStructuredBuffer(new BufferElementCount(maxFaceCount * (int)Microsoft.Kinect.Face.FaceModel.VertexCount), new BufferStride(8)); this.buffer = new SharpDX.Direct3D11.Buffer(device, desc); this.shaderView = new ShaderResourceView(device, this.buffer); }
public override bool GetPropertiesSupported(ITypeDescriptorContext context) { // try to convert to IList if (context != null && context.Instance != null && context.PropertyDescriptor != null) { return(DescriptorUtils.GetAllPropertiesCustom(context.PropertyDescriptor.GetValue(context.Instance), null).Count > 0); } else { return(originalConverter.GetPropertiesSupported(context)); } }
public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes) { PropertyDescriptorCollection col = DescriptorUtils.GetAllPropertiesCustom(context.PropertyDescriptor.GetValue(value), attributes); if (col.Count > 0) { return(col); } else { return(originalConverter.GetProperties(context, value, attributes)); } }
public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object component, Attribute[] attributes) { EventInfoConverter eventConverter = component as EventInfoConverter; if (eventConverter != null) { return(eventConverter.GetProperties()); } else { return(DescriptorUtils.GetInstanceEvents(component)); } }
public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object component, Attribute[] attributes) { if (context.PropertyDescriptor is RemapPropertyDescriptor) { RemapPropertyDescriptor remapDescriptor = context.PropertyDescriptor as RemapPropertyDescriptor; if (remapDescriptor.Name == "CurrentApplication") { PropertyDescriptorCollection realProperties = DescriptorUtils.GetStaticProperties(typeof(Application)); PropertyDescriptorCollection remappedProperties = DescriptorUtils.RemapComponent(realProperties, component, null, null, new ChildTypeConverter()); return(remappedProperties); } else { PropertyDescriptorCollection realProperties = ReadProperties(null, component, attributes, component, null); return(realProperties); } } else { if (cachedComponentInfo != component) { cachedApplicationInfo = new ApplicationInfo(); cachedComponentInfo = component; } PropertyDescriptorCollection result = ReadProperties(context, component, attributes, cachedApplicationInfo, null); //PropertyDescriptorCollection appProps = PropertyDescriptorUtils.GetStaticProperties(typeof(Application)); //result = PropertyDescriptorUtils.MergeProperties(result, appProps); return(result); } //temp = ReadProperties(context, component, attributes, cachedApplicationInfo.CurrentPrincipal, "CurrentPrincipal"); //result = PropertyDescriptorUtils.MergeProperties(result, temp); //temp = ReadProperties(context, component, attributes, cachedApplicationInfo.CurrentPrincipal.Identity, "CurrentIdentity"); //result = PropertyDescriptorUtils.MergeProperties(result, temp); //temp = ReadProperties(context, component, attributes, cachedApplicationInfo.CurrentPrincipal, "CurrentPrincipal"); //result = PropertyDescriptorUtils.MergeProperties(result, temp); //temp = ReadProperties(context, component, attributes, cachedApplicationInfo.CurrentThread, "CurrentThread"); //result = PropertyDescriptorUtils.MergeProperties(result, temp); //temp = ReadProperties(context, component, attributes, cachedApplicationInfo.CurrentProcess, "CurrentProcess"); //result = PropertyDescriptorUtils.MergeProperties(result, temp); }
public void ImmutableTestUShort() { BufferElementCount count = new BufferElementCount(1024); var desc = DescriptorUtils.ImmutableIndexBufferUShort(count); var expected = new BufferDescription() { BindFlags = BindFlags.IndexBuffer, CpuAccessFlags = CpuAccessFlags.None, OptionFlags = ResourceOptionFlags.None, SizeInBytes = count * sizeof(ushort), StructureByteStride = sizeof(ushort), Usage = ResourceUsage.Immutable }; Assert.AreEqual(desc, expected); }
/// <summary> /// Constructor /// </summary> /// <param name="device">Direct3D11 Device</param> /// <param name="maxBodyCount">Maximum body count</param> public JointTableIndexBuffer(Device device, int maxBodyCount) { if (device == null) { throw new ArgumentNullException("device"); } uint[] data = JointDataTable.RepeatTableUInt(maxBodyCount); var desc = DescriptorUtils.ImmutableIndexBufferUint(new BufferElementCount(data.Length)); fixed(uint *ptr = &data[0]) { DataStream ds = new DataStream(new IntPtr(ptr), data.Length * sizeof(uint), true, true); this.buffer = new SharpDX.Direct3D11.Buffer(device, ds, desc); } }
public void InvalidElementCounterView() { var desc = DescriptorUtils.CounterStructuredBufferView(new BufferElementCount(0)); }
public static extern bool GetCursorInfo(out DescriptorUtils.Structures.CursorInfo pci);
public void AppendView() { var desc = DescriptorUtils.AppendStructuredBufferView(new BufferElementCount(1024)); }
public void CounterView() { var desc = DescriptorUtils.CounterStructuredBufferView(new BufferElementCount(1024)); }
public void InvalidStrideWriteBufferDesc() { var desc = DescriptorUtils.WriteableStructuredBuffer(new BufferElementCount(1024), new BufferStride(1)); }
public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes) { //return method.GetChildProperties(null, null); return(DescriptorUtils.GetAllProperties(null, value, attributes)); }
public void InvalidElementImmutableBufferDesc() { var desc = DescriptorUtils.ImmutableStructuredBuffer(new BufferElementCount(0), new BufferStride(32)); }
/// <summary> /// Creates a random string based on Descriptors MaxLength and CharacterType got /// from the propertyExpression /// </summary> /// <param name="propertyExpression">Property to create a random valid value for.</param> /// <returns>string</returns> public static string CreateRandomValidValue <T>(Expression <Func <T> > propertyExpression) { return(CreateRandomValidValue(DescriptorUtils.GetDescriptor(propertyExpression))); }
public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object component, Attribute[] attributes) { PropertyDescriptorCollection propsCollection = DescriptorUtils.GetAllFields(context, component, attributes); return(DescriptorUtils.RemapComponent(propsCollection, component, component, null, null)); }
private static object CreateRandomIncorrectLength <T>(T value, PropertyInfo property) { var descriptor = DescriptorUtils.GetDescriptorFromPropertyName <T>(property.Name); // If property doesn't have a DescriptorAttribute give back a random string and log this. if (null == descriptor) { Debug.WriteLine("Generation for invalid value for property {0} with no DescriptorAttribute.", property); return(StringCreation.CreateRandomCfString(DefaultStringLength, false, CharacterType.Letters)); } // Detect if the property is a List if (property.GetValue(value) is IList && property.PropertyType.IsGenericType) { // Set the list to an empty new list var propertyConstructor = property.PropertyType.GetConstructor(Type.EmptyTypes); if (propertyConstructor != null) { return(propertyConstructor.Invoke(null)); } throw new ArgumentException("Property is a List but has no default constructor", "property"); } // If the descriptorAttribute is an enum what do I give back as invalid? if (null != descriptor.EnumType) { // TODO: This length doesn't necessarily reflect the invalidation length in the db for all uses of enums. return(StringCreation.CreateRandomCfString(11, false, CharacterType.DigitsOrLetters)); } // Return random string that isn't in the array if the array is defined. if (null != descriptor.Array) { var randomString = string.Empty; var isInArray = true; while (isInArray) { randomString = StringCreation.CreateRandomCfString(11, false, CharacterType.DigitsOrLetters); if (!descriptor.Array.Contains(randomString)) { isInArray = false; } } return(randomString); } // Return value longer than maxLength is a regex is used. if (null != descriptor.Regex) { return(CreateInvalidLengthCfString(descriptor)); } // Return value generated from PropertyType switch (descriptor.PropertyType) { case PropertyType.String: return(CreateInvalidLengthCfString(descriptor)); case PropertyType.Int: return(StringCreation.CreateRandomCfString(DefaultStringLength, false, CharacterType.Letters)); case PropertyType.Decimal: return(StringCreation.CreateRandomCfString(DefaultStringLength, false, CharacterType.Letters)); case PropertyType.Bool: return(StringCreation.CreateRandomCfString(DefaultStringLength, false, CharacterType.Letters)); case PropertyType.Date: return(StringCreation.CreateRandomCfString(DefaultStringLength, false, CharacterType.DigitsOrLetters)); case PropertyType.Email: return(StringCreation.CreateRandomCfString(DefaultStringLength, false)); default: throw new ArgumentOutOfRangeException(); } }
public static extern bool GetIconInfo(IntPtr hIcon, out DescriptorUtils.Structures.IconInfo piconinfo);
/// <summary> /// Creates a random string based on Descriptors MaxLength and CharacterType got /// from the propertyExpression /// </summary> /// <param name="propertyInfo">Property to create a random valid value for.</param> /// <returns>string</returns> public static string CreateRandomValidValue(PropertyInfo propertyInfo) { return(CreateRandomValidValue(DescriptorUtils.GetDescriptorFromPropertyInfo(propertyInfo))); }
public void InvalidStrideDynamicBufferDesc() { var desc = DescriptorUtils.DynamicStructuredBuffer(new BufferElementCount(1024), new BufferStride(1)); }