public static RoleDescriptor ResolveAndBuild(RoleDescriptorConfiguration configuration) { var descriptor = DescriptorBuildersHelper.ResolveDescriptor(configuration.RoleDescriptorType); var del = DescriptorBuildersHelper.GetDescriptorDelegate(configuration.RoleDescriptorType); return(del(descriptor, configuration)); }
public static object ResolveDescriptor(Type type) { var genericType = typeof(IDescriptorBuilder <>).MakeGenericType(type); var builder = DescriptorBuildersHelper.GetTypes(t => !t.IsAbstract && !t.IsInterface && genericType.IsAssignableFrom(t)) .FirstOrDefault(); if (builder == null) { throw new InvalidOperationException(String.Format("Descriptor builder for type: {0} not found.", genericType.Name)); } return(Activator.CreateInstance(builder)); }
public static Func <object, RoleDescriptorConfiguration, RoleDescriptor> GetDescriptorDelegate(Type type) { return(DescriptorBuildersHelper._delCache.GetOrAdd(type, t => DescriptorBuildersHelper.BuildDelegate(t))); }