public static bool LoadPackageFile(string filePath, bool throwOnError) { if (!File.Exists(filePath)) { if (throwOnError) { throw new FileNotFoundException("File '" + filePath + "' does not exist."); } return(false); } if (new FileInfo(filePath).Extension != ".tssp") { if (throwOnError) { throw new ArgumentException("Provided file is not a valid RadThemePackage"); } return(false); } Theme theme = new TSSPThemeReader().Read(filePath); if (theme == null) { return(false); } ThemeRepository.Add(theme); return(true); }
public static bool LoadPackageFile(string filePath) { Theme theme = new TSSPThemeReader().Read(filePath); if (theme == null) { return(false); } ThemeRepository.Add(theme); return(true); }
public static bool LoadPackageResource( ThemeResolutionService.ResourceParams resourceParams, bool throwOnError) { Assembly assembly = resourceParams.UserAssembly; string resourcePath = resourceParams.ResourcePath; if ((object)assembly == null) { assembly = resourceParams.CallingAssembly; if ((object)assembly == null) { assembly = Assembly.GetCallingAssembly(); } } Stream manifestResourceStream = assembly.GetManifestResourceStream(resourcePath); if (manifestResourceStream == null) { Assembly executingAssembly = resourceParams.ExecutingAssembly; if ((object)executingAssembly == null) { executingAssembly = Assembly.GetExecutingAssembly(); } manifestResourceStream = executingAssembly.GetManifestResourceStream(resourcePath); } if (manifestResourceStream == null) { if (throwOnError) { throw new ArgumentException("Specified resource does not exist in the provided assembly."); } return(false); } using (manifestResourceStream) { Theme theme = new TSSPThemeReader().Read(manifestResourceStream); if (theme != null) { ThemeRepository.Add(theme); return(true); } } return(false); }
public static Theme ReadResource(Assembly resourceAssembly, string resourcePath) { Theme theme = (Theme)null; try { using (Stream manifestResourceStream = resourceAssembly.GetManifestResourceStream(resourcePath)) { if (manifestResourceStream != null) { theme = new TSSPThemeReader().Read(manifestResourceStream); } } } catch { int num = (int)MessageBox.Show(string.Format("Failed to load {0} theme.", (object)resourcePath)); } return(theme); }
protected virtual bool LoadResource(Assembly resourceAssembly, string resourcePath) { try { using (Stream manifestResourceStream = resourceAssembly.GetManifestResourceStream(resourcePath)) { if (manifestResourceStream != null) { Theme theme = new TSSPThemeReader().Read(manifestResourceStream); if (theme != null) { ThemeRepository.Add(theme); return(true); } } } } catch { int num = (int)MessageBox.Show(string.Format("Failed to load {0} theme.", (object)resourcePath)); } return(false); }