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


C# ElementInfo类代码示例

本文整理汇总了C#中ElementInfo的典型用法代码示例。如果您正苦于以下问题:C# ElementInfo类的具体用法?C# ElementInfo怎么用?C# ElementInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ElementInfo类属于命名空间,在下文中一共展示了ElementInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: decodeString

        public override DecodedObject<object> decodeString(DecodedObject<object> decodedTag, System.Type objectClass, ElementInfo elementInfo, System.IO.Stream stream)
        {
            if (!PERCoderUtils.is7BitEncodedString(elementInfo))
                return base.decodeString(decodedTag, objectClass, elementInfo, stream);
            else
            {
                DecodedObject<object> result = new DecodedObject<object>();
                int strLen = decodeLength(elementInfo, stream);

                if (strLen <= 0)
                {
                    result.Value = ("");
                    return result;
                }

                BitArrayInputStream bitStream = (BitArrayInputStream) stream;
                byte[] buffer = new byte[strLen];
                // 7-bit decoding of string
                for (int i = 0; i < strLen; i++)
                    buffer[i] = (byte)bitStream.readBits(7);
                result.Value = new string(
                    System.Text.ASCIIEncoding.ASCII.GetChars(buffer)
                );
                return result;
            }
        }
开发者ID:huliang,项目名称:BinaryNotes,代码行数:26,代码来源:PERUnalignedDecoder.cs

示例2: encode

 public override int encode(IASN1TypesEncoder encoder, object obj, Stream stream, ElementInfo elementInfo)
 {
     Object result = null;
     ASN1ElementMetadata saveInfo = elementInfo.PreparedASN1ElementInfo;
     elementInfo.PreparedInfo = (valueFieldMeta);
     if (!CoderUtils.isNullField(valueField, elementInfo))
     {
         result = encoder.invokeGetterMethodForField(valueField, obj, elementInfo);
     }
     if (saveInfo != null)
     {
         if (!saveInfo.HasTag
             && elementInfo.hasPreparedASN1ElementInfo()
             && elementInfo.PreparedASN1ElementInfo.HasTag)
         {
             ASN1ElementMetadata elData = new ASN1ElementMetadata(
                 saveInfo.Name,
                 saveInfo.IsOptional,
                 elementInfo.PreparedASN1ElementInfo.HasTag,
                 elementInfo.PreparedASN1ElementInfo.IsImplicitTag,
                 elementInfo.PreparedASN1ElementInfo.TagClass,
                 elementInfo.PreparedASN1ElementInfo.Tag,
                 saveInfo.HasDefaultValue
                 );
             elementInfo.PreparedASN1ElementInfo = elData;
         }
         else
             elementInfo.PreparedASN1ElementInfo = (saveInfo);
     }
     return valueFieldMeta.TypeMetadata.encode(encoder, result, stream, elementInfo);
 }
开发者ID:rmc00,项目名称:gsf,代码行数:31,代码来源:ASN1BoxedTypeMetadata.cs

示例3: LoadInfoFromFile

        /// <summary>
        /// Loads all the elements found in the elements file.
        /// </summary>
        /// <param name="includeDisabled"></param>
        /// <returns>An array of the the elements found.</returns>
        public ElementInfo[] LoadInfoFromFile(bool includeDisabled)
        {
            // Logging disabled to boost performance
            //using (LogGroup logGroup = LogGroup.StartDebug("Loading the elements from the XML file."))
            //{
            if (Elements == null)
            {
                List<ElementInfo> validElements = new List<ElementInfo>();

                ElementInfo[] elements = new ElementInfo[]{};

                using (StreamReader reader = new StreamReader(File.OpenRead(FileNamer.ElementsInfoFilePath)))
                {
                    XmlSerializer serializer = new XmlSerializer(typeof(ElementInfo[]));
                    elements = (ElementInfo[])serializer.Deserialize(reader);
                }

                foreach (ElementInfo element in elements)
                    if (element.Enabled || includeDisabled)
                        validElements.Add(element);

                Elements = validElements.ToArray();
            }
            //}
            return Elements;
        }
开发者ID:jeremysimmons,项目名称:sitestarter,代码行数:31,代码来源:ElementLoader.cs

示例4: decodeAny

        public override DecodedObject<object> decodeAny(DecodedObject<object> decodedTag, System.Type objectClass, ElementInfo elementInfo, System.IO.Stream stream)
        {
            int bufSize = elementInfo.MaxAvailableLen;
            if (bufSize == 0)
                return null;
            System.IO.MemoryStream anyStream = new System.IO.MemoryStream(1024);
            /*int tagValue = (int)decodedTag.Value;
            for (int i = 0; i < decodedTag.Size; i++)
            {
                anyStream.WriteByte((byte)tagValue);
                tagValue = tagValue >> 8;
            }*/

            if(bufSize<0)
                bufSize = 1024;
            int len = 0;
            if (bufSize > 0)
            {
                byte[] buffer = new byte[bufSize];
                int readed = stream.Read(buffer, 0, buffer.Length);
                while (readed > 0)
                {
                    anyStream.Write(buffer, 0, readed);
                    len += readed;
                    if (elementInfo.MaxAvailableLen > 0)
                        break;
                    readed = stream.Read(buffer, 0, buffer.Length);
                }
            }
            CoderUtils.checkConstraints(len, elementInfo);
            return new DecodedObject<object>(anyStream.ToArray(), len);
        }
