当前位置: 首页>>代码示例>>C#>>正文


C# BoundPropertyEntry.ParseExpression方法代码示例

本文整理汇总了C#中System.Web.UI.BoundPropertyEntry.ParseExpression方法的典型用法代码示例。如果您正苦于以下问题:C# BoundPropertyEntry.ParseExpression方法的具体用法?C# BoundPropertyEntry.ParseExpression怎么用?C# BoundPropertyEntry.ParseExpression使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Web.UI.BoundPropertyEntry的用法示例。


在下文中一共展示了BoundPropertyEntry.ParseExpression方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: FillUpBoundPropertyEntry

        private void FillUpBoundPropertyEntry(BoundPropertyEntry entry, string name) {

            // Grab a member info corresponding to the property
            string objectModelName;

            MemberInfo memberInfo = PropertyMapper.GetMemberInfo(_controlType, name, out objectModelName);
            entry.Name = objectModelName;

            // If we got a memberInfo
            if (memberInfo != null) {

                if (memberInfo is PropertyInfo) {
                    // If it's a property, make sure it is persistable
                    PropertyInfo propInfo = ((PropertyInfo)memberInfo);

                    if (propInfo.GetSetMethod() == null) {
                        if (!SupportsAttributes) {
                            throw new HttpException(SR.GetString(SR.Property_readonly, name));
                        }
                        else {
                            // If the property is readonly, fall back to using SetAttribute
                            if (entry.TwoWayBound) {
                                entry.ReadOnlyProperty = true;
                            }
                            else {
                                entry.UseSetAttribute = true;
                            }
                        }
                    }
                    else {
                        // The property is settable, so we can use it
                        entry.PropertyInfo = propInfo;
                        entry.Type = propInfo.PropertyType;
                    }

                }
                else {
                    // If it's a field, just grab the type
                    Debug.Assert(memberInfo is FieldInfo);
                    entry.Type = ((FieldInfo)memberInfo).FieldType;
                }
            }
                // If we didn't find a member, we need to use the IAttributeAccessor
            else {
                if (!SupportsAttributes) {
                    throw new HttpException(SR.GetString(SR.Type_doesnt_have_property, _controlType.FullName, name));
                }
                else {
                    if (entry.TwoWayBound) {
                        throw new InvalidOperationException(SR.GetString(SR.ControlBuilder_TwoWayBindingNonProperty, name, ControlType.Name));
                    }
                    entry.Name = name;
                    entry.UseSetAttribute = true;
                }
            }

            // Make sure we have parsed expression data
            if (entry.ParsedExpressionData == null) {
                entry.ParseExpression(new ExpressionBuilderContext(VirtualPath));
            }

            if (!Parser.IgnoreParseErrors && entry.ParsedExpressionData == null) {
                // Disallow empty expressions (VSWhidbey 234273)
                if (Util.IsWhiteSpaceString(entry.Expression)) {

                    throw new HttpException(
                        SR.GetString(SR.Empty_expression));
                }
            }
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:70,代码来源:ControlBuilder.cs

示例2: FillUpBoundPropertyEntry

 private void FillUpBoundPropertyEntry(BoundPropertyEntry entry, string name)
 {
     string str;
     MemberInfo info = PropertyMapper.GetMemberInfo(this._controlType, name, out str);
     entry.Name = str;
     if (info != null)
     {
         if (info is PropertyInfo)
         {
             PropertyInfo info2 = (PropertyInfo) info;
             if (info2.GetSetMethod() == null)
             {
                 if (!this.SupportsAttributes)
                 {
                     throw new HttpException(System.Web.SR.GetString("Property_readonly", new object[] { name }));
                 }
                 if (entry.TwoWayBound)
                 {
                     entry.ReadOnlyProperty = true;
                 }
                 else
                 {
                     entry.UseSetAttribute = true;
                 }
             }
             else
             {
                 entry.PropertyInfo = info2;
                 entry.Type = info2.PropertyType;
             }
         }
         else
         {
             entry.Type = ((FieldInfo) info).FieldType;
         }
     }
     else
     {
         if (!this.SupportsAttributes)
         {
             throw new HttpException(System.Web.SR.GetString("Type_doesnt_have_property", new object[] { this._controlType.FullName, name }));
         }
         if (entry.TwoWayBound)
         {
             throw new InvalidOperationException(System.Web.SR.GetString("ControlBuilder_TwoWayBindingNonProperty", new object[] { name, this.ControlType.Name }));
         }
         entry.Name = name;
         entry.UseSetAttribute = true;
     }
     if (entry.ParsedExpressionData == null)
     {
         entry.ParseExpression(new ExpressionBuilderContext(this.VirtualPath));
     }
     if ((!this.Parser.IgnoreParseErrors && (entry.ParsedExpressionData == null)) && System.Web.UI.Util.IsWhiteSpaceString(entry.Expression))
     {
         throw new HttpException(System.Web.SR.GetString("Empty_expression"));
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:58,代码来源:ControlBuilder.cs


注:本文中的System.Web.UI.BoundPropertyEntry.ParseExpression方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。