Advertisement
Guest User

Untitled

a guest
May 2nd, 2018
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.15 KB | None | 0 0
  1. public AppBuilder UsePlatformDetect()
  2. {
  3. OperatingSystemType os = this.RuntimePlatform.GetRuntimeInfo().OperatingSystem;
  4. this.LoadAssembliesInDirectory();
  5. Assembly[] loadedAssemblies1 = this.RuntimePlatform.GetLoadedAssemblies();
  6. Func<Assembly, IEnumerable<ExportWindowingSubsystemAttribute>> func1 = (Func<Assembly, IEnumerable<ExportWindowingSubsystemAttribute>>) (assembly => assembly.GetCustomAttributes<ExportWindowingSubsystemAttribute>());
  7. Func<Assembly, IEnumerable<ExportWindowingSubsystemAttribute>> collectionSelector1;
  8. ExportWindowingSubsystemAttribute windowingSubsystemAttribute = ((IEnumerable<Assembly>) loadedAssemblies1).SelectMany(collectionSelector1, (assembly, attribute) => new
  9. {
  10. assembly = assembly,
  11. attribute = attribute
  12. }).Where(_param1 =>
  13. {
  14. if (_param1.attribute.RequiredOS == os)
  15. return this.CheckEnvironment(_param1.attribute.EnvironmentChecker);
  16. return false;
  17. }).OrderBy(_param1 => _param1.attribute.Priority).Select(_param1 => _param1.attribute).FirstOrDefault<ExportWindowingSubsystemAttribute>();
  18. if (windowingSubsystemAttribute == null)
  19. throw new InvalidOperationException("No windowing subsystem found. Are you missing assembly references?");
  20. Assembly[] loadedAssemblies2 = this.RuntimePlatform.GetLoadedAssemblies();
  21. Func<Assembly, IEnumerable<ExportRenderingSubsystemAttribute>> func2 = (Func<Assembly, IEnumerable<ExportRenderingSubsystemAttribute>>) (assembly => assembly.GetCustomAttributes<ExportRenderingSubsystemAttribute>());
  22. Func<Assembly, IEnumerable<ExportRenderingSubsystemAttribute>> collectionSelector2;
  23. ExportRenderingSubsystemAttribute renderingSubsystemAttribute = ((IEnumerable<Assembly>) loadedAssemblies2).SelectMany(collectionSelector2, (assembly, attribute) => new
  24. {
  25. assembly = assembly,
  26. attribute = attribute
  27. }).Where(_param1 =>
  28. {
  29. if (_param1.attribute.RequiredOS == os)
  30. return this.CheckEnvironment(_param1.attribute.EnvironmentChecker);
  31. return false;
  32. }).Where(_param1 =>
  33. {
  34. if (_param1.attribute.RequiresWindowingSubsystem != null)
  35. return _param1.attribute.RequiresWindowingSubsystem == windowingSubsystemAttribute.Name;
  36. return true;
  37. }).OrderBy(_param1 => _param1.attribute.Priority).Select(_param1 => _param1.attribute).FirstOrDefault<ExportRenderingSubsystemAttribute>();
  38. if (renderingSubsystemAttribute == null)
  39. throw new InvalidOperationException("No rendering subsystem found. Are you missing assembly references?");
  40. this.UseWindowingSubsystem((Action) (() => windowingSubsystemAttribute.InitializationType.GetRuntimeMethod(windowingSubsystemAttribute.InitializationMethod, Type.EmptyTypes).Invoke((object) null, (object[]) null)), windowingSubsystemAttribute.Name);
  41. this.UseRenderingSubsystem((Action) (() => renderingSubsystemAttribute.InitializationType.GetRuntimeMethod(renderingSubsystemAttribute.InitializationMethod, Type.EmptyTypes).Invoke((object) null, (object[]) null)), renderingSubsystemAttribute.Name);
  42. return this;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement