本文整理汇总了C#中XmlData.LoadData方法的典型用法代码示例。如果您正苦于以下问题:C# XmlData.LoadData方法的具体用法?C# XmlData.LoadData怎么用?C# XmlData.LoadData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XmlData
的用法示例。
在下文中一共展示了XmlData.LoadData方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EditForm_OnBeforeSave
void EditForm_OnBeforeSave(object sender, EventArgs e)
{
elemInfo = (UIElementInfo)EditForm.EditedObject;
// Clear icon field based on icon type
int type = EditForm.FieldControls["ElementIconType"].Value.ToInteger(0);
if (type == 0)
{
elemInfo.ElementIconClass = "";
}
else
{
elemInfo.ElementIconPath = "";
}
// Check unique code name
UIElementInfo testUI = UIElementInfoProvider.GetUIElementInfo(elemInfo.ElementResourceID, elemInfo.ElementName);
if ((testUI != null) && (testUI.ElementID != elemInfo.ElementID))
{
ShowError(GetString("ui.element.alreadyexists"));
EditForm.StopProcessing = true;
return;
}
UIElementInfo oldItem = UIContext.EditedObject as UIElementInfo;
// If new element or display name has changed or parent changed, refresh tree and recalculate order
if ((oldItem != null) && ((oldItem.ElementParentID != elemInfo.ElementParentID) || (oldItem.ElementDisplayName != elemInfo.ElementDisplayName)) || (ElementID == 0))
{
// If element is new or changed parent, put him in the end of the order, otherwise it stays on it's place
if ((ElementID == 0) || (oldItem.ElementParentID != elemInfo.ElementParentID))
{
elemInfo.ElementOrder = UIElementInfoProvider.GetLastElementOrder(elemInfo.ElementParentID) + 1;
}
refreshTree = true;
}
// Clear target URL for page template type
if (elemInfo.ElementType == UIElementTypeEnum.PageTemplate)
{
elemInfo.ElementTargetURL = null;
}
else
{
// Empty Page Template ID for non page template type
elemInfo.ElementPageTemplateID = 0;
}
// Add javascript prefix for TargetURL if javascript type is selected
if ((elemInfo.ElementType == UIElementTypeEnum.Javascript) && !elemInfo.ElementTargetURL.StartsWithCSafe("javascript", true))
{
elemInfo.ElementTargetURL = "javascript:" + elemInfo.ElementTargetURL;
}
if (isNew)
{
elemInfo.ElementIsCustom = !SystemContext.DevelopmentMode;
}
// For new elements or when template is changed, create new element's properties based on default values
bool templateChanged = ValidationHelper.GetBoolean(EditForm.FieldControls["ElementPageTemplateID"].GetValue("TemplateChanged"), false);
if (isNew || templateChanged)
{
// Get page template if any template is selected
PageTemplateInfo pti = (elemInfo.ElementPageTemplateID > 0) ? PageTemplateInfoProvider.GetPageTemplateInfo(elemInfo.ElementPageTemplateID) : null;
// Create form info based on either template combined with default general data (XML file) or default general data only (if no template is selected)
FormInfo fi = (pti != null) ? pti.PageTemplatePropertiesForm : PortalFormHelper.GetUIElementDefaultPropertiesForm(UIElementPropertiesPosition.Both);
// Create XMLData collection for current element (this make sense only for template change). New elements obviously have no properties.
XmlData data = new XmlData();
data.LoadData(elemInfo.ElementProperties);
// Apply default data do element's properties, but only it has not it's own data (based by column name)
foreach (FormFieldInfo ffi in fi.GetFields(true, true))
{
if (!data.ColumnNames.Contains(ffi.Name) && !String.IsNullOrEmpty(ffi.DefaultValue))
{
data[ffi.Name] = ffi.DefaultValue;
}
}
elemInfo.ElementProperties = data.GetData();
}
}
示例2: RemoveAnalyticsExtenderFromUiElement
/// <summary>
/// Removes Analytics Extender from given UIElement
/// </summary>
private static void RemoveAnalyticsExtenderFromUiElement(UIElementInfo uiElement)
{
XmlData customData = new XmlData();
customData.LoadData(uiElement.ElementProperties);
string pageExtenderClassName = ValidationHelper.GetString(customData.GetValue("pageextenderclassname"), String.Empty);
if ("analyticsextender".EqualsCSafe(pageExtenderClassName.ToLower()))
{
customData.Remove("pageextenderclassname");
customData.Remove("pageextenderassemblyname");
uiElement.ElementProperties = customData.GetData();
uiElement.Update();
}
}
示例3: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
// Setup info/error message placeholder
if (MessagesPlaceHolder != null)
{
MessagesPlaceHolder.UseRelativePlaceHolder = false;
form.EnsureMessagesPlaceholder(MessagesPlaceHolder);
}
// Load default properties from XML
XmlDocument xml = new XmlDocument();
xml.Load(ResolveUrl(HttpContext.Current.Server.MapPath(UIContextHelper.BEFOREPROPERTIESDEFINITION)));
String merged = xml.InnerXml;
// Load UI element and element's page tempalte (if any)
mUIElementInfo = UIElementInfoProvider.GetUIElementInfo(QueryHelper.GetInteger("elementID", 0));
if (mUIElementInfo != null)
{
PageTemplateInfo pti = null;
if (mUIElementInfo.ElementType == UIElementTypeEnum.PageTemplate)
{
pti = PageTemplateInfoProvider.GetPageTemplateInfo(mUIElementInfo.ElementPageTemplateID);
}
form.Enabled = ((SystemContext.DevelopmentMode || mUIElementInfo.ElementIsCustom) && (!UIElementInfoProvider.AllowEditOnlyCurrentModule || (mUIElementInfo.ElementResourceID == QueryHelper.GetInteger("moduleId", 0))));
// Create form info
FormInfo fi = (pti != null) ? pti.PageTemplatePropertiesForm : PortalFormHelper.GetUIElementDefaultPropertiesForm(UIElementPropertiesPosition.Both);
form.FormInformation = fi;
form.MacroTable = new Hashtable();
// Load data row from properties
DataRow dr = fi.GetDataRow(true);
fi.LoadDefaultValues(dr);
if ((mUIElementInfo == null) || !mUIElementInfo.IsApplication)
{
fi.RemoveFormField("DescriptionLink");
}
XmlData customData = new XmlData();
// Load element properties
XmlData data = new XmlData();
data.AllowMacros = true;
data.LoadData(mUIElementInfo.ElementProperties);
form.MacroTable = data.MacroTable;
// Fill template datarow with element's properties. If template does not contain such column, add it to custom
foreach (String col in data.ColumnNames)
{
if (col.StartsWith(UIContextData.CATEGORYNAMEPREFIX))
{
if (!RequestHelper.IsPostBack())
{
String catName = col.Substring(UIContextData.CATEGORYNAMEPREFIX.Length);
FormCategoryInfo fci = fi.GetFormCategory(catName);
if (fci != null)
{
fci.SetPropertyValue(FormCategoryPropertyEnum.CollapsedByDefault, ValidationHelper.GetBoolean(data[col], false).ToString().ToLower());
}
}
}
else
{
if (dr.Table.Columns.Contains(col))
{
DataHelper.SetDataRowValue(dr, col, data[col]);
}
else
{
customData[col] = data[col];
}
}
}
dr["CustomProperties"] = customData.GetData();
form.DataRow = dr;
form.LoadData(dr);
form.FormInformation = fi;
// Master page style for margin
CurrentMaster.PanelContent.CssClass = "WebpartProperties PageContent";
form.OnAfterSave += form_OnAfterSave;
}
else
{
EditedObject = null;
}
}
示例4: AssignExtenderToShippingOptionTabs
/// <summary>
/// Assigns ShippingOptionTabsExtender to Edit.Configuration.ShippingOptionProperties UI element
/// </summary>
private static void AssignExtenderToShippingOptionTabs()
{
var element = UIElementInfoProvider.GetUIElementInfo(ModuleName.ECOMMERCE, "Edit.Configuration.ShippingOptionProperties");
if (element != null)
{
var properties = new XmlData();
properties.LoadData(element.ElementProperties);
properties.SetValue("tabextender", "CMS.Ecommerce");
properties.SetValue("extenderclassname", "CMS.Ecommerce.Extenders.ShippingOptionTabsExtender");
element.ElementProperties = properties.GetData();
element.Update();
}
}
示例5: form_OnAfterSave
void form_OnAfterSave(object sender, EventArgs e)
{
if (mUIElementInfo != null)
{
XmlData data = new XmlData();
data.AllowMacros = true;
// Store basic form data to XMLData structure
DataRow drActual = form.DataRow;
foreach (DataColumn dc in drActual.Table.Columns)
{
if ((dc.ColumnName != "CustomProperties") && (drActual[dc.ColumnName] != DBNull.Value) && (drActual[dc.ColumnName].ToString() != ""))
{
data[dc.ColumnName] = drActual[dc.ColumnName];
}
// Append values from macro table
object o = form.MacroTable[dc.ColumnName.ToLowerCSafe()];
if (o != null)
{
data[dc.ColumnName] = o;
}
}
// Store category changes
var categories = form.FormInformation.GetCategoryNames();
foreach (string category in categories)
{
FormCategoryInfo fci = form.FormInformation.GetFormCategory(category);
if (ValidationHelper.GetBoolean(fci.GetPropertyValue(FormCategoryPropertyEnum.Collapsible, form.ContextResolver), false))
{
bool collapsedByDefault = ValidationHelper.GetBoolean(fci.GetPropertyValue(FormCategoryPropertyEnum.CollapsedByDefault, form.ContextResolver), false);
bool collapsed = form.IsCategoryCollapsed(category);
if (collapsed != collapsedByDefault)
{
data[UIContextData.CATEGORYNAMEPREFIX + category] = collapsed;
}
}
}
data.MacroTable = form.MacroTable;
// Add custom data
XmlData customData = new XmlData();
customData.LoadData(ValidationHelper.GetString(drActual["CustomProperties"], String.Empty));
// Add (replace) default properties with custom data
foreach (String col in customData.ColumnNames)
{
data[col] = customData[col];
}
mUIElementInfo.ElementProperties = data.GetData();
mUIElementInfo.Update();
ShowChangesSaved();
}
}