Exemple #1
0
 private void Save(DotNetDelegate _delegate, string directory, string filename)
 {
     using (StreamWriter writer = new StreamWriter(Path.Combine(directory, FormatFilename(filename))))
     {
         writer.Write(_delegate.ToMarkdownFile().ToMarkdownString());
     }
 }
        public void DotNetDelegate_ConvertFromType_Global()
        {
            //arrange
            XElement xmlElement = XElement.Parse("<member name='T:DataFileTest.DotNetDelegateTests.GlobalDelegate' />", LoadOptions.PreserveWhitespace);
            Type     type       = typeof(GlobalDelegate);
            //act
            DotNetType     typeResult     = DotNetType.FromVisualStudioXml(xmlElement);
            DotNetDelegate delegateResult = typeResult.ToDelegate(typeResult.Name);

            delegateResult.AddAssemblyInfo(type);
            //assert
            Assert.AreEqual(2, delegateResult.MethodName.Parameters.Count);
            Assert.AreEqual("a", delegateResult.MethodName.Parameters[0].Name);
            Assert.AreEqual("b", delegateResult.MethodName.Parameters[1].Name);
            Assert.AreEqual("System.Int32", delegateResult.MethodName.Parameters[0].FullTypeName);
            Assert.AreEqual("System.String", delegateResult.MethodName.Parameters[1].FullTypeName);
            Assert.AreEqual("System.EventHandler", delegateResult.MethodName.ReturnTypeName.FullName);
        }