#C#

基于.NET框架的、面向对象的高级编程语言

C#Task<T>获取T下面的属性?

请教,如何在后端调用前端js中的自定义函数?

为什么调试c#实时音视频的demo,有些电脑本地的 视频显示不出来?

如何自动匹配关键字并对数据进行替换?

EatRice

腾云先锋 · 腾云先锋(TDP)成员 (已认证)

您好可以考虑C#的正则表达式。 using System.Text.RegularExpressions; 在读取文件一之后,读取height1 变量的值,然后再读取文件二,修改文件二中的gaodu ...... 展开详请

C#中field:NonSerialized在C++/CLI怎么处理?

如何利用C#语言编写下列程序?

量化研究的10个迷思?

unity游戏运行后脚本出现命名空间不存在的问题,需要引入程序集?

EatRice

腾云先锋 · 腾云先锋(TDP)成员 (已认证)

已采纳

您好,问题似乎是您的IDE没有找到Unity.FPS.Game程序集的位置,请检查您是否安装成功了该程序集,且在IDE的引用列表中。

VSTO在WPS中调试显示参数问题?

请问如何在页眉部分的一行中创建左对齐的页眉,居中对齐的页眉,右对齐的页眉呢?

看了你写的自定义 TEXTBOX 控件的文件,我有个想法,不知道能不能实现?

EatRice

腾云先锋 · 腾云先锋(TDP)成员 (已认证)

您好,是可以的,请参考TextBox的源代码进行设计即可:

[ControlBuilder(typeof(TextBoxControlBuilder)), DefaultProperty("Text"), ParseChildren(false), DataBindingHandler("System.Web.UI.Design.TextDataBindingHandler, System.Design, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"), ValidationProperty("Text"), DefaultEvent("TextChanged"), PermissionSet(SecurityAction.LinkDemand, XML = "<PermissionSet class=\"System.Security.PermissionSet\"\r\n version=\"1\">\r\n <IPermission class=\"System.Web.AspNetHostingPermission, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\"\r\n version=\"1\"\r\n Level=\"Minimal\"/>\r\n</PermissionSet>\r\n"), PermissionSet(SecurityAction.InheritanceDemand, XML = "<PermissionSet class=\"System.Security.PermissionSet\"\r\n version=\"1\">\r\n <IPermission class=\"System.Web.AspNetHostingPermission, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\"\r\n version=\"1\"\r\n Level=\"Minimal\"/>\r\n</PermissionSet>\r\n")]
public class TextBox : WebControl, IPostBackDataHandler
{
    // Fields
    private static readonly object EventTextChanged;

    // Events
    [WebCategory("Action"), WebSysDescription("TextBox_OnTextChanged")]
    public event EventHandler TextChanged;

    // Methods
    static TextBox();
    public TextBox();
    protected override void AddAttributesToRender(HtmlTextWriter writer);
    protected override void AddParsedSubObject(object obj);
    protected override void OnPreRender(EventArgs e);
    protected virtual void OnTextChanged(EventArgs e);
    protected override void Render(HtmlTextWriter writer);
    bool IPostBackDataHandler.LoadPostData(string postDataKey, NameValueCollection postCollection);
    void IPostBackDataHandler.RaisePostDataChangedEvent();

