Exemplo n.º 1
0
 public void Add(SystemFunction systemFunction)
 {
     string functionId = systemFunction.Id.ToLower();
     if (map.ContainsKey(functionId))
     {
         //throw new PsimulexCoreException(
         //    string.Format("System function with name {0} already defined.", systemFunction.Name));
     }
     else
     {
         map.Add(functionId, systemFunction);
     }
 }
Exemplo n.º 2
0
        private void Explore(ILibrary library)
        {
            // The BindingFlags parameter must be extended
            MethodInfo[] methodsOfLibrary = library.GetType().GetMethods(System.Reflection.BindingFlags.IgnoreCase |
                        System.Reflection.BindingFlags.Instance |
                        System.Reflection.BindingFlags.Public);

            methodsOfLibrary = methodsOfLibrary.Where(mi => mi.Name != "get_System" && mi.Name != "set_System").ToArray();

            foreach (var method in methodsOfLibrary)
            {
                var systemFunction = new SystemFunction
                {
                    Name = method.Name.ToLower(),
                    HostObject = library,
                    MethodInfo = method,
                };
                if (method.ReturnType != typeof(void))
                {
                    systemFunction.ReturnValueType = new VariableDescriptor { Name = null, Type = CreateTypeIdFromSystemType(method.ReturnType) };
                }

                foreach(var parameter in method.GetParameters())
                {
                    systemFunction.Parameters.Add(new VariableDescriptor
                    {
                        Name = parameter.Name,
                        Type = CreateTypeIdFromSystemType(parameter.ParameterType),
                        IsReference = parameter.ParameterType.IsByRef || parameter.IsOut
                    });
                }

                systemFunctions.Add(systemFunction);
            }
        }