• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# PropertyInfo类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中PropertyInfo的典型用法代码示例。如果您正苦于以下问题:C# PropertyInfo类的具体用法?C# PropertyInfo怎么用?C# PropertyInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



PropertyInfo类属于命名空间,在下文中一共展示了PropertyInfo类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: ShouldGenerateNameWithPropForList

 public void ShouldGenerateNameWithPropForList()
 {
     var info = new PropertyInfo(new ClassInfo { XmlName = "someClass" });
     info.XmlName = "someClass";
     info.IsList = true;
     Assert.That(info.GetCodeName(), Is.EqualTo("SomeClassProps"));
 }
开发者ID:7digital,项目名称:XsdToObject,代码行数:7,代码来源:PropertyInfoTest.cs


示例2: LocalizedPropertyStringLengthRule

        /// <summary>
        /// Initializes a new instance of the <see cref="LocalizedPropertyStringLengthRule"/> class.
        /// </summary>
        /// <param name="primaryProperty">
        /// The primary property.
        /// </param>
        /// <param name="mainProperty">
        /// The main property.
        /// </param>
        /// <param name="maxLength">
        /// The max length.
        /// </param>
        /// <param name="propertyDisplayName">
        /// The property display name.
        /// </param>
        /// <param name="resourceManager">
        /// The resource manager.
        /// </param>
        /// <param name="localizationName">
        /// The localization name.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// The <paramref name="primaryProperty"/> parameter is null.
        /// </exception>
        /// <exception cref="ArgumentOutOfRangeException">
        /// The <paramref name="maxLength"/> is less than zero.
        /// </exception>
        public LocalizedPropertyStringLengthRule(
            PropertyInfo<string> primaryProperty,
            PropertyInfo<string> mainProperty,
            int maxLength,
            string propertyDisplayName,
            ResourceManager resourceManager,
            string localizationName)
            : base(primaryProperty)
        {
            if (primaryProperty == null)
                throw new ArgumentNullException("primaryProperty");

            if (maxLength < 0)
                throw new ArgumentOutOfRangeException("maxLength");

            _primaryProperty = primaryProperty;
            _maxLength = maxLength;
            _propertyDisplayName = propertyDisplayName;
            _resourceManager = resourceManager;
            _mainProperty = mainProperty;
            _localizationName = localizationName;

            InputProperties = InputProperties ?? new List<IPropertyInfo>();
            InputProperties.Add(primaryProperty);

            if (_mainProperty != null)
                AffectedProperties.Add(_mainProperty);
        }
开发者ID:mparsin,项目名称:Elements,代码行数:55,代码来源:LocalizedPropertyStringLengthRule.cs


示例3: CanEdit

    public static bool CanEdit(PropertyInfo property)
    {
        if (!property.CanRead)
        {
            return false;
        }

        var browsableAttribute = (BrowsableAttribute)Attribute.GetCustomAttribute(property, typeof(BrowsableAttribute), false);
        if (browsableAttribute != null && !browsableAttribute.Browsable)
        {
            return false;
        }

        var designerSerializationVisibilityAttribute = (DesignerSerializationVisibilityAttribute)Attribute.GetCustomAttribute(property, typeof(DesignerSerializationVisibilityAttribute), false);
        if (designerSerializationVisibilityAttribute != null && designerSerializationVisibilityAttribute.Visibility == DesignerSerializationVisibility.Hidden)
        {
            return false;
        }

        if (!property.CanWrite && !typeof(System.Collections.IList).IsAssignableFrom(property.PropertyType))
        {
            return false;
        }

        return true;
    }
开发者ID:san90279,项目名称:UK_OAS,代码行数:26,代码来源:JsonHelper.cs


示例4: ShouldGenerateNameForListWithSAtTheEnd

 public void ShouldGenerateNameForListWithSAtTheEnd()
 {
     var info = new PropertyInfo(new ClassInfo { XmlName = "someClass" });
     info.XmlName = "tests";
     info.IsList = true;
     Assert.That(info.GetCodeName(), Is.EqualTo("Tests"));
 }
开发者ID:7digital,项目名称:XsdToObject,代码行数:7,代码来源:PropertyInfoTest.cs


