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


C# ISchemaElement.GetType方法代码示例

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


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

示例1: SetAttributeOnObject

 /// <summary>
 /// Sets an attribute on an ISchemaElement.
 /// </summary>
 /// <param name="schemaElement">Schema element to set attribute on.</param>
 /// <param name="name">Name of the attribute to set.</param>
 /// <param name="value">Value to set on the attribute.</param>
 private void SetAttributeOnObject(ISchemaElement schemaElement, string name, string value)
 {
     ISetAttributes setAttributes = schemaElement as ISetAttributes;
     if (setAttributes == null)
     {
         throw new InvalidOperationException("ISchemaElement with name "
             + schemaElement.GetType().FullName.ToString()
             + " does not implement ISetAttributes.");
     }
     else
     {
         setAttributes.SetAttribute(name, value);
     }
 }
开发者ID:Jeremiahf,项目名称:wix3,代码行数:20,代码来源:CodeDomReader.cs

示例2: RemoveElement

            /// <summary>
            /// Removes an element from this collection.
            /// </summary>
            /// <param name="element">The element to remove.</param>
            /// <exception cref="ArgumentException">Thrown if the element's type isn't assignable to the collection's type.</exception>
            public void RemoveElement(ISchemaElement element)
            {
                if (!this.elementType.IsAssignableFrom(element.GetType()))
                {
                    throw new ArgumentException(
                        String.Format(
                            CultureInfo.InvariantCulture,
                            WixStrings.EXP_ElementIsSubclassOfDifferentType,
                            this.elementType.Name,
                            element.GetType().Name),
                        "element");
                }

                this.elements.Remove(element);
            }
开发者ID:Jeremiahf,项目名称:wix3,代码行数:20,代码来源:ElementCollection.cs

示例3: RemoveElement

            /// <summary>
            /// Removes an element from this collection.
            /// </summary>
            /// <param name="element">The element to remove.</param>
            /// <exception cref="ArgumentException">Thrown if the element's type isn't assignable to the collection's type.</exception>
            public void RemoveElement(ISchemaElement element)
            {
                if (!this.elementType.IsAssignableFrom(element.GetType()))
                {
                    throw new ArgumentException(
                        String.Format(
                            CultureInfo.InvariantCulture,
                            "Element must be a subclass of {0}, but was of type {1}.",
                            this.elementType.Name,
                            element.GetType().Name),
                        "element");
                }

                this.elements.Remove(element);
            }
开发者ID:sillsdev,项目名称:FwSupportTools,代码行数:20,代码来源:ElementCollection.cs

示例4: AddElement

        /// <summary>
        /// Adds a child element to this collection.
        /// </summary>
        /// <param name="element">The element to add.</param>
        /// <exception cref="ArgumentException">Thrown if the child is not of an allowed type.</exception>
        public void AddElement(ISchemaElement element)
        {
            foreach (object obj in this.items)
            {
                bool containerUsed;

                CollectionItem collectionItem = obj as CollectionItem;
                if (collectionItem != null)
                {
                    containerUsed = collectionItem.Elements.Count != 0;
                    if (collectionItem.ElementType.IsAssignableFrom(element.GetType()))
                    {
                        collectionItem.AddElement(element);

                        if (!containerUsed)
                        {
                            this.containersUsed++;
                        }

                        this.totalContainedItems++;
                        return;
                    }

                    continue;
                }

                ElementCollection collection = obj as ElementCollection;
                if (collection != null)
                {
                    containerUsed = collection.Count != 0;

                    try
                    {
                        collection.AddElement(element);

                        if (!containerUsed)
                        {
                            this.containersUsed++;
                        }

                        this.totalContainedItems++;
                        return;
                    }
                    catch (ArgumentException)
                    {
                        // Eat the exception and keep looking. We'll throw our own if we can't find its home.
                    }

                    continue;
                }
            }

            throw new ArgumentException(String.Format(
                CultureInfo.InvariantCulture,
                "Element of type {0} is not valid for this collection.",
                element.GetType().Name));
        }
开发者ID:sillsdev,项目名称:FwSupportTools,代码行数:62,代码来源:ElementCollection.cs

示例5: SetAttributeOnObject

 private static void SetAttributeOnObject(ISchemaElement schemaElement, string name, string value)
 {
     ISetAttributes setAttributes = schemaElement as ISetAttributes;
     if (setAttributes == null)
     {
         throw new InvalidOperationException(String.Format(CultureInfo.CurrentUICulture, WixStrings.EXP_ISchemaElementDoesnotImplementISetAttribute, schemaElement.GetType().FullName));
     }
     else
     {
         setAttributes.SetAttribute(name, value);
     }
 }
开发者ID:Jeremiahf,项目名称:wix3,代码行数:12,代码来源:CodeDomReader.cs


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