本文整理汇总了C#中System.Attribute方法的典型用法代码示例。如果您正苦于以下问题:C# System.Attribute方法的具体用法?C# System.Attribute怎么用?C# System.Attribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System
的用法示例。
在下文中一共展示了System.Attribute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ToPhysical
public System.Xml.Linq.XElement ToPhysical(System.Xml.Linq.XElement udsService)
{
string name = udsService.Attribute("Name").Value;
XElement x = new XElement("Service", new XAttribute("Name", name));
XElement prop = new XElement("Property", new XAttribute("Name", "Definition"));
x.Add(prop);
XElement serv = new XElement("Service");
prop.Add(serv);
XElement sd = new XElement("ServiceDescription");
serv.Add(sd);
XElement handler = new XElement("Handler", new XAttribute("ExecType", "RemoteComponent"));
sd.Add(handler);
XElement udsDefinition = udsService.Element("Definition");
foreach (XElement e in udsDefinition.Elements())
sd.Add(e);
XElement usage = new XElement("Usage");
sd.Add(usage);
XElement sh = new XElement("ServiceHelp");
sh.Add(new XElement("Description"));
sh.Add(new XElement("RequestSDDL"));
sh.Add(new XElement("ResponseSDDL"));
sh.Add(new XElement("Errors"));
sh.Add(new XElement("RelatedDocumentServices"));
sh.Add(new XElement("Samples"));
serv.Add(sh);
return x;
}
示例2: WriteFixedWidth
public void WriteFixedWidth(System.Xml.Linq.XElement CommandNode, DataTable Table, Stream outputStream)
{
StreamWriter Output = new StreamWriter(outputStream);
int StartAt = CommandNode.Attribute("StartAt") != null ? int.Parse(CommandNode.Attribute("StartAt").Value) : 0;
var positions = from c in CommandNode.Descendants("Position")
orderby int.Parse(c.Attribute("Start").Value) ascending
select new
{
Name = c.Attribute("Name").Value,
Start = int.Parse(c.Attribute("Start").Value) - StartAt,
Length = int.Parse(c.Attribute("Length").Value),
Justification = c.Attribute("Justification") != null ? c.Attribute("Justification").Value.ToLower() : "left"
};
int lineLength = positions.Last().Start + positions.Last().Length;
foreach (DataRow row in Table.Rows)
{
StringBuilder line = new StringBuilder(lineLength);
foreach (var p in positions)
line.Insert(p.Start,
p.Justification == "left" ? (row.Field<string>(p.Name) ?? "").PadRight(p.Length, ' ')
: (row.Field<string>(p.Name) ?? "").PadLeft(p.Length, ' ')
);
Output.WriteLine(line.ToString());
}
Output.Flush();
}
示例3: FromXml
public static ColorInfo FromXml(System.Xml.Linq.XElement el)
{
var c = new ColorInfo();
c.Category = el.Attribute("Category").Value;
c.Name= el.Attribute("Name").Value;
c.rgb = int.Parse(el.Attribute("RGB").Value.Substring(1),System.Globalization.NumberStyles.HexNumber);
return c;
}
示例4: GetFileAsync
public override async Task<DriveFile> GetFileAsync(System.Xml.Linq.XElement xml, CancellationToken token)
{
var file = new MockDriveFile(this,
xml.Attribute("name").Value,
bool.Parse(xml.Attribute("isFolder").Value),
bool.Parse(xml.Attribute("isImage").Value),
bool.Parse(xml.Attribute("isRoot").Value));
return file;
}
示例5: AddTypeElement
public bool AddTypeElement(System.Xml.Linq.XElement elemtype)
{
XAttribute colorRedAtt = elemtype.Attribute("red");
if (colorRedAtt == null)
{
//Add error message here
color = default(Color);
return false;
}
XAttribute colorGreenAtt = elemtype.Attribute("green");
if (colorGreenAtt == null)
{
//Add error message here
color = default(Color);
return false;
}
XAttribute colorBlueAtt = elemtype.Attribute("blue");
if (colorBlueAtt == null)
{
//Add error message here
color = default(Color);
return false;
}
int alpha = 255;
XAttribute colorAlphaAtt = elemtype.Attribute("metal");
if (colorAlphaAtt != null)
{
switch (colorAlphaAtt.Value)
{
case "yes":
alpha = 0;
break;
case "no":
alpha = 255;
break;
default:
if (!int.TryParse(colorAlphaAtt.Value, out alpha))
alpha = 255;
break;
}
}
int red, green, blue;
int.TryParse(colorRedAtt.Value, out red);
int.TryParse(colorGreenAtt.Value, out green);
int.TryParse(colorBlueAtt.Value, out blue);
color = new Color(red / 255.0f, green / 255.0f, blue / 255.0f, alpha / 255.0f);
// LINEAR
//if (PlayerSettings.colorSpace == ColorSpace.Linear)
{
color = color.linear;
}
UniqueIndex = num_created;
num_created++;
return true;
}
示例6: Location
public Location(System.Xml.Linq.XElement data)
{
this.RealName = data.Attribute("RealName").Value;
this.Latitude = data.Attribute("Latitude").Value;
this.Longtitude = data.Attribute("Longtitude").Value;
this.LocationType = (TransportType)Enum.Parse(typeof(TransportType), data.Attribute("LocationType").Value);
foreach (var x in data.Elements("Alias"))
{
this.aliases.Add(x.Value);
}
}
示例7: FromXmlElement
public static PidProfile FromXmlElement(System.Xml.Linq.XElement pidProfileElement)
{
var profile = new PidProfile()
{
DirectionProfile = (DirectionProfile)Enum.Parse(typeof(DirectionProfile), pidProfileElement.Attribute("Direction").Value),
ProportionalGain = pidProfileElement.Attribute("ProportionalGain").ParseDouble(),
IntegralGain = pidProfileElement.Attribute("IntegralGain").ParseDouble(),
DerivativeGain = pidProfileElement.Attribute("DerivativeGain").ParseDouble(),
};
return profile;
}
示例8: draw
public override void draw(System.Xml.Linq.XElement e, System.Windows.Controls.Canvas c)
{
if (e.Attribute("color") != null)
{
String col = e.Attribute("color").Value;
Console.WriteLine("BGCOL : " + col);
Rectangle rect = new Rectangle();
rect.Height = cHeight;//HARD CODED BUG
rect.Width = cWidth;
rect.Fill = new SolidColorBrush(ColorParser.parse(col));
addToCanvas(e, rect, c);
}
}
示例9: ParseDefinition
public override bool ParseDefinition(System.Xml.Linq.XElement element)
{
bool result = this.parse(element);
Tag = element.Attribute("Tag").Value;
return result;
}
示例10: AddTypeElement
public bool AddTypeElement(System.Xml.Linq.XElement elemtype)
{
if (store == null) //nowhere to put the image.
{
Debug.LogError("Texture Storage is Null: " + elemtype);
return false;
}
XAttribute fileAtt = elemtype.Attribute("file");
if (fileAtt == null)
{
Debug.LogError("No file attribute in " + elemtype);
//Add error message here
return false;
}
string filePath = Path.Combine(Path.GetDirectoryName(new Uri(elemtype.BaseUri).LocalPath), fileAtt.Value);
filePath = Path.GetFullPath(filePath);
if (!File.Exists(filePath))
{
Debug.LogError("File not found: " + filePath);
return false;
}
byte[] fileData = File.ReadAllBytes(filePath);
Texture2D tex = new Texture2D(2,2);
tex.LoadImage(fileData);
tex.name = filePath;
storageIndex = store.AddTexture(tex);
return true;
}
示例11: AddTypeElement
public bool AddTypeElement(System.Xml.Linq.XElement elemtype)
{
XAttribute fileAtt = elemtype.Attribute("file");
if (fileAtt == null)
{
//Add error message here
return false;
}
string filePath = Path.Combine(Path.GetDirectoryName(new Uri(elemtype.BaseUri).LocalPath), fileAtt.Value);
filePath = Path.GetFullPath(filePath);
// Load the OBJ in
var lStream = new FileStream(filePath, FileMode.Open);
var lOBJData = OBJLoader.LoadOBJ(lStream);
lStream.Close();
meshData = new MeshData[(int)MeshLayer.Count];
Mesh tempMesh = new Mesh();
for (int i = 0; i < meshData.Length; i++)
{
tempMesh.LoadOBJ(lOBJData, ((MeshLayer)i).ToString());
meshData[i] = new MeshData(tempMesh);
tempMesh.Clear();
}
lStream = null;
lOBJData = null;
return true;
}
示例12: FromXmlElement
public static TiltControllerSettings FromXmlElement(System.Xml.Linq.XElement angleControllerElement)
{
var cwProfileElement = angleControllerElement.Elements("PidProfile").Single(x => x.Attribute("Direction").Value == DirectionProfile.CW.ToString());
var settings = new TiltControllerSettings()
{
IsEnabled = angleControllerElement.Attribute("IsEnabled").ParseOptionalBoolean(),
MotorDriver = (MotorDriver)Enum.Parse(typeof(MotorDriver), angleControllerElement.Attribute("MotorDriver").Value),
IntegralWindupThreshold = angleControllerElement.Attribute("IntegralWindupThreshold").ParseDouble(),
OutputRateLimit = angleControllerElement.Attribute("OutputRateLimit").ParseInt(),
PidProfiles = new Dictionary<DirectionProfile, PidProfile>
{
{DirectionProfile.CW, PidProfile.FromXmlElement(cwProfileElement) }
},
};
return settings;
}
示例13: AddTypeElement
public bool AddTypeElement(System.Xml.Linq.XElement elemtype)
{
XAttribute indexAtt = elemtype.Attribute("index");
if (indexAtt == null)
{
//Add error message here
value = default(int);
return false;
}
return int.TryParse(indexAtt.Value, out value);
}
示例14: ListItem
//<tcm:Item ID="tcm:17-384-64" Title="Some Page Title" Type="64" OrgItemID="tcm:17-107-4" Path="\040 Web Publication\Root\030 - Work" Icon="T64L1P0" Publication="040 Web Publication"></tcm:Item>
public ListItem(System.Xml.Linq.XElement node)
{
TcmId = node.Attribute("ID").SafeStringVal();
Title = node.Attribute("Title").SafeStringVal();
ItemTypeId = node.Attribute("Type").SafeStringVal();
WebDavPath = node.Attribute("Path").SafeStringVal();
Icon = node.Attribute("Icon").SafeStringVal();
ParentTcmId = node.Attribute("OrgItemID").SafeStringVal();
PublicationTitle = node.Attribute("Publication").SafeStringVal();
ItemTypeName = EnumHelper<Tridion.ContentManager.CoreService.Client.ItemType>.Parse(ItemTypeId, true);
}
示例15: From_XML
public virtual void From_XML(System.Xml.Linq.XElement xml)
{
Source_Startup_Policy = Libvirt.Models.Concrete.Disk.Source_Startup_Policies.mandatory;
if (xml != null)
{
var attr = xml.Attribute("startupPolicy");
if (attr != null)
{
var b = Libvirt.Models.Concrete.Disk.Source_Startup_Policies.mandatory;
Enum.TryParse(attr.Value, true, out b);
Source_Startup_Policy = b;
}
}
}