Beispiel #1
0
 public byte[] GetPublicKeyToken()
 {
     if (this.InternalAssembly == null)
     {
         return(null);
     }
     return(AssemblyHelper.GetAssemblyName(this.InternalAssembly).GetPublicKeyToken());
 }
        private bool IsCorePlatformType(Type sourceType)
        {
            AssemblyName assemblyName = AssemblyHelper.GetAssemblyName(sourceType.Assembly);

            if (((PlatformTypes)this.platformMetadata).GetPlatformAssembly(assemblyName.Name) != null)
            {
                return(true);
            }
            return(false);
        }
Beispiel #3
0
        public static AssemblyName GetAssemblyName(IAssembly assembly)
        {
            Assembly reflectionAssembly = AssemblyHelper.GetReflectionAssembly(assembly);

            if (reflectionAssembly == null)
            {
                return(null);
            }
            return(AssemblyHelper.GetAssemblyName(reflectionAssembly));
        }
Beispiel #4
0
        public void Initialize(IXmlNamespace xmlNamespace, Type type, string key)
        {
            if (type == null)
            {
                throw new ArgumentNullException("type");
            }
            PlatformTypes platformMetadata = (PlatformTypes)this.PlatformMetadata;

            this.isBuilt      = true;
            this.xmlNamespace = xmlNamespace;
            this.type         = type;
            Type nearestSupportedType = platformMetadata.GetNearestSupportedType(this.type);

            if (nearestSupportedType != null)
            {
                this.nearestSupportedType = platformMetadata.GetType(nearestSupportedType);
            }
            this.lastResolvedType = this.type;
            this.name             = ProjectContextType.GetNameIncludingAnyDeclaringTypes(this.type);
            Assembly  assembly        = this.type.Assembly;
            IAssembly projectAssembly = this.typeResolver.ProjectAssembly;

            if (projectAssembly == null || !projectAssembly.CompareTo(assembly))
            {
                this.assemblyName = AssemblyHelper.GetAssemblyName(assembly).Name;
                if (projectAssembly != null)
                {
                    bool name = this.assemblyName == projectAssembly.Name;
                }
            }
            this.members  = new MemberCollection(this.typeResolver, this);
            this.assembly = this.GetAssembly(this.typeResolver, this.assemblyName);
            if (type.IsArray)
            {
                this.arrayItemType = ProjectContextType.GetItemType(this.typeResolver, type);
                this.arrayRank     = type.GetArrayRank();
            }
            this.genericTypeArguments = PlatformTypeHelper.GetGenericTypeArguments(this.typeResolver, this.type);
            if (this.genericTypeArguments.Count > 0)
            {
                foreach (IType genericTypeArgument in this.genericTypeArguments)
                {
                    ProjectContextType projectContextType = genericTypeArgument as ProjectContextType;
                    if (projectContextType == null)
                    {
                        continue;
                    }
                    this.genericDepth = Math.Max(projectContextType.genericDepth + 1, this.genericDepth);
                }
            }
            this.Cache();
            this.hashCode = key.GetHashCode();
        }
Beispiel #5
0
 protected IAssembly GetAssembly(Assembly assembly)
 {
     return(this.GetAssembly(AssemblyHelper.GetAssemblyName(assembly).Name));
 }
Beispiel #6
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;
 }
Beispiel #7
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);
        }
		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
				{
				}
			}
		}