public PluginService(IPathProvider pathProvider, IReflectionProvider reflectionProvider, IDirectoryProvider directoryProvider, IAssemblyProvider assemblyProvider) { _pathProvider = pathProvider; _reflectionProvider = reflectionProvider; _directoryProvider = directoryProvider; _assemblyProvider = assemblyProvider; }
public BDDTestSuite(IReflectionProvider reflectionProvider, ITypeManager typeManager, Type fixtureType) : base(fixtureType) { _reflectionProvider = reflectionProvider; _typeManager = typeManager; BuildTestsFromFixtureType(fixtureType); }
//public static bool IsDefault(object value, IReflectionProvider provider) //{ // if (value is string) // return (string)value == string.Empty; // if (value is char) // return (char)value == '\0'; // if(IsINT(value)) // return Convert.ToInt64(value) == 0; // if (IsUINT(value)) // return Convert.ToUInt64(value) == 0; // if (IsFLOAT(value)) // return Convert.ToDecimal(value) == 0; // if (value is bool) // return (bool)value == false; // if (value is ICollection) // return (value as ICollection).Count == 0; // if (value is Array) // return (value as Array).Length == 0; // Type type = value.GetType(); // if (type.IsEnum) // return (int)value == 0; // if (type.IsHashSet()) // return (int)provider.GetValue(type // .GetProperty("Count", BindingFlags.ExactBinding | ReflectionHelper.PublicInstanceMembers, null, typeof(int), Type.EmptyTypes, null), // value) == 0; // return value.Equals(provider.Instantiate(type)); //} public static object GetDefaultValue(Type inType, IReflectionProvider provider, ILogPrinter inLogger) { if (inType.IsValueType) { return(provider.Instantiate(inType, inLogger)); } return(null); }
/// <summary> /// Creates the type space. /// </summary> /// <param name="provider">The reflection provider to use.</param> public InvertedTypeSpace(IReflectionProvider provider) { _properties = new Dictionary <PropertyInfoSlim, PropertyInfo>(); _fields = new Dictionary <FieldInfoSlim, FieldInfo>(); _methods = new Dictionary <MethodInfoSlim, MethodInfo>(); _constructors = new Dictionary <ConstructorInfoSlim, ConstructorInfo>(); _typeConverter = new TypeSlimToTypeConverter(provider); _provider = provider; }
public CCascadeSerializer(EReflectorType inReflectorType, CParserManager parser) { switch (inReflectorType) { case EReflectorType.Cached: _reflectionProvider = new CachedReflector(); break; case EReflectorType.Direct: _reflectionProvider = new DirectReflector(); break; } _parser = parser; }
public BDDNUnitTestMethod(MethodInfo method, Type testTypeAttribute, IReflectionProvider reflectionProvider, ITestDescriber testDescriber, ITestExceptionWriter testExceptionWriter) : base(method) { _reflectionProvider = reflectionProvider; _testDescriber = testDescriber; _testExceptionWriter = testExceptionWriter; TestTypeAttribute = testTypeAttribute; GivenMethods = new BDDNUnitTestMethod[0]; WhenMethods = new BDDNUnitTestMethod[0]; }
public void SetReflectionAssemblies(IEnumerable <string> assemblyPaths) { List <Assembly> assemblies = new List <Assembly>(); foreach (string assemblyPath in assemblyPaths) { assemblies.Add(Assembly.LoadFrom(assemblyPath)); } reflectionProvider = new ReflectionProvider(assemblies); }
public DistributeLogDumpCreator( IServiceClient <LogDto> logRepository, IDateTimeProvider dateTimeProvider, IFileProvider fileProvider, IDirectoryProvider directoryProvider, IPathProvider pathProvider, IConsoleProvider consoleProvider, IReflectionProvider reflectionProvider) { _logRepository = logRepository; _dateTimeProvider = dateTimeProvider; _fileProvider = fileProvider; _directoryProvider = directoryProvider; _pathProvider = pathProvider; _consoleProvider = consoleProvider; _reflectionProvider = reflectionProvider; }
public SCollect(object inInstance, Type type, IReflectionProvider provider) { _instance = inInstance; bool isHashSet = type.IsHashSet(); if (isHashSet) { _addToHashSet = provider.GetDelegate(type.GetMethod("Add")); _list = null; } else { _addToHashSet = null; _list = inInstance as IList; } }
public static bool IsDefault(object value, IReflectionProvider provider, ILogPrinter inLogger) { Type type = value.GetType(); if (type.IsValueType) { var t = provider.Instantiate(type, inLogger); return(t.Equals(value)); } else { if (value == null) { return(true); } if (value is string) { return(string.IsNullOrEmpty((string)value)); } if (value is ICollection) { return((value as ICollection).Count == 0); } if (type.IsHashSet()) { return((int)provider.GetValue(type .GetProperty("Count", BindingFlags.ExactBinding | ReflectionHelper.PublicInstanceMembers, null, typeof(int), Type.EmptyTypes, null), value) == 0); } return(false); } }
public Serializer(IReflectionProvider reflectionProvider) { _reflectionProvider = reflectionProvider; this.serializer = new NetDataContractSerializer("object", string.Empty); }
public static bool StringToAtomicValue(string inText, Type inType, out object outValue, IReflectionProvider provider, ILogPrinter inLogger) { if (inType == typeof(string)) { outValue = inText; return(true); } if (inType.IsEnum) { if (string.IsNullOrEmpty(inText)) { outValue = GetDefaultValue(inType, provider, inLogger); return(false); } try { outValue = Enum.Parse(inType, inText, true); } catch (ArgumentException) { outValue = GetDefaultValue(inType, provider, inLogger); return(false); } return(true); } outValue = 0; TypeConverter converter = TypeDescriptor.GetConverter(inType); try { outValue = converter.ConvertFromString(null, CultureInfo.InvariantCulture, inText); } catch (Exception ex) { //inLogger.LogError(ex.Message); return(false); } return(true); }
public BDDSuiteBuilder(IReflectionProvider reflectionProvider) : base() { _reflectionProvider = reflectionProvider; }
public BDDSuiteBuilder(IReflectionProvider reflectionProvider, ITypeManager typeManager) : base() { _reflectionProvider = reflectionProvider; _typeManager = typeManager; }
public BDDTestCaseBuilder(IReflectionProvider reflectionProvider, ITestDescriber testDescriber) : base() { _reflectionProvider = reflectionProvider; _testDescriber = testDescriber; }
public TypeManager(IReflectionProvider reflectionProvider, ITestDescriber testDescriber, ITestExceptionWriter testExceptionWriter) { _reflectionProvider = reflectionProvider; _testDescriber = testDescriber; _testExceptionWriter = testExceptionWriter; }
public MemoizedReflectionProvider(IReflectionProvider reflectionProvider) { provider = reflectionProvider; Reset(); }
/// <summary> /// Converts the lightweight representation of an expression to an expression using the specified expression factory and reflection provider. /// </summary> /// <param name="expression">Slim expression to convert.</param> /// <param name="factory">The expression factory to use.</param> /// <param name="provider">The reflection provider to use.</param> /// <returns>Expression represented by the slim expression.</returns> public static Expression ToExpression(this ExpressionSlim expression, IExpressionFactory factory, IReflectionProvider provider) { if (expression == null) { throw new ArgumentNullException(nameof(expression)); } if (factory == null) { throw new ArgumentNullException(nameof(factory)); } if (provider == null) { throw new ArgumentNullException(nameof(provider)); } return(new ExpressionSlimToExpressionConverter(new InvertedTypeSpace(provider), factory).Visit(expression)); }