Ejemplo n.º 1
0
        private static void AddPropertyAndDependentLegalTrackingPropertiesToSet <T>(HashSet <T> propertySet, StorePropertyDefinition propertyDefinition) where T : PropertyDefinition
        {
            SmartPropertyDefinition smartPropertyDefinition = propertyDefinition as SmartPropertyDefinition;

            if (smartPropertyDefinition != null)
            {
                Schema.AddSmartPropertyToSet <T>(propertySet, smartPropertyDefinition.LegalTrackingDependencies, PropertyDependencyType.AllRead);
                return;
            }
            propertySet.Add(propertyDefinition as T);
        }
        internal static QueryFilter ConversationIdBasedSmartFilterToNativeFilter(this SmartPropertyDefinition conversationIdSmartPropertyDefinition, SinglePropertyFilter filter, PropertyDefinition conversationIdNativePropertyDefinition)
        {
            ComparisonFilter comparisonFilter = filter as ComparisonFilter;

            if (comparisonFilter != null)
            {
                ConversationId conversationId = (ConversationId)comparisonFilter.PropertyValue;
                return(new ComparisonFilter(comparisonFilter.ComparisonOperator, conversationIdNativePropertyDefinition, conversationId.GetBytes()));
            }
            ExistsFilter existsFilter = filter as ExistsFilter;

            if (existsFilter != null)
            {
                return(new ExistsFilter(conversationIdNativePropertyDefinition));
            }
            throw conversationIdSmartPropertyDefinition.CreateInvalidFilterConversionException(filter);
        }
Ejemplo n.º 3
0
        protected PropertyAggregationStrategy(params StorePropertyDefinition[] propertyDefinitions)
        {
            List <PropertyDependency> list = new List <PropertyDependency>(propertyDefinitions.Length);

            foreach (StorePropertyDefinition storePropertyDefinition in propertyDefinitions)
            {
                SmartPropertyDefinition       smartPropertyDefinition       = storePropertyDefinition as SmartPropertyDefinition;
                NativeStorePropertyDefinition nativeStorePropertyDefinition = storePropertyDefinition as NativeStorePropertyDefinition;
                if (smartPropertyDefinition != null)
                {
                    list.AddRange(smartPropertyDefinition.Dependencies);
                }
                else if (nativeStorePropertyDefinition != null)
                {
                    list.Add(new PropertyDependency(nativeStorePropertyDefinition, PropertyDependencyType.NeedForRead));
                }
            }
            this.dependencies = list.ToArray();
        }
        internal static QueryFilter NativeFilterToConversationIdBasedSmartFilter(this SmartPropertyDefinition conversationIdSmartPropertyDefinition, QueryFilter filter, PropertyDefinition conversationIdNativePropertyDefinition)
        {
            SinglePropertyFilter singlePropertyFilter = filter as SinglePropertyFilter;

            if (singlePropertyFilter != null && singlePropertyFilter.Property.Equals(conversationIdNativePropertyDefinition))
            {
                ComparisonFilter comparisonFilter = filter as ComparisonFilter;
                if (comparisonFilter != null)
                {
                    return(new ComparisonFilter(comparisonFilter.ComparisonOperator, conversationIdSmartPropertyDefinition, ConversationId.Create((byte[])comparisonFilter.PropertyValue)));
                }
                ExistsFilter existsFilter = filter as ExistsFilter;
                if (existsFilter != null)
                {
                    return(new ExistsFilter(conversationIdSmartPropertyDefinition));
                }
            }
            return(null);
        }
        public bool IsModifiedProperty(PropertyDefinition propertyDefinition)
        {
            this.CheckDisposed("IsModifiedProperty");
            if (!this.IsException)
            {
                return(false);
            }
            SmartPropertyDefinition smartPropertyDefinition = propertyDefinition as SmartPropertyDefinition;

            if (smartPropertyDefinition != null)
            {
                for (int i = 0; i < smartPropertyDefinition.Dependencies.Length; i++)
                {
                    PropertyDependency propertyDependency = smartPropertyDefinition.Dependencies[i];
                    if ((propertyDependency.Type & PropertyDependencyType.NeedForRead) != PropertyDependencyType.None && this.OccurrencePropertyBag.IsModifiedProperty(propertyDependency.Property))
                    {
                        return(true);
                    }
                }
                return(false);
            }
            return(this.OccurrencePropertyBag.IsModifiedProperty(propertyDefinition));
        }
