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


C# ElementInfo.getProperties方法代码示例

本文整理汇总了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;
            }
        }
开发者ID:huliang,项目名称:BinaryNotes,代码行数:35,代码来源:DEREncoder.cs

示例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);
        }
开发者ID:huliang,项目名称:BinaryNotes,代码行数:78,代码来源:BERDecoder.cs


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