示例5: ConvertToPropertyString

        private static string ConvertToPropertyString(string entityName, PropertyInfo property)
        {
            string typeName = ConvertTypeName(property);

            var propertyString = string.Format(
            @"public static readonly Property<{0}> {1}Property = P<{2}>.Register(e => e.{1});
            ",
            typeName, property.Name, entityName);
            if (!string.IsNullOrEmpty(property.Comment))
            {
                propertyString += string.Format(
            @"/// <summary>
            /// {0}
            /// </summary>
            ", property.Comment);
            }
            propertyString += string.Format(
            @"public {0} {1}
            {{
            get {{ return this.GetProperty({1}Property); }}
            set {{ this.SetProperty({1}Property, value); }}
            }}", typeName, property.Name);

            return propertyString;
        }
开发者ID:569550384,项目名称:Rafy,代码行数:25,代码来源:QueryEntityGenerator.xaml.cs


示例6: ProcessRes

 void ProcessRes(PropertyInfo pi)
 {
     var obj = pi.GetValue(null, null);
     var type = obj.GetType();
     if(type == typeof(string))
     {
         var item = new RString();
         item.name = pi.Name;
         item.value = obj as string;
         listString.Add(item);
     }
     else if (type == typeof(Texture2D))
     {
         var item = new RTexture();
         item.name = pi.Name;
         item.value = obj as Texture2D;
         listTexture.Add(item);
     }
     else
     {
         var item = new RUnknown();
         item.name = pi.Name;
         item.type = type.Name;
         item.value = obj.ToString();
         listUnknown.Add(item);
     }
 }
开发者ID:woncomp,项目名称:UnityLab,代码行数:27,代码来源:L002ResourcesPathsWindow.cs


示例7: Parse

        public Class Parse(String json, String className)
        {
            Class result = new Class(AccessModifier.Public, className);

            var oo = JsonConvert.DeserializeObject(json);
            var c = new ClassInfo(className);
            if (oo is JArray)
            {
                foreach (var jo in (JArray)oo)
                {
                    if (jo is JObject)
                    {
                        SetProperties(c, (JObject)jo);
                    }
                    else if (jo is JValue)
                    {
                        var pi = new PropertyInfo();
                        pi.Validate(jo);
                        return new Class(AccessModifier.Public, pi.GetCSharpTypeName());
                    }
                }
            }
            else if (oo is JObject)
            {
                SetProperties(c, (JObject)oo);
            }
            SetProperties(result, c);

            return result;
        }
开发者ID:fengweijp,项目名称:higlabo,代码行数:30,代码来源:JsonParser.cs


示例8: PropertyAccessor

 public PropertyAccessor(PropertyInfo propertyInfo)
     : base(propertyInfo)
 {
     _hasSetter = (propertyInfo.GetSetMethod(true) != null);
     if (_hasSetter)
         _lateBoundPropertySet = DelegateFactory.CreateSet(propertyInfo);
 }
开发者ID:BclEx,项目名称:AdamsyncEx,代码行数:7,代码来源:PropertyAccessor.cs


示例9: ConvertTypeName

        private static string ConvertTypeName(PropertyInfo property)
        {
            Type type = property.Type;
            if (type == typeof(decimal))
            {
                type = typeof(double);
            }

            string typeName = type.Name;
            if (type != typeof(string))
            {
                if (type == typeof(int))
                {
                    typeName = "int";
                }
                else if (type == typeof(double))
                {
                    typeName = "double";
                }
                else if (type == typeof(bool))
                {
                    typeName = "bool";
                }
                typeName += "?";
            }
            else
            {
                typeName = "string";
            }
            return typeName;
        }
开发者ID:569550384,项目名称:Rafy,代码行数:31,代码来源:QueryEntityGenerator.xaml.cs


示例10: boolField

 public void boolField(object pObject, PropertyInfo pPropertyInfo)
 {
     bool lValue = (bool)pPropertyInfo.GetValue(pObject, null);
     content.text="";
     bool lNewValue = GUILayout.Toggle(lValue, content);
     if(lValue!=lNewValue)
         pPropertyInfo.SetValue(pObject, lNewValue, null);
 }
开发者ID:orange030,项目名称:modelPainter,代码行数:8,代码来源:FieldUIAttribute.cs


示例11: PropertyOperation

 public PropertyOperation(PropertyInfo propertyInfo)
 {
     if (propertyInfo == null)
     {
         throw new ArgumentNullException("pi");
     }
     this.propertyInfo = propertyInfo;
 }
开发者ID:nakijun,项目名称:FastDBEngine,代码行数:8,代码来源:PropertyOperation.cs


示例12: ValueTypePropertyAccessor

 public ValueTypePropertyAccessor(PropertyInfo propertyInfo)
     : base(propertyInfo)
 {
     var setMethod = propertyInfo.GetSetMethod(true);
     _hasSetter = (setMethod != null);
     if (_hasSetter)
         _lateBoundPropertySet = setMethod;
 }
开发者ID:BclEx,项目名称:AdamsyncEx,代码行数:8,代码来源:ValueTypePropertyAccessor.cs


示例13: Eval

 public override Property Eval(Property[] args, PropertyInfo pInfo)
 {
     string propName = args[0].GetString();
     if (propName == null)
     {
         throw new PropertyException("Incorrect parameter to inherited-property-value function");
     }
     return pInfo.getPropertyList().GetInheritedProperty(propName);
 }
开发者ID:nholik,项目名称:Fo.Net,代码行数:9,代码来源:InheritedPropFunction.cs


示例14: PropertyDecorator

 public PropertyDecorator(TypeModel model, Type forType, PropertyInfo property, IProtoSerializer tail) : base(tail)
 {
     Helpers.DebugAssert(forType != null);
     Helpers.DebugAssert(property != null);
     this.forType = forType;
     this.property = property;
     SanityCheck(model, property, tail, out readOptionsWriteValue, true, true);
     shadowSetter = GetShadowSetter(model, property);
 }
开发者ID:GeorchW,项目名称:protobuf-net,代码行数:9,代码来源:PropertyDecorator.cs


示例15: Eval

 public override Property Eval(Property[] args, PropertyInfo pInfo)
 {
     string propName = args[0].GetString();
     if (propName == null)
     {
         throw new PropertyException("Incorrect parameter to from-table-column function");
     }
     throw new PropertyException("from-table-column unimplemented!");
 }
开发者ID:nholik,项目名称:Fo.Net,代码行数:9,代码来源:FromTableColumnFunction.cs


示例16: Eval

 public override Property Eval(Property[] args, PropertyInfo pInfo)
 {
     string propName = args[0].GetString();
     if (propName == null)
     {
         throw new PropertyException("Incorrect parameter to from-nearest-specified-value function");
     }
     return pInfo.getPropertyList().GetNearestSpecifiedProperty(propName);
 }
开发者ID:nholik,项目名称:Fo.Net,代码行数:9,代码来源:NearestSpecPropFunction.cs


示例17: Eval

 public override Property Eval(Property[] args, PropertyInfo pInfo)
 {
     string propName = args[0].GetString();
     if (propName == null)
     {
         throw new PropertyException("Missing property name.");
     }
     return pInfo.getPropertyList().GetProperty(propName);
 }
开发者ID:nholik,项目名称:Fo.Net,代码行数:9,代码来源:FonetPropValFunction.cs


示例18: Eval

 public override Property Eval(Property[] args, PropertyInfo propInfo)
 {
     Numeric num = args[0].GetNumeric();
     if (num == null)
     {
         throw new PropertyException("Non numeric operand to abs function");
     }
     return new NumericProperty(num.abs());
 }
开发者ID:nholik,项目名称:Fo.Net,代码行数:9,代码来源:AbsFunction.cs


示例19: Eval

        public override Property Eval(Property[] args, PropertyInfo pInfo)
        {
            string propName = args[0].GetString();
            if (propName == null)
            {
                throw new PropertyException("Incorrect parameter to from-parent function");
            }

            return pInfo.getPropertyList().GetFromParentProperty(propName);
        }
开发者ID:nholik,项目名称:Fo.Net,代码行数:10,代码来源:FromParentFunction.cs


示例20: Eval

 public override Property Eval(Property[] args, PropertyInfo pInfo)
 {
     Numeric n1 = args[0].GetNumeric();
     Numeric n2 = args[1].GetNumeric();
     if (n1 == null || n2 == null)
     {
         throw new PropertyException("Non numeric operands to max function");
     }
     return new NumericProperty(n1.max(n2));
 }
开发者ID:nholik,项目名称:Fo.Net,代码行数:10,代码来源:MaxFunction.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# PropertyItem类代码示例发布时间:2022-05-24
下一篇:
C# PropertyHolder类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap