本文整理汇总了C#中AttributeType类的典型用法代码示例。如果您正苦于以下问题:C# AttributeType类的具体用法?C# AttributeType怎么用?C# AttributeType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AttributeType类属于命名空间,在下文中一共展示了AttributeType类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: Attribute
public string value_string { get; set; } //value of the attribute. only needed if type is string
/**
* Note: if t = STRING => lb and ub are excluded automatically
*/
public Attribute(String name, AttributeType t, int lb, int ub)
{
this.Name = name;
this.type = t;
if (t != AttributeType.STRING)
{
this.upperbound = ub;
this.lowerbound = lb;
}
}
开发者ID:ciavy,项目名称:ProjectONE,代码行数:15,代码来源:Attribute.cs
示例17: RegisterAttribute
internal void RegisterAttribute(Type fieldType, string attrName, AttributeType type)
{
Dictionary<string, AttributeType> fieldsForType;
if (!_registry.TryGetValue(fieldType, out fieldsForType))
{
fieldsForType = new Dictionary<string, AttributeType>();
_registry.Add(fieldType, fieldsForType);
}
fieldsForType.Add(attrName, type);
}
开发者ID:thawk,项目名称:structorian,代码行数:10,代码来源:AttributeRegistry.cs
示例18: Attribute
/// <summary>Create a new Attribute.</summary>
public Attribute(AttributeType type, MemBlock value)
{
Type = type;
Value = value;
byte[] data = new byte[4 + value.Length];
NumberSerializer.WriteUShort((ushort) type, data, 0);
NumberSerializer.WriteUShort((ushort) value.Length, data, 2);
value.CopyTo(data, 4);
Data = MemBlock.Reference(data);
}
开发者ID:pstjuste,项目名称:brunet,代码行数:11,代码来源:Stun.cs
示例19: SetUp
public void SetUp()
{
var assemblies = new[]
{
typeof(Umbraco.Tests.Extensions.TestDynamicExtensions).Assembly
};
var supportedDynamicTypes = new[]
{
typeof(Content),
typeof(BendyObject)
};
var supportedDynamicFieldTypes = new[]
{
typeof(Content),
typeof(TypedAttribute),
typeof(BendyObject)
};
var bendyMethods = DynamicExtensionsHelper.GetExtensions(assemblies, supportedDynamicTypes);
var subBendyMethods = DynamicExtensionsHelper.GetExtensions<DynamicFieldExtensionAttribute>(assemblies, supportedDynamicFieldTypes);
var bendy = new BendyObject();
BendyObjectExtensionsHelper.ApplyDynamicExtensions<Content>(bendy, bendyMethods);
var content = new Content();
_bendy = bendy;
_bendy["__OriginalItem"] = content;
var attrType1 = new AttributeType {RenderTypeProvider = CorePluginConstants.FileUploadPropertyEditorId};
var attrDef1 = new AttributeDefinition {AttributeType = attrType1};
var attr1 = new TypedAttribute(attrDef1);
var subBendy1 = new BendyObject();
subBendy1["__OriginalItem"] = attr1;
subBendy1.AddLazy("__Parent", () => bendy);
subBendy1["__ParentKey"] = "Test";
BendyObjectExtensionsHelper.ApplyDynamicFieldExtensions(content, CorePluginConstants.FileUploadPropertyEditorId, subBendy1, subBendyMethods);
_bendy["Test"] = subBendy1;
var attrType2 = new AttributeType { RenderTypeProvider = CorePluginConstants.TreeNodePickerPropertyEditorId };
var attrDef2 = new AttributeDefinition { AttributeType = attrType2 };
var attr2 = new TypedAttribute(attrDef2);
var subBendy2 = new BendyObject();
subBendy2["__OriginalItem"] = attr2;
subBendy2.AddLazy("__Parent", () => bendy);
subBendy2["__ParentKey"] = "Test2";
BendyObjectExtensionsHelper.ApplyDynamicFieldExtensions(content, CorePluginConstants.TreeNodePickerPropertyEditorId, subBendy2, subBendyMethods);
_bendy["Test2"] = subBendy2;
}
开发者ID:paulsuart,项目名称:rebelcmsxu5,代码行数:55,代码来源:BendyObjectExtensionsHelperTests.cs
示例20: TestEquality
public void TestEquality()
{
var attrType1 = new AttributeType("xkcd", typeof(string));
var attrInfo1 = new AttributeInfo("xkcd", attrType1);
var domNodeType = new DomNodeType("WebComic", DomNodeType.BaseOfAllTypes);
var childInfo1 = new ChildInfo("xkcd", domNodeType);
attrInfo1.DefaultValue = "Firefly";
var desc1 = new ChildAttributePropertyDescriptor(
"xkcd", attrInfo1, childInfo1, "Category 1", "A commonly used word or phrase in the xkcd comic", true);
int originalHashCode = desc1.GetHashCode();
// test if two identically created property descriptors compare as being equal
var desc2 = new ChildAttributePropertyDescriptor(
"xkcd", attrInfo1, childInfo1, "Category 1", "A commonly used word or phrase in the xkcd comic", true);
Assert.AreEqual(desc1, desc2);
Assert.AreEqual(desc1.GetHashCode(), desc2.GetHashCode());
// test category being different; oddly, although I think they should not be considered equal,
// the .Net PropertyDescriptor ignores the difference in category name. So, I'm guessing that
// the AttributePropertyDescriptor should behave the same as PropertyDescriptor.
var desc3 = new ChildAttributePropertyDescriptor(
"xkcd", attrInfo1, childInfo1, "Category 2", "A commonly used word or phrase in the xkcd comic", true);
Assert.AreEqual(desc1, desc3);
Assert.AreEqual(desc1.GetHashCode(), desc3.GetHashCode());
// test description being different; similarly here, the .Net PropertyDescriptor doesn't care.
var desc4 = new ChildAttributePropertyDescriptor(
"xkcd", attrInfo1, childInfo1, "Category 1", "slightly different description", true);
Assert.AreEqual(desc1, desc4);
Assert.AreEqual(desc1.GetHashCode(), desc4.GetHashCode());
// test readOnly being different; ditto for read-only flag!
var desc5 = new ChildAttributePropertyDescriptor(
"xkcd", attrInfo1, childInfo1, "Category 1", "A commonly used word or phrase in the xkcd comic", false);
Assert.AreEqual(desc1, desc5);
Assert.AreEqual(desc1.GetHashCode(), desc5.GetHashCode());
// test that the hash code hasn't changed after using the AttributeInfo
var attrInfo2 = new AttributeInfo("xkcd", attrType1);
domNodeType.Define(attrInfo2);
Assert.AreEqual(desc1.GetHashCode(), originalHashCode);
// test that the hash code hasn't changed after creating a derived DomNodeType
var derivedDomNodeType = new DomNodeType("ScientificWebComic", domNodeType);
var derivedAttrInfo = new AttributeInfo("xkcd", attrType1);
var derivedChildInfo = new ChildInfo("xkcd", derivedDomNodeType);
derivedDomNodeType.Define(derivedAttrInfo);
Assert.AreEqual(desc1.GetHashCode(), originalHashCode);
// test that an AttributeInfo used in a derived DomNodeType doesn't change equality or hash code
var desc6 = new ChildAttributePropertyDescriptor(
"xkcd", derivedAttrInfo, derivedChildInfo, "Category 1", "A commonly used word or phrase in the xkcd comic", true);
Assert.AreEqual(desc1, desc6);
Assert.AreEqual(desc1.GetHashCode(), desc6.GetHashCode());
}
开发者ID:Joxx0r,项目名称:ATF,代码行数:55,代码来源:TestChildAttributePropertyDescriptor.cs
注:本文中的AttributeType类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论