Ejemplo n.º 1
0
        /// <summary>
        /// Creates a condition node that is a logical conjunction ("AND") or disjunction ("OR")
        /// of a collection of subconditions.
        /// </summary>
        /// <param name="conditionType">The SearchConditionType of the condition node.
        /// Must be either AndCondition or OrCondition.</param>
        /// <param name="simplify">TRUE to logically simplify the result, if possible;
        /// then the result will not necessarily to be of the specified kind. FALSE if the result should
        /// have exactly the prescribed structure. An application that plans to execute a query based on the
        /// condition tree would typically benefit from setting this parameter to TRUE. </param>
        /// <param name="conditionNodes">Array of subconditions</param>
        /// <returns>New SearchCondition based on the operation</returns>
        public static SearchCondition CreateAndOrCondition(SearchConditionType conditionType, bool simplify, params SearchCondition[] conditionNodes)
        {
            // Same as the native "IConditionFactory:MakeAndOr" method
            IConditionFactory nativeConditionFactory = (IConditionFactory) new ConditionFactoryCoClass();
            ICondition        result = null;

            try
            {
                //
                List <ICondition> conditionList = new List <ICondition>();
                if (conditionNodes != null)
                {
                    foreach (SearchCondition c in conditionNodes)
                    {
                        conditionList.Add(c.NativeSearchCondition);
                    }
                }

                IEnumUnknown subConditions = new EnumUnknownClass(conditionList.ToArray());

                HResult hr = nativeConditionFactory.MakeAndOr(conditionType, subConditions, simplify, out result);

                if (!CoreErrorHelper.Succeeded(hr))
                {
                    throw new ShellException(hr);
                }
            }
            finally
            {
                if (nativeConditionFactory != null)
                {
                    Marshal.ReleaseComObject(nativeConditionFactory);
                }
            }

            return(new SearchCondition(result));
        }
Ejemplo n.º 2
0
 public HResult Clone(out IEnumUnknown result)
 {
     result = new EnumUnknownClass(this.conditionList.ToArray());
     return(HResult.Ok);
 }
Ejemplo n.º 3
0
 public HResult Clone(out IEnumUnknown result)
 {
     result = new EnumUnknownClass(this.conditionList.ToArray());
     return HResult.Ok;
 }
        /// <summary>
        /// Creates a condition node that is a logical conjunction ("AND") or disjunction ("OR") 
        /// of a collection of subconditions.
        /// </summary>
        /// <param name="conditionType">The SearchConditionType of the condition node. 
        /// Must be either AndCondition or OrCondition.</param>
        /// <param name="simplify">TRUE to logically simplify the result, if possible; 
        /// then the result will not necessarily to be of the specified kind. FALSE if the result should 
        /// have exactly the prescribed structure. An application that plans to execute a query based on the 
        /// condition tree would typically benefit from setting this parameter to TRUE. </param>
        /// <param name="conditionNodes">Array of subconditions</param>
        /// <returns>New SearchCondition based on the operation</returns>
        public static SearchCondition CreateAndOrCondition(SearchConditionType conditionType, bool simplify, params SearchCondition[] conditionNodes)
        {
            // Same as the native "IConditionFactory:MakeAndOr" method
            IConditionFactory nativeConditionFactory = (IConditionFactory)new ConditionFactoryCoClass();
            ICondition result = null;

            try
            {
                // 
                List<ICondition> conditionList = new List<ICondition>();
                if (conditionNodes != null)
                {
                    foreach (SearchCondition c in conditionNodes)
                    {
                        conditionList.Add(c.NativeSearchCondition);
                    }
                }

                IEnumUnknown subConditions = new EnumUnknownClass(conditionList.ToArray());

                HResult hr = nativeConditionFactory.MakeAndOr(conditionType, subConditions, simplify, out result);

                if (!CoreErrorHelper.Succeeded(hr)) { throw new ShellException(hr); }
            }
            finally
            {
                if (nativeConditionFactory != null)
                {
                    Marshal.ReleaseComObject(nativeConditionFactory);
                }
            }

            return new SearchCondition(result);
        }