Ejemplo n.º 1
0
 protected Document(DocumentProjectItem projectItem)
 {
     this._guid = Guid.NewGuid();
     if (projectItem == null)
     {
         throw new ArgumentNullException("projectItem");
     }
     this._projectItem = projectItem;
 }
Ejemplo n.º 2
0
 public CodeDocument(DocumentProjectItem projectItem, CodeDocumentLanguage language)
     : base(projectItem)
 {
     if (language == null)
     {
         throw new ArgumentNullException("language");
     }
     this._language = language;
 }
 public void ClearDesignTimeHtml(DocumentProjectItem projectItem)
 {
     ProjectEntry entry = null;
     if (this._projectTable != null)
     {
         entry = (ProjectEntry) this._projectTable[projectItem.Project];
     }
     if (entry != null)
     {
         entry.RemoveDesignTimeHtml(projectItem);
     }
 }
Ejemplo n.º 4
0
 public override Document OpenProjectItem(DocumentProjectItem item, bool readOnly, DocumentViewType initialView)
 {
     IProjectManager service = (IProjectManager) base.GetService(typeof(IProjectManager));
     if (service != null)
     {
         Project localFileSystemProject = service.LocalFileSystemProject;
         if (localFileSystemProject != null)
         {
             return localFileSystemProject.OpenProjectItem(item, readOnly, initialView);
         }
     }
     return null;
 }
Ejemplo n.º 5
0
 public override Document OpenProjectItem(DocumentProjectItem projectItem, bool readOnly, DocumentViewType initialView)
 {
     if ((projectItem is TableProjectItem) || (projectItem is StoredProcedureProjectItem))
     {
         IDocumentManager service = (IDocumentManager) base.GetService(typeof(IDocumentManager));
         if (service == null)
         {
             return null;
         }
         try
         {
             return service.OpenDocument(projectItem, readOnly, DocumentViewType.Default);
         }
         catch (Exception exception)
         {
             ((IMxUIService) base.GetService(typeof(IMxUIService))).ReportError(exception, "Error opening document.", false);
             return null;
         }
     }
     return null;
 }
 public string GetDesignTimeHtml(DocumentProjectItem projectItem, bool forceRegenerate)
 {
     ProjectEntry entry = null;
     if (this._projectTable != null)
     {
         entry = (ProjectEntry) this._projectTable[projectItem.Project];
         if (forceRegenerate && (entry != null))
         {
             entry.RemoveDesignTimeHtml(projectItem);
         }
     }
     else
     {
         this._projectTable = new HybridDictionary();
     }
     if (entry == null)
     {
         entry = new ProjectEntry();
         this._projectTable[projectItem.Project] = entry;
     }
     return entry.GetDesignTimeHtml(projectItem);
 }
Ejemplo n.º 7
0
 public HtmlDocument(DocumentProjectItem projectItem)
     : base(projectItem)
 {
 }
Ejemplo n.º 8
0
 Document IDocumentFactory.CreateDocument(DocumentProjectItem projectItem, bool readOnly, DocumentMode mode, DocumentViewType initialView, out DocumentWindow documentWindow, out DesignerHost designerHost)
 {
     throw new NotSupportedException("Invalid use of CodeDocumentFactory. This class only exists to represent a arbitrary code file.");
 }
Ejemplo n.º 9
0
 public StoredProcedureDocument(DocumentProjectItem projectItem)
     : base(projectItem)
 {
 }
Ejemplo n.º 10
0
 public override DocumentProjectItem GetSaveAsProjectItem(DocumentProjectItem item)
 {
     return null;
 }
