This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using HtmlAgilityPack; | |
| //Download http://somapage | |
| WebClient wc = new WebClient(); | |
| var page = wc.DownloadString("http://somepage"); | |
| //use Html Agility Pack to load Html | |
| HtmlDocument doc = new HtmlDocument(); | |
| doc.LoadHtml(page); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class WebDownload : WebClient | |
| { | |
| private int _timeout; | |
| /// <summary> | |
| /// 超时时间(毫秒) | |
| /// </summary> | |
| public int Timeout | |
| { | |
| get | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| XPathDocument myXPathDoc = new XPathDocument(myXmlFile) ; | |
| XslCompiledTransform myXslTrans = new XslCompiledTransform(); | |
| myXslTrans.Load(myStyleSheet); | |
| XmlTextWriter myWriter = new XmlTextWriter("result.html",null); | |
| myXslTrans.Transform(myXPathDoc,null,myWriter); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| public class clsPerson | |
| { | |
| public string FirstName; | |
| public string MI; | |
| public string LastName; | |
| } | |
| class class1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Test instance = new Test(); | |
| Type type = typeof(Test); | |
| Dictionary<string, object> properties = new Dictionary<string, object>(); | |
| foreach (PropertyInfo prop in type.GetProperties()) | |
| properties.Add(prop.Name, prop.GetValue(instance)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Multiuse attribute. | |
| [System.AttributeUsage(System.AttributeTargets.Class | | |
| System.AttributeTargets.Struct, | |
| AllowMultiple = true) // Multiuse attribute. | |
| ] | |
| public class Author : System.Attribute | |
| { | |
| string name; | |
| public double version; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static IEnumerable<Type> FindDerivedInterfaceTypes(Type type) | |
| { | |
| return System.Reflection.Assembly.GetAssembly(type).GetTypes().Where(t => t.GetInterfaces().Contains(type)); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Type type = SchemaAssemblyUtility.GetType(schemaName); | |
| var method = typeof(SchemaContext).GetMethod("CreateModel"); | |
| var genericMethod = method.MakeGenericMethod(type);//Here use type | |
| return genericMethod.Invoke(schemaContext, null); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static bool IsList(Type type) | |
| { | |
| return type != null && type.GetGenericTypeDefinition() == typeof(IList<>); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private void treeView_MouseUp(object sender, MouseEventArgs e) | |
| { | |
| if (e.Button != MouseButtons.Right) | |
| { | |
| return; | |
| } | |
| TreeViewHitTestInfo info = treeView.HitTest(e.Location); | |
| if (info.Node == null) |