Exemplo n.º 1
0
        public static void LsObj(string[] args)
        {
            if (args.Length != 1)
            {
                Log.WriteError("Expected OdbObject name.");
                return;
            }

            OdbObject obj = ObjectDatabase.Global.GetObject(args[0]);

            if (obj == null)
            {
                Log.WriteError("No OdbObject with that name.");
                return;
            }

            Log.WriteLine($"OdbObject {obj.identifier} has {obj.fields.Count} fields and {obj.methods.Count} methods.");
            string fieldPrefix = " FLD| ";

            foreach (OdbField field in obj.fields.Values)
            {
                Log.WriteLine(fieldPrefix + field.type.Name + " " + field.identifier);
            }

            string methodPrefix = " MTH| ";

            foreach (OdbMethod method in obj.methods.Values)
            {
                string argsStr = string.Join <Type>(',', method.arguments);
                Log.WriteLine(methodPrefix + (method.returnsData ? method.returnType.Name : "void") + " " + method.identifier + "(" + argsStr + ")");
            }
        }
Exemplo n.º 2
0
        private ObjectDatabase(Type scanType)
        {
            List <Type> scanningTypes = new List <Type>();

            scanningTypes.AddRange(Assembly.GetExecutingAssembly().GetTypes());

            ImmutableDictionary <string, OdbObject> .Builder objsBuilder = ImmutableDictionary.CreateBuilder <string, OdbObject>();
            foreach (Type t in scanningTypes)
            {
                if (scanType.IsAssignableFrom(t))
                {
                    OdbObject obj = new OdbObject(t);
                    objsBuilder.Add(obj.identifier, obj);
                }
            }

            objects = objsBuilder.ToImmutable();
            Log.WriteLine("ObjectDB found " + objects.Count + " usable objects within codebase.");
        }
Exemplo n.º 3
0
        public static void LsDb(string[] args)
        {
            bool showDetails = false;

            foreach (string a in args)
            {
                if (a == "-l")
                {
                    showDetails = true;
                }
            }

            List <string> objNames = ObjectDatabase.Global.GetObjectNames();

            foreach (string objName in objNames)
            {
                OdbObject obj = ObjectDatabase.Global.GetObject(objName);
                if (obj == null)
                {
                    Log.WriteLine($"OdbObject {objName} had no actually object, despite being named.");
                    continue;
                }
                Log.WriteLine($"OdbObject {objName} has {obj.fields.Count} fields and {obj.methods.Count} methods.");
                if (showDetails)
                {
                    foreach (OdbField field in obj.fields.Values)
                    {
                        Log.WriteLine($"    | FIELD is={field.type} name={field.identifier}");
                    }

                    foreach (OdbMethod method in obj.methods.Values)
                    {
                        string argsStr = string.Join <Type>(',', method.arguments);
                        Log.WriteLine($"    | METHOD rtns={(method.returnsData ? method.returnType.ToString() : "null")} name={method.identifier} args=({argsStr})");
                    }
                }
            }
        }