Beispiel #1
0
        public static RoleDescriptor ResolveAndBuild(RoleDescriptorConfiguration configuration)
        {
            var descriptor = DescriptorBuildersHelper.ResolveDescriptor(configuration.RoleDescriptorType);
            var del        = DescriptorBuildersHelper.GetDescriptorDelegate(configuration.RoleDescriptorType);

            return(del(descriptor, configuration));
        }
Beispiel #2
0
        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));
        }
Beispiel #3
0
 public static Func <object, RoleDescriptorConfiguration, RoleDescriptor> GetDescriptorDelegate(Type type)
 {
     return(DescriptorBuildersHelper._delCache.GetOrAdd(type, t => DescriptorBuildersHelper.BuildDelegate(t)));
 }