开发者ID:huliang,项目名称:BinaryNotes,代码行数:32,代码来源:BERDecoder.cs

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

示例6: is7BitEncodedString

 public static bool is7BitEncodedString(ElementInfo info)
 {
     bool is7Bit = false;
     int stringType = CoderUtils.getStringTagForElement(info);
     is7Bit = (
                  stringType == UniversalTags.PrintableString
                  || stringType == UniversalTags.VisibleString
              );
     return is7Bit;
 }
开发者ID:rmc00,项目名称:gsf,代码行数:10,代码来源:PERCoderUtils.cs

示例7: Clone

        /// <summary>
        /// Creates a new copy of this ElementInfo.
        /// </summary>
        /// <returns>A new ElementInfo that is a copy of this instance.</returns>
        public ElementInfo Clone()
        {
            var cloneElementInfo = new ElementInfo();

            cloneElementInfo.Texture = Texture.Clone();
            cloneElementInfo.XOffset = XOffset;
            cloneElementInfo.YOffset = YOffset;

            return cloneElementInfo;
        }
开发者ID:rozniak,项目名称:RozWorld-Editor,代码行数:14,代码来源:ElementInfo.cs

示例8: decodeBitString

 public override DecodedObject<object> decodeBitString(DecodedObject<object> decodedTag, System.Type objectClass, ElementInfo elementInfo, System.IO.Stream stream)
 {
     if (!checkTagForObject(decodedTag, TagClasses.Universal, ElementType.Primitive, UniversalTags.Bitstring, elementInfo))
         return null;
     DecodedObject<int> len = decodeLength(stream);
     int trailBitCnt = stream.ReadByte();
     CoderUtils.checkConstraints(len.Value * 8 - trailBitCnt, elementInfo);
     byte[] byteBuf = new byte[len.Value - 1];
     stream.Read(byteBuf,0,byteBuf.Length);
     return new DecodedObject<object>( new BitString(byteBuf,trailBitCnt), len.Value + len.Size);
 }
开发者ID:huliang,项目名称:BinaryNotes,代码行数:11,代码来源:BERDecoder.cs

示例9: decodeBoolean

 public override DecodedObject<object> decodeBoolean(DecodedObject<object> decodedTag, System.Type objectClass, ElementInfo elementInfo, System.IO.Stream stream)
 {
     if (!checkTagForObject(decodedTag, TagClasses.Universal, ElementType.Primitive, UniversalTags.Boolean, elementInfo))
         return null;
     DecodedObject<object> result = decodeIntegerValue(stream);
     int val = (int) result.Value;
     if (val != 0)
         result.Value  = true;
     else
         result.Value = false;
     return result;
 }
开发者ID:huliang,项目名称:BinaryNotes,代码行数:12,代码来源:BERDecoder.cs

示例10: translateIntoBlocks

        /**
         * tries to group the chained elements into blocks
         *
         * the elements must be in a valid order allready
         *
         * this function also translates all constraints into the blocks of TranslateInfo
         *
         */
        public static TranslateInfo translateIntoBlocks(List<int> elements, List<CausalSets.Constraint> constraints)
        {
            int i;
            int elementI;
            int blockIdCounter;
            bool blockIdCounterWasIncremented;
            TranslateInfo resultTranslateInfo;

            ElementInfo[] elementInfos;

            debugInput(elements, constraints);

            resultTranslateInfo = new TranslateInfo();

            elementInfos = new ElementInfo[elements.Count];

            for( i = 0; i < elements.Count; i++ )
            {
                elementInfos[i] = new ElementInfo();
            }

            // go througth all the constraints and search the index of the dependencies and the element then store it in the array
            storeDependenciesIntoElementInfos(elements, elementInfos, constraints);

            // search in the array for interlinked blocks, label the elements with a blockcounter
            blockIdCounter = 0;
            blockIdCounterWasIncremented = false;

            for( elementI = 1; elementI < elements.Count; elementI++ )
            {
                if( elementInfos[elementI].dependencies.Count > 0 && elementInfos[elementI].dependencies.Contains(elementI-1) )
                {
                    elementInfos[elementI].blockId = blockIdCounter;
                }
                else
                {
                    blockIdCounter++;
                    elementInfos[elementI].blockId = blockIdCounter;
                }
            }

            // store the elements into the blocks
            // and transfer the orginal constraints to the blocks
            storeElementsIntoBlocks(elements, elementInfos, resultTranslateInfo);
            checkInvariantForBlocks(elements, resultTranslateInfo);
            transferConstraintsToBlocks(resultTranslateInfo, constraints);

            debugResultTranslateInfo(resultTranslateInfo);

            return resultTranslateInfo;
        }
