/// <summary>
    /// Creates a <see cref="MethodNameBasedNodeTypeRegistry"/> and automatically registers all types implementing <see cref="IExpressionNode"/> 
    /// from a given type sequence that offer a public static <c>SupportedMethodNames</c> field.
    /// </summary>
    /// <returns>A <see cref="MethodInfoBasedNodeTypeRegistry"/> with all <see cref="IExpressionNode"/> types with a <c>SupportedMethodNames</c>
    /// field registered.</returns>
    public static MethodNameBasedNodeTypeRegistry CreateFromTypes (IEnumerable<Type> searchedTypes)
    {
      ArgumentUtility.CheckNotNull ("searchedTypes", searchedTypes);

      var expressionNodeTypes = from t in searchedTypes
                                where typeof (IExpressionNode).GetTypeInfo().IsAssignableFrom (t.GetTypeInfo())
                                select t;

      var infoForTypes =
          from t in expressionNodeTypes
          let supportedMethodNamesField = t.GetRuntimeField ("SupportedMethodNames")
          select new
                 {
                     Type = t,
                     RegistrationInfo =
                         supportedMethodNamesField != null && supportedMethodNamesField.IsStatic
                             ? ((IEnumerable<NameBasedRegistrationInfo>) supportedMethodNamesField.GetValue (null))
                             : Enumerable.Empty<NameBasedRegistrationInfo>()
                 };

      var registry = new MethodNameBasedNodeTypeRegistry();

      foreach (var infoForType in infoForTypes)
        registry.Register (infoForType.RegistrationInfo, infoForType.Type);

      return registry;
    }
Esempio n. 2
0
        /// <summary>
        /// Creates a <see cref="MethodNameBasedNodeTypeRegistry"/> and automatically registers all types implementing <see cref="IExpressionNode"/>
        /// from a given type sequence that offer a public static <c>SupportedMethodNames</c> field.
        /// </summary>
        /// <returns>A <see cref="MethodInfoBasedNodeTypeRegistry"/> with all <see cref="IExpressionNode"/> types with a <c>SupportedMethodNames</c>
        /// field registered.</returns>
        public static MethodNameBasedNodeTypeRegistry CreateFromTypes(IEnumerable <Type> searchedTypes)
        {
            ArgumentUtility.CheckNotNull("searchedTypes", searchedTypes);

            var expressionNodeTypes = from t in searchedTypes
                                      where typeof(IExpressionNode).GetTypeInfo().IsAssignableFrom(t.GetTypeInfo())
                                      select t;

            var infoForTypes =
                from t in expressionNodeTypes
                let supportedMethodNamesField = t.GetRuntimeField("SupportedMethodNames")
                                                select new
            {
                Type             = t,
                RegistrationInfo =
                    supportedMethodNamesField != null && supportedMethodNamesField.IsStatic
                             ? ((IEnumerable <NameBasedRegistrationInfo>)supportedMethodNamesField.GetValue(null))
                             : Enumerable.Empty <NameBasedRegistrationInfo>()
            };

            var registry = new MethodNameBasedNodeTypeRegistry();

            foreach (var infoForType in infoForTypes)
            {
                registry.Register(infoForType.RegistrationInfo, infoForType.Type);
            }

            return(registry);
        }
