Пример #1
0
        //FIXME: this shouldn't be part of the core API
        //that also applies to much of the other object mapping code
        //it should cache proxies and objects, really

        //inspired by System.Activator
        public object GetObject(Type type, string bus_name, ObjectPath path)
        {
            BusObject busObject = new BusObject(this, bus_name, path);
            DProxy    prox      = new DProxy(busObject, type);

            object obj = prox.GetTransparentProxy();

            return(obj);
        }
Пример #2
0
        public static object GetObject(Connection conn, string bus_name, ObjectPath object_path, Type declType)
        {
            Type proxyType = DefineType(declType);

            BusObject inst = (BusObject)Activator.CreateInstance(proxyType);

            inst.conn        = conn;
            inst.bus_name    = bus_name;
            inst.object_path = object_path;

            return(inst);
        }
Пример #3
0
        public static object GetObject(Connection conn, string bus_name, ObjectPath object_path, Type declType)
        {
            Type proxyType = TypeImplementer.Root.GetImplementation(declType);

            //BusObject inst = (BusObject)Activator.CreateInstance (proxyType);
            object    instObj = Activator.CreateInstance(proxyType);
            BusObject inst    = GetBusObject(instObj);

            inst.conn        = conn;
            inst.bus_name    = bus_name;
            inst.object_path = object_path;

            return(instObj);
        }
        public static BusObject GetBusObject(object instObj)
        {
            if (instObj is BusObject)
                return (BusObject)instObj;

            BusObject inst;
            if (boCache.TryGetValue (instObj, out inst))
                return inst;

            inst = new BusObject ();
            boCache[instObj] = inst;

            return inst;
        }
Пример #5
0
        public static BusObject GetBusObject(object instObj)
        {
            if (instObj is BusObject)
            {
                return((BusObject)instObj);
            }

            BusObject inst;

            if (boCache.TryGetValue(instObj, out inst))
            {
                return(inst);
            }

            inst             = new BusObject();
            boCache[instObj] = inst;

            return(inst);
        }
        public void WriteObject(Type type, object val)
        {
            ObjectPath path;

            BusObject bobj = val as BusObject;

            if (bobj == null && val is MarshalByRefObject)
            {
                bobj = ((MarshalByRefObject)val).GetLifetimeService() as BusObject;
            }

            if (bobj == null)
            {
                throw new Exception("No object reference to write");
            }

            path = bobj.Path;

            Write(path);
        }
Пример #7
0
        //FIXME: this shouldn't be part of the core API
        //that also applies to much of the other object mapping code

        public object GetObject(Type type, string bus_name, ObjectPath path)
        {
            //if (type == null)
            //	return GetObject (bus_name, path);

            //if the requested type is an interface, we can implement it efficiently
            //otherwise we fall back to using a transparent proxy
            if (type.IsInterface || type.IsAbstract)
            {
                return(BusObject.GetObject(this, bus_name, path, type));
            }
            else
            {
                if (Protocol.Verbose)
                {
                    Console.Error.WriteLine("Warning: Note that MarshalByRefObject use is not recommended; for best performance, define interfaces");
                }

                BusObject busObject = new BusObject(this, bus_name, path);
                DProxy    prox      = new DProxy(busObject, type);
                return(prox.GetTransparentProxy());
            }
        }
Пример #8
0
 public DProxy(BusObject busObject, Type type) : base(type)
 {
     this.busObject = busObject;
 }
Пример #9
0
		public DProxy (BusObject busObject, Type type) : base(type)
		{
			this.busObject = busObject;
		}