コード例 #1
0
 /// <summary>
 ///    <para>Adds a <see cref='.ProjectReference'/> with the specified value to the
 ///    <see cref='.ProjectReferenceCollection'/> .</para>
 /// </summary>
 /// <param name='value'>The <see cref='.ProjectReference'/> to add.</param>
 /// <returns>
 ///    <para>The index at which the new element was inserted.</para>
 /// </returns>
 /// <seealso cref='.ProjectReferenceCollection.AddRange'/>
 public int Add(ProjectReference value)
 {
     return List.Add(value);
 }
コード例 #2
0
 /// <summary>
 /// <para>Copies the elements of an array to the end of the <see cref='.ProjectReferenceCollection'/>.</para>
 /// </summary>
 /// <param name='value'>
 ///    An array of type <see cref='.ProjectReference'/> containing the objects to add to the collection.
 /// </param>
 /// <returns>
 ///   <para>None.</para>
 /// </returns>
 /// <seealso cref='.ProjectReferenceCollection.Add'/>
 public void AddRange(ProjectReference[] value)
 {
     for (int i = 0; (i < value.Length); i = (i + 1)) {
         this.Add(value[i]);
     }
 }
コード例 #3
0
 /// <summary>
 /// <para>Inserts a <see cref='.ProjectReference'/> into the <see cref='.ProjectReferenceCollection'/> at the specified index.</para>
 /// </summary>
 /// <param name='index'>The zero-based index where <paramref name='value'/> should be inserted.</param>
 /// <param name=' value'>The <see cref='.ProjectReference'/> to insert.</param>
 /// <returns><para>None.</para></returns>
 /// <seealso cref='.ProjectReferenceCollection.Add'/>
 public void Insert(int index, ProjectReference value)
 {
     List.Insert(index, value);
 }
コード例 #4
0
 /// <summary>
 ///    <para> Removes a specific <see cref='.ProjectReference'/> from the
 ///    <see cref='.ProjectReferenceCollection'/> .</para>
 /// </summary>
 /// <param name='value'>The <see cref='.ProjectReference'/> to remove from the <see cref='.ProjectReferenceCollection'/> .</param>
 /// <returns><para>None.</para></returns>
 /// <exception cref='System.ArgumentException'><paramref name='value'/> is not found in the Collection. </exception>
 public void Remove(ProjectReference value)
 {
     List.Remove(value);
 }
コード例 #5
0
 public ProjectReference AddReference(string filename)
 {
     foreach (ProjectReference rInfo in ProjectReferences) {
         if (rInfo.Reference == filename) {
             return rInfo;
         }
     }
     ProjectReference newReferenceInformation = new ProjectReference (ReferenceType.Assembly, filename);
     ProjectReferences.Add (newReferenceInformation);
     return newReferenceInformation;
 }
コード例 #6
0
 /// <summary>
 ///    <para>Returns the index of a <see cref='.ProjectReference'/> in
 ///       the <see cref='.ProjectReferenceCollection'/> .</para>
 /// </summary>
 /// <param name='value'>The <see cref='.ProjectReference'/> to locate.</param>
 /// <returns>
 /// <para>The index of the <see cref='.ProjectReference'/> of <paramref name='value'/> in the
 /// <see cref='.ProjectReferenceCollection'/>, if found; otherwise, -1.</para>
 /// </returns>
 /// <seealso cref='.ProjectReferenceCollection.Contains'/>
 public int IndexOf(ProjectReference value)
 {
     return List.IndexOf(value);
 }
