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


C# ElementType.ToString方法代码示例

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


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

示例1: ValidateElement

        /// <summary>
        /// Validates the element.
        /// </summary>
        /// <param name="elementType">Type of the element.</param>
        /// <param name="name">The element name.</param>
        /// <param name="value">The element value.</param>
        /// <param name="modelState">State of the model.</param>
        public static void ValidateElement(ElementType elementType, String name, String value, ModelStateDictionary modelState)
        {
            var element = elementType.GetType().GetField(elementType.ToString()).GetCustomAttributes(typeof(CustomElementAttribute), true).FirstOrDefault() as CustomElementAttribute;

            if (element != null && element is IValidatableElement)
            {
                (element as IValidatableElement).Validate(modelState, name, value);
            }
        }
开发者ID:coreframework,项目名称:Core-Framework,代码行数:16,代码来源:ElementTypeUtility.cs

示例2: ReadTypeReference

        public TypeReference ReadTypeReference(ElementType type)
        {
            switch (type)
            {
                case ElementType.Void:
                    return _netHeader.TypeSystem.Void;
                case ElementType.I:
                    return _netHeader.TypeSystem.IntPtr;
                case ElementType.I1:
                    return _netHeader.TypeSystem.Int8;
                case ElementType.I2:
                    return _netHeader.TypeSystem.Int16;
                case ElementType.I4:
                    return _netHeader.TypeSystem.Int32;
                case ElementType.I8:
                    return _netHeader.TypeSystem.Int64;
                case ElementType.U:
                    return _netHeader.TypeSystem.UIntPtr;
                case ElementType.U1:
                    return _netHeader.TypeSystem.UInt8;
                case ElementType.U2:
                    return _netHeader.TypeSystem.UInt16;
                case ElementType.U4:
                    return _netHeader.TypeSystem.UInt32;
                case ElementType.U8:
                    return _netHeader.TypeSystem.UInt64;
                case ElementType.Object:
                    return _netHeader.TypeSystem.Object;
                case ElementType.R4:
                    return _netHeader.TypeSystem.Single;
                case ElementType.R8:
                    return _netHeader.TypeSystem.Double;
                case ElementType.String:
                    return _netHeader.TypeSystem.String;
                case ElementType.Char:
                    return _netHeader.TypeSystem.Char;
                case ElementType.Type:
                    return _netHeader.TypeSystem.Type;
                case ElementType.Boolean:
                    return _netHeader.TypeSystem.Boolean;
                case ElementType.Ptr:
                    return new PointerType(ReadTypeReference((ElementType)this.ReadByte()));
                case ElementType.MVar:
                    return GetGenericParameter(GenericParamType.Method, (int)NETGlobals.ReadCompressedUInt32(this));
                case ElementType.Var:
                    return GetGenericParameter(GenericParamType.Type, (int)NETGlobals.ReadCompressedUInt32(this));
                case ElementType.Array:
                    return ReadArrayType();
                case ElementType.SzArray:
                    return new ArrayType(ReadTypeReference((ElementType)this.ReadByte()));
                case ElementType.Class:
                    TypeReference typeRef;
                    if (_netHeader.TablesHeap.TypeDefOrRef.TryGetMember((int)NETGlobals.ReadCompressedUInt32(this), out typeRef))
                    {
                        return typeRef;
                    }
                    break;
                case ElementType.ValueType:
                    if (_netHeader.TablesHeap.TypeDefOrRef.TryGetMember((int)NETGlobals.ReadCompressedUInt32(this), out typeRef))
                    {
                        typeRef.IsValueType = true;
                        return typeRef;
                    }
                    break;

                case ElementType.ByRef:
                    return new ByReferenceType(ReadTypeReference( (ElementType)this.ReadByte()));
                case ElementType.Pinned:
                    return new PinnedType(ReadTypeReference((ElementType)this.ReadByte()));
                case ElementType.GenericInst:
                    bool isValueType = this.ReadByte() == 0x11;
                    TypeReference reference2 = ReadTypeToken();
                    GenericInstanceType instance = new GenericInstanceType(reference2);
                    instance._genericArguments = ReadGenericArguments();
                    instance.IsValueType = isValueType;

                    return instance;

                case ElementType.CModOpt:
                    return new CustomModifierType(ReadTypeToken(), ReadTypeReference(), false);
                case ElementType.CModReqD:
                    return new CustomModifierType(ReadTypeToken(), ReadTypeReference(), true);
            }
            return new TypeReference(string.Empty, type.ToString(), null) { _netheader = this._netHeader };
        }
开发者ID:Rex-Hays,项目名称:GNIDA,代码行数:85,代码来源:BlobSignatureReader.cs