开发者ID:PtrMan,项目名称:ai2,代码行数:59,代码来源:BlockResponsibility.cs

示例11: handleProperties

  static bool handleProperties (XmlNode node, ElementInfo ei) {
    if (ei.properties == null)
      ei.properties = new ArrayList ();

    XmlElement elt = node as XmlElement;
    if (elt == null)
      return true;

    foreach (XmlElement property in elt.ChildNodes) {
      if (IsHidden (property))
        continue;

      PropertyInfo pi = new PropertyInfo ();
      pi.name = property["name"].InnerText;
      pi.managed_name = (property["managed_name"] != null) ? property["managed_name"].InnerText : null;
      pi.type = property["type"].InnerText;
      pi.readable = property["flags"].InnerText.IndexOf ('R') != -1;
      pi.writeable = property["flags"].InnerText.IndexOf ('W') != -1;

      if (property["enum-values"] != null) {
        pi.enuminfo = new EnumInfo ();
        pi.enuminfo.flag = false;
        pi.enuminfo.values = new ArrayList ();

        foreach (XmlNode val in property["enum-values"].ChildNodes) {
          EnumValue env = new EnumValue ();

          env.name = val.Attributes["nick"].InnerText;
          env.value = Int32.Parse (val.Attributes["value"].InnerText);
          pi.enuminfo.values.Add (env);
        }
      } else if (property["flags-values"] != null) {
        pi.enuminfo = new EnumInfo ();
        pi.enuminfo.flag = true;
        pi.enuminfo.values = new ArrayList ();

        foreach (XmlNode val in property["flags-values"].ChildNodes) {
          FlagValue env = new FlagValue ();

          env.name = val.Attributes["nick"].InnerText;
          env.value = UInt32.Parse (val.Attributes["value"].InnerText);
          pi.enuminfo.values.Add (env);
        }
      }

      ei.properties.Add (pi);
    }

    return true;
  }
开发者ID:jwzl,项目名称:ossbuild,代码行数:50,代码来源:elementgen.cs

示例12: handlePads

  static bool handlePads (XmlNode node, ElementInfo ei) {
    if (ei.pads == null)
      ei.pads = new ArrayList ();

    XmlElement elt = node as XmlElement;
    if (elt == null)
      return true;

    foreach (XmlElement pad in elt.ChildNodes)
      if (!IsHidden (pad) && !IsHidden (pad["name"]))
        ei.pads.Add (pad["name"].InnerText);

    return true;
  }
开发者ID:jwzl,项目名称:ossbuild,代码行数:14,代码来源:elementgen.cs

示例13: StoreChild

        /// <summary>
        /// Stores the <see cref="XliffElement"/> as a child of this <see cref="XliffElement"/>.
        /// </summary>
        /// <param name="child">The child to add.</param>
        /// <returns>True if the child was stored, otherwise false.</returns>
        protected override bool StoreChild(ElementInfo child)
        {
            bool result;

            result = true;
            if (child.Element is Match)
            {
                this.Matches.Add((Match)child.Element);
            }
            else
            {
                result = base.StoreChild(child);
            }

            return result;
        }
开发者ID:jogleasonjr,项目名称:XLIFF2-Object-Model,代码行数:21,代码来源:TranslationMatches.cs

示例14: StoreElement

        /// <summary>
        /// Stores the element in an extension.
        /// </summary>
        /// <param name="extensible">The object that is being extended.</param>
        /// <param name="element">The element to store.</param>
        /// <returns>This method always returns true.</returns>
        public bool StoreElement(IExtensible extensible, ElementInfo element)
        {
            GenericExtension extension;

            extension = extensible.Extensions.FirstOrDefault((e) => e.Name == GenericExtensionHandler.ExtensionName) as GenericExtension;
            if (extension == null)
            {
                extension = new GenericExtension(GenericExtensionHandler.ExtensionName);
                extensible.Extensions.Add(extension);
            }

            Utilities.SetParent(element.Element, extensible as XliffElement);
            extension.AddChild(element);

            return true;
        }
开发者ID:jogleasonjr,项目名称:XLIFF2-Object-Model,代码行数:22,代码来源:GenericExtensionHandler.cs

示例15: StoreChild

        /// <summary>
        /// Stores the <see cref="XliffElement"/> as a child of this <see cref="XliffElement"/>.
        /// </summary>
        /// <param name="child">The child to add.</param>
        /// <returns>True if the child was stored, otherwise false.</returns>
        protected override bool StoreChild(ElementInfo child)
        {
            bool result;

            result = true;
            if (child.Element is XliffDocument)
            {
                Utilities.ThrowIfPropertyNotNull(this, PropertyNames.Document, this.Document);
                this.Document = (XliffDocument)child.Element;
            }
            else
            {
                result = base.StoreChild(child);
            }

            return result;
        }
开发者ID:jogleasonjr,项目名称:XLIFF2-Object-Model,代码行数:22,代码来源:XliffProvider.cs


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