Example #1
0
        public override Type ResolveName(string typeName, string typeNamespace, Type declaredType,
                                         DataContractResolver knownTypeResolver)
        {
            Type type;
            int  deserializationIndex;
            int  poundIndex = typeNamespace.IndexOf("#");

            if (poundIndex < 0)
            {
                if (Int32.TryParse(typeNamespace, out deserializationIndex))
                {
                    deserializationDictionary.TryGetValue(deserializationIndex, out typeNamespace);
                }
                type = knownTypeResolver.ResolveName(typeName, typeNamespace, declaredType, null);
            }
            else
            {
                if (Int32.TryParse(typeNamespace.Substring(0, poundIndex), out deserializationIndex))
                {
                    typeNamespace = typeNamespace.Substring(poundIndex + 1, typeNamespace.Length - poundIndex - 1);
                    deserializationDictionary.Add(deserializationIndex, typeNamespace);
                }
                type = knownTypeResolver.ResolveName(typeName, typeNamespace, declaredType, null);
            }
            return(type);
        }
Example #2
0
            public override Type ResolveName(string typeName, string typeNamespace, Type declaredType, DataContractResolver knownTypeResolver)
            {
                try
                {
                    if (typeNamespace == (this.GetType().Namespace + ".Base64Encoded"))
                    {
                        var txt   = stringToAQN(typeName);
                        var ttype = Type.GetType(txt, false);
                        if (ttype != null)
                        {
                            return(ttype);
                        }
                    }
                }
                catch (Exception)
                {
                }
                return(knownTypeResolver.ResolveName(typeName, typeNamespace, declaredType, null));// ?? AppDomain.CurrentDomain.GetAssemblies().SelectMany(ass => ass.GetTypes()).FirstOrDefault(t => t.Namespace == typeNamespace && t.Name == typeName);
                // Todo: does this create a security hole? Though mods can do everything anyway, this may abuse a mod to do sth harmful. Consider it!
                // for now i don't think so, since typeName has to be assignable to it. And object or whatsoever...
                // it still could change the mods function. What about just loading stuff that the mod does reference? (eighter by game + modconfig or assembly?)
                // type.IsAssignableFrom

                /*var matches = AppDomain.CurrentDomain.GetAssemblies().SelectMany(a => a.GetTypes()).Where(t => t.Name == typeName && t.Namespace == typeNamespace).ToArray();
                 * matches.Count();
                 * throw new NotImplementedException();*/
            }
        public override Type ResolveName(string typeName, string typeNamespace, Type declaredType, DataContractResolver knownTypeResolver)
        {
            Debugger.Launch();
            var resolvedType = knownTypeResolver.ResolveName(typeName, typeNamespace, declaredType, null) ?? GetTypeFromContractName(typeName, typeNamespace);

            return(resolvedType);
        }
Example #4
0
        public override Type ResolveName(string typeName, string typeNamespace, Type declaredType, DataContractResolver KTResolver)
        {
            if (typeNamespace.Equals(s_defaultNs))
            {
                if (typeName.Equals(typeof(Person).FullName))
                {
                    return(typeof(Person));
                }
                if (typeName.Equals(typeof(CharClass).FullName))
                {
                    return(typeof(CharClass));
                }
                if (typeName.Equals("System.String"))
                {
                    return(typeof(string));
                }
                if (typeName.Equals(typeof(Version1).FullName))
                {
                    return(typeof(Version1));
                }
                if (typeName.Equals(typeof(Employee).FullName))
                {
                    return(typeof(Employee));
                }
            }

            return(KTResolver.ResolveName(typeName, typeNamespace, declaredType, null));
        }
Example #5
0
        public override Type ResolveName(string typeName, string typeNamespace, Type declaredType, DataContractResolver KTResolver)
        {
            TypeLibraryManager mgr           = new TypeLibraryManager();
            string             inputTypeName = typeName.Trim('*');
            Type result = null;

            if (null != mgr.AllTypesHashtable[inputTypeName])
            {
                result = (Type)mgr.AllTypesHashtable[inputTypeName];
            }
            else
            {
                result = KTResolver.ResolveName(typeName, typeNamespace, declaredType, null);
            }
            if (null == result)
            {
                try
                {
                    result = Type.GetType(string.Format("{0}, {1}", typeName, typeNamespace));
                }
                catch (System.IO.FileLoadException)
                {
                    //Type.GetType throws exception on netfx if it cannot find a type while it just returns null on NetCore.
                    //The behavior difference of Type.GetType is a known issue.
                    //Catch the exception so that test case can pass on netfx.
                    return(null);
                }
            }
            return(result);
        }
