当前位置: 首页>>代码示例>>C#>>正文


C# XDocument.GetProperty方法代码示例

本文整理汇总了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,
开发者ID:Uolifry,项目名称:spmeta2,代码行数:67,代码来源:WebPartDefinitionValidator.cs

示例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;
//.........这里部分代码省略.........
开发者ID:karayakar,项目名称:spmeta2,代码行数:101,代码来源:WebPartDefinitionValidator.cs


注:本文中的System.Xml.Linq.XDocument.GetProperty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。