public object Create(Type type)
        {
            logger.DebugFormat("Trying to find local reference to type {0}...", TypesHelper.GetFlatClassName(type));

            object obj = ServiceLocationFactory.Do[ConfigCache].TryGet(type);

            if (obj != null)
            {
                logger.DebugFormat("Found it, returning...");
                return(obj);
            }
            logger.DebugFormat("Creating remoting proxy to type {0}...", TypesHelper.GetFlatClassName(type));

            Uri    uriBase     = ConfigCache.GetUriFromAddressBase();
            string relativeUri = ConfigCache.GetEndpointKey(type);
            Uri    uriFinal;



            if (Uri.TryCreate(uriBase, relativeUri, out uriFinal))
            {
                logger.DebugFormat("Constructed URI: {0}...", uriFinal);

                ConfigCache.TryRegisterClientChannel();
                obj = RemotingServices.Connect(type, uriFinal.AbsoluteUri);

                return(obj);
            }
            throw new InvalidOperationException("Invalid uri pair in configuration: '" +
                                                uriBase.AbsoluteUri + "' and '" + relativeUri + "'.");
        }
Beispiel #2
0
        public string GetEndpointKey(Type type)
        {
            string mask = EndpointMask ?? MaskVariable;

            return(mask.Replace(MaskVariable, TypesHelper.GetFlatClassName(type)));
        }