Example #6
0
        public override Type ResolveName(string typeName, string typeNamespace, Type declaredType, DataContractResolver knownTypeResolver)
        {
            if (typeNamespace == CrmSvcUtilNamespace)
            {
                switch (typeName)
                {
                case Names.SdkMessages:
                    return(typeof(SdkMessages));

                case Names.SdkMessage:
                    return(typeof(SdkMessage));

                case Names.SdkMessagePair:
                    return(typeof(SdkMessagePair));

                case Names.SdkMessageRequest:
                    return(typeof(SdkMessageRequest));

                case Names.SdkMessageRequestField:
                    return(typeof(SdkMessageRequestField));

                case Names.SdkMessageResponse:
                    return(typeof(SdkMessageResponse));

                case Names.SdkMessageResponseField:
                    return(typeof(SdkMessageResponseField));
                }
            }
            // Defer to the known type resolver
            return(knownTypeResolver.ResolveName(typeName, typeNamespace, declaredType, knownTypeResolver));
        }
Example #7
0
        public override Type ResolveName(string typeName, string typeNamespace, Type declaredType,
                                         DataContractResolver knownTypeResolver)
        {
            if (declaredType == null)
            {
                throw new ArgumentNullException("declaredType");
            }
            if (knownTypeResolver == null)
            {
                throw new ArgumentNullException("knownTypeResolver");
            }

            var type = knownTypeResolver.ResolveName(typeName, typeNamespace, declaredType, knownTypeResolver);

            if (type != null)
            {
                return(type);
            }


            var tuple = new Tuple <string, string>(typeName, typeNamespace);

            if (typesCache.TryGetValue(tuple, out type))
            {
                return(type);
            }

            type = TryGetType(typeName, typeNamespace);
            typesCache.Add(tuple, type);
            return(type);
        }
Example #8
0
 /// <summary>
 ///     Override this method to map the specified xsi:type name and namespace to a data contract type during
 ///     deserialization.
 /// </summary>
 /// <param name="typeName">The xsi:type name to map.</param>
 /// <param name="typeNamespace">The xsi:type namespace to map.</param>
 /// <param name="declaredType">The type declared in the data contract.</param>
 /// <param name="knownTypeResolver">The known type resolver.</param>
 /// <returns>
 ///     The type the xsi:type name and namespace is mapped to.
 /// </returns>
 public override Type ResolveName(string typeName,
                                  string typeNamespace,
                                  Type declaredType,
                                  DataContractResolver knownTypeResolver)
 {
     return(knownTypeResolver.ResolveName(typeName, typeNamespace, declaredType, null));
 }
        public override Type ResolveName(string typeName, string typeNamespace, Type declaredType, DataContractResolver knownTypeResolver)
        {
            if (this._nameToTypeDictionary.ContainsKey(typeNamespace) && this._nameToTypeDictionary[typeNamespace].ContainsKey(typeName))
            {
                Type result = this._nameToTypeDictionary[typeNamespace][typeName];

                if (result.IsSubclassOf(declaredType))
                {
                    return(result);
                }
            }

            if (Directory.Exists(this._assemblyPath))
            {
                this.AddKnownTypeRange(this._assemblyPath, this._recursive);
            }

            if (this._assemblyFiles != null && this._assemblyFiles.Count() > 0 && this._reload)
            {
                this.AddKnownTypeRange(this._assemblyFiles);
            }

            this.AddKnownTypeRange(LoadTypesFrom(typeNamespace + ".dll"));
            this.AddKnownTypeRange(LoadTypesFrom(typeNamespace + ".exe"));

            if (this._nameToTypeDictionary.ContainsKey(typeNamespace) && this._nameToTypeDictionary[typeNamespace].ContainsKey(typeName))
            {
                return(this._nameToTypeDictionary[typeNamespace][typeName]);
            }

            return(knownTypeResolver.ResolveName(typeName, typeNamespace, declaredType, null));
        }
