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);
  • 相关阅读:
    京东饭粒捡漏V1.15
    京东饭粒捡漏V1.14
    京东饭粒捡漏V1.13
    京东饭粒捡漏V1.1.0
    京东饭粒捡漏V1.0.8
    京东饭粒捡漏V1.0.7
    性能瓶颈分析总结
    Jmeter循环控制
    HttpClient接口测试之会话保持
    Jenkins自动部署Tomcat项目
  • 原文地址:https://www.cnblogs.com/shenshiting/p/7776590.html
Copyright © 2011-2022 走看看