Esempio n. 1
0
        public static HRESULT GetPropertyName(IContactPropertyCollection propertyCollection, out string name)
        {
            name = null;
            Verify.IsNotNull(propertyCollection, "propertyCollection");

            var sb = new StringBuilder((int)Win32Value.MAX_PATH);
            uint cch;
            HRESULT hr = propertyCollection.GetPropertyName(sb, (uint)sb.Capacity, out cch);
            // If we didn't have enough space for the node the first time through, try the bigger size.
            if (Win32Error.ERROR_INSUFFICIENT_BUFFER == hr)
            {
                sb.EnsureCapacity((int)cch);
                hr = propertyCollection.GetPropertyName(sb, (uint)sb.Capacity, out cch);

                // If this failed a second time, it shouldn't be because of an insufficient buffer.
                Assert.Implies(hr.Failed(), Win32Error.ERROR_INSUFFICIENT_BUFFER != hr);
            }

            if (hr.Succeeded())
            {
                name = sb.ToString();
            }

            return hr;
        }
 public extern virtual HRESULT GetPropertyCollection(out IContactPropertyCollection ppPropertyCollection, uint dwFlags, string pszMultiValueName, uint dwLabelCount, IntPtr ppszLabels, uint fAnyLabelMatches);
Esempio n. 3
0
        public static HRESULT GetPropertyCollection(INativeContactProperties contact, string collection, string[] labels, bool anyLabelMatches, out IContactPropertyCollection propertyCollection)
        {
            Verify.IsNotNull(contact, "contact");

            uint fAnyLabelMatches = anyLabelMatches ? Win32Value.TRUE : Win32Value.FALSE;

            using (var mlc = new MarshalableLabelCollection(labels))
            {
                return contact.GetPropertyCollection(out propertyCollection, ContactValue.CGD_DEFAULT, collection, mlc.Count, mlc.MarshaledLabels, fAnyLabelMatches);
            }
        }
Esempio n. 4
0
        public static HRESULT GetPropertyVersion(IContactPropertyCollection propertyCollection, out int version)
        {
            version = -1;
            Verify.IsNotNull(propertyCollection, "propertyCollection");

            uint dwVersion;
            HRESULT hr = propertyCollection.GetPropertyVersion(out dwVersion);
            if (hr.Succeeded())
            {
                version = (int)dwVersion;
            }

            return hr;
        }
Esempio n. 5
0
        public static HRESULT GetPropertyType(IContactPropertyCollection propertyCollection, out uint type)
        {
            type = ContactValue.CGD_UNKNOWN_PROPERTY;
            Verify.IsNotNull(propertyCollection, "propertyCollection");

            return propertyCollection.GetPropertyType(out type);
        }
Esempio n. 6
0
        public static HRESULT GetPropertyID(IContactPropertyCollection propertyCollection, out Guid guid)
        {
            guid = default(Guid);
            Verify.IsNotNull(propertyCollection, "propertyCollection");

            // Allocate a StringBuilder big enough to hold a guid.  No retry logic here.
            StringBuilder sb = new StringBuilder(100);
            uint cch;
            HRESULT hr = propertyCollection.GetPropertyArrayElementID(sb, (uint)sb.Capacity, out cch);
            // This should never fail for the reason of insufficient buffer.
            Assert.AreNotEqual<HRESULT>(Win32Error.ERROR_INSUFFICIENT_BUFFER, hr);
            
            // Contacts returns S_OK when this isn't an array-node, but it leaves the string blank.
            if (hr.Succeeded())
            {
                if (sb.Length == 0)
                {
                    uint dwType;
					GetPropertyType(propertyCollection, out dwType);
                    Assert.AreNotEqual(dwType, ContactValue.CGD_ARRAY_NODE);
                    hr = Win32Error.ERROR_INVALID_DATATYPE;
                }
                else
                {
                    guid = new Guid(sb.ToString());
                }
            }

            return hr;
        }
Esempio n. 7
0
        public static HRESULT GetPropertyModificationDate(IContactPropertyCollection propertyCollection, out DateTime date)
        {
            date = default(DateTime);
            Verify.IsNotNull(propertyCollection, "propertyCollection");

            FILETIME ft;
            HRESULT hr = propertyCollection.GetPropertyModificationDate(out ft);
            if (hr.Succeeded())
            {
                date = DateTimeFromFILETIME(ft);
            }
            return hr;
        }