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


C# AttributeType类代码示例

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


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

示例1: Get

 public static string Get(AttributeType attr)
 {
     string output = "";
     switch (attr)
     {
         case AttributeType.Title:
             AssemblyTitleAttribute title = (AssemblyTitleAttribute)Attribute.GetCustomAttribute(Assembly.GetExecutingAssembly(), typeof(AssemblyTitleAttribute));
             output = title.Title;
             break;
         case AttributeType.Product:
             AssemblyProductAttribute product = (AssemblyProductAttribute)Attribute.GetCustomAttribute(Assembly.GetExecutingAssembly(), typeof(AssemblyProductAttribute));
             output = product.Product;
             break;
         case AttributeType.Description:
             AssemblyDescriptionAttribute description = (AssemblyDescriptionAttribute)Attribute.GetCustomAttribute(Assembly.GetExecutingAssembly(), typeof(AssemblyDescriptionAttribute));
             output = description.Description;
             break;
         case AttributeType.Copyright:
             AssemblyCopyrightAttribute copyright = (AssemblyCopyrightAttribute)Attribute.GetCustomAttribute(Assembly.GetExecutingAssembly(), typeof(AssemblyCopyrightAttribute));
             output = copyright.Copyright;
             break;
         case AttributeType.Company:
             AssemblyCompanyAttribute company = (AssemblyCompanyAttribute)Attribute.GetCustomAttribute(Assembly.GetExecutingAssembly(), typeof(AssemblyCompanyAttribute));
             output = company.Company;
             break;
         case AttributeType.Version:
             output = Assembly.GetExecutingAssembly().GetName().Version.ToString();
             break;
     }
     return output;
 }
开发者ID:brentmaxwell,项目名称:php-auth,代码行数:31,代码来源:AppDetails.cs

示例2: TestDefaultValue

        public void TestDefaultValue()
        {
            AttributeType type = new AttributeType("test", typeof(string));
            AttributeInfo test = new AttributeInfo("test", type);
            test.DefaultValue = "foo";
            Assert.AreEqual(test.DefaultValue, "foo");
            test.DefaultValue = null;
            Assert.AreEqual(test.DefaultValue, type.GetDefault());
            Assert.Throws<InvalidOperationException>(delegate { test.DefaultValue = 1; });

            AttributeType length2Type = new AttributeType("length2Type", typeof(int[]), 2);
            AttributeInfo length2Info = new AttributeInfo("length2", length2Type);
            Assert.AreEqual(length2Info.DefaultValue, length2Type.GetDefault());
            Assert.AreEqual(length2Info.DefaultValue, new int[] { default(int), default(int) });
            DomNodeType nodeType = new DomNodeType("testNodeType");
            nodeType.Define(length2Info);
            DomNode node = new DomNode(nodeType);
            Assert.AreEqual(node.GetAttribute(length2Info), length2Info.DefaultValue);
            node.SetAttribute(length2Info, new int[] { 1, 2 });
            Assert.AreEqual(node.GetAttribute(length2Info), new int[] { 1, 2 });
            node.SetAttribute(length2Info, new int[] { 1 });
            Assert.AreEqual(node.GetAttribute(length2Info), new int[] { 1 });

            AttributeType length1Type = new AttributeType("length1Type", typeof(int[]), 1);
            AttributeInfo length1Info = new AttributeInfo("length1", length1Type);
            Assert.AreEqual(length1Info.DefaultValue, length1Type.GetDefault());
            Assert.AreEqual(length1Info.DefaultValue, new int[] { default(int) });
            nodeType = new DomNodeType("testNodeType");
            nodeType.Define(length1Info);
            node = new DomNode(nodeType);
            Assert.AreEqual(node.GetAttribute(length1Info), length1Info.DefaultValue);
            node.SetAttribute(length1Info, new int[] { 1 });
            Assert.AreEqual(node.GetAttribute(length1Info), new int[] { 1 });
        }
开发者ID:Joxx0r,项目名称:ATF,代码行数:34,代码来源:TestAttributeInfo.cs

示例3: NtfsFileStream

        public NtfsFileStream(NtfsFileSystem fileSystem, DirectoryEntry entry, AttributeType attrType, string attrName, FileAccess access)
        {
            _entry = entry;

            _file = fileSystem.GetFile(entry.Reference);
            _baseStream = _file.OpenStream(attrType, attrName, access);
        }
开发者ID:marinehero,项目名称:ThinkAway.net,代码行数:7,代码来源:NtfsFileStream.cs

示例4: DynamicConfig

 public DynamicConfig(string key,string title, AttributeType input, object value = null)
 {
     Key = key;
     Title = title;
     Type = input;
     Value = value;
 }
开发者ID:gowhy,项目名称:LoveBank,代码行数:7,代码来源:DynamicConfig.cs