Example #10
0
            public override Type ResolveName(string typeName, string typeNamespace, Type declaredType, DataContractResolver knownTypeResolver)
            {
                Type type = knownTypeResolver.ResolveName(typeName, typeNamespace, declaredType, null);

                if (type == null)
                {
                    if (typeNamespace.StartsWith("http:", StringComparison.OrdinalIgnoreCase))
                    {
                        return(null);
                    }
                    try
                    {
                        string typeName2 = typeName + ", " + typeNamespace;
                        type = Type.GetType(typeName2);
                    }
                    catch (Exception ex)
                    {
                        EventLogger.LogErr("ResolveName err: {0}", new object[]
                        {
                            ex
                        });
                    }
                }
                return(type);
            }
Example #11
0
        public override Type ResolveName(string typeName, string typeNamespace, Type declaredType, DataContractResolver knownTypeResolver)
        {
            Type type = knownTypeResolver.ResolveName(typeName, typeNamespace, declaredType, null);

            if (type != null)
            {
                return(type);
            }
            if (typeNamespace.StartsWith("lb:"))
            {
                string arg = typeNamespace.Split(new char[]
                {
                    ':'
                }, 2)[1];
                try
                {
                    return(Type.GetType(string.Format("{0}, {1}", typeName, arg)));
                }
                catch (IOException arg2)
                {
                    ExTraceGlobals.MailboxLoadBalanceTracer.TraceError <string, string, IOException>(0L, "Failed to load type {0}, {1}: {2}", typeName, arg, arg2);
                }
            }
            return(null);
        }
Example #12
0
 public override Type ResolveName(string typeName, string typeNamespace, Type declaredType, DataContractResolver knownTypeResolver)
 {
     if (typeNamespace == "http://tempuri.org")
     {
         return(Type.GetType(typeName));    // assembly qualified already
     }
     return(knownTypeResolver.ResolveName(typeName, typeNamespace, declaredType, null));
 }
Example #13
0
    public override Type ResolveName(string typeName, string typeNamespace, Type declaredType, DataContractResolver knownTypeResolver)
    {
        if (typeName == "T2" && typeNamespace == "MyNamespace")
        {
            return(typeof(T1));
        }

        return(knownTypeResolver.ResolveName(typeName, typeNamespace, declaredType, null) ?? declaredType);
    }
Example #14
0
        /// <summary>During deserialization, maps any xsi:type information to the actual type of the persistence-ignorant object. </summary>
        /// <returns>Returns the type that the xsi:type is mapped to. Returns null if no known type was found that matches the xsi:type.</returns>
        /// <param name="typeName">The xsi:type information to map.</param>
        /// <param name="typeNamespace">The namespace of the xsi:type.</param>
        /// <param name="declaredType">The declared type.</param>
        /// <param name="knownTypeResolver">
        ///     An instance of <see cref="T:System.Data.Entity.Core.Objects.ProxyDataContractResolver" />.
        /// </param>
        public override Type ResolveName(string typeName, string typeNamespace, Type declaredType, DataContractResolver knownTypeResolver)
        {
            Check.NotEmpty(typeName, "typeName");
            Check.NotEmpty(typeNamespace, "typeNamespace");
            Check.NotNull(declaredType, "declaredType");
            Check.NotNull(knownTypeResolver, "knownTypeResolver");

            return(knownTypeResolver.ResolveName(typeName, typeNamespace, declaredType, null));
        }
        public override Type ResolveName(string typeName, string typeNamespace, Type declaredType, DataContractResolver knownTypeResolver)
        {
            EntityUtil.CheckStringArgument(typeName, "typeName");
            EntityUtil.CheckStringArgument(typeNamespace, "typeNamespace");
            EntityUtil.CheckArgumentNull(declaredType, "declaredType");
            EntityUtil.CheckArgumentNull(knownTypeResolver, "knownTypeResolver");

            return(knownTypeResolver.ResolveName(typeName, typeNamespace, declaredType, null));
        }
