本文整理汇总了C#中System.Xml.Linq.XElement.StrAttr方法的典型用法代码示例。如果您正苦于以下问题:C# XElement.StrAttr方法的具体用法?C# XElement.StrAttr怎么用?C# XElement.StrAttr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.Linq.XElement
的用法示例。
在下文中一共展示了XElement.StrAttr方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Load
/// <summary>
/// Load properties from xml
/// </summary>
/// <param name="element">The XElement object.</param>
/// <param name="locale">The locale name.</param>
public override void Load(XElement element, string locale = "")
{
base.Load(element, locale);
this.FieldType = 7;
//this.DefaultValue = element.StrAttr(DEFAULT);
this.ListName = element.StrAttr("list");
this.ViewName = element.StrAttr("view");
this.FieldName = element.StrAttr("rel");
}
示例2: ViewFileTemplate
/// <summary>
/// Initializes a new instance of the ViewFileTemplate class.
/// </summary>
/// <param name="element">The template data xml file.</param>
public ViewFileTemplate(XElement element)
{
this.Title = element.Element("title") != null ? element.Element("title").Value : element.Value;
this.Description = element.Element("desc") != null ? element.Element("desc").Value : "";
this.Name = element.StrAttr("name");
this.Icon = element.StrAttr("icon");
if (element.Element("title") != null)
this.ResKey = element.Element("title").StrAttr("resKey");
if (element.Element("desc") != null)
this.DescResKey = element.Element("desc").StrAttr("resKey");
}
示例3: Load
/// <summary>
/// Overrided. Load properties from xml.
/// </summary>
/// <param name="element">The XElement object.</param>
/// <param name="locale">The locale name.</param>
public override void Load(XElement element, string locale = "")
{
base.Load(element, locale);
this.FieldType = 1;
//if (this.DefaultValue != null && !string.IsNullOrEmpty(this.DefaultValue.ToString()))
this.DefaultValue = element.StrAttr(DEFAULT);
//if (MinLength > 0)
this.MinLength = element.IntAttr(MIN_LEN);
//if (MaxLength > 0)
this.MaxLength = element.IntAttr(MAX_LEN);
}
示例4: Load
/// <summary>
/// Overrided. Load properties from xml.
/// </summary>
/// <param name="element">The XElement object.</param>
/// <param name="locale">The local name.</param>
public override void Load(XElement element, string locale = "")
{
base.Load(element, locale);
this.FieldType = (int)ContentFieldTypes.Video;
this.DefaultValue = element.StrAttr(DEFAULT);
this.Width = element.IntAttr(WIDTH);
this.Height = element.IntAttr(HEIGHT);
this.ThumbnailWidth = element.IntAttr("thumbWidth");
this.ThumbnailHeight = element.IntAttr("thumbHeight");
}
示例5: Load
/// <summary>
/// Load properties from xml.
/// </summary>
/// <param name="element">The XElement object</param>
/// <param name="locale">The locale name.</param>
public void Load(XElement element, string locale = "")
{
var _id = element.StrAttr(DataNames.ID);
var ns = element.GetDefaultNamespace();
if (!string.IsNullOrEmpty(_id))
{
Guid gid = Guid.Empty;
if (Guid.TryParse(_id, out gid))
ID = gid;
}
if (this.ID == Guid.Empty || this.ID == null)
this.ID = Guid.NewGuid();
Privacy = element.IntAttr(DataNames.Privacy);
Created = element.DateAttr(DataNames.Created);
if (Created == DateTime.MinValue)
Created = DateTime.Now;
IsPublished = element.BoolAttr(DataNames.IsPublished);
if (IsPublished)
{
Published = element.DateAttr(DataNames.Published);
if (Published == DateTime.MinValue)
Published = DateTime.Now;
}
ModerateState = element.IntAttr(DataNames.State);
EnableComments = element.BoolAttr(DataNames.EnableComments);
Tags = element.StrAttr(DataNames.Tags);
//Categories = element.StrAttr(DataNames.Categories);
Path = element.StrAttr(DataNames.Path);
Reads = element.IntAttr(DataNames.Reads);
Ratings = (double)element.DecimalAttr(DataNames.Ratings);
IsCurrentVersion = true;
var parentID = element.StrAttr(DataNames.ParentID);
if (!string.IsNullOrEmpty(parentID))
{
Guid gPID = Guid.Empty;
if (Guid.TryParse(parentID, out gPID))
ParentItemID = gPID;
}
Pos = element.IntAttr(DataNames.Pos);
Slug = element.StrAttr(DataNames.Slug);
Modified = element.DateAttr(DataNames.Modified);
RawData = element.Element(ns + "data").Value;
if (RawData.StartsWith("data:text/xml;base64"))
{
RawData = element.Element(ns + "data").Value.Replace("data:text/xml;base64,", "");
RawData = Encoding.UTF8.GetString(Convert.FromBase64String(RawData));
}
if (RawData.Contains(ContentList.DefaultNamespace))
RawData = RawData.Replace(" xmlns=\"" + ContentList.DefaultNamespace + "\"", "");
if (Modified == DateTime.MinValue)
Modified = DateTime.Now;
}
示例6: RenderColPattern
private static void RenderColPattern(XElement element, TextWriter w, ContentListDecorator list)
{
var prop = element.StrAttr("prop");
var name = element.StrAttr("name");
if (!string.IsNullOrEmpty(prop) && !string.IsNullOrEmpty(name))
{
var field = list.Fields[name];
if (field != null)
{
if (prop.Equals("title") && !string.IsNullOrEmpty(field.Title))
{
w.Write(field.Title);
return;
}
if (prop.Equals("description") && !string.IsNullOrEmpty(field.Description))
{
w.Write(field.Description);
return;
}
}
}
}
示例7: Load
/// <summary>
/// Load field properties from xml.
/// </summary>
/// <param name="element">The XElement.</param>
/// <param name="locale">The locale name.</param>
public virtual void Load(XElement element, string locale = "")
{
this.Name = element.StrAttr(NAME);
this.IsRequired = element.BoolAttr(REQUIRED);
this.IsReadOnly = element.BoolAttr(READONLY);
this.IsSlug = element.BoolAttr(SLUG);
this.IsLinkToItem = element.BoolAttr(LINKTOITEM);
this.HideInDisplayForm = element.BoolAttr(HIDEINDISP);
this.HideInActForm = element.BoolAttr(HIDEINACT);
this.HideInNewForm = element.BoolAttr(HIDEINNEW);
this.HideInEditForm = element.BoolAttr(HIDEINEDIT);
this.HideInView = element.BoolAttr(HIDEINVIEW);
this.IsHidden = element.BoolAttr(HIDDEN);
this.IsSortable = element.BoolAttr(SORTABLE);
this.ItemProp = element.StrAttr(ITEM_PROP);
this.ItemType = element.StrAttr(ITEM_TYPE);
var ns = element.GetDefaultNamespace();
this.ActivityTemplate = element.StrAttr(ACTTMPL);
this.EditTemplate = element.StrAttr(EDITTMPL);
this.NewTemplate = element.StrAttr(NEWTMPL);
this.ViewTemplate = element.StrAttr(VIEWTMPL);
this.DisplayTemplate = element.StrAttr(DISPTMPL);
var title = element.ElementWithLocale(ns + TITLE, locale);
var desc = element.ElementWithLocale(ns + DESC, locale);
var placeHolder = element.ElementWithLocale(ns + PLACEHOLDER, locale);
if (title == null)
title = element.ElementWithLocale(ns + TITLE, "");
if (desc == null)
desc = element.ElementWithLocale(ns + DESC, "");
if (placeHolder == null)
placeHolder = element.ElementWithLocale(ns + PLACEHOLDER, "");
if (title != null)
this.Title = title.Value;
if (desc != null)
this.Description = desc.Value;
if (placeHolder != null)
this.Placeholder = placeHolder.Value;
}
示例8: Load
/// <summary>
/// Overrided.Load proeprties from xml.
/// </summary>
/// <param name="element">The XElement object.</param>
/// <param name="locale">The locale name.</param>
public override void Load(XElement element, string locale = "")
{
base.Load(element, locale);
this.FieldType = (int)ContentFieldTypes.User;
this.DefaultValue = element.StrAttr(DEFAULT);
var dispAsStr = element.StrAttr("dispAs");
if (!string.IsNullOrEmpty(dispAsStr))
this.DisplayStyle = (UserDisplayStyles)Enum.Parse(typeof(UserDisplayStyles), dispAsStr);
if (this.ThumbnailWidth > 0)
element.Add(new XAttribute("thumbWidth", this.ThumbnailWidth));
if (this.ThumbnailHeight > 0)
element.Add(new XAttribute("thumbHeight", this.ThumbnailHeight));
}
示例9: Load
public virtual void Load(XElement element, string locale)
{
var ns = element.GetDefaultNamespace();
this.IsAjax = element.BoolAttr(AJAX);
this.FormType = (int)((ContentFormTypes)Enum.Parse(typeof(ContentFormTypes), element.StrAttr(TYPE)));
this.Roles = element.StrAttr(DataNames.AccessRoles);
//this.CaptionField = element.StrAttr(CAPTION_FIELD);
//this.HideCaption = element.BoolAttr(HIDE_CAP);
//this.ShowAuthor = element.BoolAttr(SHOW_AUTHOR);
this.NoPage = element.BoolAttr(NOPAGE);
var title = element.ElementWithLocale(ns + DataNames.Title, locale);
var desc = element.ElementWithLocale(ns + DataNames.Description, locale);
var tmpl = element.ElementWithLocale(ns + DataNames.Body, locale);
//if (element.Attribute(ANONYMOUS) != null)
this.AllowAnonymous = element.BoolAttr(ANONYMOUS);
//else
//this.AllowAnonymous = true;
if (title==null)
title=element.ElementWithLocale(ns + DataNames.Title, "");
if (desc==null)
desc=element.ElementWithLocale(ns + DataNames.Description, "");
if (tmpl==null)
tmpl = element.ElementWithLocale(ns + DataNames.Body, "");
if (title != null)
this.Title = title.Value;
if (desc != null)
this.Description = desc.Value;
var fieldsEle = element.Element(ns + "fields");
if (fieldsEle != null)
FieldsXml = fieldsEle.OuterXml();
//string.Format("<fields>{0}</fields>", fieldsEle.InnerXml());
if (tmpl != null)
this.BodyTemplateXml = tmpl.OuterXml();
#region style and scripts
var scripts = element.ElementsWithLocale(ns + SCRIPT, locale);
var styles = element.ElementsWithLocale(ns + STYLE_SHEET, locale);
if (scripts == null || (scripts != null && scripts.Count() == 0))
scripts = element.ElementsWithLocale(ns + SCRIPT, "");
if (styles == null || (styles != null && styles.Count() == 0))
styles = element.ElementsWithLocale(ns + STYLE_SHEET, "");
if (scripts!=null && scripts.Count() > 0)
{
var scriptEl = new XElement("scripts", scripts);
this.ScriptsXml = scriptEl.OuterXml();
}
if (styles!=null && styles.Count() > 0)
{
var styleEl = new XElement("styles", styles);
this.StyleSheetsXml = styleEl.OuterXml();
}
#endregion
}
示例10: Load
public override void Load(XElement element, string locale = "")
{
var ns = element.GetDefaultNamespace();
base.Load(element, locale);
this.FieldType = 6;
var fieldRefs = element.Elements(ns+FIELDREF);
if (fieldRefs != null && fieldRefs.Count() > 0)
this.FieldRefs = fieldRefs.Select(f => f.StrAttr(NAME)).ToArray();
var dispPattern = element.Element(ns+PATTERN);
if (dispPattern != null)
DispPattern = dispPattern.OuterXml();
this.DefaultValue = element.StrAttr(DEFAULT);
}
示例11: Load
public override void Load(XElement element, string locale = "")
{
base.Load(element, locale);
FieldType = 9;
var defaultDateStr = element.StrAttr(DEFAULT);
if (!string.IsNullOrEmpty(defaultDateStr))
{
DateTime defaultDate=DateTime.MinValue;
if (DateTime.TryParse(defaultDateStr, out defaultDate))
this.DefaultValue = defaultDate;
}
this.FormatString = element.StrAttr(FORMAT);
this.ShowTime = element.BoolAttr(SHOW_TIME);
}
示例12: Create
/// <summary>
/// Create a field instance by specified xml element.
/// </summary>
/// <param name="element">The XElement object.</param>
/// <param name="locale">The locale name.</param>
/// <returns>A new field instance returns.</returns>
public ContentField Create(XElement element, string locale = "")
{
var field = Create(element.StrAttr("type"));
field.Load(element, locale);
return field;
}
示例13: Load
/// <summary>
/// Load choice field property from xml element
/// </summary>
/// <param name="element">The xelement object.</param>
/// <param name="locale">The locale name</param>
public override void Load(XElement element, string locale = "")
{
var ns = element.GetDefaultNamespace();
base.Load(element, locale);
this.FieldType = 3;
var chocieEle = element.Element(ns + CHOCIES);
this.DefaultValue = element.StrAttr(DEFAULT);
if (chocieEle != null)
{
this.FillInChoice = chocieEle.BoolAttr(FILL);
this.AllowMultiChoice = chocieEle.BoolAttr(MULTIPLE);
this.DropdownFormat = chocieEle.IntAttr(FORMAT);
var options = chocieEle.Elements(ns + OPTION);
if (options != null && options.Count() > 0)
{
// this.Choices = new NameValueCollection();
var _choices = new List<string>();
foreach (var opt in options)
{
_choices.Add(opt.StrAttr(VALUE));
}
if (_choices.Count > 0)
this.Choices = string.Join(",", _choices.ToArray());
else
this.Choices = "";
}
}
}
示例14: Load
public virtual void Load(XElement element, string locale = "")
{
var ns = element.GetDefaultNamespace();
this.Name = element.StrAttr(NAME);
this.IsDefault = element.BoolAttr(DEFAULT);
this.Icon = element.StrAttr(ICON);
this.IsHierarchy = element.BoolAttr(HIERARCHY);
this.HideToolbar = element.BoolAttr(HIDE_TOOLBAR);
this.Roles = element.StrAttr(ACCESS_ROLES);
this.Sort = element.StrAttr(SORT);
this.Filter = element.StrAttr(FILTER);
var title = element.ElementWithLocale(ns + TITLE, locale);
var desc = element.ElementWithLocale(ns + DESC, locale);
var paging = element.Element(ns + PAGING);
if (element.Attribute(ANONYMOUS) != null)
this.AllowAnonymous = element.BoolAttr(ANONYMOUS);
else
this.AllowAnonymous = true;
if (title == null)
title = element.ElementWithLocale(ns + TITLE, "");
if (desc == null)
desc = element.ElementWithLocale(ns + DESC, "");
if (title != null)
this.Title = title.Value;
if (desc != null)
this.Description = desc.Value;
if (paging != null)
{
this.PageIndex = paging.IntAttr(INDEX);
this.PageSize = paging.IntAttr(SIZE);
this.AllowPaging = paging.BoolAttr(ALLOW);
}
var fieldsEle = element.Element(ns + FIELDS);
if (fieldsEle != null)
FieldRefsXml = fieldsEle.OuterXml();
//FieldRefsXml = string.Format("<fields>{0}</fields>", fieldsEle.InnerXml());
var body = element.ElementWithLocale(ns + BODY, locale);
if (body == null)
body = element.ElementWithLocale(ns + BODY, "");
if (body != null)
this.BodyTemplateXml = body.OuterXml();
var empty = element.ElementWithLocale(ns + EMPTY_PATTERN, locale);
if (empty == null)
element.ElementWithLocale(ns + EMPTY_PATTERN, "");
if (empty != null)
this.EmptyTemplateXml = empty.OuterXml();
this.NoPage = element.BoolAttr(NOPAGE);
#region style and scripts
var scripts = element.ElementsWithLocale(ns + SCRIPT, locale);
var styles = element.ElementsWithLocale(ns + STYLE_SHEET, locale);
if (scripts == null || (scripts != null && scripts.Count() == 0))
scripts = element.ElementsWithLocale(ns + SCRIPT, "");
if (styles == null || (styles != null && styles.Count() == 0))
styles = element.ElementsWithLocale(ns + STYLE_SHEET, "");
if (scripts != null && scripts.Count() > 0)
{
var scriptEl = new XElement("scripts", scripts);
this.ScriptsXml = scriptEl.OuterXml();
}
if (styles != null && styles.Count() > 0)
{
var styleEl = new XElement("styles", styles);
this.StyleSheetsXml = styleEl.OuterXml();
}
#endregion
}
示例15: Load
/// <summary>
/// Load properties from xelement object.
/// </summary>
/// <param name="element">The XElement object.</param>
/// <param name="locale">The locale name.</param>
public override void Load(XElement element, string locale = "")
{
base.Load(element, locale);
this.FieldType = 8;
this.DefaultValue = element.BoolAttr(DEFAULT);
if (!string.IsNullOrEmpty(element.StrAttr(YESTEXT)))
this.YesText = element.StrAttr(YESTEXT);
if (!string.IsNullOrEmpty(element.StrAttr(NOTEXT)))
this.NoText = element.StrAttr(NOTEXT);
}