Ejemplo n.º 11
0
 private void OnClickOKButton(object sender, EventArgs e)
 {
     IMxUIService service = (IMxUIService) this.GetService(typeof(IMxUIService));
     CodeDocumentLanguage codeLanguage = null;
     string fileName = this.GetFileName();
     string itemPath = (this._location != null) ? this._location : this._locationText.Text.Trim();
     string str3 = null;
     if (!this._project.ValidateProjectItemName(fileName))
     {
         service.ReportError("'" + fileName + "' is not a valid file name.\r\nPlease try again.", this.Text, true);
         this._fileNameText.Focus();
     }
     else if ((this._location == null) && !this._project.ValidateProjectItemPath(itemPath, true))
     {
         service.ReportError("'" + itemPath + "' is not a valid location for the new file.\r\nPlease try again.", this.Text, true);
         this._locationText.Focus();
     }
     else
     {
         try
         {
             byte[] buffer;
             try
             {
                 str3 = this._project.CombinePath(itemPath, fileName);
                 if (!this._project.ProjectItemExists(str3) || (service.ShowMessage("A file with the path '" + str3 + "' already exists.\r\nClick 'Yes' to continue and overwrite the existing file.\r\nClick 'No' to pick a different file.", this.Text, MessageBoxIcon.Question, MessageBoxButtons.YesNo, MessageBoxDefaultButton.Button2) != DialogResult.No))
                 {
                     goto Label_013D;
                 }
                 this._fileNameText.Focus();
             }
             catch
             {
                 service.ReportError("Unable to create the specified file.\r\nPlease try again.", this.Text, true);
                 this._fileNameText.Focus();
             }
             return;
         Label_013D:
             buffer = null;
             try
             {
                 DocumentInstanceArguments instanceArguments = null;
                 if ((this._currentTemplateItem.DocumentType.TemplateFlags & TemplateFlags.HasCode) == TemplateFlags.None)
                 {
                     instanceArguments = new DocumentInstanceArguments(fileName);
                 }
                 else
                 {
                     codeLanguage = this.GetCodeLanguage();
                     string namespaceName = string.Empty;
                     string str5 = string.Empty;
                     if (this._classInfoCheckBox.Checked)
                     {
                         namespaceName = this._namespaceText.Text.Trim();
                         str5 = this._classText.Text.Trim();
                         if (codeLanguage != null)
                         {
                             ICodeGenerator generator = codeLanguage.CodeDomProvider.CreateGenerator();
                             if (!generator.IsValidIdentifier(str5))
                             {
                                 service.ReportError("'" + str5 + "' is not a valid class name.\r\nPlease try again.", this.Text, true);
                                 this._classText.Focus();
                                 return;
                             }
                             foreach (string str6 in namespaceName.Split(new char[] { '.' }))
                             {
                                 if (!generator.IsValidIdentifier(str6))
                                 {
                                     service.ReportError("'" + namespaceName + "' is not a valid namespace name.\r\nPlease try again.", this.Text, true);
                                     this._namespaceText.Focus();
                                     return;
                                 }
                             }
                         }
                     }
                     instanceArguments = new DocumentInstanceArguments(fileName, codeLanguage, namespaceName, str5);
                 }
                 buffer = this._currentTemplateItem.DocumentType.Instantiate(base.ServiceProvider, instanceArguments);
             }
             catch
             {
                 service.ReportError("Unable to use the selected document template to create a new file.\r\nPlease try again.", this.Text, true);
                 buffer = null;
             }
             if (buffer != null)
             {
                 DocumentProjectItem item = this._project.ParsePath(str3, true) as DocumentProjectItem;
                 if (item != null)
                 {
                     Stream stream = null;
                     try
                     {
                         stream = item.GetStream(ProjectItemStreamMode.Write);
                         if (buffer.Length != 0)
                         {
                             stream.Write(buffer, 0, buffer.Length);
                         }
                         this._newProjectItem = item;
                     }
                     finally
                     {
                         if (stream != null)
                         {
                             stream.Close();
                             stream = null;
                         }
                     }
                 }
             }
         }
         catch (Exception exception)
         {
             service.ReportError(exception.Message, this.Text, false);
         }
         if (this._newProjectItem != null)
         {
             IPreferencesService service2 = (IPreferencesService) this.GetService(typeof(IPreferencesService));
             if (service2 != null)
             {
                 PreferencesStore preferencesStore = service2.GetPreferencesStore(typeof(AddFileDialog));
                 if (preferencesStore != null)
                 {
                     if (this._location == null)
                     {
                         preferencesStore.SetValue("Location", itemPath, string.Empty);
                     }
                     preferencesStore.SetValue("View", (this._templateListView.View == View.List) ? 1 : 0, 0);
                 }
             }
             if (codeLanguage != null)
             {
                 ILanguageManager manager = (ILanguageManager) this.GetService(typeof(ILanguageManager));
                 if (manager != null)
                 {
                     ((LanguageManager) manager).SetCurrentCodeLanguage(codeLanguage);
                 }
             }
             base.DialogResult = DialogResult.OK;
             base.Close();
         }
         else
         {
             this._fileNameText.Focus();
         }
     }
 }
Ejemplo n.º 12
0
 public TableDocument(DocumentProjectItem projectItem)
     : base(projectItem)
 {
 }
Ejemplo n.º 13
0
 protected override Stream GetProjectItemStream(DocumentProjectItem projectItem, ProjectItemStreamMode mode)
 {
     return null;
 }
