internal tagDBPROP[] GetPropertySet(int index, out Guid propertyset) { if ((index < 0) || (this.PropertySetCount <= index)) { if (this.lastErrorFromProvider != null) { throw ADP.InternalError(ADP.InternalErrorCode.InvalidBuffer, this.lastErrorFromProvider); } throw ADP.InternalError(ADP.InternalErrorCode.InvalidBuffer); } tagDBPROPSET structure = new tagDBPROPSET(); tagDBPROP[] gdbpropArray = null; bool success = false; RuntimeHelpers.PrepareConstrainedRegions(); try { base.DangerousAddRef(ref success); Marshal.PtrToStructure(ADP.IntPtrOffset(base.DangerousGetHandle(), index * ODB.SizeOf_tagDBPROPSET), structure); propertyset = structure.guidPropertySet; gdbpropArray = new tagDBPROP[structure.cProperties]; for (int i = 0; i < gdbpropArray.Length; i++) { gdbpropArray[i] = new tagDBPROP(); Marshal.PtrToStructure(ADP.IntPtrOffset(structure.rgProperties, i * ODB.SizeOf_tagDBPROP), gdbpropArray[i]); } } finally { if (success) { base.DangerousRelease(); } } return(gdbpropArray); }
internal void SetPropertySet(int index, Guid propertySet, tagDBPROP[] properties) { if ((index < 0) || (PropertySetCount <= index)) { if (lastErrorFromProvider != null) { // add extra error information for CSS/stress troubleshooting. // We need to keep same exception type to avoid breaking change with Orcas RTM/SP1. throw ADP.InternalError(ADP.InternalErrorCode.InvalidBuffer, lastErrorFromProvider); } else { throw ADP.InternalError(ADP.InternalErrorCode.InvalidBuffer); } } Debug.Assert(Guid.Empty != propertySet, "invalid propertySet"); Debug.Assert((null != properties) && (0 < properties.Length), "invalid properties"); IntPtr countOfBytes = (IntPtr)(properties.Length * ODB.SizeOf_tagDBPROP); tagDBPROPSET propset = new tagDBPROPSET(properties.Length, propertySet); bool mustRelease = false; RuntimeHelpers.PrepareConstrainedRegions(); try { DangerousAddRef(ref mustRelease); IntPtr propsetPtr = ADP.IntPtrOffset(DangerousGetHandle(), index * ODB.SizeOf_tagDBPROPSET); RuntimeHelpers.PrepareConstrainedRegions(); try { } finally { // must allocate and clear the memory without interruption propset.rgProperties = SafeNativeMethods.CoTaskMemAlloc(countOfBytes); if (ADP.PtrZero != propset.rgProperties) { // clearing is important so that we don't treat existing // garbage as important information during releaseHandle SafeNativeMethods.ZeroMemory(propset.rgProperties, (int)countOfBytes); // writing the structure to native memory so that it knows to free the referenced pointers Marshal.StructureToPtr(propset, propsetPtr, false /*deleteold*/); } } if (ADP.PtrZero == propset.rgProperties) { throw new OutOfMemoryException(); } for (int i = 0; i < properties.Length; ++i) { Debug.Assert(null != properties[i], "null tagDBPROP " + i.ToString(CultureInfo.InvariantCulture)); IntPtr propertyPtr = ADP.IntPtrOffset(propset.rgProperties, i * ODB.SizeOf_tagDBPROP); Marshal.StructureToPtr(properties[i], propertyPtr, false /*deleteold*/); } } finally { if (mustRelease) { DangerousRelease(); } } }
internal void SetPropertySet(int index, Guid propertySet, tagDBPROP[] properties) { if ((index < 0) || (PropertySetCount <= index)) { if (lastErrorFromProvider != null) { // VSDD 621427: add extra error information for CSS/stress troubleshooting. // We need to keep same exception type to avoid breaking change with Orcas RTM/SP1. throw ADP.InternalError(ADP.InternalErrorCode.InvalidBuffer, lastErrorFromProvider); } else { throw ADP.InternalError(ADP.InternalErrorCode.InvalidBuffer); } } Debug.Assert(Guid.Empty != propertySet, "invalid propertySet"); Debug.Assert((null != properties) && (0 < properties.Length), "invalid properties"); IntPtr countOfBytes = (IntPtr)(properties.Length * ODB.SizeOf_tagDBPROP); tagDBPROPSET propset = new tagDBPROPSET(properties.Length, propertySet); bool mustRelease = false; RuntimeHelpers.PrepareConstrainedRegions(); try { DangerousAddRef(ref mustRelease); IntPtr propsetPtr = ADP.IntPtrOffset(DangerousGetHandle(), index * ODB.SizeOf_tagDBPROPSET); RuntimeHelpers.PrepareConstrainedRegions(); try {} finally { // must allocate and clear the memory without interruption propset.rgProperties = SafeNativeMethods.CoTaskMemAlloc(countOfBytes); if (ADP.PtrZero != propset.rgProperties) { // clearing is important so that we don't treat existing // garbage as important information during releaseHandle SafeNativeMethods.ZeroMemory(propset.rgProperties, countOfBytes); // writing the structure to native memory so that it knows to free the referenced pointers Marshal.StructureToPtr(propset, propsetPtr, false/*deleteold*/); } } if (ADP.PtrZero == propset.rgProperties) { throw new OutOfMemoryException(); } for(int i = 0; i < properties.Length; ++i) { Debug.Assert(null != properties[i], "null tagDBPROP " + i.ToString(CultureInfo.InvariantCulture)); IntPtr propertyPtr = ADP.IntPtrOffset(propset.rgProperties, i * ODB.SizeOf_tagDBPROP); Marshal.StructureToPtr(properties[i], propertyPtr, false/*deleteold*/); } } finally { if (mustRelease) { DangerousRelease(); } } }
internal tagDBPROP[] GetPropertySet(int index, out Guid propertyset) { if ((index < 0) || (PropertySetCount <= index)) { if (lastErrorFromProvider != null) { // VSDD 621427: add extra error information for CSS/stress troubleshooting. // We need to keep same exception type to avoid breaking change with Orcas RTM/SP1. throw ADP.InternalError(ADP.InternalErrorCode.InvalidBuffer, lastErrorFromProvider); } else { throw ADP.InternalError(ADP.InternalErrorCode.InvalidBuffer); } } tagDBPROPSET propset = new tagDBPROPSET(); tagDBPROP[] properties = null; bool mustRelease = false; RuntimeHelpers.PrepareConstrainedRegions(); try { DangerousAddRef(ref mustRelease); IntPtr propertySetPtr = ADP.IntPtrOffset(DangerousGetHandle(), index * ODB.SizeOf_tagDBPROPSET); Marshal.PtrToStructure(propertySetPtr, propset); propertyset = propset.guidPropertySet; properties = new tagDBPROP[propset.cProperties]; for(int i = 0; i < properties.Length; ++i) { properties[i] = new tagDBPROP(); IntPtr ptr = ADP.IntPtrOffset(propset.rgProperties, i * ODB.SizeOf_tagDBPROP); Marshal.PtrToStructure(ptr, properties[i]); } } finally { if (mustRelease) { DangerousRelease(); } } return properties; }
internal tagDBPROP[] GetPropertySet(int index, out Guid propertyset) { if ((index < 0) || (this.PropertySetCount <= index)) { if (this.lastErrorFromProvider != null) { throw ADP.InternalError(ADP.InternalErrorCode.InvalidBuffer, this.lastErrorFromProvider); } throw ADP.InternalError(ADP.InternalErrorCode.InvalidBuffer); } tagDBPROPSET structure = new tagDBPROPSET(); tagDBPROP[] gdbpropArray = null; bool success = false; RuntimeHelpers.PrepareConstrainedRegions(); try { base.DangerousAddRef(ref success); Marshal.PtrToStructure(ADP.IntPtrOffset(base.DangerousGetHandle(), index * ODB.SizeOf_tagDBPROPSET), structure); propertyset = structure.guidPropertySet; gdbpropArray = new tagDBPROP[structure.cProperties]; for (int i = 0; i < gdbpropArray.Length; i++) { gdbpropArray[i] = new tagDBPROP(); Marshal.PtrToStructure(ADP.IntPtrOffset(structure.rgProperties, i * ODB.SizeOf_tagDBPROP), gdbpropArray[i]); } } finally { if (success) { base.DangerousRelease(); } } return gdbpropArray; }
internal void SetPropertySet(int index, Guid propertySet, tagDBPROP[] properties) { if ((index < 0) || (this.PropertySetCount <= index)) { if (this.lastErrorFromProvider != null) { throw ADP.InternalError(ADP.InternalErrorCode.InvalidBuffer, this.lastErrorFromProvider); } throw ADP.InternalError(ADP.InternalErrorCode.InvalidBuffer); } IntPtr cb = (IntPtr) (properties.Length * ODB.SizeOf_tagDBPROP); tagDBPROPSET structure = new tagDBPROPSET(properties.Length, propertySet); bool success = false; RuntimeHelpers.PrepareConstrainedRegions(); try { base.DangerousAddRef(ref success); IntPtr ptr = ADP.IntPtrOffset(base.DangerousGetHandle(), index * ODB.SizeOf_tagDBPROPSET); RuntimeHelpers.PrepareConstrainedRegions(); try { } finally { structure.rgProperties = SafeNativeMethods.CoTaskMemAlloc(cb); if (ADP.PtrZero != structure.rgProperties) { SafeNativeMethods.ZeroMemory(structure.rgProperties, cb); Marshal.StructureToPtr(structure, ptr, false); } } if (ADP.PtrZero == structure.rgProperties) { throw new OutOfMemoryException(); } for (int i = 0; i < properties.Length; i++) { IntPtr ptr2 = ADP.IntPtrOffset(structure.rgProperties, i * ODB.SizeOf_tagDBPROP); Marshal.StructureToPtr(properties[i], ptr2, false); } } finally { if (success) { base.DangerousRelease(); } } }