Exemplo n.º 1
0
        internal static IEnumerable <Attribute> GetCustomAttributes(this DbMethodInfoCache type)
        {
            if (IsAnonymousType(type.DeclaringClass))
            {
                return(new Attribute[0]);                //Anonymous types does not have any Attributes
            }

            return(type.Attributes.Select(s => s.Attribute));
        }
Exemplo n.º 2
0
        /// <summary>
        ///     Adds a Fake Mehtod to the class
        /// </summary>
        public void CreateMethod(string methodName, Func <object, object[], object> methodBody,
                                 params DbAttributeInfoCache[] attributes)
        {
            if (methodName == null)
            {
                throw new ArgumentNullException(nameof(methodName));
            }
            if (methodBody == null)
            {
                throw new ArgumentNullException(nameof(methodBody));
            }
            if (ClassInfoCache.Mehtods.Any(s => s.MethodName == methodName))
            {
                throw new ArgumentOutOfRangeException(nameof(methodName), "Method name does exist. Cannot define a Method twice");
            }
            var mehtodInfo = new DbMethodInfoCache(methodBody, ClassInfoCache.Type, methodName, attributes);

            ClassInfoCache.Mehtods.Add(mehtodInfo);
        }
Exemplo n.º 3
0
        /// <summary>
        ///     Adds a Fake Mehtod to the class
        /// </summary>
        public void CreateMethod <Source, Output>(string methodName, Func <Source, Output> methodBody)
        {
            if (methodName == null)
            {
                throw new ArgumentNullException(nameof(methodName));
            }
            if (methodBody == null)
            {
                throw new ArgumentNullException(nameof(methodBody));
            }
            if (ClassInfoCache.Mehtods.Any(s => s.MethodName == methodName))
            {
                throw new ArgumentOutOfRangeException(nameof(methodName), "Method name does exist. Cannot define a Method twice");
            }
            var mehtodInfo = new DbMethodInfoCache();

            mehtodInfo.Init((o, objects) => { return(methodBody((Source)o)); }, ClassInfoCache.Type,
                            methodName);
            ClassInfoCache.Mehtods.Add(mehtodInfo);
        }
Exemplo n.º 4
0
        /// <summary>
        ///     Adds a Fake Mehtod to the class
        /// </summary>
        public void CreateMethod <Source, Input>(string methodName, Action <Source, Input> methodBody,
                                                 params DbAttributeInfoCache[] attributes)
        {
            if (methodName == null)
            {
                throw new ArgumentNullException(nameof(methodName));
            }
            if (methodBody == null)
            {
                throw new ArgumentNullException(nameof(methodBody));
            }
            if (ClassInfoCache.Mehtods.Any(s => s.MethodName == methodName))
            {
                throw new ArgumentOutOfRangeException(nameof(methodName), "Method name does exist. Cannot define a Method twice");
            }
            var mehtodInfo = new DbMethodInfoCache((o, objects) =>
            {
                methodBody((Source)o, (Input)objects[0]);
                return(null);
            }, ClassInfoCache.Type, methodName, attributes);

            ClassInfoCache.Mehtods.Add(mehtodInfo);
        }