コード例 #7
0
        public string Import(ProjectReference refinfo, Project project)
        {
            RegistryKey root = Registry.ClassesRoot;
            RegistryKey typelibsKey = root.OpenSubKey("TypeLib");
            int index = refinfo.Reference.LastIndexOf("{");
            if (index < 0) {
                return null;
            }
            RegistryKey typelibKey = typelibsKey.OpenSubKey(refinfo.Reference.Substring(index, refinfo.Reference.Length - index));
            if (typelibKey == null) {
                return null;
            }
            string[] versions = typelibKey.GetSubKeyNames();

            if (versions.Length <= 0) {
                return null;
            }
            // Use the last version
            string version = versions[versions.Length - 1];
            RegistryKey versionKey = typelibKey.OpenSubKey(version);

            string tlbname = (string)versionKey.GetValue(null);

            string tlpath = GetTypelibPath(versionKey);
            if (tlpath == null) {
                return null;
            }
            string proxyfilename = "Interop." + Path.GetFileNameWithoutExtension(tlpath) + ".dll";

            AbstractProjectConfiguration ac = (AbstractProjectConfiguration)project.ActiveConfiguration;
            string fullpath = Path.Combine(ac.OutputDirectory,proxyfilename);

            if (!File.Exists(fullpath)) {
                string saveCurrDir = Directory.GetCurrentDirectory();
                if (!Directory.Exists(ac.OutputDirectory)) {
                    Directory.CreateDirectory(ac.OutputDirectory);
                }
                Directory.SetCurrentDirectory(ac.OutputDirectory);
                if (!ImportTypelibUsingTlbImpCode(tlpath, ac.OutputDirectory, proxyfilename)) {

                    MessageBox.Show("Cannot import type library using .Net SDK 1.0. Some, but not all type libraries can succesfully be imported without it. ",
                                        ".Net SDK 1.0 not present ?",
                                        MessageBoxButtons.OK,
                                        MessageBoxIcon.Warning,
                                        MessageBoxDefaultButton.Button1);

                    Object typeLib;
                    LoadTypeLibEx(tlpath, RegKind.RegKind_None, out typeLib);

                    if( typeLib == null ) {
                        throw new System.Exception("LoadTypeLibEx failed.");
                    }

                    TypeLibConverter converter = new TypeLibConverter();
                    ConversionEventHandler eventHandler = new ConversionEventHandler();

                    AssemblyBuilder asm = converter.ConvertTypeLibToAssembly( typeLib,
                                                                             proxyfilename, 0, eventHandler, null, null,
                                                                             Marshal.GetTypeLibName((UCOMITypeLib)typeLib), null );

                    asm.Save( proxyfilename );

                }
                Directory.SetCurrentDirectory(saveCurrDir);
            }
            return fullpath;
        }
コード例 #8
0
 public ProjectReferenceEventArgs(Project project, ProjectReference reference)
 {
     this.project = project;
     this.reference = reference;
 }
コード例 #9
0
 void AddNonGacReference(ProjectReference refInfo)
 {
     gacRefPanel.SignalRefChange (refInfo.Reference, true);
     projectRefPanel.SignalRefChange (refInfo.Reference, true);
     refTreeStore.AppendValues (System.IO.Path.GetFileName (refInfo.Reference), refInfo.ReferenceType.ToString (), System.IO.Path.GetFullPath (refInfo.GetReferencedFileName ()), refInfo);
 }
コード例 #10
0
        public void AddReference(ReferenceType referenceType, string referenceName, string referenceLocation)
        {
            TreeIter looping_iter;
            if (refTreeStore.GetIterFirst (out looping_iter)) {
                do {
                    try {
                        if (referenceLocation == (string)refTreeStore.GetValue (looping_iter, 2) && referenceName == (string)refTreeStore.GetValue (looping_iter, 0)) {
                            return;
                        }
                    } catch {
                    }
                } while (refTreeStore.IterNext (ref looping_iter));
            }

            ProjectReference tag;
            switch (referenceType) {
                case ReferenceType.Typelib:
                    tag = new ProjectReference(referenceType, referenceName + "|" + referenceLocation);
                    break;
                case ReferenceType.Project:
                    tag = new ProjectReference(referenceType, referenceName);
                    break;
                default:
                    tag = new ProjectReference(referenceType, referenceLocation);
                    break;

            }
            TreeIter ni = refTreeStore.AppendValues (referenceName, referenceType.ToString (), referenceLocation, tag);
            ReferencesTreeView.ScrollToCell (refTreeStore.GetPath (ni), null, false, 0, 0);
        }
