public static void GoLink(string href) { object obj = CssValue.DetectSource(href); FileInfo fileInfo = obj as FileInfo; MethodInfo methodInfo = obj as MethodInfo; Uri uri = obj as Uri; try { if (fileInfo != null || uri != null) { ProcessStartInfo processStartInfo = new ProcessStartInfo(href) { UseShellExecute = true }; Process.Start(processStartInfo); } else if (methodInfo != null) { methodInfo.Invoke(null, null); } } catch { throw; } }
public static string GetStyleSheet(string path) { string value; object obj = CssValue.DetectSource(path); FileInfo fileInfo = obj as FileInfo; PropertyInfo propertyInfo = obj as PropertyInfo; MethodInfo methodInfo = obj as MethodInfo; try { if (fileInfo != null) { if (fileInfo.Exists) { StreamReader streamReader = new StreamReader(fileInfo.FullName); string end = streamReader.ReadToEnd(); streamReader.Dispose(); value = end; } else { value = null; } } else if (propertyInfo != null) { if (propertyInfo.PropertyType.Equals(typeof(string))) { value = propertyInfo.GetValue(null, null) as string; } else { value = null; } } else if (methodInfo == null) { value = string.Empty; } else if (methodInfo.ReturnType.Equals(typeof(string))) { value = methodInfo.Invoke(null, null) as string; } else { value = null; } } catch { value = string.Empty; } return(value); }
public static Image GetImage(string path) { Image value; object obj = CssValue.DetectSource(path); FileInfo fileInfo = obj as FileInfo; PropertyInfo propertyInfo = obj as PropertyInfo; MethodInfo methodInfo = obj as MethodInfo; try { if (fileInfo != null) { if (fileInfo.Exists) { value = Image.FromFile(fileInfo.FullName); } else { value = null; } } else if (propertyInfo != null) { if (propertyInfo.PropertyType.IsSubclassOf(typeof(Image)) || propertyInfo.PropertyType.Equals(typeof(Image))) { value = propertyInfo.GetValue(null, null) as Image; } else { value = null; } } else if (methodInfo == null) { value = null; } else if (methodInfo.ReturnType.IsSubclassOf(typeof(Image))) { value = methodInfo.Invoke(null, null) as Image; } else { value = null; } } catch { value = new Bitmap(50, 50); } return(value); }