    // Properties
    [WebCategory("Behavior"), WebSysDescription("TextBox_AutoPostBack"), DefaultValue(false)]
    public virtual bool AutoPostBack { get; set; }
    [DefaultValue(0), WebSysDescription("TextBox_Columns"), Bindable(true), WebCategory("Appearance")]
    public virtual int Columns { get; set; }
    [Bindable(true), WebCategory("Behavior"), DefaultValue(0), WebSysDescription("TextBox_MaxLength")]
    public virtual int MaxLength { get; set; }
    [WebCategory("Behavior"), Bindable(true), DefaultValue(false), WebSysDescription("TextBox_ReadOnly")]
    public virtual bool ReadOnly { get; set; }
    [Bindable(true), WebCategory("Behavior"), DefaultValue(0), WebSysDescription("TextBox_Rows")]
    public virtual int Rows { get; set; }
    private bool SaveTextViewState { get; }
    protected override HtmlTextWriterTag TagKey { get; }
    [Bindable(true), WebCategory("Appearance"), DefaultValue(""), WebSysDescription("TextBox_Text"), PersistenceMode(PersistenceMode.EncodedInnerDefaultProperty)]
    public virtual string Text { get; set; }
    [DefaultValue(0), WebSysDescription("TextBox_TextMode"), WebCategory("Behavior")]
    public virtual TextBoxMode TextMode { get; set; }
    [WebCategory("Layout"), DefaultValue(true), WebSysDescription("TextBox_Wrap")]
    public virtual bool Wrap { get; set; }
}
[ControlBuilder(typeof(TextBoxControlBuilder)), DefaultProperty("Text"), ParseChildren(false), DataBindingHandler("System.Web.UI.Design.TextDataBindingHandler, System.Design, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"), ValidationProperty("Text"), DefaultEvent("TextChanged"), PermissionSet(SecurityAction.LinkDemand, XML = "<PermissionSet class=\"System.Security.PermissionSet\"\r\n version=\"1\">\r\n <IPermission class=\"System.Web.AspNetHostingPermission, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\"\r\n version=\"1\"\r\n Level=\"Minimal\"/>\r\n</PermissionSet>\r\n"), PermissionSet(SecurityAction.InheritanceDemand, XML = "<PermissionSet class=\"System.Security.PermissionSet\"\r\n version=\"1\">\r\n <IPermission class=\"System.Web.AspNetHostingPermission, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\"\r\n version=\"1\"\r\n Level=\"Minimal\"/>\r\n</PermissionSet>\r\n")]
public class TextBox : WebControl, IPostBackDataHandler
{
    // Fields
    private static readonly object EventTextChanged = new object();

    // Events
    [WebCategory("Action"), WebSysDescription("TextBox_OnTextChanged")]
    public event EventHandler TextChanged
    {
        add
        {
            base.Events.AddHandler(EventTextChanged, value);
        }
        remove
        {
            base.Events.RemoveHandler(EventTextChanged, value);
        }
    }

    // Methods
    public TextBox() : base(HtmlTextWriterTag.Input)
    {
    }

    protected override void AddAttributesToRender(HtmlTextWriter writer)
    {
        int maxLength;
        if (this.Page != null)
        {
            this.Page.VerifyRenderingInServerForm(this);
        }
        writer.AddAttribute(HtmlTextWriterAttribute.Name, this.UniqueID);
        switch (this.TextMode)
        {
            case TextBoxMode.SingleLine:
                {
                    writer.AddAttribute(HtmlTextWriterAttribute.Type, "text");
                    string text = this.Text;
                    if (text.Length > 0)
                    {
                        writer.AddAttribute(HtmlTextWriterAttribute.Value, text);
                    }
                    break;
                }
            case TextBoxMode.Password:
                writer.AddAttribute(HtmlTextWriterAttribute.Type, "password");
                break;

            case TextBoxMode.MultiLine:
                maxLength = this.Rows;
                if (maxLength > 0)
                {
                    writer.AddAttribute(HtmlTextWriterAttribute.Rows, maxLength.ToString(NumberFormatInfo.InvariantInfo));
                }
                maxLength = this.Columns;
                if (maxLength > 0)
                {
                    writer.AddAttribute(HtmlTextWriterAttribute.Cols, maxLength.ToString(NumberFormatInfo.InvariantInfo));
                }
                if (!this.Wrap)
                {
                    writer.AddAttribute(HtmlTextWriterAttribute.Wrap, "off");
                }
                goto Label_00FF;
        }
        maxLength = this.MaxLength;
        if (maxLength > 0)
        {
            writer.AddAttribute(HtmlTextWriterAttribute.Maxlength, maxLength.ToString(NumberFormatInfo.InvariantInfo));
        }
        maxLength = this.Columns;
        if (maxLength > 0)
        {
            writer.AddAttribute(HtmlTextWriterAttribute.Size, maxLength.ToString(NumberFormatInfo.InvariantInfo));
        }
    Label_00FF:
        if (this.ReadOnly)
        {
            writer.AddAttribute(HtmlTextWriterAttribute.ReadOnly, "readonly");
        }
        if (this.AutoPostBack && (this.Page != null))
        {
            string postBackClientEvent = this.Page.GetPostBackClientEvent(this, "");
            if (base.HasAttributes)
            {
                string str3 = base.Attributes["onchange"];
                if (str3 != null)
                {
                    postBackClientEvent = str3 + postBackClientEvent;
                    base.Attributes.Remove("onchange");
                }
            }
            writer.AddAttribute(HtmlTextWriterAttribute.Onchange, postBackClientEvent);
            writer.AddAttribute("language", "javascript");
        }
        base.AddAttributesToRender(writer);
    }