コード例 #11
0
 void AddGacReference(ProjectReference refInfo, Project referencedProject)
 {
     gacRefPanel.SignalRefChange (refInfo.Reference, true);
     projectRefPanel.SignalRefChange (refInfo.Reference, true);
     refTreeStore.AppendValues (System.IO.Path.GetFileNameWithoutExtension (refInfo.GetReferencedFileName ()), refInfo.ReferenceType.ToString (), refInfo.Reference, refInfo);
 }
コード例 #12
0
 internal void NotifyReferenceRemovedFromProject(ProjectReference reference)
 {
     isDirty = true;
     OnReferenceRemovedFromProject (new ProjectReferenceEventArgs (this, reference));
 }
コード例 #13
0
 internal void NotifyReferenceAddedToProject(ProjectReference reference)
 {
     isDirty = true;
     OnReferenceAddedToProject (new ProjectReferenceEventArgs (this, reference));
 }
コード例 #14
0
        /// <summary>
        /// This method returns the absolute path to an GAC assembly.
        /// </summary>
        /// <param name ="refInfo">
        /// The reference information containing a GAC reference information.
        /// </param>
        /// <returns>
        /// the absolute path to the GAC assembly which refInfo points to.
        /// </returns>
        static string GetPathToGACAssembly(ProjectReference refInfo)
        {
            // HACK : Only works on windows.
            Debug.Assert(refInfo.ReferenceType == ReferenceType.Gac);
            string[] info = refInfo.Reference.Split(',');

            //if (info.Length < 4) {
            return info[0];
            //	}

            /*string aName      = info[0];
            string aVersion   = info[1].Substring(info[1].LastIndexOf('=') + 1);
            string aPublicKey = info[3].Substring(info[3].LastIndexOf('=') + 1);

            return System.Environment.GetFolderPath(Environment.SpecialFolder.System) +
                   Path.DirectorySeparatorChar + ".." +
                   Path.DirectorySeparatorChar + "assembly" +
                   Path.DirectorySeparatorChar + "GAC" +
                   Path.DirectorySeparatorChar + aName +
                   Path.DirectorySeparatorChar + aVersion + "__" + aPublicKey +
                   Path.DirectorySeparatorChar + aName + ".dll";*/
        }
コード例 #15
0
 /// <summary>
 /// <para>Gets a value indicating whether the
 ///    <see cref='.ProjectReferenceCollection'/> contains the specified <see cref='.ProjectReference'/>.</para>
 /// </summary>
 /// <param name='value'>The <see cref='.ProjectReference'/> to locate.</param>
 /// <returns>
 /// <para><see langword='true'/> if the <see cref='.ProjectReference'/> is contained in the collection;
 ///   otherwise, <see langword='false'/>.</para>
 /// </returns>
 /// <seealso cref='.ProjectReferenceCollection.IndexOf'/>
 public bool Contains(ProjectReference value)
 {
     return List.Contains(value);
 }
コード例 #16
0
        string GetReferenceKey(ProjectReference pr)
        {
            string refId = pr.ReferenceType == ReferenceType.Project ? "Project" : "Assembly";
            refId += ":" + pr.Reference;

            if (pr.ReferenceType == ReferenceType.Gac && refId.ToLower().EndsWith (".dll"))
                refId = refId.Substring (0, refId.Length - 4);
            return refId;
        }
コード例 #17
0
 /// <summary>
 /// <para>Copies the <see cref='.ProjectReferenceCollection'/> values to a one-dimensional <see cref='System.Array'/> instance at the
 ///    specified index.</para>
 /// </summary>
 /// <param name='array'><para>The one-dimensional <see cref='System.Array'/> that is the destination of the values copied from <see cref='.ProjectReferenceCollection'/> .</para></param>
 /// <param name='index'>The index in <paramref name='array'/> where copying begins.</param>
 /// <returns>
 ///   <para>None.</para>
 /// </returns>
 /// <exception cref='System.ArgumentException'><para><paramref name='array'/> is multidimensional.</para> <para>-or-</para> <para>The number of elements in the <see cref='.ProjectReferenceCollection'/> is greater than the available space between <paramref name='arrayIndex'/> and the end of <paramref name='array'/>.</para></exception>
 /// <exception cref='System.ArgumentNullException'><paramref name='array'/> is <see langword='null'/>. </exception>
 /// <exception cref='System.ArgumentOutOfRangeException'><paramref name='arrayIndex'/> is less than <paramref name='array'/>'s lowbound. </exception>
 /// <seealso cref='System.Array'/>
 public void CopyTo(ProjectReference[] array, int index)
 {
     List.CopyTo(array, index);
 }
