コード例 #1
0
        internal UserDefinedTypeReader RegisterType(System.Type type)
        {
            var instance    = new UserDefinedTypeImporter(type);
            var typedReader = new UserDefinedTypeReader {
                Reader = instance.Read, RealType = type
            };
            var typeId = new UserDefinedType {
                Type = type, TypeName = instance.TypeName
            };

            UserTypeReaders[typeId] = typedReader;
            return(typedReader);
        }
コード例 #2
0
        private ReadDelegate CreateUserDefinedReader(ref System.Type realType)
        {
            var typename = Reader.ReadStringProperty("__Type");

            if (typename.Length > 0)
            {
                UserDefinedTypeReader reader;
                var typeid = new UserDefinedType {
                    Type = realType, TypeName = typename
                };
                if (!UserTypeReaders.TryGetValue(typeid, out reader))
                {
                    var type = System.Type.GetType(typename, false, false);
                    if (type == null)
                    {
                        // try to locate type in the assembly of T
                        var assembly = realType.Assembly;
                        type = assembly.GetType(typename, false, false);
                        if (type == null)
                        {
                            // try to locate the type in all loaded assemblies
                            var assemblies = System.AppDomain.CurrentDomain.GetAssemblies();
                            for (var i = 0; i < assemblies.Length && type == null; ++i)
                            {
                                type = assemblies[i].GetType(typename, false, false);
                            }
                        }
                    }
                    if (type != null)
                    {
                        var userTypeReader = RegisterType(type);
                        realType = userTypeReader.RealType;
                        return(userTypeReader.Reader);
                    }
                    throw new BindingException(ScriptCallErrorType.SCE_ArgumentType, string.Format("Could not determine managed type from __Type {0}", typename));
                }
                realType = reader.RealType;
                return(reader.Reader);
            }
            throw new BindingException(ScriptCallErrorType.SCE_ArgumentType, string.Format("Could not determine managed type from JavaScript value"));
        }
コード例 #3
0
		internal UserDefinedTypeReader RegisterType(System.Type type)
		{
			var instance = new UserDefinedTypeImporter(type);
			var typedReader = new UserDefinedTypeReader { Reader = instance.Read, RealType = type };
			var typeId = new UserDefinedType { Type = type, TypeName = instance.TypeName };
			UserTypeReaders[typeId] = typedReader;
			return typedReader;
		}
コード例 #4
0
		private ReadDelegate CreateUserDefinedReader(ref System.Type realType)
		{
			var typename = Reader.ReadStringProperty("__Type");
			if (typename.Length > 0)
			{
				UserDefinedTypeReader reader;
				var typeid = new UserDefinedType { Type = realType, TypeName = typename };
				if (!UserTypeReaders.TryGetValue(typeid, out reader))
				{
					var type = System.Type.GetType(typename, false, false);
					if (type == null)
					{
						// try to locate type in the assembly of T
						var assembly = realType.Assembly;
						type = assembly.GetType(typename, false, false);
						if (type == null)
						{
							// try to locate the type in all loaded assemblies
							var assemblies = System.AppDomain.CurrentDomain.GetAssemblies();
							for (var i = 0; i < assemblies.Length && type == null; ++i)
							{
								type = assemblies[i].GetType(typename, false, false);
							}
						}
					}
					if (type != null)
					{
						var userTypeReader = RegisterType(type);
						realType = userTypeReader.RealType;
						return userTypeReader.Reader;
					}
					throw new BindingException(ScriptCallErrorType.SCE_ArgumentType, string.Format("Could not determine managed type from __Type {0}", typename));
				}
				realType = reader.RealType;
				return reader.Reader;
			}
			throw new BindingException(ScriptCallErrorType.SCE_ArgumentType, string.Format("Could not determine managed type from JavaScript value"));
		}