유형 이름에 따라 유형의 객체를 가져옵니다.

1340 단어 windowssilverlight
private Type GetTypeCore(string typeName)
        {
            #if SILVERLIGHT
                Assembly a = typeof(System.Action).Assembly;
                Type type = a.GetType(typeName, false);
                if (type != null)
                    return type;

                foreach (System.Windows.AssemblyPart ap in System.Windows.Deployment.Current.Parts)
                {
                    System.Windows.Resources.StreamResourceInfo sri = System.Windows.Application.GetResourceStream(new Uri(ap.Source, UriKind.Relative));
                    Assembly assembly = new System.Windows.AssemblyPart().Load(sri.Stream);
                    type = assembly.GetType(typeName, false);
                    if (type != null)
                        return type;
                }
            #else
                // First - try all loaded types
                foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
                {
                    Type type = assembly.GetType(typeName, false, true);
                    if (type != null)
                        return type;
                }
            #endif
            return type;
        }

좋은 웹페이지 즐겨찾기