Skip to content

Commit

Permalink
Made SiloAssemblyLoader recognize concrete state classes passed as ty…
Browse files Browse the repository at this point in the history
…pe arguments to Grain<T> in addition to finding codegen'ed state classes.
  • Loading branch information
sergeybykov committed Jun 2, 2015
1 parent 9a62b20 commit a9128de
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/OrleansRuntime/GrainTypeManager/SiloAssemblyLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,30 @@ public IDictionary<string, GrainTypeData> GetGrainClassTypes(bool strict)
var parameterizedName = grainType.Namespace + "." + TypeUtils.GetParameterizedTemplateName(grainType);
Type grainStateType;
grainStateTypes.TryGetValue(parameterizedName, out grainStateType);

if (grainStateType == null) // check if grainType derives from Grain<T> where T is a concrete class
{
var parentType = grainType.BaseType;
while (parentType != typeof (Grain) && parentType != typeof(object))
{
if (parentType.IsGenericType)
{
var definition = parentType.GetGenericTypeDefinition();
if (definition == typeof (Grain<>))
{
var stateArg = parentType.GetGenericArguments()[0];
if (stateArg.IsClass)
{
grainStateType = stateArg;
break;
}
}
}

parentType = parentType.BaseType;
}
}

GrainTypeData typeData = GetTypeData(grainType, grainStateType);
result.Add(className, typeData);
}
Expand Down

0 comments on commit a9128de

Please sign in to comment.