Ejemplo n.º 6
0
 public object GetValue(SmartPropertyDefinition propertyDefinition)
 {
     return(this.parent.TryGetProperty(propertyDefinition));
 }
Ejemplo n.º 7
0
        protected internal Schema()
        {
            HashSet <PropertyDefinition>      hashSet      = new HashSet <PropertyDefinition>();
            HashSet <PropertyDefinition>      hashSet2     = new HashSet <PropertyDefinition>();
            HashSet <PropertyDefinition>      hashSet3     = new HashSet <PropertyDefinition>();
            List <StoreObjectConstraint>      list         = new List <StoreObjectConstraint>();
            HashSet <PropertyDefinition>      propertySet  = new HashSet <PropertyDefinition>();
            HashSet <PropertyDefinition>      propertySet2 = new HashSet <PropertyDefinition>();
            HashSet <StorePropertyDefinition> propertySet3 = new HashSet <StorePropertyDefinition>();
            HashSet <StorePropertyDefinition> propertySet4 = new HashSet <StorePropertyDefinition>();

            foreach (FieldInfo fieldInfo in ReflectionHelper.AggregateTypeHierarchy <FieldInfo>(base.GetType(), new AggregateType <FieldInfo>(ReflectionHelper.AggregateStaticFields)))
            {
                object value = fieldInfo.GetValue(null);
                StorePropertyDefinition storePropertyDefinition = value as StorePropertyDefinition;
                if (storePropertyDefinition != null && (storePropertyDefinition.PropertyFlags & PropertyFlags.FilterOnly) == PropertyFlags.None)
                {
                    hashSet2.Add(storePropertyDefinition);
                    if (fieldInfo.IsPublic)
                    {
                        hashSet.Add(storePropertyDefinition);
                        if (storePropertyDefinition is SmartPropertyDefinition)
                        {
                            hashSet3.Add(storePropertyDefinition);
                        }
                    }
                    if (fieldInfo.GetCustomAttribute <DetectCodepageAttribute>() != null)
                    {
                        Schema.AddPropertyAndDependentPropertiesToSet <StorePropertyDefinition>(propertySet3, storePropertyDefinition);
                        Schema.AddPropertyAndDependentPropertiesToSet <PropertyDefinition>(propertySet, storePropertyDefinition);
                        Schema.AddPropertyAndDependentPropertiesToSet <PropertyDefinition>(propertySet2, storePropertyDefinition);
                    }
                    else if (fieldInfo.GetCustomAttribute <AutoloadAttribute>() != null)
                    {
                        Schema.AddPropertyAndDependentPropertiesToSet <PropertyDefinition>(propertySet, storePropertyDefinition);
                        Schema.AddPropertyAndDependentPropertiesToSet <PropertyDefinition>(propertySet2, storePropertyDefinition);
                    }
                    else if (storePropertyDefinition is SmartPropertyDefinition)
                    {
                        SmartPropertyDefinition smartPropertyDefinition = (SmartPropertyDefinition)storePropertyDefinition;
                        Schema.AddSmartPropertyToSet <PropertyDefinition>(propertySet, smartPropertyDefinition.Dependencies, PropertyDependencyType.NeedToReadForWrite);
                        Schema.AddSmartPropertyToSet <PropertyDefinition>(propertySet2, smartPropertyDefinition.Dependencies, PropertyDependencyType.NeedToReadForWrite);
                    }
                    else if (fieldInfo.GetCustomAttribute <OptionalAutoloadAttribute>() != null)
                    {
                        Schema.AddPropertyAndDependentPropertiesToSet <PropertyDefinition>(propertySet, storePropertyDefinition);
                    }
                    if (fieldInfo.GetCustomAttribute <LegalTrackingAttribute>() != null)
                    {
                        Schema.AddPropertyAndDependentLegalTrackingPropertiesToSet <StorePropertyDefinition>(propertySet4, storePropertyDefinition);
                    }
                    foreach (object obj in fieldInfo.GetCustomAttributes(typeof(ConstraintAttribute), false))
                    {
                        ConstraintAttribute constraintAttribute = obj as ConstraintAttribute;
                        if (constraintAttribute != null)
                        {
                            list.Add(constraintAttribute.GetConstraint(storePropertyDefinition));
                        }
                    }
                }
            }
            this.allProperties              = hashSet;
            this.allPropertiesInternal      = hashSet2;
            this.smartProperties            = hashSet3;
            this.autoloadProperties         = propertySet;
            this.requiredAutoloadProperties = propertySet2;
            this.detectCodepageProperties   = propertySet3;
            this.legalTrackingProperties    = propertySet4;
            this.AddConstraints(list);
            this.constraints = list.ToArray();
        }
