本文整理汇总了C#中Tag.Add方法的典型用法代码示例。如果您正苦于以下问题:C# Tag.Add方法的具体用法?C# Tag.Add怎么用?C# Tag.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tag
的用法示例。
在下文中一共展示了Tag.Add方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddNode
private void AddNode(Tag parent,string name,Node node)
{
if (node.Value==null) return;
switch (((IList<Type>)supported).IndexOf(node.Value.GetType())) {
case 8:
List<Node> l = (List<Node>)node.Value;
Tag list;
if (name==null) list = parent.AddList(ListType(l));
else list = parent.AddList(name,ListType(l));
foreach (Node n in l) AddNode(list,n);
break;
case 9:
Dictionary<string,Node> dict = (Dictionary<string,Node>)node.Value;
Tag compound;
if (name==null) compound = parent.AddCompound();
else compound = parent.AddCompound(name);
foreach (KeyValuePair<string,Node> kvp in dict)
AddNode(compound,kvp.Key,kvp.Value);
break;
default:
if (name==null) parent.Add(node.Value);
else parent.Add(name, node.Value);
break;
}
}
示例2: Read
public Tag Read(Stream apeStream)
{
Tag tag = new Tag();
//Check wether the file contains an APE tag--------------------------------
apeStream.Seek( apeStream.Length - 32 , SeekOrigin.Begin);
byte[] b = new byte[8];
apeStream.Read(b, 0, b.Length);
string tagS = new string( System.Text.Encoding.ASCII.GetChars(b) );
if(tagS != "APETAGEX" ){
throw new CannotReadException("There is no APE Tag in this file");
}
//Parse the tag -)------------------------------------------------
//Version
b = new byte[4];
apeStream.Read( b , 0, b .Length);
int version = Utils.GetNumber(b, 0,3);
if(version != 2000) {
throw new CannotReadException("APE Tag other than version 2.0 are not supported");
}
//Size
b = new byte[4];
apeStream.Read( b , 0, b .Length);
long tagSize = Utils.GetLongNumber(b, 0,3);
//Number of items
b = new byte[4];
apeStream.Read( b , 0, b .Length);
int itemNumber = Utils.GetNumber(b, 0,3);
//Tag Flags
b = new byte[4];
apeStream.Read( b , 0, b .Length);
//TODO handle these
apeStream.Seek(apeStream.Length - tagSize, SeekOrigin.Begin);
for(int i = 0; i<itemNumber; i++) {
//Content length
b = new byte[4];
apeStream.Read( b , 0, b .Length);
int contentLength = Utils.GetNumber(b, 0,3);
if(contentLength > 500000)
throw new CannotReadException("Item size is much too large: "+contentLength+" bytes");
//Item flags
b = new byte[4];
apeStream.Read( b , 0, b .Length);
//TODO handle these
bool binary = ((b[0]&0x06) >> 1) == 1;
int j = 0;
while(apeStream.ReadByte() != 0)
j++;
apeStream.Seek(apeStream.Position - j -1, SeekOrigin.Begin);
int fieldSize = j;
//Read Item key
b = new byte[fieldSize];
apeStream.Read( b , 0, b .Length);
apeStream.Seek(1, SeekOrigin.Current);
string field = new string(System.Text.Encoding.GetEncoding("ISO-8859-1").GetChars(b));
//Read Item content
b = new byte[contentLength];
apeStream.Read( b , 0, b .Length);
if(!binary) {
string content = Encoding.UTF8.GetString(b);
switch (field) {
case "Track":
string num, count;
Utils.SplitTrackNumber(content, out num, out count);
if (num != null)
tag.AddTrack(num);
if (count != null)
tag.AddTrackCount(count);
break;
default:
tag.Add(field, content);
break;
}
} //else FIXME
// tag.Add(new ApeTagBinaryField(field, b));
}
return tag;
}
示例3: OnOK
/// <summary>
/// Called when someone clicks OK.
/// </summary>
/// <param name="sender">Sending object.</param>
/// <param name="args">Event arguments.</param>
protected override void OnOK(object sender, EventArgs args)
{
Assert.ArgumentNotNull(sender, "sender");
Assert.ArgumentNotNull(args, "args");
var str = this.Filename.Value;
if (str.Length == 0)
{
SheerResponse.Alert("Select a media item.", new string[0]);
}
else
{
var root = this.DataContext.GetRoot();
if (root != null)
{
var rootItem = root.Database.GetRootItem();
if ((rootItem != null) && (root.ID != rootItem.ID))
{
str = FileUtil.MakePath(root.Paths.Path, str, '/');
}
}
MediaItem item = this.DataContext.GetItem(str);
if (item == null)
{
SheerResponse.Alert("The media item could not be found.", new string[0]);
}
else if (!(MediaManager.GetMedia(MediaUri.Parse(item)) is ImageMedia))
{
SheerResponse.Alert("The selected item is not an image. Select an image to continue.", new string[0]);
}
else
{
var options = new MediaUrlOptions { UseItemPath = false, AbsolutePath = false };
var text = !string.IsNullOrEmpty(HttpContext.Current.Request.Form["AlternateText"]) ? HttpContext.Current.Request.Form["AlternateText"] : item.Alt;
var desc = !string.IsNullOrEmpty(HttpContext.Current.Request.Form["Description"]) ? HttpContext.Current.Request.Form["Description"] : item.Description;
var image = new Tag("img");
// Use reflection to access the private method to set the image's dimensions
// ReSharper disable PossibleNullReferenceException
var dynMethod = this.GetType().BaseType.GetMethod("SetDimensions", BindingFlags.NonPublic | BindingFlags.Instance);
// ReSharper restore PossibleNullReferenceException
dynMethod.Invoke(this, new object[] { item, options, image });
image.Add("Src", MediaManager.GetMediaUrl(item, options));
image.Add("Alt", StringUtil.EscapeQuote(text));
image.Add("longdesc", StringUtil.EscapeQuote(desc));
if (this.Mode == "webedit")
{
SheerResponse.SetDialogValue(StringUtil.EscapeJavascriptString(image.ToString()));
base.OnOK(sender, args);
}
else
{
SheerResponse.Eval("scClose(" + StringUtil.EscapeJavascriptString(image.ToString()) + ")");
}
}
}
this.StoreLastAccessedMediaLibraryItem();
}
示例4: CreateFieldTag
/// <summary>Creates the field tag.</summary>
/// <param name="tagName">Name of the tag.</param>
/// <param name="args">The arguments.</param>
/// <param name="controlID"> </param>
/// <returns>The field tag.</returns>
private static Tag CreateFieldTag(string tagName, RenderFieldArgs args, string controlID)
{
Assert.ArgumentNotNull((object)tagName, "tagName");
Assert.ArgumentNotNull((object)args, "args");
Tag tag = new Tag(tagName)
{
ID = controlID + "_edit"
};
tag.Add("scFieldType", args.FieldTypeKey);
return tag;
}
示例5: AddParameters
/// <summary>Adds the parameters.</summary>
/// <param name="tag">The tag.</param>
/// <param name="args">The arguments.</param>
private void AddParameters(Tag tag, RenderFieldArgs args)
{
Assert.ArgumentNotNull((object)tag, "tag");
Assert.ArgumentNotNull((object)args, "args");
if (args.WebEditParameters.Count <= 0)
return;
UrlString urlString = new UrlString();
foreach (KeyValuePair<string, string> webEditParameter in (SafeDictionary<string, string>)args.WebEditParameters)
urlString.Add(webEditParameter.Key, webEditParameter.Value);
tag.Add("sc_parameters", urlString.ToString());
}
示例6: RenderWrapperlessField
/// <summary>Renders the field without a wrapper.</summary>
/// <param name="output">The output.</param>
/// <param name="args">The arguments.</param>
/// <param name="field"> </param>
/// <param name="controlID"> </param>
private void RenderWrapperlessField(HtmlTextWriter output, RenderFieldArgs args, Field field, string controlID)
{
Assert.ArgumentNotNull((object)output, "output");
Assert.ArgumentNotNull((object)args, "args");
Assert.ArgumentNotNull((object)controlID, "controlID");
Tag fieldTag = CreateFieldTag("code", args, controlID);
fieldTag.Class = "scpm";
fieldTag.Add("kind", "open").Add("type", "text/sitecore").Add("chromeType", "field");
string str = args.Result.FirstPart;
if (string.IsNullOrEmpty(str))
{
fieldTag.Add("scWatermark", "true");
string defaultText = GetDefaultText(args);
str = defaultText;
if (StringUtil.RemoveTags(defaultText) == defaultText)
str = "<span class='scTextWrapper'>" + defaultText + "</span>";
}
this.AddParameters(fieldTag, args);
string fieldData =GetFieldData(args, field, controlID);
fieldTag.InnerHtml = fieldData;
output.Write(fieldTag.ToString());
output.Write(str);
args.Result.FirstPart = output.InnerWriter.ToString();
Tag tag = new Tag("code")
{
Class = "scpm"
};
tag.Add("kind", "close").Add("type", "text/sitecore").Add("chromeType", "field");
args.Result.LastPart += tag.ToString();
}