    protected override void AddParsedSubObject(object obj)
    {
        if (!(obj is LiteralControl))
        {
            throw new HttpException(HttpRuntime.FormatResourceString("Cannot_Have_Children_Of_Type", "TextBox", obj.GetType().Name.ToString()));
        }
        this.Text = ((LiteralControl)obj).Text;
    }

    protected override void OnPreRender(EventArgs e)
    {
        base.OnPreRender(e);
        if (!this.SaveTextViewState)
        {
            this.ViewState.SetItemDirty("Text", false);
        }
        if (((this.Page != null) && this.AutoPostBack) && this.Enabled)
        {
            this.Page.RegisterPostBackScript();
        }
    }

    protected virtual void OnTextChanged(EventArgs e)
    {
        EventHandler handler = (EventHandler)base.Events[EventTextChanged];
        if (handler != null)
        {
            handler(this, e);
        }
    }

    protected override void Render(HtmlTextWriter writer)
    {
        this.RenderBeginTag(writer);
        if (this.TextMode == TextBoxMode.MultiLine)
        {
            HttpUtility.HtmlEncode(this.Text, writer);
        }
        this.RenderEndTag(writer);
    }

    bool IPostBackDataHandler.LoadPostData(string postDataKey, NameValueCollection postCollection)
    {
        string text = this.Text;
        string str2 = postCollection[postDataKey];
        if (!text.Equals(str2))
        {
            this.Text = str2;
            return true;
        }
        return false;
    }

    void IPostBackDataHandler.RaisePostDataChangedEvent()
    {
        this.OnTextChanged(EventArgs.Empty);
    }

    // Properties
    [WebCategory("Behavior"), WebSysDescription("TextBox_AutoPostBack"), DefaultValue(false)]
    public virtual bool AutoPostBack
    {
        get
        {
            object obj2 = this.ViewState["AutoPostBack"];
            return ((obj2 != null) && ((bool)obj2));
        }
        set
        {
            this.ViewState["AutoPostBack"] = value;
        }
    }

    [DefaultValue(0), WebSysDescription("TextBox_Columns"), Bindable(true), WebCategory("Appearance")]
    public virtual int Columns
    {
        get
        {
            object obj2 = this.ViewState["Columns"];
            if (obj2 != null)
            {
                return (int)obj2;
            }
            return 0;
        }
        set
        {
            if (value < 0)
            {
                throw new ArgumentOutOfRangeException("value");
            }
            this.ViewState["Columns"] = value;
        }
    }

    [Bindable(true), WebCategory("Behavior"), DefaultValue(0), WebSysDescription("TextBox_MaxLength")]
    public virtual int MaxLength
    {
        get
        {
            object obj2 = this.ViewState["MaxLength"];
            if (obj2 != null)
            {
                return (int)obj2;
            }
            return 0;
        }
        set
        {
            if (value < 0)
            {
                throw new ArgumentOutOfRangeException("value");
            }
            this.ViewState["MaxLength"] = value;
        }
    }

