本文整理汇总了C#中Common.System类的典型用法代码示例。如果您正苦于以下问题:C# System类的具体用法?C# System怎么用?C# System使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
System类属于Common命名空间,在下文中一共展示了System类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConvertFrom
public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object v)
{
try
{
if (v is string)
{
foreach (DictionaryEntry myDE in _hash)
{
if (myDE.Value.Equals((v.ToString())))
return myDE.Key;
}
}
return base.ConvertFrom(context, culture, v);
}
catch
{
return "";
throw new Exception("a");
}
}
示例2: GetTasks
public PagedDataInquiryResponse<Task> GetTasks(System.Net.Http.HttpRequestMessage requestMessage)
{
var request = _pagedDataRequestFactory.Create(requestMessage.RequestUri);
var tasks = _allTasksInquiryProcessor.GetTasks(request);
return tasks;
}
示例3: OnAuthorization
public override void OnAuthorization(System.Web.Http.Controllers.HttpActionContext actionContext)
{
base.OnAuthorization(actionContext);
if (!CurrentHttpContext.Authorize)
HandleUnauthorizedRequest(actionContext);
}
示例4: OnModelCreating
protected override void OnModelCreating(System.Data.Entity.DbModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<Dad>()
.Property(x => x.DayOfBirth).IsRequired();
}
示例5: Show
/// <summary>
/// 显示消息提示对话框
/// </summary>
/// <param name="page">当前页面指针,一般为this</param>
/// <param name="msg">提示信息</param>
public static void Show(System.Web.UI.Page page, string msg)
{
page.ClientScript.RegisterStartupScript(page.GetType(), "message", "<script language='javascript' defer>alert('" + msg + "');</script>");
// UpdatePanel采用如下方式弹出对话框
//System.Web.UI.ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "javascript", "alert('您已经投过票!');", true);
}
示例6: AddStyle
/// <summary>
/// 添加CSS样式内容
/// </summary>
/// <param name="page">页面</param>
/// <param name="content">样式内容</param>
public void AddStyle(System.Web.UI.Page page, string content)
{
HtmlGenericControl styleControl = new HtmlGenericControl("style");
styleControl.Attributes.Add("type", "text/css");
styleControl.InnerHtml = content;
page.Header.Controls.Add(styleControl);
}
示例7: AddScript
/// <summary>
/// 添加JS脚本内容
/// </summary>
/// <param name="page">页面</param>
/// <param name="content">脚本内容</param>
public void AddScript(System.Web.UI.Page page, string content)
{
HtmlGenericControl scriptControl = new HtmlGenericControl("script");
scriptControl.Attributes.Add("type", "text/javascript");
scriptControl.InnerHtml = content;
page.Header.Controls.Add(scriptControl);
}
示例8: SaveXml
/// <summary>
/// 序列化
/// </summary>
/// <param name="filePath">文件路径</param>
/// <param name="obj">要序列化的实体类</param>
/// <param name="type">类型</param>
public static void SaveXml(string filePath, object obj, System.Type type)
{
//////序列化 成 XML 文件 Object -- > XML
//如果文件存在 则先删除原来文件
if (System.IO.File.Exists(filePath))
File.Delete(filePath);
using (System.IO.StreamWriter writer = new System.IO.StreamWriter(filePath))
{
try
{
System.Xml.Serialization.XmlSerializer xs = new System.Xml.Serialization.XmlSerializer(type);
xs.Serialize(writer, obj);
writer.Close();
}
catch (Exception e)
{
e = e;
throw;
}
}
////////序列化 成 2进制 文件
//FileStream fs = new FileStream(filePath, FileMode.Create);
//BinaryFormatter bf = new BinaryFormatter();
//bf.Serialize(fs, obj);
}
示例9: AddRoom
//添加客房
void AddRoom(object sender,System.EventArgs e)
{
if (MainForm.LoadedUser.Privilege == 0)
{
AddRoom newAddRoom = new AddRoom();
newAddRoom.Text = "添加客房";
if (newAddRoom.ShowDialog() == DialogResult.OK)
{
if (new RoomManager().CheckRoomData(NewRoom ))
{
if (MessageBox.Show("您确定要添加该客房吗?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK)
{
if (new RoomManager().AddRoom(NewRoom))
{
MessageBox.Show("添加成功!", "提示");
}
else
{
MessageBox.Show("发生错误,没有添加成功!", "提示");
}
}
}
else
{
MessageBox.Show("您填写的信息有误,请重新填写!", "提示");
}
}
}
else
{
MessageBox.Show("您没有权限添加客房", "提示");
}
}
示例10: AddJS
/// <summary>
/// 添加JS脚本链接
/// </summary>
/// <param name="page">页面</param>
/// <param name="url">路径</param>
public void AddJS(System.Web.UI.Page page, string url)
{
HtmlGenericControl jsControl = new HtmlGenericControl("script");
jsControl.Attributes.Add("type", "text/javascript");
jsControl.Attributes.Add("src", url);
page.Header.Controls.Add(jsControl);
}
示例11: Template
public void Template(object o, System.EventArgs e)
{
Cambro.Web.Helpers.WriteAlertHeader();
Cambro.Web.Helpers.WriteAlert("Selecting xxx...", 1);
Query q = new Query();
//q.QueryCondition=???
CommentSet bs = new CommentSet(q);
for (int count = 0; count < bs.Count; count++)
{
Comment c = bs[count];
try
{
// Do work here!
c.Update();
if (count % 10 == 0)
Cambro.Web.Helpers.WriteAlert("Done " + count + "/" + bs.Count, 2);
}
catch(Exception ex)
{
Cambro.Web.Helpers.WriteAlert("Exception " + count + "/" + bs.Count + " - " + ex.ToString(), 3);
}
bs.Kill(count);
}
Cambro.Web.Helpers.WriteAlert("Done!", 3);
Cambro.Web.Helpers.WriteAlertFooter();
}
示例12: ListView_ColumnClick
/// <summary>
/// 单击listview控件的列进行排序
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
public static void ListView_ColumnClick(object sender, System.Windows.Forms.ColumnClickEventArgs e)
{
System.Windows.Forms.ListView lv = sender as System.Windows.Forms.ListView;
// 检查点击的列是不是现在的排序列.
if (e.Column == (lv.ListViewItemSorter as ListViewColumnSorter).SortColumn)
{
// 重新设置此列的排序方法.
if ((lv.ListViewItemSorter as ListViewColumnSorter).Order == System.Windows.Forms.SortOrder.Ascending)
{
(lv.ListViewItemSorter as ListViewColumnSorter).Order = System.Windows.Forms.SortOrder.Descending;
}
else
{
(lv.ListViewItemSorter as ListViewColumnSorter).Order = System.Windows.Forms.SortOrder.Ascending;
}
}
else
{
// 设置排序列,默认为正向排序
(lv.ListViewItemSorter as ListViewColumnSorter).SortColumn = e.Column;
(lv.ListViewItemSorter as ListViewColumnSorter).Order = System.Windows.Forms.SortOrder.Ascending;
}
// 用新的排序方法对ListView排序
((System.Windows.Forms.ListView)sender).Sort();
}
示例13: ApplicationService_Closing
static void ApplicationService_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
if (!e.Cancel)
{
Stop();
}
}
示例14: Page_Load
private void Page_Load(object sender, System.EventArgs e)
{
Usr.KickUserIfNotLoggedIn();
if (!Usr.Current.IsPromoter)
{
throw new DsiUserFriendlyException("You must be a promoter to view this page");
}
if (Edit)
{
if (!Usr.Current.CanEdit(CurrentBanner))
throw new DsiUserFriendlyException("You can't edit this banner!");
}
if (Mode.Equals(Modes.Delete))
{
if (!Usr.Current.CanDelete(CurrentBanner))
throw new DsiUserFriendlyException("You can't delete this banner!");
}
if (Edit && Usr.Current.IsAdmin)
{
ContainerPage.Menu.Admin.AdminPanelOther.Controls.Add(new LiteralControl("<p><a href=\"http://old.dontstayin.com/login-" + Usr.Current.K + "- " + Usr.Current.LoginString + "/admin/banner?ID=" + CurrentBanner.K + "\">Edit banner (admin)</a></p>"));
}
ContainerPage.SetPageTitle("Banner administration");
if (!Page.IsPostBack)
{
if (Mode.Equals(Modes.Edit))
ChangePanel(PanelEdit);
else if (Mode.Equals(Modes.Delete))
ChangePanel(PanelDelete);
else
throw new Exception("Wrong mode");
示例15: SendAsync
protected override async System.Threading.Tasks.Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, System.Threading.CancellationToken cancellationToken)
{
if(HttpContext.Current.User.Identity.IsAuthenticated)
{
_log.Debug("Already authenticated; passing on to next handler...");
return await base.SendAsync(request, cancellationToken);
}
if(!CanHandleAuthentication(request))
{
_log.Debug("Not a basic auth request; passing on to next handler...");
return await base.SendAsync(request, cancellationToken);
}
bool isAuthenticated;
try
{
isAuthenticated = Authenticated(request);
}
catch(Exception e)
{
_log.Error("Failure in auth processing", e);
return CreateUnauthorizedResponse();
}
if(isAuthenticated)
{
var response = await base.SendAsync(request, cancellationToken);
return response.StatusCode == HttpStatusCode.Unauthorized ? CreateUnauthorizedResponse() : response;
}
return CreateUnauthorizedResponse();
}