/// <summary>
        /// Static method for creating masked structural values. Will not hide any properties initially.
        /// </summary>
        /// <param name="toMask">The structural value to mask</param>
        /// <returns>A masked structural value</returns>
        internal static MaskedQueryStructuralValue Create(QueryStructuralValue toMask)
        {
            ExceptionUtilities.CheckArgumentNotNull(toMask, "toMask");
            var masked = new MaskedQueryStructuralValue(toMask.Type, toMask.IsNull, toMask.EvaluationError, toMask.Type.EvaluationStrategy);
            foreach (var memberName in toMask.MemberNames)
            {
                masked.SetValue(memberName, toMask.GetValue(memberName));
            }

            masked.Annotations.AddRange(toMask.Annotations.Select(a => a.Clone()));

            return masked;
        }
        /// <summary>
        /// Static method for creating masked structural values. Will not hide any properties initially.
        /// </summary>
        /// <param name="toMask">The structural value to mask</param>
        /// <returns>A masked structural value</returns>
        internal static MaskedQueryStructuralValue Create(QueryStructuralValue toMask)
        {
            ExceptionUtilities.CheckArgumentNotNull(toMask, "toMask");
            var masked = new MaskedQueryStructuralValue(toMask.Type, toMask.IsNull, toMask.EvaluationError, toMask.Type.EvaluationStrategy);

            foreach (var memberName in toMask.MemberNames)
            {
                masked.SetValue(memberName, toMask.GetValue(memberName));
            }

            masked.Annotations.AddRange(toMask.Annotations.Select(a => a.Clone()));

            return(masked);
        }
Esempio n. 3
0
        /// <summary>
        /// Recursively hides the properties, and any child properties.
        /// </summary>
        /// <param name="maskedQueryValue">The query value with properties to hide.</param>
        /// <param name="propertyName">The name of the property to hide.</param>
        private static void HidePropertyRecursive(MaskedQueryStructuralValue maskedQueryValue, string propertyName)
        {
            var propertyValue = maskedQueryValue.GetValue(propertyName) as QueryStructuralValue;
            if (propertyValue != null)
            {
                var maskedPropertyValue = propertyValue as MaskedQueryStructuralValue;
                if (maskedPropertyValue == null)
                {
                    maskedPropertyValue = MaskedQueryStructuralValue.Create(propertyValue);
                }

                var subPropertyNames = maskedPropertyValue.AllMemberNames.ToList();
                foreach (string subPropertyName in subPropertyNames)
                {
                    HidePropertyRecursive(maskedPropertyValue, subPropertyName);
                }

                maskedQueryValue.SetValue(propertyName, maskedPropertyValue);
            }

            maskedQueryValue.HideMember(propertyName);
        }