Example #16
0
        // Used at deserialization
        // Allows users to map xsi:type name to any Type
        public override Type ResolveName(string typeName, string typeNamespace, Type declaredType, DataContractResolver knownTypeResolver)
        {
            Type type = knownTypeResolver.ResolveName(typeName, typeNamespace, declaredType, null);

            if (type == null)
            {
                type = Type.GetType(typeName + ", " + typeNamespace);
            }
            return(type);
        }
 //    public override Type ResolveName(string typeName, string typeNamespace, DataContractResolver knownTypeResolver)
 public override Type ResolveName(string typeName, string typeNamespace, Type type, DataContractResolver knownTypeResolver)
 {
     if (typeName == "PropiedadTexto" && typeNamespace == "JuegoMesa")
     {
         return(typeof(PropiedadTexto));
     }
     else
     {
         return(knownTypeResolver.ResolveName(typeName, typeNamespace, type, null));
     }
 }
        /// <summary>
        /// Override this method to map the specified type name and namespace to a data contract type during deserialization.
        /// </summary>
        /// <returns>
        /// The type the type name and namespace is mapped to.
        /// </returns>
        /// <param name="typeName">The type name that is used in the SOAP XML declaration.</param>
        /// <param name="typeNamespace">The type namespace that is used in the SOAP XML declaration.</param>
        /// <param name="declaredType">The type declared in the data contract.</param>
        /// <param name="knownTypeResolver">The known type resolver.</param>
        public override Type ResolveName(
            string typeName,
            string typeNamespace,
            Type declaredType,
            DataContractResolver knownTypeResolver)
        {
            var result = knownTypeResolver.ResolveName(typeName, typeNamespace, declaredType, null)
                         ?? TypeLoader.FromPartialInformation(typeName, typeNamespace, throwOnError: false);

            return(result);
        }
Example #19
0
            public override Type ResolveName(string typeName, string typeNamespace, Type declaredType, DataContractResolver knownTypeResolver)
            {
                Type type = Type.GetType(typeName, false);

                if (type == null)
                {
                    Assembly assembly = Assembly.Load(typeNamespace);
                    type = assembly.GetType(typeName, false);
                }
                return(type ?? knownTypeResolver.ResolveName(typeName, typeNamespace, declaredType, null));
            }
Example #20
0
 public override Type ResolveName(string typeName, string typeNamespace, Type declaredType, DataContractResolver knownTypeResolver)
 {
     if (m_NamesToType.ContainsKey(typeNamespace))
     {
         if (m_NamesToType[typeNamespace].ContainsKey(typeName))
         {
             return(m_NamesToType[typeNamespace][typeName]);
         }
     }
     return(knownTypeResolver.ResolveName(typeName, typeNamespace, declaredType, null));
 }
Example #21
0
        public override Type ResolveName(string typeName, string typeNamespace, Type declaredType, DataContractResolver knownTypeResolver)
        {
            var resolvedType =
                (from type in registeredTypes
                 where type.Name == typeName
                 where $"http://schemas.datacontract.org/2004/07/{type.Namespace}" == typeNamespace
                 select type)
                .FirstOrDefault(knownTypeResolver.ResolveName(typeName, typeNamespace, declaredType, null));

            return(resolvedType);
        }
Example #22
0
 /// <inheritdoc />
 public override Type ResolveName(string typeName, string typeNamespace, Type declaredType, DataContractResolver knownTypeResolver)
 {
     if (this.typeMap.ContainsKey(typeName))
     {
         return(this.typeMap[typeName]);
     }
     else
     {
         return(knownTypeResolver.ResolveName(typeName, typeNamespace, declaredType, knownTypeResolver));
     }
 }
        public override Type ResolveName(string typeName, string typeNamespace, Type declaredType, DataContractResolver knownTypeResolver)
        {
            var result = knownTypeResolver.ResolveName(typeName, typeNamespace, declaredType, knownTypeResolver);

            if (result != null)
            {
                return(result);
            }

            return(_serializer.IncludedTypes.FirstOrDefault(x => x.Name == typeName));
        }
