示例#1
0
        public object?InvokeMethod(string method, Type type, object parameters)
        {
            if (TypeManipulations.GetMethodInfo(TypeOfObject, method, parameters)?.ContainsGenericParameters ?? false)
            {
                var genericMethod = TypeManipulations.GetMethodInfo(TypeOfObject, method, parameters)?.MakeGenericMethod(new[] { type }) ?? null;

                return(genericMethod?.Invoke((TypeManipulations.GetMethodInfo(TypeOfObject, method, parameters)?.IsStatic ?? false) ? null : ActualObject, TypeManipulations.ToObjectArray(parameters)));
            }

            return(TypeManipulations.GetMethodInfo(TypeOfObject, method, parameters)?
                   .Invoke(ActualObject, TypeManipulations.ToObjectArray(parameters)));
        }
示例#2
0
 public List <string> GetMethodsName()
 {
     return(TypeManipulations.GetMethodsInfo(TypeOfObject)
            .Where(method =>
                   !method.IsSpecialName &&
                   !method.Name.Equals("Show") &&
                   !method.Name.Equals("Equals") &&
                   !method.Name.Equals("ToString") &&
                   !method.Name.Equals("GetType") &&
                   !method.Name.Equals("GetHashCode"))
            .Select(method => method.Name)
            .ToList());
 }
示例#3
0
        public List <Property> GetProperties()
        {
            List <Property> properties = new List <Property>();

            TypeManipulations.GetPropertiesInfos(TypeOfObject).ForEach(propertyInfo => properties.Add(new Property()
            {
                PropertyName  = propertyInfo.Name,
                PropertyType  = propertyInfo.PropertyType,
                PropertyValue = propertyInfo?.GetValue(ActualObject) ?? null
            }));


            return(properties);
        }
示例#4
0
        public static Dependency AddDependency(string name, Type type)
        {
            var tpe = (name != type.Name) ? TypeManipulations.GetType(name, type) : type;

            Dependency dep = new Dependency(tpe);

            if (Dependencies.FirstOrDefault(t => t.TypeOfObject != null && t.TypeOfObject.Name.Equals(tpe.Name)) == null)
            {
                if (dep.TypeOfObject.Name.Contains("Services") || (dep.TypeOfObject.BaseType != null && dep.TypeOfObject.BaseType.Name.Equals("Menu") || dep.Needed))
                {
                    Dependencies.Add(dep);
                }
            }

            return(dep);
        }
示例#5
0
        private object?InvokeCrudMethod(string methodName, object?parameters)
        {
            Dependency crudDependency = Container.GetDependency("CrudOperations");
            string     method         = crudDependency.GetMethodsName().FirstOrDefault(meth => methodName.StartsWith(meth));

            if (!String.IsNullOrEmpty(method))
            {
                Type modelType = TypeManipulations.GetType(methodName.Remove(0, method.Length), GetType());

                if (modelType != null)
                {
                    return(crudDependency.InvokeMethod(method, modelType, parameters != null ? method.Equals("Create") ? parameters.GetType().Name.Equals("Property") ? new [] { parameters } : new [] { TypeManipulations.ToProperty(parameters) } : new [] { parameters } : null));
                }
            }

            return(null);
        }
示例#6
0
 public object?InvokeMethod(string method, object parameters)
 {
     return(TypeManipulations.GetMethodInfo(TypeOfObject, method, parameters)?.Invoke(ActualObject, TypeManipulations.ToObjectArray(parameters)) ?? null);
 }
示例#7
0
 public object?InvokeMethod(string method)
 {
     return(TypeManipulations.GetMethodInfo(TypeOfObject, method, null)?.Invoke(ActualObject, null));
 }
示例#8
0
        public object Initialise(object parameters)
        {
            Initialised = true;

            return(ActualObject = TypeOfObject.GetConstructors()[0].Invoke(TypeManipulations.ToObjectArray(parameters)));
        }