示例#1
0
        private Type GetRuntimeType(ITypeResolver typeResolver, ProjectContextType typeId)
        {
            Type type;

            if (RuntimeGeneratedTypesHelper.IsControlEditingAssembly(typeId.assembly))
            {
                Type sourceType = ControlEditingDesignTypeGenerator.GetSourceType(typeId.RuntimeType);
                if (sourceType != null)
                {
                    ProjectContextType projectContextType = typeResolver.GetType(sourceType) as ProjectContextType;
                    if (projectContextType != null)
                    {
                        Type runtimeType = projectContextType.GetRuntimeType();
                        if (runtimeType != sourceType && runtimeType != null)
                        {
                            Type type1 = (new ControlEditingDesignTypeGenerator(typeResolver)).DefineType(runtimeType);
                            if (type1 != typeId.RuntimeType)
                            {
                                this.assemblyName = AssemblyHelper.GetAssemblyName(type1.Assembly).Name;
                                this.assembly     = this.GetAssembly(this.typeResolver, this.assemblyName);
                                return(type1);
                            }
                        }
                    }
                }
            }
            if (typeId.arrayItemType == null)
            {
                IAssembly runtimeAssembly = typeId.RuntimeAssembly;
                if (runtimeAssembly != null)
                {
                    runtimeAssembly = this.GetAssembly(typeResolver, runtimeAssembly.Name);
                }
                if (runtimeAssembly != null)
                {
                    Type type2 = PlatformTypeHelper.GetType(runtimeAssembly, typeId.FullName);
                    if (type2 != null)
                    {
                        if (!typeId.IsGenericType)
                        {
                            return(type2);
                        }
                        IList <IType> genericTypeArguments = typeId.GetGenericTypeArguments();
                        int           count = genericTypeArguments.Count;
                        if (count > 0)
                        {
                            Type[] typeArray = new Type[count];
                            for (int i = 0; i < count; i++)
                            {
                                Type runtimeType1 = this.GetRuntimeType(genericTypeArguments[i]);
                                if (runtimeType1 == null)
                                {
                                    return(null);
                                }
                                typeArray[i] = runtimeType1;
                            }
                            try
                            {
                                type = type2.MakeGenericType(typeArray);
                            }
                            catch (ArgumentException argumentException)
                            {
                                return(null);
                            }
                            return(type);
                        }
                    }
                }
            }
            else
            {
                Type runtimeType2 = this.GetRuntimeType(typeId.arrayItemType);
                if (runtimeType2 != null)
                {
                    if (typeId.arrayRank <= 1)
                    {
                        return(runtimeType2.MakeArrayType());
                    }
                    return(runtimeType2.MakeArrayType(typeId.arrayRank));
                }
            }
            return(null);
        }
示例#2
0
 public RuntimeAssembly(Assembly assembly, Microsoft.Expression.DesignModel.Metadata.AssemblySource assemblySource, bool isResolvedImplicitAssembly) : this(AssemblyHelper.GetAssemblyName(assembly).Name, assemblySource)
 {
     base.InternalAssembly           = assembly;
     base.IsResolvedImplicitAssembly = isResolvedImplicitAssembly;
 }
示例#3
0
		protected void RegisterAssemblies(IEnumerable<IAssembly> assemblies)
		{
			foreach (IAssembly assembly in assemblies)
			{
				try
				{
					Assembly reflectionAssembly = AssemblyHelper.GetReflectionAssembly(assembly);
					Assembly assembly1 = reflectionAssembly;
					if (reflectionAssembly != null)
					{
						IPlatformTypes platformMetadata = (IPlatformTypes)this.typeResolver.PlatformMetadata;
						if (platformMetadata.RuntimeContext != null && platformMetadata.ReferenceContext != null && platformMetadata.RuntimeContext.ResolveRuntimeAssembly(AssemblyHelper.GetAssemblyName(reflectionAssembly)) != null)
						{
							Assembly assembly2 = platformMetadata.ReferenceContext.ResolveReferenceAssembly(reflectionAssembly);
							if (assembly2 != null)
							{
								assembly1 = assembly2;
							}
						}
						this.RegisterAssemblyNamespaces(assembly, assembly1.GetCustomAttributesData());
					}
				}
				catch
				{
				}
			}
		}