コード例 #1
0
ファイル: DbPropSet.cs プロジェクト: aik-jahoda/runtime
        internal static DBPropSet CreateProperty(Guid propertySet, int propertyId, bool required, object value)
        {
            ItagDBPROP dbprop      = OleDbStructHelpers.CreateTagDbProp(propertyId, required, value);
            DBPropSet  propertyset = new DBPropSet(1);

            propertyset.SetPropertySet(0, propertySet, new ItagDBPROP[1] {
                dbprop
            });
            return(propertyset);
        }
コード例 #2
0
        internal Dictionary <string, OleDbPropertyInfo> GetValues()
        {
            Dictionary <string, OleDbPropertyInfo> propertyLookup = null;

            bool mustRelease = false;

            RuntimeHelpers.PrepareConstrainedRegions();
            try
            {
                DangerousAddRef(ref mustRelease);
                if (ADP.PtrZero != this.handle)
                {
                    propertyLookup = new Dictionary <string, OleDbPropertyInfo>(StringComparer.OrdinalIgnoreCase);

                    IntPtr           setPtr      = this.handle;
                    ItagDBPROPINFO   propinfo    = OleDbStructHelpers.CreateTagDbPropInfo();
                    tagDBPROPINFOSET propinfoset = new tagDBPROPINFOSET();

                    for (int i = 0; i < setCount; ++i, setPtr = ADP.IntPtrOffset(setPtr, ODB.SizeOf_tagDBPROPINFOSET))
                    {
                        Marshal.PtrToStructure(setPtr, propinfoset);

                        int    infoCount = propinfoset.cPropertyInfos;
                        IntPtr infoPtr   = propinfoset.rgPropertyInfos;
                        for (int k = 0; k < infoCount; ++k, infoPtr = ADP.IntPtrOffset(infoPtr, ODB.SizeOf_tagDBPROPINFO))
                        {
                            Marshal.PtrToStructure(infoPtr, propinfo);

                            OleDbPropertyInfo propertyInfo = new OleDbPropertyInfo();
                            propertyInfo._propertySet     = propinfoset.guidPropertySet;
                            propertyInfo._propertyID      = propinfo.dwPropertyID;
                            propertyInfo._flags           = propinfo.dwFlags;
                            propertyInfo._vtype           = propinfo.vtType;
                            propertyInfo._supportedValues = propinfo.vValue;
                            propertyInfo._description     = propinfo.pwszDescription;
                            propertyInfo._lowercase       = propinfo.pwszDescription.ToLowerInvariant();
                            propertyInfo._type            = PropertyInfoSet.FromVtType(propinfo.vtType);

                            propertyLookup[propertyInfo._lowercase] = propertyInfo;
                        }
                    }
                }
            }
            finally
            {
                if (mustRelease)
                {
                    DangerousRelease();
                }
            }
            return(propertyLookup);
        }
コード例 #3
0
ファイル: DbPropSet.cs プロジェクト: aik-jahoda/runtime
        internal ItagDBPROP[] GetPropertySet(int index, out Guid propertyset)
        {
            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);
                }
            }

            tagDBPROPSET propset = new tagDBPROPSET();

            ItagDBPROP[] 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 ItagDBPROP[propset.cProperties];
                for (int i = 0; i < properties.Length; ++i)
                {
                    properties[i] = OleDbStructHelpers.CreateTagDbProp();
                    IntPtr ptr = ADP.IntPtrOffset(propset.rgProperties, i * ODB.SizeOf_tagDBPROP);
                    Marshal.PtrToStructure(ptr, properties[i]);
                }
            }
            finally
            {
                if (mustRelease)
                {
                    DangerousRelease();
                }
            }
            return(properties);
        }