本文整理汇总了C#中ElementInfo.getProperties方法的典型用法代码示例。如果您正苦于以下问题:C# ElementInfo.getProperties方法的具体用法?C# ElementInfo.getProperties怎么用?C# ElementInfo.getProperties使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ElementInfo
的用法示例。
在下文中一共展示了ElementInfo.getProperties方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: encodeSequence
public override int encodeSequence(Object obj, System.IO.Stream stream, ElementInfo elementInfo)
{
if(!CoderUtils.isSequenceSet(elementInfo))
return base.encodeSequence(obj, stream, elementInfo);
else {
int resultSize = 0;
PropertyInfo[] fields = null;
if (elementInfo.hasPreparedInfo())
{
fields = elementInfo.getProperties(obj.GetType());
}
else
{
SortedList<int, PropertyInfo> fieldOrder = CoderUtils.getSetOrder(obj.GetType());
//TO DO Performance optimization need (unnecessary copy)
fields = new PropertyInfo[fieldOrder.Count];
fieldOrder.Values.CopyTo(fields, 0);
}
for (int i = 0; i < fields.Length; i++)
{
PropertyInfo field = fields[fields.Length - 1 - i];
resultSize += encodeSequenceField(obj, fields.Length - 1 - i, field, stream, elementInfo);
}
resultSize += encodeHeader(
BERCoderUtils.getTagValueForElement(
elementInfo,
TagClasses.Universal,
ElementType.Constructed,
UniversalTags.Set)
, resultSize, stream);
return resultSize;
}
}
示例2: decodeSet
protected virtual DecodedObject<object> decodeSet(DecodedObject<object> decodedTag, System.Type objectClass, ElementInfo elementInfo, int len, System.IO.Stream stream)
{
object sequence = createInstanceForElement(objectClass,elementInfo);
initDefaultValues(sequence);
DecodedObject<object> fieldTag = null;
int sizeOfSequence = 0;
int maxSeqLen = elementInfo.MaxAvailableLen;
if (maxSeqLen == -1 || maxSeqLen > 0)
{
fieldTag = decodeTag(stream);
if (fieldTag != null)
sizeOfSequence += fieldTag.Size;
}
PropertyInfo[] fields =
elementInfo.getProperties(objectClass);
bool fieldEncoded = false;
do
{
for (int i = 0; i < fields.Length; i++)
{
PropertyInfo field = fields[i];
DecodedObject<object> obj = decodeSequenceField(
fieldTag, sequence, i, field, stream, elementInfo, false
);
if (obj != null)
{
fieldEncoded = true;
sizeOfSequence += obj.Size;
bool isAny = false;
if (i + 1 == fields.Length - 1)
{
ElementInfo info = new ElementInfo();
info.AnnotatedClass = (fields[i + 1]);
info.MaxAvailableLen = (elementInfo.MaxAvailableLen);
if (elementInfo.hasPreparedInfo())
{
info.PreparedInfo = (elementInfo.PreparedInfo.getPropertyMetadata(i + 1));
}
else
info.ASN1ElementInfo = CoderUtils.getAttribute<ASN1Element>(fields[i + 1]);
isAny = CoderUtils.isAnyField(fields[i + 1], info);
}
if (maxSeqLen != -1)
{
elementInfo.MaxAvailableLen = (maxSeqLen - sizeOfSequence);
}
if (!isAny)
{
if (i < fields.Length - 1)
{
if (maxSeqLen == -1 || elementInfo.MaxAvailableLen > 0)
{
fieldTag = decodeTag(stream);
if (fieldTag != null)
sizeOfSequence += fieldTag.Size;
else
{
break;
}
}
else
fieldTag = null;
}
else
break;
}
}
;
}
}
while (sizeOfSequence < len && fieldEncoded);
return new DecodedObject<object>(sequence, sizeOfSequence);
}