internal TestMultiIndexGrainBase(Type grainClassType, IIndexedState <TGrainState> indexedState)
        {
            this.IndexedState = indexedState;

            var grainInterfaceTypes = ApplicationPartsIndexableGrainLoader.EnumerateIndexedInterfacesForAGrainClassType(grainClassType).ToArray();

            Assert.Single(grainInterfaceTypes);
            var propertiesType = grainInterfaceTypes[0].propertiesType;

            Assert.True(propertiesType.IsClass);

            bool isIndexed(string propertyName)
            {
                var propInfo = propertiesType.GetProperty(propertyName);

                return(propInfo.GetCustomAttributes <IndexAttribute>(inherit: false).Any());
            }

            this.IsUniqueIntIndexed       = isIndexed(nameof(ITestMultiIndexProperties.UniqueInt));
            this.IsUniqueStringIndexed    = isIndexed(nameof(ITestMultiIndexProperties.UniqueString));
            this.IsNonUniqueIntIndexed    = isIndexed(nameof(ITestMultiIndexProperties.NonUniqueInt));
            this.IsNonUniqueStringIndexed = isIndexed(nameof(ITestMultiIndexProperties.NonUniqueString));

            Assert.True(this.IsUniqueIntIndexed || this.IsUniqueStringIndexed || this.IsNonUniqueIntIndexed || this.IsNonUniqueStringIndexed);
        }
Пример #2
0
 internal static void GetDSMIFieldsForASingleGrainType(Type grainClassType, Dictionary <Type, string[]> interfacesToIndexedPropertyNames)
 {
     foreach (var(grainInterfaceType, propertiesClassType) in ApplicationPartsIndexableGrainLoader.EnumerateIndexedInterfacesForAGrainClassType(grainClassType)
              .Where(tup => !interfacesToIndexedPropertyNames.ContainsKey(tup.interfaceType)))
     {
         interfacesToIndexedPropertyNames[grainInterfaceType] = propertiesClassType.GetProperties()
                                                                .Where(propInfo => propInfo.GetCustomAttributes <StorageManagedIndexAttribute>(inherit: false).Any())
                                                                .Select(propInfo => IndexingConstants.UserStatePrefix + propInfo.Name)
                                                                .ToArray();
     }
 }
Пример #3
0
 internal static void GetDSMIFieldsForASingleGrainType(Type grainClassType, Dictionary <Type, string[]> interfacesToIndexedPropertyNames)
 {
     foreach (var(grainInterfaceType, propertiesClassType) in ApplicationPartsIndexableGrainLoader.EnumerateIndexedInterfacesForAGrainClassType(grainClassType)
              .Where(tup => !interfacesToIndexedPropertyNames.ContainsKey(tup.interfaceType)))
     {
         // TODO: See comments in DSMIGrain.LookupGrainReferences; get the path with and without the transactional storage wrapper prefix.
         interfacesToIndexedPropertyNames[grainInterfaceType] = propertiesClassType.GetProperties()
                                                                .Where(propInfo => propInfo.GetCustomAttributes <StorageManagedIndexAttribute>(inherit: false).Any())
                                                                .Select(propInfo => IndexingConstants.UserStatePrefix + propInfo.Name)
                                                                .SelectMany(path => new[] { path, $"{nameof(TransactionalStateRecord<object>.CommittedState)}.{path}" })
                                                                .ToArray();
     }
 }