本文整理汇总了C#中System.Xml.Linq.XDocument.GetProperty方法的典型用法代码示例。如果您正苦于以下问题:C# XDocument.GetProperty方法的具体用法?C# XDocument.GetProperty怎么用?C# XDocument.GetProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.Linq.XDocument
的用法示例。
在下文中一共展示了XDocument.GetProperty方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DeployModel
//.........这里部分代码省略.........
if (CurrentWebPartXml.IsV3version())
chromeType = WebPartChromeTypesConvertService.NormilizeValueToPartChromeTypes(definition.ChromeType);
else if (CurrentWebPartXml.IsV2version())
chromeType = WebPartChromeTypesConvertService.NormilizeValueToFrameTypes(definition.ChromeType);
assert.ShouldBeEqual((p, s, d) =>
{
var srcProp = s.GetExpressionValue(m => m.ChromeType);
var isValid = chromeType == value;
return new PropertyValidationResult
{
Tag = p.Tag,
Src = srcProp,
Dst = null,
IsValid = isValid
};
});
}
else
assert.SkipProperty(m => m.ChromeType, "ChromeType is null or empty. Skipping.");
if (!string.IsNullOrEmpty(definition.Description))
{
}
else
{
assert.SkipProperty(m => m.Description, "Description is null or empty. Skipping.");
}
if (definition.Height.HasValue)
{
var value = ConvertUtils.ToInt(CurrentWebPartXml.GetProperty("Height").Replace("px", string.Empty));
assert.ShouldBeEqual((p, s, d) =>
{
var srcProp = s.GetExpressionValue(m => m.Height);
var isValid = definition.Height == value;
return new PropertyValidationResult
{
Tag = p.Tag,
Src = srcProp,
Dst = null,
IsValid = isValid
};
});
}
else
assert.SkipProperty(m => m.Height, "Height is null or empty. Skipping.");
if (definition.Width.HasValue)
{
var value = ConvertUtils.ToInt(CurrentWebPartXml.GetProperty("Width").Replace("px", string.Empty));
assert.ShouldBeEqual((p, s, d) =>
{
var srcProp = s.GetExpressionValue(m => m.Width);
var isValid = definition.Width == value;
return new PropertyValidationResult
{
Tag = p.Tag,
Src = srcProp,
Dst = null,
示例2: DeployModel
public override void DeployModel(object modelHost, DefinitionBase model)
{
var listItemModelHost = modelHost.WithAssertAndCast<ListItemModelHost>("modelHost", value => value.RequireNotNull());
var definition = model.WithAssertAndCast<WebPartDefinition>("model", value => value.RequireNotNull());
var pageFile = listItemModelHost.HostFile;
var context = pageFile.Context;
context.Load(pageFile);
context.ExecuteQueryWithTrace();
var siteServerUrl = listItemModelHost.HostSite.ServerRelativeUrl;
var webUrl = listItemModelHost.HostWeb.Url;
var serverUrl = context.Url;
if (siteServerUrl != "/")
serverUrl = context.Url.Split(new string[] { siteServerUrl }, StringSplitOptions.RemoveEmptyEntries)[0];
var absItemUrl = UrlUtility.CombineUrl(serverUrl, pageFile.ServerRelativeUrl);
WithExistingWebPart(pageFile, definition, (spObject, spObjectDefintion) =>
{
var webpartExportUrl = UrlUtility.CombineUrl(new[]{
webUrl,
"_vti_bin/exportwp.aspx?pageurl=" + absItemUrl + "&" + "guidstring=" + spObjectDefintion.Id.ToString()
});
var assert = ServiceFactory.AssertService
.NewAssert(model, definition, spObject)
.ShouldNotBeNull(spObject);
var webClient = new WebClient();
if (context.Credentials != null)
{
webClient.Credentials = context.Credentials;
webClient.Headers.Add("X-FORMS_BASED_AUTH_ACCEPTED", "f");
}
else
webClient.UseDefaultCredentials = true;
var webPartXmlString = webClient.DownloadString(webpartExportUrl);
CurrentWebPartXml = WebpartXmlExtensions.LoadWebpartXmlDocument(webPartXmlString);
assert.ShouldBeEqual(m => m.Title, o => o.Title);
// checking the web part type, shoul be as expected
// Add regression on 'expected' web part type #690
var currentType = CurrentWebPartXml.GetWebPartAssemblyQualifiedName();
var currentClassName = currentType.Split(',').First().Trim();
var expectedTypeAttr = (definition.GetType().GetCustomAttributes(typeof(ExpectWebpartType))
.FirstOrDefault() as ExpectWebpartType);
// NULL can be on generic web part
// test should not care about that case, there other tests to enfore that attr usage
if (expectedTypeAttr != null)
{
var expectedType = expectedTypeAttr.WebPartType;
var expectedClassName = expectedType.Split(',').First().Trim();
assert.ShouldBeEqual((p, s, d) =>
{
var isValid = true;
isValid = currentClassName.ToUpper() == expectedClassName.ToUpper();
return new PropertyValidationResult
{
Tag = p.Tag,
Src = null,
Dst = null,
IsValid = isValid
};
});
}
// props
if (definition.Properties.Count > 0)
{
assert.ShouldBeEqual((p, s, d) =>
{
var isValid = true;
foreach (var prop in definition.Properties)
{
// returns correct one depending on the V2/V3
var value = CurrentWebPartXml.GetProperty(prop.Name);
// that True / true issue give a pain
// toLower for the time being
isValid = value.ToLower() == prop.Value.ToLower();
if (!isValid)
break;
//.........这里部分代码省略.........