zoukankan      html  css  js  c++  java
  • RemotingHelper 构建远程对象

     public class RemotingHelper
        {
            private static bool _isInit;
            private static IDictionary _wellKnownTypes;
            public static object GetObject(Type type) 
            {
                if (!_isInit) InitTypeCache();
                WellKnownClientTypeEntry item = (WellKnownClientTypeEntry)_wellKnownTypes[type];
    
                if (item == null)
                {
                    throw new RemotingException("Type not found !");
                }
                //为指定类型和 URL 所指示的已知对象创建一个代理。
                return Activator.GetObject(item.ObjectType, item.ObjectUrl);
            }
            public static void InitTypeCache()
            {
                _isInit = true;
                _wellKnownTypes = new Hashtable();
                foreach (WellKnownClientTypeEntry item in RemotingConfiguration.GetRegisteredWellKnownClientTypes())
                {
                    if (item.ObjectType == null) 
                    {
                        throw new RemotingException("A configured type could not be found. Please check spelling");
                    }
                    _wellKnownTypes.Add(item.ObjectType, item);
                }
    
            }
        }
    1 Type t = Assembly.LoadFrom(sDllName).GetType(sObjName);
    2 //  使用指定类型的默认构造函数来创建该类型的实例
    3  Activator.CreateInstance(t);
  • 相关阅读:
    QT解析和组装json
    linux下磁盘存储空间不足
    linux下的QT打包方法
    linux下编译protobuf
    linux下编译opencv
    linux下的qt串口通信
    QT执行shell脚本及linux指令相关
    windows下QT打包
    启动zookeeper却没有进程
    Linux命令
  • 原文地址:https://www.cnblogs.com/shenshiting/p/7776590.html
Copyright © 2011-2022 走看看