Esempio n. 1
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);
        }
Esempio n. 2
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);
        }