コード例 #18
0
        public static ProjectDescriptor CreateProjectDescriptor(XmlElement element)
        {
            ProjectDescriptor projectDescriptor = new ProjectDescriptor(element.Attributes["name"].InnerText, element.Attributes["directory"].InnerText);

            projectDescriptor.projectType = element.GetAttribute ("type");
            if (projectDescriptor.projectType == "") projectDescriptor.projectType = "DotNet";

            projectDescriptor.projectOptions = element["Options"];
            if (projectDescriptor.projectOptions == null)
                projectDescriptor.projectOptions = element.OwnerDocument.CreateElement ("Options");

            if (element["Files"] != null) {
                foreach (XmlNode node in element["Files"].ChildNodes) {
                    if (node != null && node.Name == "File") {
                        projectDescriptor.files.Add(new FileDescriptionTemplate(node.Attributes["name"].InnerText, node.InnerText));
                    }
                }
            }
            if (element["Resources"] != null) {
                foreach (XmlNode node in element["Resources"].ChildNodes) {
                    if (node != null && node.Name == "File") {
                        projectDescriptor.resources.Add (new FileDescriptionTemplate (node.Attributes["name"].InnerText, node.InnerText));
                    }
                }
            }
            if (element["References"] != null) {
                foreach (XmlNode node in element["References"].ChildNodes) {
                    if (node != null && node.Name == "Reference") {
                        ProjectReference projectReference = new ProjectReference();

                        projectReference.ReferenceType = (ReferenceType)Enum.Parse(typeof(ReferenceType), node.Attributes["type"].InnerXml);
                        projectReference.Reference     = node.Attributes["refto"].InnerXml;
                        projectDescriptor.references.Add(projectReference);
                    }
                }
            }
            return projectDescriptor;
        }
コード例 #19
0
        public static ProjectReference GenerateWebProxyDLL(Project project, ServiceDescription desc)
        {
            ProjectReference refInfo = null;

            string nmspace = GetNamespaceFromUri(desc.RetrievalUrl);

            StringBuilder savedir = new StringBuilder();
            savedir.Append(project.BaseDirectory);
            savedir.Append(Path.DirectorySeparatorChar);
            savedir.Append("WebReferences");
            // second, create the path if it doesn't exist
            if(!Directory.Exists(savedir.ToString()))
                Directory.CreateDirectory(savedir.ToString());

            // generate the assembly
            ServiceDescriptionImporter importer = new ServiceDescriptionImporter();
            importer.AddServiceDescription(desc, null, null);

            CodeNamespace codeNamespace = new CodeNamespace(nmspace);
            CodeCompileUnit codeUnit = new CodeCompileUnit();
            codeUnit.Namespaces.Add(codeNamespace);
            importer.Import(codeNamespace, codeUnit);

            CodeDomProvider provider = new Microsoft.CSharp.CSharpCodeProvider();
            System.CodeDom.Compiler.ICodeCompiler compiler;

            if(provider != null) {
                compiler = provider.CreateCompiler();
                CompilerParameters parms = new CompilerParameters();
                parms.ReferencedAssemblies.Add("System.Dll");
                parms.ReferencedAssemblies.Add("System.Xml.Dll");
                parms.ReferencedAssemblies.Add("System.Web.Services.Dll");
                parms.OutputAssembly = project.BaseDirectory + Path.DirectorySeparatorChar + "WebReferences" + Path.DirectorySeparatorChar + nmspace + ".Reference.Dll";
                CompilerResults results = compiler.CompileAssemblyFromDom(parms, codeUnit);
                Assembly assembly = results.CompiledAssembly;

                if(assembly != null) {
                    refInfo = new ProjectReference();
                    refInfo.ReferenceType = ReferenceType.Assembly;
                    refInfo.Reference = parms.OutputAssembly;
                }
            }

            return refInfo;
        }