protected string DynamicCompile(string name, AbstractClause clause) { MethodInfo methodInfo = this.GetType() .GetMethod(name, BindingFlags.NonPublic | BindingFlags.Instance); if (methodInfo == null) { throw new Exception($"Failed to locate a compiler for {name}."); } var isGeneric = clause.GetType() #if FEATURE_TYPE_INFO .GetTypeInfo() #endif .IsGenericType; if (isGeneric && methodInfo.GetGenericArguments().Any()) { var args = clause.GetType().GetGenericArguments(); methodInfo = methodInfo.MakeGenericMethod(args); } var result = methodInfo.Invoke(this, new object[] { clause }); return(result as string); }
/// <summary> /// Add a component clause to the factory. /// </summary> /// <param name="component"></param> /// <param name="clause"></param> /// <param name="engineCode"></param> /// <returns></returns> public Q AddComponent(string component, AbstractClause clause, string engineCode = null) { if (engineCode == null) { engineCode = EngineScope; } clause.Engine = engineCode; clause.Component = component; Clauses.Add(clause); return(instance); }
protected string DynamicCompile(string name, AbstractClause clause) { MethodInfo methodInfo = this.GetType() .GetMethod(name, BindingFlags.NonPublic | BindingFlags.Instance); if (methodInfo == null) { throw new Exception($"Failed to locate a compiler for {name}."); } if (methodInfo.GetGenericArguments().Any() && clause.GetType().GetTypeInfo().IsGenericType) { methodInfo = methodInfo.MakeGenericMethod(clause.GetType().GenericTypeArguments.First()); } var result = methodInfo.Invoke(this, new object[] { clause }); return(result as string); }
private InvalidCastException InvalidClauseException(string section, AbstractClause clause) { return(new InvalidCastException($"Invalid type \"{clause.GetType().Name}\" provided for the \"{section}\" clause.")); }
public AbstractClause(AbstractClause other) { Engine = other.Engine; Component = other.Component; }