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


C# ElementInfo.hasPreparedInfo方法代码示例

本文整理汇总了C#中ElementInfo.hasPreparedInfo方法的典型用法代码示例。如果您正苦于以下问题:C# ElementInfo.hasPreparedInfo方法的具体用法?C# ElementInfo.hasPreparedInfo怎么用?C# ElementInfo.hasPreparedInfo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ElementInfo的用法示例。


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

        public static DecodedObject<int> getTagValueForElement(ElementInfo info, int tagClass, int elemenType, int universalTag)
        {
            DecodedObject<int> result = new DecodedObject<int>();
            // result.Value =  tagClass | elemenType | universalTag;
            if (universalTag < UniversalTags.LastUniversal)
            {
                result.Value = tagClass | elemenType | universalTag;
            }
            else
                result = getTagValue(tagClass, elemenType, universalTag, universalTag, tagClass);

            result.Size = 1;
            if (info.hasPreparedInfo())
            {
                ASN1ElementMetadata meta = info.PreparedASN1ElementInfo;
                if (meta != null && meta.HasTag)
                {
                    result = getTagValue(tagClass, elemenType, universalTag,
                                         meta.Tag,
                                         meta.TagClass
                        );
                }
            }
            else
            {
                ASN1Element elementInfo = null;
                if (info.ASN1ElementInfo != null)
                {
                    elementInfo = info.ASN1ElementInfo;
                }
                else if (info.isAttributePresent<ASN1Element>())
                {
                    elementInfo = info.getAttribute<ASN1Element>();
                }

                if (elementInfo != null)
                {
                    if (elementInfo.HasTag)
                    {
                        result = getTagValue(tagClass, elemenType, universalTag, elementInfo.Tag, elementInfo.TagClass);
                    }
                }
            }
            return result;
        }
开发者ID:rmc00,项目名称:gsf,代码行数:45,代码来源:BERCoderUtils.cs

示例3: decodeChoice

 public override DecodedObject<object> decodeChoice(DecodedObject<object> decodedTag, Type objectClass, ElementInfo elementInfo, System.IO.Stream stream)
 {
     if ( (elementInfo.hasPreparedInfo() && elementInfo.hasPreparedASN1ElementInfo() && elementInfo.PreparedASN1ElementInfo.HasTag)
         || (elementInfo.ASN1ElementInfo != null && elementInfo.ASN1ElementInfo.HasTag))
     {
         if (!checkTagForObject(decodedTag, TagClasses.ContextSpecific, ElementType.Constructed, UniversalTags.LastUniversal, elementInfo))
             return null;
         DecodedObject<int> len =  decodeLength(stream);
         DecodedObject<object> childDecodedTag = decodeTag(stream);
         DecodedObject<object> result = base.decodeChoice(childDecodedTag, objectClass, elementInfo, stream);
         result.Size += len.Size + childDecodedTag.Size;
         return result;
     }
     else
         return base.decodeChoice(decodedTag, objectClass, elementInfo, stream);
 }
开发者ID:huliang,项目名称:BinaryNotes,代码行数:16,代码来源:BERDecoder.cs

示例4: 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

示例5: decodeSequenceOf

        public override DecodedObject<object> decodeSequenceOf(DecodedObject<object> decodedTag, System.Type objectClass, ElementInfo elementInfo, System.IO.Stream stream)
        {
            if (!CoderUtils.isSequenceSetOf(elementInfo))
            {
                if (!checkTagForObject(decodedTag, TagClasses.Universal, ElementType.Constructed, UniversalTags.Sequence, elementInfo))
                    return null;
            }
            else
            {
                if (!checkTagForObject(decodedTag, TagClasses.Universal, ElementType.Constructed, UniversalTags.Set, elementInfo))
                    return null;
            }

            Type paramType = (System.Type)objectClass.GetGenericArguments()[0];
            Type collectionType = typeof(List<>);
            Type genCollectionType = collectionType.MakeGenericType(paramType);
            Object param = Activator.CreateInstance(genCollectionType);

            DecodedObject<int> len = decodeLength(stream);
            if (len.Value != 0)
            {
                int lenOfItems = 0;
                int itemsCnt = 0;
                do
                {
                    ElementInfo info = new ElementInfo();
                    info.ParentAnnotatedClass = elementInfo.AnnotatedClass;
                    info.AnnotatedClass = paramType;

                    if (elementInfo.hasPreparedInfo())
                    {
                        ASN1SequenceOfMetadata seqOfMeta = (ASN1SequenceOfMetadata)elementInfo.PreparedInfo.TypeMetadata;
                        info.PreparedInfo = (seqOfMeta.getItemClassMetadata());
                    }

                    DecodedObject<object> itemTag = decodeTag(stream);
                    DecodedObject<object> item = decodeClassType(itemTag, paramType, info, stream);
                    MethodInfo method = param.GetType().GetMethod("Add");
                    if (item != null)
                    {
                        lenOfItems += item.Size + itemTag.Size;
                        method.Invoke(param, new object[] { item.Value });
                        itemsCnt++;
                    }
                }
                while (lenOfItems < len.Value);
                CoderUtils.checkConstraints(itemsCnt, elementInfo);
            }
            return new DecodedObject<object>(param, len.Value + len.Size);
        }
开发者ID:huliang,项目名称:BinaryNotes,代码行数:50,代码来源:BERDecoder.cs


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