Ejemplo n.º 1
0
        internal static PropertyCall GenPropertyCall(PropertyInfo target)
        {
            var pc = new PropertyCall {
                Get      = GenGetCall(target),
                Set      = GenSetCall(target),
                MetaData = target
            };

            return(pc);
        }
Ejemplo n.º 2
0
        private void HandlePropertyCall(MessageContainer method_call)
        {
            Message       msg       = method_call.Message;
            MessageReader msgReader = new MessageReader(msg);
            MessageWriter retWriter = new MessageWriter();

            object[] args = MessageHelper.GetDynamicValues(msg);

            string face = (string)args [0];

            if ("GetAll" == method_call.Member)
            {
                Signature asv = Signature.MakeDict(Signature.StringSig, Signature.VariantSig);

                MethodCaller call = typeMembers [Object.GetType()].GetPropertyAllCall(face);

                Exception ex = null;
                try {
                    if (call == null)
                    {
                        throw new BusException("org.freedesktop.DBus.Error.InvalidArgs", "No such interface");
                    }
                    call(Object, msgReader, msg, retWriter);
                } catch (Exception e) { ex = e; }

                IssueReply(method_call, asv, retWriter, null, ex);
                return;
            }

            string name = (string)args [1];

            PropertyCall pcs = typeMembers[Object.GetType()].GetPropertyCall(
                face,
                name
                );

            MethodInfo   mi;
            MethodCaller pc;
            Signature    outSig, inSig = method_call.Signature;

            switch (method_call.Member)
            {
            case "Set":
                mi     = pcs.MetaData.GetSetMethod();
                pc     = pcs.Set;
                outSig = Signature.Empty;
                break;

            case "Get":
                mi     = pcs.MetaData.GetGetMethod();
                pc     = pcs.Get;
                outSig = Signature.GetSig(mi.ReturnType);
                break;

            default:
                throw new ArgumentException(string.Format("No such method {0}.{1}", method_call.Interface, method_call.Member));
            }

            if (null == pc)
            {
                conn.MaybeSendUnknownMethodError(method_call);
                return;
            }

            Exception raised = null;

            try {
                pc(Object, msgReader, msg, retWriter);
            } catch (Exception e) {
                raised = e;
            }

            IssueReply(method_call, outSig, retWriter, mi, raised);
        }