示例3: ReadTypeReference

        internal TypeReference ReadTypeReference(BinaryReader reader, ElementType type, IGenericParametersProvider provider)
        {
            switch (type)
            {
                case ElementType.Void:
                    return netheader.TypeSystem.Void;
                case ElementType.I:
                    return netheader.TypeSystem.IntPtr;
                case ElementType.I1:
                    return netheader.TypeSystem.Int8;
                case ElementType.I2:
                    return netheader.TypeSystem.Int16;
                case ElementType.I4:
                    return netheader.TypeSystem.Int32;
                case ElementType.I8:
                    return netheader.TypeSystem.Int64;
                case ElementType.U:
                    return netheader.TypeSystem.UIntPtr;
                case ElementType.U1:
                    return netheader.TypeSystem.UInt8;
                case ElementType.U2:
                    return netheader.TypeSystem.UInt16;
                case ElementType.U4:
                    return netheader.TypeSystem.UInt32;
                case ElementType.U8:
                    return netheader.TypeSystem.UInt64;
                case ElementType.Object:
                    return netheader.TypeSystem.Object;
                case ElementType.R4:
                    return netheader.TypeSystem.Single;
                case ElementType.R8:
                    return netheader.TypeSystem.Double;
                case ElementType.String:
                    return netheader.TypeSystem.String;
                case ElementType.Char:
                    return netheader.TypeSystem.Char;
                case ElementType.Type:
                    return netheader.TypeSystem.Type;
                case ElementType.Boolean:
                    return netheader.TypeSystem.Boolean;
                case ElementType.Ptr:
                    return new PointerType(ReadTypeReference(reader,(ElementType)reader.ReadByte(), provider));
                case ElementType.MVar:
                    uint token = ReadCompressedUInt32(reader);
                    if (provider != null && provider.GenericParameters != null && provider.GenericParameters.Length > token)
                        return provider.GenericParameters[token];
                    else
                        return new GenericParamReference((int)token, new TypeReference() { name = "MVar", elementType = ElementType.MVar, @namespace = "", netheader = this.netheader });

                case ElementType.Var:
                    token =ReadCompressedUInt32(reader);
                    if (provider != null && provider is MemberReference)
                    {
                        var member = provider as MemberReference;
                        if (member.DeclaringType is IGenericParametersProvider)
                        {
                            var genericprovider = (IGenericParametersProvider)member.DeclaringType;
                            if (genericprovider.GenericParameters != null)
                                return genericprovider.GenericParameters[token];
                        }
                    }
                    return new GenericParamReference((int)token, new TypeReference() { name = "Var", elementType = ElementType.Var, @namespace = "", netheader = this.netheader });

                    break;
                case ElementType.Array:

                    return ReadArrayType(reader);

                case ElementType.SzArray:
                    return new ArrayType(ReadTypeReference(reader,(ElementType)reader.ReadByte(), provider));
                case ElementType.Class:
                    return (TypeReference)netheader.TablesHeap.tablereader.TypeDefOrRef.GetMember((int)ReadCompressedUInt32(reader));
                case ElementType.ValueType:
                    TypeReference typeRef = (TypeReference)netheader.TablesHeap.tablereader.TypeDefOrRef.GetMember((int)ReadCompressedUInt32(reader));
                    typeRef.IsValueType = true;
                    return typeRef;
                case ElementType.ByRef:
                    return new ByReferenceType(ReadTypeReference(reader, (ElementType)reader.ReadByte(), provider));
                case ElementType.Pinned:
                    return new PinnedType(ReadTypeReference(reader, (ElementType)reader.ReadByte(), provider));
                case ElementType.GenericInst:
                    bool flag = reader.ReadByte() == 0x11;
                    TypeReference reference2 = ReadTypeToken(reader);
                    GenericInstanceType instance = new GenericInstanceType(reference2);
                     this.ReadGenericInstanceSignature(reader,reference2, instance);
                    if (flag)
                    {
                        instance.IsValueType = true;

                    }
                    return instance;
            }
            return new TypeReference() { name = type.ToString(), @namespace = "" , netheader = this.netheader};
        }
开发者ID:Chemiculs,项目名称:AsmResolver,代码行数:94,代码来源:BlobHeap.cs

示例4: Child

 /// <summary>
 /// Retrieves the specified Child. This data member only works for Composite UI element types.
 /// This data member uses two arguments. The first is the 'type' the element, which can be 
 /// either "Button", "Icon", "Text", "CheckBox", "Page", "DataSourceContainer", or "Composite". 
 /// The second argument is the index location of the child within the composite's children array.
 /// This number will be between 1 and NumChildren.  
 /// </summary>
 /// <param name="type">type</param>
 /// <param name="index">index</param>
 /// <returns>EQ2UIElement</returns>
 public EQ2UIElement Child(ElementType type, int index)
 {
     Trace.WriteLine(String.Format("EQ2UIElement:Child({0}, {1})", type.ToString(), index.ToString(CultureInfo.InvariantCulture)));
     return new EQ2UIElement(this.GetMember("ChildType", type.ToString(), index.ToString(CultureInfo.InvariantCulture)));
 }
