public CustomAttributeValueProjection(AttributeTargets targets, CustomAttributeValueTreatment treatment) { Targets = targets; Treatment = treatment; }
private BlobHandle GetProjectedValue(CustomAttributeValueTreatment treatment) { BlobHandle.VirtualIndex virtualIndex; bool isVersionOrDeprecated; switch (treatment) { case CustomAttributeValueTreatment.AttributeUsageVersionAttribute: case CustomAttributeValueTreatment.AttributeUsageDeprecatedAttribute: virtualIndex = BlobHandle.VirtualIndex.AttributeUsage_AllowMultiple; isVersionOrDeprecated = true; break; case CustomAttributeValueTreatment.AttributeUsageAllowMultiple: virtualIndex = BlobHandle.VirtualIndex.AttributeUsage_AllowMultiple; isVersionOrDeprecated = false; break; case CustomAttributeValueTreatment.AttributeUsageAllowSingle: virtualIndex = BlobHandle.VirtualIndex.AttributeUsage_AllowSingle; isVersionOrDeprecated = false; break; default: Debug.Assert(false); return default(BlobHandle); } // Raw blob format: // 01 00 - Fixed prolog for CA's // xx xx xx xx - The Windows.Foundation.Metadata.AttributeTarget value // 00 00 - Indicates 0 name/value pairs following. var rawBlob = _reader.CustomAttributeTable.GetValue(Handle); var rawBlobReader = _reader.GetBlobReader(rawBlob); if (rawBlobReader.Length != 8) { return rawBlob; } if (rawBlobReader.ReadInt16() != 1) { return rawBlob; } AttributeTargets projectedValue = ProjectAttributeTargetValue(rawBlobReader.ReadUInt32()); if (isVersionOrDeprecated) { projectedValue |= AttributeTargets.Constructor | AttributeTargets.Property; } return BlobHandle.FromVirtualIndex(virtualIndex, (ushort)projectedValue); }
public CustomAttributeValueProjection(AttributeTargets targets, CustomAttributeValueTreatment treatment) { Targets = targets; Treatment = treatment; }