本文整理汇总了C#中System.Reflection.PropertyInfo.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# PropertyInfo.ToString方法的具体用法?C# PropertyInfo.ToString怎么用?C# PropertyInfo.ToString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Reflection.PropertyInfo
的用法示例。
在下文中一共展示了PropertyInfo.ToString方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OutputSettingsException
public OutputSettingsException(PropertyInfo setting, object reqValue, object capValue)
: base("Failed to create output setting for '" + setting.ToString() + "'")
{
this.setting = setting;
this.reqValue = reqValue;
this.capValue = capValue;
}
示例2: PropertyMetadata
internal PropertyMetadata(PropertyInfo info)
{
PropertyInfo = info;
#if !DataAnnotations_Missing
Validators = ImmutableArray.CreateRange(info.GetCustomAttributes(typeof(ValidationAttribute), true).OfType<ValidationAttribute>());
#endif
IsIndexed = info.GetIndexParameters().Length > 0;
m_GetMethod = PropertyInfo.GetMethod;
m_SetMethod = PropertyInfo.SetMethod;
PropertyType = info.PropertyType;
var name = info.ToString();
Name = name.Substring(name.IndexOf(" ", StringComparison.Ordinal) + 1);
if (IsIndexed)
PropertyChangedEventArgs = new PropertyChangedEventArgs(info.Name + "[]");
else
PropertyChangedEventArgs = new PropertyChangedEventArgs(info.Name);
#if !DataAnnotations_Missing
IsKey = info.GetCustomAttributes(typeof(KeyAttribute), true).Any();
var doNotMap = info.GetCustomAttributes(typeof(NotMappedAttribute), true).Any();
if (!doNotMap)
{
var column = (ColumnAttribute)info.GetCustomAttributes(typeof(ColumnAttribute), true).SingleOrDefault();
MappedColumnName = column != null ? column.Name : Name;
}
var decomposeAttribute = (DecomposeAttribute)(info.GetCustomAttributes(typeof(DecomposeAttribute), true).FirstOrDefault());
if (decomposeAttribute != null)
{
Decompose = true;
DecompositionPrefix = decomposeAttribute.Prefix;
}
IgnoreOnInsert = info.GetCustomAttributes(typeof(IgnoreOnInsertAttribute), true).Any();
IgnoreOnUpdate = info.GetCustomAttributes(typeof(IgnoreOnUpdateAttribute), true).Any();
#endif
}
示例3: ProcessSingleObject
private void ProcessSingleObject(EntityContextInfo entityInfo, ElasticsearchCrudJsonWriter elasticsearchCrudJsonWriter, PropertyInfo prop, bool createPropertyMappings)
{
TraceProvider.Trace(TraceEventType.Verbose, "ElasticsearchMapping: Property is an Object: {0}", prop.ToString());
// This is a single object and not a reference to it's parent
if (createPropertyMappings && prop.GetValue(entityInfo.Document) == null)
{
prop.SetValue(entityInfo.Document,Activator.CreateInstance(prop.PropertyType));
}
if (prop.GetValue(entityInfo.Document) != null && SaveChildObjectsAsWellAsParent)
{
var child = GetDocumentType(prop.GetValue(entityInfo.Document).GetType());
var parent = GetDocumentType(entityInfo.EntityType);
if (!SerializedTypes.Contains(child + parent))
{
SerializedTypes.Add(parent + child);
if (ProcessChildDocumentsAsSeparateChildIndex)
{
ProcessSingleObjectAsChildDocument(entityInfo, elasticsearchCrudJsonWriter, prop, createPropertyMappings);
}
else
{
ProcessSingleObjectAsNestedObject(entityInfo, elasticsearchCrudJsonWriter, prop, createPropertyMappings);
}
}
}
}
示例4: ValidationException
public ValidationException(ValidationConstraint constraint, PropertyInfo prop)
: base(prop.ToString())
{
ValidationConstraint = constraint;
Property = prop;
}
示例5: ProcessProperty
void ProcessProperty(PropertyInfo propertyInfo)
{
Debug.WriteLine ("Add property " + propertyInfo.ToString ());
}
示例6: ValueToString
public static string ValueToString( object obj, PropertyInfo prop )
{
try
{
if (prop == null)
return "!Null PropertyInfo!";
if (obj == null)
{
MethodInfo mi = prop.GetGetMethod(false);
if (mi == null) // don't expect this to *ever* get hit.. would only occur on set-only props
return "!Null Obj, MethodInfo!"; // or non-public ones
if (!mi.IsStatic)
return "-null-";
// okay, wtf is going on!
throw new ApplicationException(String.Format("{0} was null", prop.ToString()));
}
return ValueToString( prop.GetValue( obj, null ) );
}
catch ( Exception e )
{
LogHelper.LogException(e);
return String.Format( "!{0}!", e.GetType() );
}
}
示例7: CreateSetHandler
// CreateSetDelegate
public static SetHandler CreateSetHandler(Type type, PropertyInfo propertyInfo)
{
string _key = string.Format("{0}.{1}", propertyInfo.DeclaringType, propertyInfo.ToString());
if (s_SetHandlerCache.ContainsKey(_key))
{
return s_SetHandlerCache[_key] as SetHandler;
}
MethodInfo setMethodInfo = propertyInfo.GetSetMethod(true);
DynamicMethod dynamicSet = CreateSetDynamicMethod(type);
ILGenerator setGenerator = dynamicSet.GetILGenerator();
setGenerator.Emit(OpCodes.Ldarg_0);
setGenerator.Emit(OpCodes.Ldarg_1);
UnboxIfNeeded(setMethodInfo.GetParameters()[0].ParameterType, setGenerator);
setGenerator.Emit(OpCodes.Call, setMethodInfo);
setGenerator.Emit(OpCodes.Ret);
SetHandler _newHandler = (SetHandler)dynamicSet.CreateDelegate(typeof(SetHandler));
s_SetHandlerCache.Add(_key, _newHandler);
return _newHandler;
}