本文整理汇总了C#中System.Reflection.PropertyInfo.Clone方法的典型用法代码示例。如果您正苦于以下问题:C# PropertyInfo.Clone方法的具体用法?C# PropertyInfo.Clone怎么用?C# PropertyInfo.Clone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Reflection.PropertyInfo
的用法示例。
在下文中一共展示了PropertyInfo.Clone方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SelectProperty
[System.Security.SecuritySafeCritical] // auto-generated
public override PropertyInfo SelectProperty(BindingFlags bindingAttr,PropertyInfo[] match,Type returnType,
Type[] indexes,ParameterModifier[] modifiers)
{
// Allow a null indexes array. But if it is not null, every element must be non-null as well.
if (indexes != null && !Contract.ForAll(indexes, delegate(Type t) { return t != null; }))
{
Exception e; // Written this way to pass the Code Contracts style requirements.
#if FEATURE_LEGACYNETCF
if (CompatibilitySwitches.IsAppEarlierThanWindowsPhone8)
e = new NullReferenceException();
else
#endif
e = new ArgumentNullException("indexes");
throw e;
}
if (match == null || match.Length == 0)
throw new ArgumentException(Environment.GetResourceString("Arg_EmptyArray"), "match");
Contract.EndContractBlock();
PropertyInfo[] candidates = (PropertyInfo[]) match.Clone();
int i,j = 0;
// Find all the properties that can be described by type indexes parameter
int CurIdx = 0;
int indexesLength = (indexes != null) ? indexes.Length : 0;
for (i=0;i<candidates.Length;i++) {
if (indexes != null)
{
ParameterInfo[] par = candidates[i].GetIndexParameters();
if (par.Length != indexesLength)
continue;
for (j=0;j<indexesLength;j++) {
Type pCls = par[j]. ParameterType;
// If the classes exactly match continue
if (pCls == indexes[j])
continue;
if (pCls == typeof(Object))
continue;
if (pCls.IsPrimitive) {
if (!(indexes[j].UnderlyingSystemType is RuntimeType) ||
!CanConvertPrimitive((RuntimeType)indexes[j].UnderlyingSystemType,(RuntimeType)pCls.UnderlyingSystemType))
break;
}
else {
if (!pCls.IsAssignableFrom(indexes[j]))
break;
}
}
}
if (j == indexesLength) {
if (returnType != null) {
if (candidates[i].PropertyType.IsPrimitive) {
if (!(returnType.UnderlyingSystemType is RuntimeType) ||
!CanConvertPrimitive((RuntimeType)returnType.UnderlyingSystemType,(RuntimeType)candidates[i].PropertyType.UnderlyingSystemType))
continue;
}
else {
if (!candidates[i].PropertyType.IsAssignableFrom(returnType))
continue;
}
}
candidates[CurIdx++] = candidates[i];
}
}
if (CurIdx == 0)
return null;
if (CurIdx == 1)
return candidates[0];
// Walk all of the properties looking the most specific method to invoke
int currentMin = 0;
bool ambig = false;
int[] paramOrder = new int[indexesLength];
for (i=0;i<indexesLength;i++)
paramOrder[i] = i;
for (i=1;i<CurIdx;i++) {
int newMin = FindMostSpecificType(candidates[currentMin].PropertyType, candidates[i].PropertyType,returnType);
if (newMin == 0 && indexes != null)
newMin = FindMostSpecific(candidates[currentMin].GetIndexParameters(),
paramOrder,
null,
candidates[i].GetIndexParameters(),
paramOrder,
null,
indexes,
null);
if (newMin == 0)
{
newMin = FindMostSpecificProperty(candidates[currentMin], candidates[i]);
if (newMin == 0)
ambig = true;
}
if (newMin == 2) {
//.........这里部分代码省略.........
示例2: SelectProperty
public static PropertyInfo SelectProperty(PropertyInfo[] match, Type returnType, Type[] indexes)
{
// Allow a null indexes array. But if it is not null, every element must be non-null as well.
if (indexes != null && !Contract.ForAll(indexes, delegate (Type t) { return t != null; }))
{
Exception e; // Written this way to pass the Code Contracts style requirements.
e = new ArgumentNullException("indexes");
throw e;
}
if (match == null || match.Length == 0)
{
throw new ArgumentException(SR.Arg_EmptyArray, "match");
}
PropertyInfo[] candidates = (PropertyInfo[])match.Clone();
int i, j = 0;
// Find all the properties that can be described by type indexes parameter
int CurIdx = 0;
int indexesLength = (indexes != null) ? indexes.Length : 0;
for (i = 0; i < candidates.Length; i++)
{
if (indexes != null)
{
ParameterInfo[] par = candidates[i].GetIndexParameters();
if (par.Length != indexesLength)
{
continue;
}
for (j = 0; j < indexesLength; j++)
{
Type pCls = par[j].ParameterType;
// If the classes exactly match continue
if (pCls == indexes[j])
{
continue;
}
if (pCls == typeof(Object))
{
continue;
}
if (pCls.GetTypeInfo().IsPrimitive)
{
if (!CanConvertPrimitive(indexes[j], pCls))
{
break;
}
}
else
{
if (!pCls.GetTypeInfo().IsAssignableFrom(indexes[j].GetTypeInfo()))
{
break;
}
}
}
}
if (j == indexesLength)
{
if (returnType != null)
{
if (candidates[i].PropertyType.GetTypeInfo().IsPrimitive)
{
if (!CanConvertPrimitive(returnType, candidates[i].PropertyType))
{
continue;
}
}
else
{
if (!candidates[i].PropertyType.GetTypeInfo().IsAssignableFrom(returnType.GetTypeInfo()))
{
continue;
}
}
}
candidates[CurIdx++] = candidates[i];
}
}
if (CurIdx == 0)
{
return null;
}
if (CurIdx == 1)
{
return candidates[0];
}
// Walk all of the properties looking the most specific method to invoke
int currentMin = 0;
bool ambig = false;
int[] paramOrder = new int[indexesLength];
for (i = 0; i < indexesLength; i++)
{
paramOrder[i] = i;
//.........这里部分代码省略.........
示例3: SelectProperty
public override PropertyInfo SelectProperty(BindingFlags bindingAttr, PropertyInfo[] match, Type returnType, Type[] indexes, ParameterModifier[] modifiers)
{
int num;
if ((indexes != null) && !Contract.ForAll<Type>(indexes, t => t != null))
{
throw new ArgumentNullException("indexes");
}
if ((match == null) || (match.Length == 0))
{
throw new ArgumentException(Environment.GetResourceString("Arg_EmptyArray"), "match");
}
PropertyInfo[] infoArray = (PropertyInfo[]) match.Clone();
int index = 0;
int num3 = 0;
int num4 = (indexes != null) ? indexes.Length : 0;
for (num = 0; num < infoArray.Length; num++)
{
if (indexes != null)
{
ParameterInfo[] indexParameters = infoArray[num].GetIndexParameters();
if (indexParameters.Length != num4)
{
continue;
}
index = 0;
while (index < num4)
{
Type parameterType = indexParameters[index].ParameterType;
if ((parameterType != indexes[index]) && (parameterType != typeof(object)))
{
if (parameterType.IsPrimitive)
{
if (!(indexes[index].UnderlyingSystemType is RuntimeType) || !CanConvertPrimitive((RuntimeType) indexes[index].UnderlyingSystemType, (RuntimeType) parameterType.UnderlyingSystemType))
{
break;
}
}
else if (!parameterType.IsAssignableFrom(indexes[index]))
{
break;
}
}
index++;
}
}
if (index != num4)
{
continue;
}
if (returnType != null)
{
if (infoArray[num].PropertyType.IsPrimitive)
{
if ((returnType.UnderlyingSystemType is RuntimeType) && CanConvertPrimitive((RuntimeType) returnType.UnderlyingSystemType, (RuntimeType) infoArray[num].PropertyType.UnderlyingSystemType))
{
goto Label_0173;
}
continue;
}
if (!infoArray[num].PropertyType.IsAssignableFrom(returnType))
{
continue;
}
}
Label_0173:
infoArray[num3++] = infoArray[num];
}
switch (num3)
{
case 0:
return null;
case 1:
return infoArray[0];
}
int num5 = 0;
bool flag = false;
int[] numArray = new int[num4];
for (num = 0; num < num4; num++)
{
numArray[num] = num;
}
for (num = 1; num < num3; num++)
{
int num6 = FindMostSpecificType(infoArray[num5].PropertyType, infoArray[num].PropertyType, returnType);
if ((num6 == 0) && (indexes != null))
{
num6 = FindMostSpecific(infoArray[num5].GetIndexParameters(), numArray, null, infoArray[num].GetIndexParameters(), numArray, null, indexes, null);
}
if (num6 == 0)
{
num6 = FindMostSpecificProperty(infoArray[num5], infoArray[num]);
if (num6 == 0)
{
flag = true;
}
}
if (num6 == 2)
{
flag = false;
//.........这里部分代码省略.........
示例4: TypeRow
//.........这里部分代码省略.........
gui = new Vector3DWithRandom();
}
else if (p.PropertyType == typeof(Data.Value.Color))
{
gui = new ColorCtrl();
}
else if (p.PropertyType == typeof(Data.Value.ColorWithRandom))
{
gui = new ColorWithRandom();
}
else if (p.PropertyType == typeof(Data.Value.Path))
{
gui = new Path();
}
else if (p.PropertyType == typeof(Data.Value.PathForImage))
{
gui = new PathForImage();
}
else if (p.PropertyType == typeof(Data.Value.PathForSound))
{
gui = new PathForSound();
}
else if (p.PropertyType == typeof(Data.Value.FCurveVector3D))
{
FCurveButton button = new FCurveButton();
button.Text = "Fカーブ";
gui = button;
}
else if (p.PropertyType == typeof(Data.Value.FCurveColorRGBA))
{
FCurveButton button = new FCurveButton();
button.Text = "Fカーブ";
gui = button;
}
else if (p.PropertyType == typeof(Data.Value.FCurve<float>))
{
gui = null;
return;
}
else if (p.PropertyType == typeof(Data.Value.FCurve<byte>))
{
gui = null;
return;
}
else if (p.PropertyType == typeof(Data.Value.IFCurveKey))
{
gui = null;
return;
}
else if (p.PropertyType.IsGenericType)
{
var types = p.PropertyType.GetGenericArguments();
var generic_type = typeof(Enum<>).MakeGenericType(types);
var constructor = generic_type.GetConstructor(new Type[] { });
gui = constructor.Invoke(null) as Control;
}
var selector_attribute = (from a in attributes where a is Data.SelectorAttribute select a).FirstOrDefault() as Data.SelectorAttribute;
if (selector_attribute != null)
{
IsSelector = true;
SelectorID = selector_attribute.ID;
}
else
{
IsSelector = false;
SelectorID = -1;
}
Properties = properties.Clone() as PropertyInfo[];
Title = NameAttribute.GetName(attributes);
Description = DescriptionAttribute.GetDescription(attributes);
Control = gui;
// Selector
var selected_attribute = (from a in attributes where a is Data.SelectedAttribute select a).FirstOrDefault() as Data.SelectedAttribute;
if (selected_attribute != null)
{
var selector = sameLayer.Where(_ => _.IsSelector && _.SelectorID == selected_attribute.ID).LastOrDefault();
if (selector != null)
{
Selector = selector;
SelectorValue = selected_attribute.Value;
}
}
Label = new Label();
Label.Width = 0;
Label.AutoSize = true;
Label.Text = Title;
Label.TextAlign = ContentAlignment.MiddleCenter;
Label.Font = new Font(Label.Font.FontFamily, 9);
ControlDynamic = Control;
if (Control != null && !(Control is Button))
{
ControlDynamic.EnableUndo = EnableUndo;
}
}
示例5: SelectProperty
public override PropertyInfo SelectProperty(BindingFlags bindingAttr, PropertyInfo[] match, Type returnType, Type[] indexes, ParameterModifier[] modifiers)
{
if (indexes != null)
{
if (!Contract.ForAll<Type>(indexes, (Type t) => t != null))
{
throw new ArgumentNullException("indexes");
}
}
if (match == null || match.Length == 0)
{
throw new ArgumentException(Environment.GetResourceString("Arg_EmptyArray"), "match");
}
PropertyInfo[] array = (PropertyInfo[])match.Clone();
int i = 0;
int num = 0;
int num2 = (indexes != null) ? indexes.Length : 0;
int j = 0;
while (j < array.Length)
{
if (indexes == null)
{
goto IL_113;
}
ParameterInfo[] indexParameters = array[j].GetIndexParameters();
if (indexParameters.Length == num2)
{
for (i = 0; i < num2; i++)
{
Type parameterType = indexParameters[i].ParameterType;
if (!(parameterType == indexes[i]) && !(parameterType == typeof(object)))
{
if (parameterType.IsPrimitive)
{
if (!(indexes[i].UnderlyingSystemType is RuntimeType))
{
break;
}
if (!DefaultBinder.CanConvertPrimitive((RuntimeType)indexes[i].UnderlyingSystemType, (RuntimeType)parameterType.UnderlyingSystemType))
{
break;
}
}
else
{
if (!parameterType.IsAssignableFrom(indexes[i]))
{
break;
}
}
}
}
goto IL_113;
}
IL_17D:
j++;
continue;
IL_113:
if (i == num2)
{
if (returnType != null)
{
if (array[j].PropertyType.IsPrimitive)
{
if (!(returnType.UnderlyingSystemType is RuntimeType))
{
goto IL_17D;
}
if (!DefaultBinder.CanConvertPrimitive((RuntimeType)returnType.UnderlyingSystemType, (RuntimeType)array[j].PropertyType.UnderlyingSystemType))
{
goto IL_17D;
}
}
else
{
if (!array[j].PropertyType.IsAssignableFrom(returnType))
{
goto IL_17D;
}
}
}
array[num++] = array[j];
goto IL_17D;
}
goto IL_17D;
}
if (num == 0)
{
return null;
}
if (num == 1)
{
return array[0];
}
int num3 = 0;
bool flag = false;
int[] array2 = new int[num2];
for (j = 0; j < num2; j++)
{
array2[j] = j;
//.........这里部分代码省略.........