示例5: AttributeDefinition

        public AttributeDefinition(IMetaModel metaModel, XmlElement element)
        {
            this.metaModel = metaModel;

            token = element.GetAttribute("token");

            TextBuilder.SplitPrefix(token, '.', out assetTypeToken, out name);

            displayName = element.GetAttribute("displayname");
            attributeType = (AttributeType)Enum.Parse(typeof(AttributeType), element.GetAttribute("attributetype"));

            isReadonly = bool.Parse(element.GetAttribute("isreadonly"));
            isRequired = bool.Parse(element.GetAttribute("isrequired"));
            isMultivalue = bool.Parse(element.GetAttribute("ismultivalue"));

            var baseelement = element.SelectSingleNode("Base") as XmlElement;

            if (baseelement != null)
            {
                baseToken = baseelement.GetAttribute("tokenref");
            }

            var relatedelement = element.SelectSingleNode("RelatedAsset") as XmlElement;

            if (relatedelement != null)
            {
                relatedAssetToken = relatedelement.GetAttribute("nameref");
            }

            ((AssetType)AssetType).SaveAttributeDefinition(this);
        }
开发者ID:xtremeRacer,项目名称:VersionOne.SDK.NET.APIClient,代码行数:31,代码来源:AttributeDefinition.cs

示例6: Generate

 /// <summary>
 ///     Static method to return generated code for a single JSON schema with no references.
 /// </summary>
 /// <param name="schema">Location of schema file.</param>
 /// <param name="ns">The namespace.</param>
 /// <param name="type">The attribute type.</param>
 /// <returns>The generated code.</returns>
 public static string Generate(string schema, string ns = "generated", AttributeType type = AttributeType.SystemDefault)
 {
     var jsonSchemaToCodeUnit = new JsonSchemaToCodeUnit(JsonSchemaResolver.ConvertToWrapper(schema), ns, type);
     CodeCompileUnit codeUnit = jsonSchemaToCodeUnit.Execute();
     var csharpGenerator = new CodeCompileUnitToCSharp(codeUnit);
     return csharpGenerator.Execute();
 }
开发者ID:MichaelSL,项目名称:json-schema-2-poco,代码行数:14,代码来源:JsonSchemaToPoco.cs

示例7: FileIO

 public FileIO(IGraph g)
 {
     try
     {
         graph = g;
         outputnodetype = g.Model.NodeModel.GetType("grIO_OUTPUT");
         if (outputnodetype == null) throw new Exception();
         createOrOverwriteType = g.Model.EdgeModel.GetType("grIO_CreateOrOverwrite");
         if (createOrOverwriteType == null) throw new Exception();
         createOrAppendType = g.Model.EdgeModel.GetType("grIO_CreateOrAppend");
         if (createOrAppendType == null) throw new Exception();
         fileType = g.Model.NodeModel.GetType("grIO_File");
         if (fileType == null) throw new Exception();
         fileNameAttrType = fileType.GetAttributeType("path");
         if (fileNameAttrType == null) throw new Exception();
         lineType = g.Model.NodeModel.GetType("grIO_File_Line");
         if (lineType == null) throw new Exception();
         containsLineType = g.Model.EdgeModel.GetType("grIO_File_ContainsLine");
         if (containsLineType == null) throw new Exception();
         nextLineType = g.Model.EdgeModel.GetType("grIO_File_NextLine");
         if (nextLineType == null) throw new Exception();
         lineContentAttrType = lineType.GetAttributeType("content");
         if (lineContentAttrType == null) throw new Exception();
     }
     catch (Exception)
     {
         throw new Exception("Could not find the required node/edge types. Did you include the GrIO-model?");
     }
 }
开发者ID:jblomer,项目名称:GrGen.NET,代码行数:29,代码来源:FileIO.cs

示例8: ResidentAttributeRecord

 public ResidentAttributeRecord(AttributeType type, string name, ushort id, bool indexed, AttributeFlags flags)
     : base(type, name, id, flags)
 {
     _nonResidentFlag = 0;
     _indexedFlag = (byte)(indexed ? 1 : 0);
     _memoryBuffer = new SparseMemoryBuffer(1024);
 }
开发者ID:easymetadata,项目名称:DiscUtils,代码行数:7,代码来源:ResidentAttributeRecord.cs

示例9: CreateByType

 public static AttributeUpdateBase CreateByType(AttributeType type)
 {
     switch (type)
     {
         case AttributeType.Integer:
             return new AttributeUpdateInt32();
         case AttributeType.Float:
             return new AttributeUpdateFloat();
         case AttributeType.Timestamp:
             return new AttributeUpdateDateTime();
         case AttributeType.Boolean:
             return new AttributeUpdateBoolean();
         case AttributeType.Ordinal:
             return new AttributeUpdateOrdinal();
         case AttributeType.MultiBoolean:
             return new AttributeUpdateMultiBoolean();
         case AttributeType.MultiFloat:
             return new AttributeUpdateMultiFloat();
         case AttributeType.MultiInteger:
             return new AttributeUpdateMultiInt32();
         case AttributeType.MultiOrdinal:
             return new AttributeUpdateMultiOrdinal();
         case AttributeType.MultiTimestamp:
             return new AttributeUpdateMultiDateTime();
         // NOTE: Bigint (64-bit) attribute type currently is not supported by Sphinx server (0.9.9-rc2)
     }
     throw new NotSupportedException(String.Format(Messages.Exception_UnsupportedAttributeType, Enum.GetName(typeof(AttributeType), type)));
 }
