public void CallMethod_Static() { // public static bool string.IsNullOrEmpty (string aString); var output = ReflectedObject.CallMethod(typeof(string), "IsNullOrEmpty", "notEmpty"); Assert.That(output.To <bool>(), Is.False); }
public void CallMethod_ExistingMethod_WithReflectedObject() { var reflectedObject = new ReflectedObject("stringContent"); var output = reflectedObject.CallMethod("IndexOf", new ReflectedObject('t')); Assert.That(output.To <int>(), Is.EqualTo(1)); }
public override ReflectedObject BuildConfigurationFromAssemblies(Assembly[] assemblies) { ArgumentUtility.CheckNotNull("assemblies", assemblies); var declarativeConfigurationBuilderType = RemotionAssembly.GetType("Remotion.Mixins.Context.DeclarativeConfigurationBuilder", true); return(ReflectedObject.CallMethod(declarativeConfigurationBuilderType, "BuildConfigurationFromAssemblies", new object[] { assemblies })); }
public void CallMethod_ExistingMethod_Void() { // TargetDoSomething has method: public void DoSomething() var reflectedObject = new ReflectedObject(new TargetDoSomething()); var output = reflectedObject.CallMethod("DoSomething"); Assert.That(output, Is.Null); }
public override ReflectedObject GetTargetClassDefinition(Type targetType, ReflectedObject mixinConfiguration, ReflectedObject classContext) { ArgumentUtility.CheckNotNull("targetType", targetType); ArgumentUtility.CheckNotNull("mixinConfiguration", mixinConfiguration); var targetClassDefinitionFactoryType = RemotionAssembly.GetType("Remotion.Mixins.Definitions.TargetClassDefinitionFactory", true); return(ReflectedObject.CallMethod(targetClassDefinitionFactoryType, "CreateTargetClassDefinition", classContext)); }
public virtual ReflectedObject GetTargetClassDefinition(Type targetType, ReflectedObject mixinConfiguration, ReflectedObject classContext) { ArgumentUtility.CheckNotNull("targetType", targetType); ArgumentUtility.CheckNotNull("mixinConfiguration", mixinConfiguration); var targetClassDefinitionUtilityType = _remotionAssembly.GetType("Remotion.Mixins.TargetClassDefinitionUtility", true); return(ReflectedObject.CallMethod(targetClassDefinitionUtilityType, "GetConfiguration", targetType, mixinConfiguration)); }
public override void InitializeLogging() { var type = RemotionAssembly.GetType("Remotion.Logging.LogManager", true); object logger = ReflectedObject.CallMethod(type, "GetLogger", "LoggerName"); if (logger == null) { throw new InvalidOperationException("Failed to initialize log4net."); } }
public void CallMethod_NonExistingMethod() { var reflectedObject = new ReflectedObject("stringContent"); try { reflectedObject.CallMethod("nonExistingMethod"); Assert.Fail("expected exception not thrown"); } catch (MissingMethodException missingMethodException) { Assert.That(missingMethodException.Message, Is.EqualTo("Method 'nonExistingMethod' not found on type 'System.String'.")); } }
private ReflectedObject GetMixinDefiniton(Type mixinType, ReflectedObject targetClassDefinition) { return(targetClassDefinition == null ? null : targetClassDefinition.CallMethod("GetMixinByConfiguredType", mixinType)); }
public override ITypeDiscoveryService GetTypeDiscoveryService() { var type = RemotionAssembly.GetType("Remotion.Reflection.TypeDiscovery.ContextAwareTypeDiscoveryUtility", true); return(ReflectedObject.CallMethod(type, "GetTypeDiscoveryService").To <ITypeDiscoveryService>()); }
private ReflectedObject GetMixinDefiniton(Type mixinType, ReflectedObject targetClassDefinition) { return targetClassDefinition == null ? null : targetClassDefinition.CallMethod ("GetMixinByConfiguredType", mixinType); }
public void CallMethod_ExistingMethod_Void() { // TargetDoSomething has method: public void DoSomething() var reflectedObject = new ReflectedObject (new TargetDoSomething()); var output = reflectedObject.CallMethod ("DoSomething"); Assert.That (output, Is.Null); }
public void CallMethod_ExistingMethod() { var reflectedObject = new ReflectedObject ("stringContent"); var output = reflectedObject.CallMethod ("IndexOf", 't'); Assert.That (output.To<int>(), Is.EqualTo (1)); }
public void CallMethod_NonExistingMethod() { var reflectedObject = new ReflectedObject ("stringContent"); try { reflectedObject.CallMethod ("nonExistingMethod"); Assert.Fail ("expected exception not thrown"); } catch (MissingMethodException missingMethodException) { Assert.That (missingMethodException.Message, Is.EqualTo ("Method 'nonExistingMethod' not found on type 'System.String'.")); } }