Example #24
0
 public override Type ResolveName(string typeName, string typeNamespace, Type declaredType, DataContractResolver knownTypeResolver)
 {
     if (typeName == this.Name && typeNamespace == this.Namespace)
     {
         return(typeof(Manager));
     }
     else
     {
         return(knownTypeResolver.ResolveName(typeName, typeNamespace, declaredType, null));
     }
 }
Example #25
0
 public override Type ResolveName(string typeName, string typeNamespace, Type declaredType, DataContractResolver knownTypeResolver)
 {
     if (typeName == "ArrayOfKeyValueOfdateTimedouble")
     {
         return(typeof(KeyValuePair <DateTime, double>[]));
     }
     else
     {
         return(knownTypeResolver.ResolveName(typeName, typeNamespace, declaredType, null) ?? Type.GetType(typeName + ", " + typeNamespace));
     }
 }
        public override Type ResolveName(string typeName, string typeNamespace, Type declaredType, DataContractResolver knownTypeResolver)
        {
            if (typeNamespace == MyEntityNamespace)
            {
                if (typeName == typeof(MyEntity).Name)
                {
                    return(typeof(MyEntity));
                }
            }

            return(knownTypeResolver.ResolveName(typeName, typeNamespace, declaredType, null) ?? declaredType);
        }
        public override Type ResolveName(string typeName, string typeNamespace, Type declaredType, DataContractResolver knownTypeResolver)
        {
            Type result = ProcessRunTimeLocator.GetDynamicComponentNodeType(typeName);

            if (result != null)
            {
                return(result);
            }
            Type tt = knownTypeResolver.ResolveName(typeName, typeNamespace, declaredType, null) ?? Type.GetType(typeName + ", " + typeNamespace);

            return(tt);
        }
Example #28
0
 /// <summary>During deserialization, maps any xsi:type information to the actual type of the persistence-ignorant object. </summary>
 /// <returns>Returns the type that the xsi:type is mapped to. Returns null if no known type was found that matches the xsi:type.</returns>
 /// <param name="typeName">The xsi:type information to map.</param>
 /// <param name="typeNamespace">The namespace of the xsi:type.</param>
 /// <param name="declaredType">The declared type.</param>
 /// <param name="knownTypeResolver">
 /// An instance of <see cref="T:System.Data.Entity.Core.Objects.ProxyDataContractResolver" />.
 /// </param>
 public override Type ResolveName(
     string typeName,
     string typeNamespace,
     Type declaredType,
     DataContractResolver knownTypeResolver)
 {
     Check.NotEmpty(typeName, nameof(typeName));
     Check.NotEmpty(typeNamespace, nameof(typeNamespace));
     Check.NotNull <Type>(declaredType, nameof(declaredType));
     Check.NotNull <DataContractResolver>(knownTypeResolver, nameof(knownTypeResolver));
     return(knownTypeResolver.ResolveName(typeName, typeNamespace, declaredType, (DataContractResolver)null));
 }
 public override Type ResolveName(string typeName, string typeNamespace, Type declaredType, DataContractResolver knownTypeResolver)
 {
     if (typeNamespace == _contractNamespace && typeName.StartsWith(_contractNamePrefix))
     {
         var contract = typeName.Substring(_contractNamePrefixLength);
         if (!string.IsNullOrEmpty(contract))
         {
             // get the data type by the contract id
             return(GetDataContract(contract));
         }
     }
     return(knownTypeResolver.ResolveName(typeName, typeNamespace, declaredType, knownTypeResolver));
 }
        public override Type ResolveName(string typeName, string typeNamespace, Type declaredType, DataContractResolver knownTypeResolver)
        {
            if (typeNamespace == ResolverNamespace)
            {
                Type result = DynamicTypeBuilder.Instance.GetDynamicType(typeName);
                if (result != null)
                {
                    return(result);
                }
            }

            return(knownTypeResolver.ResolveName(typeName, typeNamespace, declaredType, null));
        }
 public override Type ResolveName(string typeName, string typeNamespace, Type declaredType, DataContractResolver knownTypeResolver)
 {
     return knownTypeResolver.ResolveName(typeName, typeNamespace, declaredType, null) ?? Type.GetType(typeName + ", " + typeNamespace);
 }