Ejemplo n.º 14
0
 private string GetLocalFileProjectItemRunUrl(DocumentProjectItem projectItem)
 {
     string path = projectItem.Path;
     string directoryName = Path.GetDirectoryName(path);
     string str3 = null;
     string appDirectory = null;
     string uriString = null;
     if (this._localDirectoryMappings != null)
     {
         for (string str6 = directoryName; str6 != null; str6 = Path.GetDirectoryName(str6))
         {
             uriString = (string) this._localDirectoryMappings[str6.ToLower()];
             if (uriString != null)
             {
                 appDirectory = str6;
                 break;
             }
         }
         if (uriString != null)
         {
             Socket socket = null;
             bool flag = false;
             try
             {
                 Uri uri = new Uri(uriString);
                 IPAddress address = Dns.GetHostByName(uri.Host).AddressList[0];
                 if (IPAddress.IsLoopback(address) || address.Equals(Dns.GetHostByName(Environment.MachineName).AddressList[0]))
                 {
                     IPEndPoint remoteEP = new IPEndPoint(address, uri.Port);
                     socket = new Socket(remoteEP.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
                     socket.Connect(remoteEP);
                     if (!socket.Connected)
                     {
                         flag = true;
                     }
                 }
             }
             catch
             {
                 flag = true;
             }
             finally
             {
                 if (socket != null)
                 {
                     socket.Close();
                 }
             }
             if (flag)
             {
                 this._localDirectoryMappings.Remove(appDirectory.ToLower());
                 uriString = null;
                 appDirectory = null;
             }
         }
     }
     if (uriString == null)
     {
         IUIService service = (IUIService) this._serviceProvider.GetService(typeof(IUIService));
         DialogResult cancel = DialogResult.Cancel;
         if (service != null)
         {
             StartWebAppDialog form = new StartWebAppDialog(this._serviceProvider, directoryName);
             cancel = service.ShowDialog(form);
             if (cancel == DialogResult.OK)
             {
                 appDirectory = form.AppDirectory;
                 uriString = form.AppUrl;
                 if (this._localDirectoryMappings == null)
                 {
                     this._localDirectoryMappings = new HybridDictionary(false);
                 }
                 this._localDirectoryMappings[appDirectory.ToLower()] = uriString;
             }
         }
         if (cancel == DialogResult.Cancel)
         {
             return string.Empty;
         }
     }
     if (uriString == null)
     {
         return str3;
     }
     if (directoryName.Equals(appDirectory))
     {
         return (uriString + "/" + projectItem.Caption);
     }
     string[] strArray = path.Split(new char[] { '\\' });
     string[] strArray2 = appDirectory.Split(new char[] { '\\' });
     StringBuilder builder = new StringBuilder(uriString, 0x400);
     for (int i = strArray2.Length; i < strArray.Length; i++)
     {
         builder.Append('/');
         builder.Append(strArray[i]);
     }
     return builder.ToString();
 }
Ejemplo n.º 15
0
 private void AddMruEntry(DocumentProjectItem projectItem)
 {
     string path = projectItem.Path;
     this.MruList.AddEntry(path);
     try
     {
         Interop.SHAddToRecentDocs(Interop.SHARED_PATH, path);
     }
     catch
     {
     }
 }
Ejemplo n.º 16
0
 public override DocumentProjectItem GetSaveAsProjectItem(DocumentProjectItem item)
 {
     DocumentProjectItem saveAsProjectItem = base.GetSaveAsProjectItem(item);
     if (saveAsProjectItem != null)
     {
         this.AddMruEntry(saveAsProjectItem);
     }
     return saveAsProjectItem;
 }
Ejemplo n.º 17
0
 public abstract Document OpenProjectItem(DocumentProjectItem projectItem, bool readOnly, DocumentViewType initialView);
 private string GenerateDesignTimeHtml(DocumentProjectItem projectItem)
 {
     string str = null;
     WebFormsDesignerHost designerHost = null;
     try
     {
         AscxDocument document = new AscxDocument(projectItem);
         designerHost = new WebFormsDesignerHost(document);
         document.Load(true);
         str = string.Empty;
         string html = document.Html;
         string directives = document.RegisterDirectives.ToString();
         string controlText = "<asp:PlaceHolder runat=\"server\">" + html + "</asp:PlaceHolder>";
         Control control = ControlParser.ParseControl(designerHost, controlText, directives);
         if ((control == null) || !control.HasControls())
         {
             return str;
         }
         IDesignerHost host2 = designerHost;
         IContainer container = host2.Container;
         StringBuilder builder = new StringBuilder(0x400);
         bool flag = false;
         foreach (Control control2 in control.Controls)
         {
             if (!(control2 is LiteralControl))
             {
                 if (!flag)
                 {
                     flag = true;
                     Page component = new Page();
                     component.ID = "Page";
                     container.Add(component, "Page");
                     component.DesignerInitialize();
                 }
                 container.Add(control2);
             }
         }
         foreach (Control control4 in control.Controls)
         {
             LiteralControl control5 = control4 as LiteralControl;
             if (control5 != null)
             {
                 builder.Append(control5.Text);
             }
             else
             {
                 ControlDesigner designer = (ControlDesigner) host2.GetDesigner(control4);
                 try
                 {
                     string designTimeHtml = designer.GetDesignTimeHtml();
                     builder.Append(designTimeHtml);
                     continue;
                 }
                 catch
                 {
                     continue;
                 }
             }
         }
         str = builder.ToString();
     }
     catch (Exception)
     {
     }
     finally
     {
         if (designerHost != null)
         {
             ((IDisposable) designerHost).Dispose();
             designerHost = null;
         }
     }
     return str;
 }
 public void RemoveDesignTimeHtml(DocumentProjectItem projectItem)
 {
     string path = projectItem.Path;
     if (this._documentTable.Contains(path))
     {
         this._documentTable.Remove(path);
         this._documentList.RemoveEntry(path);
     }
 }
 public string GetDesignTimeHtml(DocumentProjectItem projectItem)
 {
     string path = projectItem.Path;
     string entry = null;
     string str3 = null;
     str3 = (string) this._documentTable[path];
     if (str3 != null)
     {
         entry = this._documentList.AddEntry(path);
     }
     else
     {
         this._documentTable[path] = string.Empty;
         str3 = this.GenerateDesignTimeHtml(projectItem);
         if (str3 != null)
         {
             this._documentTable[path] = str3;
             entry = this._documentList.AddEntry(path);
         }
         else
         {
             this._documentTable.Remove(path);
         }
     }
     if (entry != null)
     {
         this._documentList.RemoveEntry(entry);
     }
     return str3;
 }
Ejemplo n.º 21
0
 public AshxDocument(DocumentProjectItem projectItem)
     : base(projectItem)
 {
 }
Ejemplo n.º 22
0
 public override Document OpenProjectItem(DocumentProjectItem item, bool readOnly, DocumentViewType initialView)
 {
     IDocumentManager service = (IDocumentManager) base.GetService(typeof(IDocumentManager));
     if (service == null)
     {
         return null;
     }
     MiscFileProjectItem projectItem = item as MiscFileProjectItem;
     if ((projectItem == null) || (projectItem.Project != this))
     {
         projectItem = new MiscFileProjectItem(item.Caption, item.Path, this);
     }
     Document document = service.OpenDocument(projectItem, readOnly, initialView);
     this.AddMruEntry(item);
     return document;
 }
Ejemplo n.º 23
0
 public abstract DocumentProjectItem GetSaveAsProjectItem(DocumentProjectItem item);
Ejemplo n.º 24
0
 public ImageDocument(DocumentProjectItem projectItem)
     : base(projectItem)
 {
 }
Ejemplo n.º 25
0
 protected internal abstract Stream GetProjectItemStream(DocumentProjectItem projectItem, ProjectItemStreamMode mode);
Ejemplo n.º 26
0
 private void OpenDocument(DocumentProjectItem projectItem, DocumentViewType viewType)
 {
     IDocumentManager service = (IDocumentManager) base.ServiceProvider.GetService(typeof(IDocumentManager));
     if (service != null)
     {
         service.OpenDocument(projectItem, false, viewType);
     }
 }
Ejemplo n.º 27
0
 Document IDocumentFactory.CreateDocument(DocumentProjectItem projectItem, bool readOnly, DocumentMode mode, DocumentViewType initialView, out DocumentWindow documentWindow, out DesignerHost designerHost)
 {
     if (projectItem == null)
     {
         throw new ArgumentNullException("projectItem");
     }
     TableDocument document = new TableDocument(projectItem);
     designerHost = new DesignerHost(document);
     document.Load(readOnly);
     if (initialView == DocumentViewType.Default)
     {
         initialView = (document.Table.GetRowCount() == 0) ? DocumentViewType.Design : DocumentViewType.Source;
     }
     documentWindow = new TableDocumentWindow(designerHost, document, initialView);
     return document;
 }
Ejemplo n.º 28
0
 public TypeDocument(DocumentProjectItem projectItem)
     : base(projectItem)
 {
     this._filter = TypeDocumentFilter.Declared | TypeDocumentFilter.Obsolete | TypeDocumentFilter.Current | TypeDocumentFilter.Public;
 }
Ejemplo n.º 29
0
 Document IDocumentFactory.CreateDocument(DocumentProjectItem projectItem, bool readOnly, DocumentMode mode, DocumentViewType initialView, out DocumentWindow documentWindow, out DesignerHost designerHost)
 {
     if (projectItem == null)
     {
         throw new ArgumentNullException("projectItem");
     }
     Document document = new AshxDocument(projectItem);
     designerHost = new DesignerHost(document);
     document.Load(readOnly);
     documentWindow = new AshxDocumentWindow(designerHost, document);
     return document;
 }
Ejemplo n.º 30
0
 Document IDocumentFactory.CreateDocument(DocumentProjectItem projectItem, bool readOnly, DocumentMode mode, DocumentViewType initialView, out DocumentWindow documentWindow, out DesignerHost designerHost)
 {
     if (projectItem == null)
     {
         throw new ArgumentNullException("projectItem");
     }
     if (initialView == DocumentViewType.Default)
     {
         initialView = WebPackage.Instance.WebDefaultView;
         if (initialView == DocumentViewType.Source)
         {
             initialView = DocumentViewType.Composite;
         }
     }
     documentWindow = null;
     AscxDocument document = new AscxDocument(projectItem);
     designerHost = new WebFormsDesignerHost(document);
     document.Load(readOnly);
     Page page = null;
     UserControl child = null;
     if (document.DocumentDirective.Inherits.ToLower().IndexOf("mobile") < 0)
     {
         page = new Page();
         child = new UserControl();
         child.ID = "Page";
         documentWindow = new AscxDocumentWindow(designerHost, document, initialView);
         page.Site = new AscxPageSite(designerHost, page);
         page.DesignerInitialize();
         page.Controls.Add(child);
     }
     else
     {
         if (!_mobileAssemblyLoadFailed)
         {
             if (_mobileAssembly == null)
             {
                 _mobileAssembly = Assembly.LoadWithPartialName(_mobileAssemblyName);
             }
             if (_mobileAssembly != null)
             {
                 document.Dispose();
                 document = new AscxDocument(projectItem);
                 Type type = _mobileAssembly.GetType("System.Web.UI.MobileControls.MobilePage");
                 Type type2 = _mobileAssembly.GetType("System.Web.UI.MobileControls.MobileUserControl");
                 Type type3 = _mobileAssembly.GetType("System.Web.UI.MobileControls.Form");
                 page = (Page) Activator.CreateInstance(type);
                 child = (UserControl) Activator.CreateInstance(type2);
                 Control control2 = (Control) Activator.CreateInstance(type3);
                 Type type4 = Type.GetType("Microsoft.Matrix.Packages.Web.Mobile.MobileDesignerHost, Microsoft.Matrix.Packages.Web.Mobile");
                 designerHost = (DesignerHost) Activator.CreateInstance(type4, new object[] { document });
                 document.Load(readOnly);
                 Type type5 = Type.GetType("Microsoft.Matrix.Packages.Web.Mobile.MobileWebFormsDocumentWindow, Microsoft.Matrix.Packages.Web.Mobile");
                 documentWindow = (DocumentWindow) Activator.CreateInstance(type5, new object[] { designerHost, document, initialView });
                 page.Site = new AscxPageSite(designerHost, page);
                 page.DesignerInitialize();
                 page.Controls.Add(control2);
                 control2.Controls.Add(child);
             }
             else
             {
                 _mobileAssemblyLoadFailed = true;
             }
         }
         if (_mobileAssemblyLoadFailed)
         {
             document.Dispose();
             Document document2 = new TextDocument(projectItem);
             designerHost = new DesignerHost(document2);
             ((IMxUIService) designerHost.GetService(typeof(IMxUIService))).ReportError("Microsoft Mobile Internet Toolkit is required for design-time editing of mobile user controls.\r\nPlease visit 'http://www.asp.net/mobile/default.aspx' for more information.\r\nThe user control will be opened in the text editor instead.", "Mobile User Controls are not enabled.", true);
             document2.Load(readOnly);
             documentWindow = new TextDocumentWindow(designerHost, document2);
             return document2;
         }
     }
     IDesignerHost host = designerHost;
     host.Container.Add(child, "UserControl");
     child.DesignerInitialize();
     return document;
 }