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


C# PropertyInfo类代码示例

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


PropertyInfo类属于命名空间,在下文中一共展示了PropertyInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: Tween

    /// <summary>
    /// Initializes a new instance of the <see cref="Tween"/> class.
    /// </summary>
    /// <param name='targetObj'>
    /// The objet to perform the Tween on.
    /// </param>
    /// <param name='propertyName'>
    /// Property name, eg. "X", "Y", "ScaleX", "Alpha", etc.
    /// </param>
    /// <param name='endVal'>
    /// The value to tween to.  The tween will run from the property's value at start time to the end value.
    /// </param>
    /// <param name='duration'>
    /// Duration in seconds of the tween.
    /// </param>
    /// <param name='easingType'>
    /// Easing type.  Any function matching the see cref="EaseValue"/> delegate.  
    /// </param>
    /// <param name='delay'>
    /// Delay, in seconds.
    /// </param>
    /// <param name='startCallback'>
    /// Called when tween starts (after any delay).  
    /// </param>
    /// <param name='endCallback'>
    /// Called when tween ends
    /// </param>
    /// <exception cref='Exception'>
    /// Thrown when a Tween is created before Stage
    /// </exception>
    /// <exception cref='ArgumentException'>
    /// Thrown when targetObj param is null or targetObj does not have property referenced by propertyName arg.
    /// </exception>
    public Tween(DisplayObjectContainer targetObj, string propertyName, float endVal, float duration, EaseValue easingType, float delay = 0f, TweenCallback startCallback = null, TweenCallback endCallback = null)
    {
        if (TweenRunner.Instance == null)
            throw new Exception("TweenRunner must be added to Stage before creating Tweens");

        if (targetObj == null)
            throw new ArgumentException("targetObj is null");

        Id = Guid.NewGuid();
        TargetObj = targetObj;
        if (!String.IsNullOrEmpty(propertyName))
        {
            Property = targetObj.GetType().GetProperty(propertyName);
            if (Property == null)
                throw new ArgumentException("targetObj does not have property named " + propertyName);
        }
        //StartVal gets set when tween actually starts running, since the value may change during a delay
        EndVal = endVal;
        StartTime = TweenRunner.Instance.__GetCurrentTime();
        Duration = duration;
        EasingType = easingType;
        Delay = delay;
        StartCallback = startCallback;
        EndCallback = endCallback;

        if (!String.IsNullOrEmpty(propertyName))
            TweenRunner.Instance.__AddTween(this);
    }
开发者ID:kyallbarrows,项目名称:Cinch_4-3,代码行数:61,代码来源:Tween.cs

示例15: Reports_RMLauncher

	static Reports_RMLauncher()
	{
		_sendEmailMaint = System.Web.Compilation.BuildManager.GetType(_SENDEMAILMAINT_TYPE, false);
		_sendEmailMethod = null;
		MemberInfo[] search = null;
		if (_sendEmailMaint != null)
		{
			_sendEmailMethod = _sendEmailMaint.GetMethod(_SENDEMAIL_METHOD, BindingFlags.Static | BindingFlags.InvokeMethod | BindingFlags.Public);
			search = _sendEmailMaint.GetMember(_SENDEMAILPARAMS_TYPE);
		}
		Type sendEmailParams = search != null && search.Length > 0 && search[0] is Type ? (Type)search[0] : null;
		if (sendEmailParams != null)
		{
			_sendEmailParamsCtor = sendEmailParams.GetConstructor(new Type[0]);
			_fromMethod = sendEmailParams.GetProperty("From");
			_toMethod = sendEmailParams.GetProperty("To");
			_ccMethod = sendEmailParams.GetProperty("Cc");
			_bccMethod = sendEmailParams.GetProperty("Bcc");
			_subjectMethod = sendEmailParams.GetProperty("Subject");
			_bodyMethod = sendEmailParams.GetProperty("Body");
			_activitySourceMethod = sendEmailParams.GetProperty("Source");
			_parentSourceMethod = sendEmailParams.GetProperty("ParentSource");
			_templateIDMethod = sendEmailParams.GetProperty("TemplateID");
			_attachmentsMethod = sendEmailParams.GetProperty("Attachments");
		}

		_canSendEmail = _sendEmailParamsCtor != null && _sendEmailMaint != null && _sendEmailMethod != null &&
			_fromMethod != null && _toMethod != null && _ccMethod != null && _bccMethod != null && 
			_subjectMethod != null && _bodyMethod != null &&
			_activitySourceMethod != null && _parentSourceMethod != null && _templateIDMethod != null && _attachmentsMethod != null;
	}
开发者ID:PavelMPD,项目名称:SimpleProjects,代码行数:31,代码来源:RMLauncher.aspx.cs


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