Пример #1
0
 private bool ProcessComponentSection(Library library, string sectionName, bool installToGac, ArrayList copyList, IServiceProvider serviceProvider)
 {
     IApplicationIdentity service = serviceProvider.GetService(typeof(IApplicationIdentity)) as IApplicationIdentity;
     IDictionary dictionary = (IDictionary) library.Sections[sectionName];
     bool flag = false;
     if ((dictionary != null) && (dictionary.Count > 0))
     {
         if (!Directory.Exists(service.ComponentsPath))
         {
             Directory.CreateDirectory(service.ComponentsPath);
         }
         foreach (string str in library.UnpackFiles(sectionName, service.ComponentsPath))
         {
             bool flag2 = false;
             if (installToGac)
             {
                 flag2 = this.InstallToGac(str);
             }
             if (!flag2)
             {
                 copyList.Add(str);
             }
             Assembly assembly = Assembly.Load(AssemblyName.GetAssemblyName(str));
             flag |= base.ProcessAssembly(assembly);
         }
     }
     return flag;
 }
Пример #2
0
 public LibraryItem(string filename, Microsoft.Matrix.Utility.Library library)
 {
     base.Text = filename;
     this._library = library;
     base.SubItems.Add(library.Version);
 }
Пример #3
0
 protected override void AddComponents(Library library, IServiceProvider serviceProvider)
 {
     string text = string.Empty;
     string caption = string.Empty;
     MessageBoxIcon asterisk = MessageBoxIcon.Asterisk;
     bool installToGac = this.GetInstallToGac(serviceProvider);
     ArrayList copyList = new ArrayList();
     if (this.ProcessComponentSection(library, Library.RuntimeFilesSection, installToGac, copyList, serviceProvider))
     {
         caption = "Web controls from the library have been added to the toolbox.";
     }
     else
     {
         caption = "No valid Web controls were found in the library.";
     }
     if (this.ProcessComponentSection(library, Library.DesignTimeFilesSection, installToGac, copyList, serviceProvider))
     {
         text = text + "\nWeb control designers from the library have been installed.";
     }
     if (copyList.Count > 0)
     {
         if (installToGac)
         {
             text = text + "\nThere was an error adding the following {0} to the Global Assembly Cache:\n\n";
             asterisk = MessageBoxIcon.Hand;
         }
         else
         {
             text = text + "\nThe following {0} {1} not added to the Global Assembly Cache:\n\n";
             asterisk = MessageBoxIcon.Exclamation;
         }
         foreach (string str3 in copyList)
         {
             text = text + str3 + "\n";
         }
         text = string.Format(text + "\nTo run a web page that uses these assemblies, you will need to copy the {0} listed above to the '\\bin' directory of your web application.", (copyList.Count > 1) ? "assemblies" : "assembly", (copyList.Count > 1) ? "were" : "was");
     }
     base.ShowMessage(caption, text, MessageBoxButtons.OK, asterisk, MessageBoxDefaultButton.Button1, serviceProvider);
     if (library.Sections.Contains(Library.ClientFilesSection))
     {
         string path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), @"ASP.NET\Client Files\");
         if (!Directory.Exists(path))
         {
             Directory.CreateDirectory(path);
         }
         library.UnpackFiles(Library.ClientFilesSection, path);
     }
 }
Пример #4
0
 protected override void AddComponents(Library library, IServiceProvider serviceProvider)
 {
     IApplicationIdentity service = serviceProvider.GetService(typeof(IApplicationIdentity)) as IApplicationIdentity;
     IDictionary dictionary = (IDictionary) library.Sections[Library.RuntimeFilesSection];
     string text = string.Empty;
     if ((dictionary != null) && (dictionary.Count > 0))
     {
         if (!Directory.Exists(service.PluginsPath))
         {
             Directory.CreateDirectory(service.PluginsPath);
         }
         bool flag = false;
         foreach (string str2 in library.UnpackFiles(Library.RuntimeFilesSection, service.PluginsPath))
         {
             Assembly assembly = Assembly.LoadFrom(str2);
             flag |= base.ProcessAssembly(assembly);
         }
         if (!flag)
         {
             text = "No valid CodeWizards were found.";
         }
         else
         {
             text = "CodeWizards have added to the toolbox.";
         }
     }
     else
     {
         text = "No CodeWizards were found in the library.";
     }
     base.ShowMessage("Customize Toolbox", text, serviceProvider);
 }
Пример #5
0
 protected abstract void AddComponents(Library library, IServiceProvider serviceProvider);
