public SortColumn(ShellPropertyKey propertyKey, SortDirection direction)
        {
            Contract.Requires <ArgumentNullException>(propertyKey != null);

            this.PropertyKey = propertyKey;
            this.Direction   = direction;
        }
        /// <summary>
        ///     指定したプロパティキーに一致する<see cref="ShellPropertyDescription" />を取得します。
        /// </summary>
        /// <param name="propertyKey">プロパティキー</param>
        /// <returns></returns>
        public static ShellPropertyDescription Create(ShellPropertyKey propertyKey)
        {
            Contract.Requires <ArgumentNullException>(propertyKey != null);

            return(Cache.GetOrAdd(propertyKey,
                                  propKey => new ShellPropertyDescription(propKey.PropertyKeyNative)));
        }
        internal SearchCondition(ICondition searchConditionNative)
        {
            Contract.Requires <ArgumentNullException>(searchConditionNative != null);

            this.SearchConditionNative = searchConditionNative;

            ConditionOperation = SearchConditionOperation.Implicit;

            this.PropertyKey = ShellPropertyKey.FromCanonicalName(this.PropertyCanonicalName);
        }
Esempio n. 4
0
        public void SetGroupColumn(ShellPropertyKey propertyKey)
        {
            Contract.Requires <ArgumentNullException>(propertyKey != null);

            var key = propertyKey.PropertyKeyNative;
            var hr  = SearchFolderItemFactory.SetGroupColumn(ref key);

            if (HRESULT.Failed(hr))
            {
                throw ShellException.FromHRESULT(hr);
            }
        }
Esempio n. 5
0
        public static SearchCondition CreateLeafCondition(ShellPropertyKey propertyKey, int value,
                                                          SearchConditionOperation operation)
        {
            Contract.Requires <ArgumentNullException>(propertyKey != null);

            var canonicalName = propertyKey.Name;

            if (string.IsNullOrEmpty(canonicalName))
            {
                throw new ArgumentException(ErrorMessages.SearchConditionFactoryInvalidProperty, nameof(propertyKey));
            }

            return(CreateLeafCondition(canonicalName, value, operation));
        }
        internal T GetPropertyValue <T>(ShellPropertyKey propertyKey)
        {
            var propVar = default(PropVariant);

            try
            {
                this.ShellItemInterface.GetProperty(ref propertyKey.PropertyKeyNative, out propVar);
                return(propVar.GetValue <T>());
            }
            finally
            {
                propVar.Clear();
            }
        }
Esempio n. 7
0
        public static SearchCondition CreateLeafCondition(ShellPropertyKey propertyKey, DateTime value,
                                                          SearchConditionOperation operation)
        {
            Contract.Requires <ArgumentNullException>(propertyKey != null);

            string canonicalName;
            var    key = propertyKey.PropertyKeyNative;

            PropertySystemNativeMethods.PSGetNameFromPropertyKey(ref key, out canonicalName);
            if (string.IsNullOrEmpty(canonicalName))
            {
                throw new ArgumentException(ErrorMessages.SearchConditionFactoryInvalidProperty, nameof(propertyKey));
            }

            return(CreateLeafCondition(canonicalName, value, operation));
        }
Esempio n. 8
0
        /// <summary>
        ///     <see cref="ShellPropertyKey" />と<see cref="ShellPropertyStore" />を指定して、
        ///     <see cref="ShellProperty{T}" />のインスタンスを作成します。
        /// </summary>
        /// <param name="propertyKey"></param>
        /// <param name="propertyStore"></param>
        /// <returns></returns>
        public static IShellProperty Create(ShellPropertyKey propertyKey, ShellPropertyStore propertyStore)
        {
            Contract.Requires <ArgumentNullException>(propertyKey != null);
            Contract.Requires <ArgumentNullException>(propertyStore != null);
            Contract.Ensures(Contract.Result <IShellProperty>() != null);

            var description = ShellPropertyDescriptionFactory.Create(propertyKey);
            var sourceType  = typeof(ShellPropertyStore);
            var type        = typeof(ShellProperty <>).MakeGenericType(VarEnumToSystemType(description.VarEnumType));

            var ctor = ConstructorCache.GetOrAdd(
                GetTypeHash(type, sourceType),
                hashValue =>
            {
                Type[] argTypes = { typeof(ShellPropertyKey), typeof(ShellPropertyDescription), sourceType };
                return(CreateConstructorExpression(type, argTypes));
            });

            return(ctor(propertyKey, description, propertyStore));
        }