Ejemplo n.º 1
0
            public Task <string> Introspect()
            {
                var path   = CallContext.CurrentPath ?? ObjectPath.Root;
                var writer = new IntrospectionWriter();

                writer.WriteDocType();
                writer.WriteNodeStart(path.Value);
                var interfaces = Connection.BaseDBusConnection.RegisteredPathHandlers(path);

                foreach (var(InterfaceName, Handler) in interfaces)
                {
                    writer.WriteInterfaceStart(InterfaceName);
                    var def = Handler.GetInterfaceDefinitions();
                    foreach (var m in def.Methods)
                    {
                        writer.WriteMethodStart(m.Name);
                        foreach (var arg in m.ArgTypes)
                        {
                            writer.WriteInArg(arg.Name, arg.Signature);
                        }
                        foreach (var arg in m.ReturnTypes)
                        {
                            writer.WriteOutArg(arg.Name, arg.Signature);
                        }
                        writer.WriteMethodEnd();
                    }
                    foreach (var p in def.Properties)
                    {
                        writer.WriteProperty(p.Name, p.Type.Signature, p.Access);
                    }
                    foreach (var s in def.Signals)
                    {
                        writer.WriteSignalStart(s.Name);
                        foreach (var arg in s.ArgDefs)
                        {
                            writer.WriteArg(arg.Name, arg.Signature);
                        }
                        writer.WriteSignalEnd();
                    }
                    writer.WriteInterfaceEnd();
                }
                var children = Connection.BaseDBusConnection.RegisteredPathChildren(path);

                foreach (var child in children)
                {
                    writer.WriteChildNode(child);
                }
                writer.WriteNodeEnd();
                return(Task.FromResult(writer.ToString()));
            }
Ejemplo n.º 2
0
        private string GenerateIntrospectionXml(TypeDescription description)
        {
            var  writer        = new IntrospectionWriter();
            bool hasProperties = false;

            foreach (var interf in description.Interfaces)
            {
                writer.WriteInterfaceStart(interf.Name);
                foreach (var method in interf.Methods)
                {
                    writer.WriteMethodStart(method.Name);
                    foreach (var arg in method.InArguments)
                    {
                        writer.WriteInArg(arg.Name, arg.Signature);
                    }
                    foreach (var arg in method.OutArguments)
                    {
                        writer.WriteOutArg(arg.Name, arg.Signature);
                    }
                    writer.WriteMethodEnd();
                }

                foreach (var signal in interf.Signals)
                {
                    writer.WriteSignalStart(signal.Name);
                    foreach (var arg in signal.SignalArguments)
                    {
                        writer.WriteArg(arg.Name, arg.Signature);
                    }
                    writer.WriteSignalEnd();
                }

                foreach (var prop in interf.Properties)
                {
                    hasProperties = true;
                    writer.WriteProperty(prop.Name, prop.Signature, prop.Access);
                }
                writer.WriteInterfaceEnd();
            }
            if (hasProperties)
            {
                writer.WritePropertiesInterface();
            }
            writer.WriteIntrospectableInterface();
            writer.WritePeerInterface();

            return(writer.ToString());
        }