Esempio n. 3
0
        /// <summary>
        /// Creates a <see cref="MethodNameBasedNodeTypeRegistry"/> and automatically registers all types implementing <see cref="IExpressionNode"/>
        /// from a given type sequence that offer a public static <c>SupportedMethodNames</c> field.
        /// </summary>
        /// <returns>A <see cref="MethodInfoBasedNodeTypeRegistry"/> with all <see cref="IExpressionNode"/> types with a <c>SupportedMethodNames</c>
        /// field registered.</returns>
        public static MethodNameBasedNodeTypeRegistry CreateFromTypes(Type[] searchedTypes)
        {
            var expressionNodeTypes = from t in searchedTypes
                                      where typeof(IExpressionNode).IsAssignableFrom(t)
                                      select t;

            var infoForTypes = from t in expressionNodeTypes
                               let supportedMethodNamesField = t.GetField("SupportedMethodNames", BindingFlags.Static | BindingFlags.Public)
                                                               select new {
                Type             = t,
                RegistrationInfo =
                    supportedMethodNamesField != null
                                             ? ((IEnumerable <NameBasedRegistrationInfo>)supportedMethodNamesField.GetValue(null))
                                             : Enumerable.Empty <NameBasedRegistrationInfo> ()
            };

            var registry = new MethodNameBasedNodeTypeRegistry();

            foreach (var infoForType in infoForTypes)
            {
                registry.Register(infoForType.RegistrationInfo, infoForType.Type);
            }

            return(registry);
        }
Esempio n. 4
0
        /// <summary>
        /// Creates a <see cref="MethodNameBasedNodeTypeRegistry"/> and registers all relevant <see cref="IExpressionNode"/> implementations in the <b>Remotion.Linq</b> assembly.
        /// </summary>
        /// <returns>
        /// A <see cref="MethodInfoBasedNodeTypeRegistry"/> with all <see cref="IExpressionNode"/> types in the <b>Remotion.Linq</b> assembly registered.
        /// </returns>
        public static MethodNameBasedNodeTypeRegistry CreateFromRelinqAssembly()
        {
            var registry = new MethodNameBasedNodeTypeRegistry();

            registry.Register(ContainsExpressionNode.GetSupportedMethodNames(), typeof(ContainsExpressionNode));

            return(registry);
        }
    /// <summary>
    /// Creates a <see cref="MethodNameBasedNodeTypeRegistry"/> and registers all relevant <see cref="IExpressionNode"/> implementations in the <b>Remotion.Linq</b> assembly.
    /// </summary>
    /// <returns>
    /// A <see cref="MethodInfoBasedNodeTypeRegistry"/> with all <see cref="IExpressionNode"/> types in the <b>Remotion.Linq</b> assembly registered.
    /// </returns>
    public static MethodNameBasedNodeTypeRegistry CreateFromRelinqAssembly ()
    {
      var registry = new MethodNameBasedNodeTypeRegistry();

      registry.Register (ContainsExpressionNode.GetSupportedMethodNames(), typeof (ContainsExpressionNode));

      return registry;
    }
    /// <summary>
    /// Creates a <see cref="MethodNameBasedNodeTypeRegistry"/> and automatically registers all types implementing <see cref="IExpressionNode"/> 
    /// from a given type sequence that offer a public static <c>SupportedMethodNames</c> field.
    /// </summary>
    /// <returns>A <see cref="MethodInfoBasedNodeTypeRegistry"/> with all <see cref="IExpressionNode"/> types with a <c>SupportedMethodNames</c>
    /// field registered.</returns>
    public static MethodNameBasedNodeTypeRegistry CreateFromTypes (Type[] searchedTypes)
    {
      var expressionNodeTypes = from t in searchedTypes
                                where typeof (IExpressionNode).IsAssignableFrom (t)
                                select t;

      var infoForTypes = from t in expressionNodeTypes
                                     let supportedMethodNamesField = t.GetField ("SupportedMethodNames", BindingFlags.Static | BindingFlags.Public)
                                     select new { 
                                         Type = t,
                                         RegistrationInfo =
                                         supportedMethodNamesField != null
                                             ? ((IEnumerable<NameBasedRegistrationInfo>) supportedMethodNamesField.GetValue (null))
                                             : Enumerable.Empty<NameBasedRegistrationInfo> ()
                                     };

      var registry = new MethodNameBasedNodeTypeRegistry();

      foreach (var infoForType in infoForTypes)
        registry.Register (infoForType.RegistrationInfo, infoForType.Type);

      return registry;
    }
 public void SetUp ()
 {
   _registry = new MethodNameBasedNodeTypeRegistry ();
 }