开发者ID:rlane187,项目名称:ISXEQ2Wrapper,代码行数:15,代码来源:EQ2UIElement.cs

示例5: RenderElementType

 /// <summary>
 /// Renders the element by the type.
 /// </summary>
 /// <param name="html">The HTML helper.</param>
 /// <param name="elementType">Type of the element.</param>
 /// <param name="name">The element name.</param>
 /// <param name="value">The element value.</param>
 /// <param name="values">The element values.</param>
 /// <returns>Returns html code by element type.</returns>
 public static String RenderElementType(HtmlHelper html, ElementType elementType, String name, String value, String values)
 {
     var elementBuilder = elementType.GetType().GetField(elementType.ToString()).GetCustomAttributes(typeof(CustomElementAttribute), true).FirstOrDefault() as CustomElementAttribute;
     return elementBuilder != null ? elementBuilder.Render(html, name, value, values) : String.Empty;
 }
开发者ID:coreframework,项目名称:Core-Framework,代码行数:14,代码来源:ElementTypeUtility.cs

示例6: UpdateElements

        private void UpdateElements(Osm update, IEnumerable<Dictionary<string, string>> data, ElementType type)
        {
            Dictionary<long, Dictionary<string, string>> dataById = data.ToDictionary(d => long.Parse(d[ID]), d => d);

            Proxy p = new Proxy();
            int page = 0;
            int pageSize = 100;
            int count = data.Count();
            while (page * pageSize < count)
            {
                //Trace.WriteLine("Page " + page.ToString() + " size " + pageSize.ToString());
                var currentPage = dataById.Keys.Skip(page * pageSize).Take(pageSize);

                Trace.WriteLine(String.Format("Getting next {0} {1}s from the API", pageSize, type));
                IEnumerable<Element> elements = null;
                #region get elements by type
                try
                {
                    switch (type)
                    {
                        case ElementType.Node:
                            elements = p.GetNodes(currentPage).Cast<Element>();
                            break;
                        case ElementType.Way:
                            elements = p.GetWays(currentPage).Cast<Element>();
                            break;
                        case ElementType.Relation:
                            elements = p.GetRelations(currentPage).Cast<Element>();
                            break;
                    }
                }
                catch (Exception ex)
                {
                    Trace.WriteLine(ex.ToString());
                    continue;
                }
                #endregion

                Update(elements, dataById, type);

                switch (type)
                {
                    case ElementType.Node:
                        var changedNodes = elements.Where(e => e.actionSpecified).Cast<Node>();
                        update.Nodes.AddRange(changedNodes);
                        break;
                    case ElementType.Way:
                        var changedWays = elements.Where(e => e.actionSpecified).Cast<Way>();
                        update.Ways.AddRange(changedWays);
                        break;
                    case ElementType.Relation:
                        var changedRelations = elements.Where(e => e.actionSpecified).Cast<Relation>();
                        update.Relations.AddRange(changedRelations);
                        break;
                    default:
                        throw new ArgumentException("Unsupported elements type: " + type.ToString());
                }

                page++;
                int done = ((page * pageSize)<count)?(page * pageSize):count;
                Trace.WriteLine(String.Format("{0} out of {1} {2}s have been processed", done, count, type));
            }
        }
开发者ID:yrtimiD,项目名称:osm-bulk-tools,代码行数:63,代码来源:TagUpdate.cs

示例7: Update

 /// <summary>
 /// Actually updates tag of elements by data in dataById
 /// </summary>
 /// <param name="elements"></param>
 /// <param name="dataById"></param>
 /// <param name="type"></param>
 private static void Update(IEnumerable<Element> elements, Dictionary<long, Dictionary<string, string>> dataById, ElementType type)
 {
     Trace.WriteLine("Updating " + type.ToString() + "s");
     Trace.Indent();
     foreach (var e in elements)
     {
         if (e.visible == false)
         {
             Trace.WriteLine("Skipping deleted " + type + ": " + e.id.ToString());
             continue;
         }
         Trace.WriteLine("ID:" + e.id);
         bool changed = UpdateTags(e.Tags, dataById[e.id]);
         if (changed)
         {
             e.action = OSM.API.v6.Action.Modify;
         }
     }
     Trace.Unindent();
 }
开发者ID:yrtimiD,项目名称:osm-bulk-tools,代码行数:26,代码来源:TagUpdate.cs


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