Example #1
0
        public static object GetProxyFactory(Type proxyType, string language)
        {
            object newValue = null;

            if (proxyType != null)
            {
                ProxyTechnology proxyTech = GetProxyTechnology(proxyType);
                if (proxyTech == ProxyTechnology.Asmx)
                {
                    newValue = WebServiceProxyFactoryName;
                }
                else if (proxyTech == ProxyTechnology.Wcf)
                {
                    Type genericImplementation = proxyType.BaseType;
                    while (genericImplementation != typeof(Object))
                    {
                        if (genericImplementation.IsGenericType &&
                            typeof(ClientBase <>).IsAssignableFrom(genericImplementation.GetGenericTypeDefinition()))
                        {
                            string wrappedServiceTypeName = string.Empty;
                            Type[] generigArguments       = genericImplementation.GetGenericArguments();
                            if (generigArguments.Length == 1)
                            {
                                wrappedServiceTypeName = generigArguments[0].FullName;
                            }

                            string clrNotationFactoryTypeName = WCFProxyFactoryGenericName;
                            string genericFactoryTypeName     = NotationHelper.RemoveTrailingCLRChars(clrNotationFactoryTypeName);
                            newValue = string.Format(GetSelectedLanguageGenericFormat(language), genericFactoryTypeName, wrappedServiceTypeName);
                            break;
                        }
                        genericImplementation = genericImplementation.BaseType;
                    }
                }

                if (newValue == null)
                {
                    newValue = ObjectProxyFactoryName;
                }
            }
            return(newValue);
        }
Example #2
0
        public void ShouldRemoveCLRNotationCharacters()
        {
            string clrNotation = typeof(GenericClass <>).FullName;

            Assert.AreEqual("SmartClientFactoryPackage.Tests.GenericClass", NotationHelper.RemoveTrailingCLRChars(clrNotation));
        }