开发者ID:vpuhoff,项目名称:sphinx-dotnet-client,代码行数:28,代码来源:AttributeUpdateBase.cs

示例10: CreateByType

        /// <summary>
        /// Factory method to create <see cref="AttributeValueBase"/> based class by specified <see cref="AttributeType"/> value.
        /// </summary>
        /// <param name="type">Attribute type</param>
        /// <returns><see cref="AttributeValueBase"/> based class</returns>
        public static AttributeValueBase CreateByType(AttributeType type)
        {
            switch (type)
            {
                case AttributeType.Integer:
                    return new AttributeValueInt32();
                case AttributeType.Bigint:
                    return new AttributeValueInt64();
                case AttributeType.Ordinal:
                    return new AttributeValueOrdinal();
                case AttributeType.Float:
                    return new AttributeValueFloat();
                case AttributeType.Timestamp:
                    return new AttributeValueDateTime();
                case AttributeType.Boolean:
                    return new AttributeValueBoolean();
				case AttributeType.String:
            		return new AttributeValueString();
                case AttributeType.MultiInteger:
                    return new AttributeValuesInt32();
                case AttributeType.MultiLong:
                    return new AttributeValuesInt64();
            }
            throw new NotSupportedException(String.Format(Messages.Exception_UnsupportedAttributeType, Enum.GetName(typeof(AttributeType), type)));
        }
开发者ID:ltbam,项目名称:Sphinx.Client,代码行数:30,代码来源:AttributeValueBase.cs

示例11: TestConstructor

 public void TestConstructor()
 {
     AttributeType type = new AttributeType("test", typeof(string));
     AttributeInfo test = new AttributeInfo("test", type);
     Assert.AreEqual(test.Name, "test");
     Assert.AreEqual(test.Type, type);
     Assert.AreEqual(test.DefaultValue, type.GetDefault());
 }
开发者ID:Joxx0r,项目名称:ATF,代码行数:8,代码来源:TestAttributeInfo.cs

示例12: SetEnumeratedType

        /// <summary>
        ///     Sets the attribute definition to have an enumerated value.
        /// </summary>
        /// <param name="enumValues">The possible values in the enumeration.</param>
        /// <param name="type">The type to set the attribute to.</param>
        /// <exception cref="ArgumentException">
        ///     If the type parameter is not either <see cref="AttributeType.ENUMERATION" /> or <see cref="AttributeType.NOTATION" />.
        /// </exception>
        public void SetEnumeratedType(string[] enumValues, AttributeType type) {
            if (type != AttributeType.ENUMERATION && type != AttributeType.NOTATION) {
                throw new ArgumentException(string.Format(CultureInfo.CurrentUICulture, "AttributeType {0} is not valid for an attribute definition with an enumerated value.", type));
            }

            m_enumValues = enumValues;
            m_type = type;
        }
开发者ID:roomaroo,项目名称:coapp.powershell,代码行数:16,代码来源:AttDef.cs

示例13: ListByType

 public List<OAttribute> ListByType(AttributeType attributeType)
 {
     //			var res = this._ah.Where (oa => oa.Value.AttributeType == (int)attributeType);
     //			if (res != null) {
     ////				return res.Select(oa=>oa.Value).ToList();
     //				return new List<OAttribute> ();
     //			} else
         return new List<OAttribute> ();
 }
开发者ID:GSazheniuk,项目名称:HOO,代码行数:9,代码来源:Attributes.cs

示例14: GetAttribute

 public Attribute GetAttribute(AttributeType targetAttribute)
 {
     if (!attributes.ContainsKey(targetAttribute))
     {
         Debug.Log("Can't found any attribute of type: " + targetAttribute, this);
         return null;
     }
     return attributes[targetAttribute];
 }
开发者ID:tryonn,项目名称:GameStartUP,代码行数:9,代码来源:AttributePool.cs

示例15: Read

 internal void Read(byte[] buffer, int offset)
 {
     Name = Encoding.Unicode.GetString(buffer, offset + 0, 128).Trim('\0');
     Type = (AttributeType)Utilities.ToUInt32LittleEndian(buffer, offset + 0x80);
     DisplayRule = Utilities.ToUInt32LittleEndian(buffer, offset + 0x84);
     CollationRule = (AttributeCollationRule)Utilities.ToUInt32LittleEndian(buffer, offset + 0x88);
     Flags = (AttributeTypeFlags)Utilities.ToUInt32LittleEndian(buffer, offset + 0x8C);
     MinSize = Utilities.ToInt64LittleEndian(buffer, offset + 0x90);
     MaxSize = Utilities.ToInt64LittleEndian(buffer, offset + 0x98);
 }
开发者ID:alexcmd,项目名称:DiscUtils,代码行数:10,代码来源:AttributeDefinitionRecord.cs


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