Ejemplo n.º 8
0
 protected IParticipant GetSimpleParticipant(SmartPropertyDefinition definition, PropertyBag.BasicPropertyStore propertyBag)
 {
     return(propertyBag.GetValue(definition) as IParticipant);
 }
Ejemplo n.º 9
0
        internal static QueryFilter SmartIdFilterToNativeIdFilter(SinglePropertyFilter filter, SmartPropertyDefinition smartProperty, PropertyDefinition nativeProperty)
        {
            ComparisonFilter comparisonFilter = filter as ComparisonFilter;

            if (comparisonFilter == null || !comparisonFilter.Property.Equals(smartProperty))
            {
                throw smartProperty.CreateInvalidFilterConversionException(filter);
            }
            if (comparisonFilter.ComparisonOperator != ComparisonOperator.Equal && comparisonFilter.ComparisonOperator != ComparisonOperator.NotEqual)
            {
                throw smartProperty.CreateInvalidFilterConversionException(filter);
            }
            StoreId id = (StoreId)comparisonFilter.PropertyValue;

            return(new ComparisonFilter(comparisonFilter.ComparisonOperator, nativeProperty, StoreId.GetStoreObjectId(id).ProviderLevelItemId));
        }
Ejemplo n.º 10
0
        internal static QueryFilter NativeIdFilterToSmartIdFilter(QueryFilter filter, SmartPropertyDefinition smartProperty, PropertyDefinition nativeProperty)
        {
            ComparisonFilter comparisonFilter = filter as ComparisonFilter;

            if (comparisonFilter == null || !comparisonFilter.Property.Equals(nativeProperty))
            {
                return(null);
            }
            if (comparisonFilter.ComparisonOperator != ComparisonOperator.Equal && comparisonFilter.ComparisonOperator != ComparisonOperator.NotEqual)
            {
                throw new CorruptDataException(ServerStrings.ExComparisonOperatorNotSupportedForProperty(comparisonFilter.ComparisonOperator.ToString(), smartProperty.Name));
            }
            return(new ComparisonFilter(comparisonFilter.ComparisonOperator, smartProperty, StoreObjectId.FromProviderSpecificId((byte[])comparisonFilter.PropertyValue, StoreObjectType.Unknown)));
        }
        public override bool Equals(object obj)
        {
            SmartPropertyDefinition smartPropertyDefinition = obj as SmartPropertyDefinition;

            return(smartPropertyDefinition != null && this.GetHashCode() == smartPropertyDefinition.GetHashCode() && base.Name == smartPropertyDefinition.Name && base.Type.Equals(smartPropertyDefinition.Type));
        }
 protected SmartPropertyDefinition(string displayName, Type valueType, PropertyFlags flags, PropertyDefinitionConstraint[] constraints, params PropertyDependency[] dependencies) : base(PropertyTypeSpecifier.Calculated, displayName, valueType, SmartPropertyDefinition.CalculateSmartPropertyFlags(flags), constraints)
 {
     for (int i = 0; i < dependencies.Length; i++)
     {
     }
     this.dependencies = dependencies;
     this.RegisterFilterTranslation();
 }