Пример #6
0
 private void OnDownloadLibraryComplete(object sender, AsyncTaskResultPostedEventArgs args)
 {
     byte[] data = (byte[]) args.Data;
     if (data == null)
     {
         MessageBox.Show(this, "Error downloading library.", "Component Gallery", MessageBoxButtons.OK, MessageBoxIcon.Hand);
     }
     string tempFileName = Path.GetTempFileName();
     try
     {
         FileStream stream = null;
         try
         {
             stream = new FileStream(tempFileName, FileMode.Create);
             stream.Write(data, 0, data.Length);
             stream.Flush();
         }
         finally
         {
             if (stream != null)
             {
                 stream.Close();
             }
         }
         Interop.WINTRUST_FILE_INFO structure = new Interop.WINTRUST_FILE_INFO();
         structure.cbStruct = Marshal.SizeOf(typeof(Interop.WINTRUST_FILE_INFO));
         structure.pcwszFilePath = Marshal.StringToHGlobalUni(tempFileName);
         structure.hFile = IntPtr.Zero;
         Interop.WINTRUST_DATA pWinTrustData = new Interop.WINTRUST_DATA();
         pWinTrustData.cbStruct = Marshal.SizeOf(typeof(Interop.WINTRUST_DATA));
         pWinTrustData.pPolicyCallbackData = IntPtr.Zero;
         pWinTrustData.pSIPClientData = IntPtr.Zero;
         pWinTrustData.dwUIChoice = 1;
         pWinTrustData.fdwRevocationChecks = 1;
         pWinTrustData.dwUnionChoice = 1;
         IntPtr ptr = Marshal.AllocHGlobal(Marshal.SizeOf(structure));
         Marshal.StructureToPtr(structure, ptr, false);
         pWinTrustData.pSomething = ptr;
         try
         {
             if (Interop.WinVerifyTrust(base.Handle, ref Interop.WINTRUST_ACTION_GENERIC_VERIFY_V2, ref pWinTrustData) != 0)
             {
                 this._library = null;
             }
             else
             {
                 try
                 {
                     this._library = Library.CreateLibrary(data);
                     base.DialogResult = DialogResult.OK;
                     base.Close();
                 }
                 catch
                 {
                     MessageBox.Show(this, "The downloaded library is invalid.", "Component Gallery", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                 }
             }
         }
         finally
         {
             if (structure.pcwszFilePath != IntPtr.Zero)
             {
                 Marshal.FreeHGlobal(structure.pcwszFilePath);
             }
             if (ptr != IntPtr.Zero)
             {
                 Marshal.FreeHGlobal(ptr);
             }
         }
     }
     catch (Exception exception)
     {
         MessageBox.Show(this, exception.Message, "Component Gallery", MessageBoxButtons.OK, MessageBoxIcon.Hand);
     }
     finally
     {
         if (File.Exists(tempFileName))
         {
             File.Delete(tempFileName);
         }
     }
 }
Пример #7
0
 public static Library CreateLibrary(string author, string email, string libraryName, System.Version version, Icon glyph)
 {
     if ((author == null) || (author.Length == 0))
     {
         throw new ArgumentException("author");
     }
     if ((email == null) || (email.Length == 0))
     {
         throw new ArgumentException("email");
     }
     if ((libraryName == null) || (libraryName.Length == 0))
     {
         throw new ArgumentException("name");
     }
     if (version == null)
     {
         throw new ArgumentException("version");
     }
     Library library = new Library();
     library.MetaData["Author"] = author;
     library.MetaData["Email"] = email;
     library.MetaData["Name"] = libraryName;
     library.MetaData["Version"] = version.ToString();
     library.Glyph = glyph;
     return library;
 }
Пример #8
0
 public static Library CreateLibrary(Assembly assembly)
 {
     if (assembly == null)
     {
         throw new ArgumentException("assembly");
     }
     Stream metaDataStream = null;
     Stream glyphStream = null;
     Stream previewStream = null;
     Stream sectionsStream = null;
     Library library = null;
     try
     {
         metaDataStream = assembly.GetManifestResourceStream("MCLMetaData");
         glyphStream = assembly.GetManifestResourceStream("MCLGlyph");
         previewStream = assembly.GetManifestResourceStream("MCLPreview");
         sectionsStream = assembly.GetManifestResourceStream("MCLSections");
         if ((metaDataStream == null) || (sectionsStream == null))
         {
             throw new ApplicationException("Invalid Managed Component Library");
         }
         library = new Library(metaDataStream, glyphStream, previewStream, sectionsStream);
     }
     finally
     {
         if (metaDataStream != null)
         {
             metaDataStream.Close();
         }
         if (glyphStream != null)
         {
             glyphStream.Close();
         }
         if (previewStream != null)
         {
             previewStream.Close();
         }
         if (sectionsStream != null)
         {
             sectionsStream.Close();
         }
     }
     return library;
 }