    [WebCategory("Behavior"), Bindable(true), DefaultValue(false), WebSysDescription("TextBox_ReadOnly")]
    public virtual bool ReadOnly
    {
        get
        {
            object obj2 = this.ViewState["ReadOnly"];
            return ((obj2 != null) && ((bool)obj2));
        }
        set
        {
            this.ViewState["ReadOnly"] = value;
        }
    }

    [Bindable(true), WebCategory("Behavior"), DefaultValue(0), WebSysDescription("TextBox_Rows")]
    public virtual int Rows
    {
        get
        {
            object obj2 = this.ViewState["Rows"];
            if (obj2 != null)
            {
                return (int)obj2;
            }
            return 0;
        }
        set
        {
            if (value < 0)
            {
                throw new ArgumentOutOfRangeException("value");
            }
            this.ViewState["Rows"] = value;
        }
    }

    private bool SaveTextViewState
    {
        get
        {
            if (this.TextMode == TextBoxMode.Password)
            {
                return false;
            }
            if (((base.Events[EventTextChanged] == null) && this.Enabled) && (this.Visible && (base.GetType() == typeof(TextBox))))
            {
                return false;
            }
            return true;
        }
    }

    protected override HtmlTextWriterTag TagKey
    {
        get
        {
            if (this.TextMode == TextBoxMode.MultiLine)
            {
                return HtmlTextWriterTag.Textarea;
            }
            return HtmlTextWriterTag.Input;
        }
    }

    [Bindable(true), WebCategory("Appearance"), DefaultValue(""), WebSysDescription("TextBox_Text"), PersistenceMode(PersistenceMode.EncodedInnerDefaultProperty)]
    public virtual string Text
    {
        get
        {
            string str = (string)this.ViewState["Text"];
            if (str != null)
            {
                return str;
            }
            return string.Empty;
        }
        set
        {
            this.ViewState["Text"] = value;
        }
    }

    [DefaultValue(0), WebSysDescription("TextBox_TextMode"), WebCategory("Behavior")]
    public virtual TextBoxMode TextMode
    {
        get
        {
            object obj2 = this.ViewState["Mode"];
            if (obj2 != null)
            {
                return (TextBoxMode)obj2;
            }
            return TextBoxMode.SingleLine;
        }
        set
        {
            if ((value < TextBoxMode.SingleLine) || (value > TextBoxMode.Password))
            {
                throw new ArgumentOutOfRangeException("value");
            }
            this.ViewState["Mode"] = value;
        }
    }

    [WebCategory("Layout"), DefaultValue(true), WebSysDescription("TextBox_Wrap")]
    public virtual bool Wrap
    {
        get
        {
            object obj2 = this.ViewState["Wrap"];
            if (obj2 != null)
            {
                return (bool)obj2;
            }
            return true;
        }
        set
        {
            this.ViewState["Wrap"] = value;
        }
    }
}

接入unitybugly以后,崩溃没法查看Unity 堆栈,只能看java堆栈?

Java&C#?

EatRice

腾云先锋 · 腾云先锋(TDP)成员 (已认证)

看你喜欢哪个吧,以前Java虚拟机平台是万金油,现在C#出了.NET Core也变成万金油了

TRTCCSharpDemo打包成EXE安装后运行报错ManageLiteAV.dll不加载,原因?

询问一个关于sql模糊查询的问题?

jwj

腾云先锋 · 腾云先锋(TDP)成员 (已认证)

建议增加查询条件,缩小数据范围。或者修改 SQLITE_MAX_EXPR_DEPTH 配置(不建议)。

腾讯IM 闪退问题?

I/O error: Broken pipe?

unity C# 人脸融合 ,AuthFailure.SignatureFailure报错?

扫码关注腾讯云开发者

领取腾讯云代金券