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


C# XElement.SetAttribute方法代码示例

本文整理汇总了C#中System.Xml.Linq.XElement.SetAttribute方法的典型用法代码示例。如果您正苦于以下问题:C# XElement.SetAttribute方法的具体用法?C# XElement.SetAttribute怎么用?C# XElement.SetAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Xml.Linq.XElement的用法示例。


在下文中一共展示了XElement.SetAttribute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ProcessSPFieldXElement

        protected override void ProcessSPFieldXElement(XElement fieldTemplate, FieldDefinition fieldModel)
        {
            base.ProcessSPFieldXElement(fieldTemplate, fieldModel);

            var businessFieldModel = fieldModel.WithAssertAndCast<BusinessDataFieldDefinition>("model", value => value.RequireNotNull());

            fieldTemplate.SetAttribute(BuiltInFieldAttributes.SystemInstance, businessFieldModel.SystemInstanceName);
            fieldTemplate.SetAttribute(BuiltInFieldAttributes.EntityNamespace, businessFieldModel.EntityNamespace);
            fieldTemplate.SetAttribute(BuiltInFieldAttributes.EntityName, businessFieldModel.EntityName);
            fieldTemplate.SetAttribute(BuiltInFieldAttributes.BdcField, businessFieldModel.BdcFieldName);
        }
开发者ID:karayakar,项目名称:spmeta2,代码行数:11,代码来源:BusinessDataFieldModelHandler.cs

示例2: ProcessSPFieldXElement

        protected override void ProcessSPFieldXElement(XElement fieldTemplate, FieldDefinition fieldModel)
        {
            base.ProcessSPFieldXElement(fieldTemplate, fieldModel);

            var typedFieldModel = fieldModel.WithAssertAndCast<NoteFieldDefinition>("model", value => value.RequireNotNull());

            if (typedFieldModel.NumberOfLines > 0)
                fieldTemplate.SetAttribute(BuiltInFieldAttributes.NumLines, typedFieldModel.NumberOfLines);

            fieldTemplate.SetAttribute(BuiltInFieldAttributes.RichText, typedFieldModel.RichText.ToString().ToUpper());
            fieldTemplate.SetAttribute(BuiltInFieldAttributes.RichTextMode, typedFieldModel.RichTextMode);
            fieldTemplate.SetAttribute(BuiltInFieldAttributes.AppendOnly, typedFieldModel.AppendOnly.ToString().ToUpper());
            fieldTemplate.SetAttribute(BuiltInFieldAttributes.UnlimitedLengthInDocumentLibrary, typedFieldModel.UnlimitedLengthInDocumentLibrary.ToString().ToUpper());
        }
开发者ID:karayakar,项目名称:spmeta2,代码行数:14,代码来源:NoteFieldModelHandler.cs

示例3: ProcessSPFieldXElement

        protected override void ProcessSPFieldXElement(XElement fieldTemplate, FieldDefinition fieldModel)
        {
            base.ProcessSPFieldXElement(fieldTemplate, fieldModel);

            var typedFieldModel = fieldModel.WithAssertAndCast<DependentLookupFieldDefinition>("model", value => value.RequireNotNull());
            fieldTemplate.SetAttribute(BuiltInFieldAttributes.Mult, typedFieldModel.AllowMultipleValues.ToString().ToUpper());

            SPField primaryField = GetPrimaryField(typedFieldModel);
            if (primaryField == null)
            {
                throw new SPMeta2Exception("PrimaryLookupField needs to be defined when creating a DependentLookupField");
            }

            fieldTemplate.SetAttribute(BuiltInFieldAttributes.FieldReference, primaryField.Id.ToString("B"));
        }
开发者ID:maratbakirov,项目名称:spmeta2,代码行数:15,代码来源:DependentLookupFieldModelHandler.cs

示例4: ProcessSPFieldXElement

        protected override void ProcessSPFieldXElement(XElement fieldTemplate, FieldDefinition fieldModel)
        {
            base.ProcessSPFieldXElement(fieldTemplate, fieldModel);

            var typedFieldModel = fieldModel.WithAssertAndCast<NumberFieldDefinition>("model", value => value.RequireNotNull());

            if (typedFieldModel.MinimumValue.HasValue)
                fieldTemplate.SetAttribute(BuiltInFieldAttributes.Min, typedFieldModel.MinimumValue);

            if (typedFieldModel.MaximumValue.HasValue)
                fieldTemplate.SetAttribute(BuiltInFieldAttributes.Max, typedFieldModel.MaximumValue);

            fieldTemplate.SetAttribute(BuiltInFieldAttributes.Percentage, typedFieldModel.ShowAsPercentage.ToString().ToUpper());

            fieldTemplate.SetAttribute(BuiltInFieldAttributes.Decimals, GetDecimalsValue(typedFieldModel.DisplayFormat));
        }
开发者ID:karayakar,项目名称:spmeta2,代码行数:16,代码来源:NumberFieldModelHandler.cs

示例5: ProcessSPFieldXElement

        protected override void ProcessSPFieldXElement(XElement fieldTemplate, FieldDefinition fieldModel)
        {
            base.ProcessSPFieldXElement(fieldTemplate, fieldModel);

            var typedFieldModel = fieldModel.WithAssertAndCast<UserFieldDefinition>("model", value => value.RequireNotNull());

            fieldTemplate.SetAttribute(BuiltInFieldAttributes.Mult, typedFieldModel.AllowMultipleValues.ToString().ToUpper());
            fieldTemplate.SetAttribute(BuiltInFieldAttributes.ForcedDisplay, typedFieldModel.AllowDisplay.ToString().ToUpper());
            fieldTemplate.SetAttribute(BuiltInFieldAttributes.Presence, typedFieldModel.Presence.ToString().ToUpper());

            if (typedFieldModel.SelectionGroup.HasValue)
                fieldTemplate.SetAttribute(BuiltInFieldAttributes.UserSelectionScope, typedFieldModel.SelectionGroup.ToString());

            if (!string.IsNullOrEmpty(typedFieldModel.SelectionMode))
                fieldTemplate.SetAttribute(BuiltInFieldAttributes.UserSelectionMode, typedFieldModel.SelectionMode);
        }
开发者ID:Uolifry,项目名称:spmeta2,代码行数:16,代码来源:UserFieldModelHandler.cs

示例6: ProcessSPFieldXElement

        protected override void ProcessSPFieldXElement(XElement fieldTemplate, FieldDefinition fieldModel)
        {
            base.ProcessSPFieldXElement(fieldTemplate, fieldModel);

            var typedFieldModel = fieldModel.WithAssertAndCast<CalculatedFieldDefinition>("model", value => value.RequireNotNull());

            if (typedFieldModel.CurrencyLocaleId.HasValue)
                fieldTemplate.SetAttribute(BuiltInFieldAttributes.LCID, typedFieldModel.CurrencyLocaleId);

            if (!string.IsNullOrEmpty(typedFieldModel.Formula))
            {
                // can't really validate it automatically
                // Improve CalculatedFieldDefinition with field ref check
                // https://github.com/SubPointSolutions/spmeta2/issues/648
                TraceService.Verbose((int)LogEventId.ModelProvisionCoreCall, "Crafting formula for a CalculatedField. Ensure FieldReferences are correct.");

                // should be a new XML node
                var formulaNode = new XElement(BuiltInFieldAttributes.Formula, typedFieldModel.Formula);
                fieldTemplate.Add(formulaNode);

                fieldTemplate.SetAttribute(BuiltInFieldAttributes.Format,
                    (int)Enum.Parse(typeof(SPDateTimeFieldFormatType), typedFieldModel.DateFormat));
            }

            if (typedFieldModel.ShowAsPercentage.HasValue)
                fieldTemplate.SetAttribute(BuiltInFieldAttributes.Percentage, typedFieldModel.ShowAsPercentage.Value.ToString().ToUpper());

            if (!string.IsNullOrEmpty(typedFieldModel.DisplayFormat))
                fieldTemplate.SetAttribute(BuiltInFieldAttributes.Decimals, NumberFieldModelHandler.GetDecimalsValue(typedFieldModel.DisplayFormat));

            fieldTemplate.SetAttribute(BuiltInFieldAttributes.ResultType, typedFieldModel.OutputType);

            if (typedFieldModel.FieldReferences.Count > 0)
            {
                var fieldRefsNode = new XElement("FieldRefs");

                foreach (var fieldRef in typedFieldModel.FieldReferences)
                {
                    var fieldRefNode = new XElement("FieldRef");

                    fieldRefNode.SetAttribute("Name", fieldRef);
                    fieldRefsNode.Add(fieldRefNode);
                }

                fieldTemplate.Add(fieldRefsNode);
            }
        }
开发者ID:karayakar,项目名称:spmeta2,代码行数:47,代码来源:CalculatedFieldModelHandler.cs

示例7: ProcessSPFieldXElement

        protected override void ProcessSPFieldXElement(XElement fieldTemplate, FieldDefinition fieldModel)
        {
            base.ProcessSPFieldXElement(fieldTemplate, fieldModel);

            var typedFieldModel = fieldModel.WithAssertAndCast<ChoiceFieldDefinition>("model", value => value.RequireNotNull());

            fieldTemplate.SetAttribute(BuiltInFieldAttributes.Format, typedFieldModel.EditFormat);
        }
开发者ID:Uolifry,项目名称:spmeta2,代码行数:8,代码来源:ChoiceFieldModelHandler.cs

示例8: ProcessSPFieldXElement

        protected override void ProcessSPFieldXElement(XElement fieldTemplate, FieldDefinition fieldModel)
        {
            base.ProcessSPFieldXElement(fieldTemplate, fieldModel);

            var typedFieldModel = fieldModel.WithAssertAndCast<CurrencyFieldDefinition>("model", value => value.RequireNotNull());

            fieldTemplate.SetAttribute(BuiltInFieldAttributes.LCID, typedFieldModel.CurrencyLocaleId);
        }
开发者ID:karayakar,项目名称:spmeta2,代码行数:8,代码来源:CurrencyFieldModelHandler.cs

示例9: ProcessSPFieldXElement

        protected override void ProcessSPFieldXElement(XElement fieldTemplate, FieldDefinition fieldModel)
        {
            base.ProcessSPFieldXElement(fieldTemplate, fieldModel);

            var typedFieldModel = fieldModel.WithAssertAndCast<TextFieldDefinition>("model", value => value.RequireNotNull());

            if (typedFieldModel.MaxLength.HasValue)
                fieldTemplate.SetAttribute(BuiltInFieldAttributes.MaxLength, typedFieldModel.MaxLength.Value);
        }
开发者ID:karayakar,项目名称:spmeta2,代码行数:9,代码来源:TextFieldModelHandler.cs

示例10: ProcessSPFieldXElement

        protected override void ProcessSPFieldXElement(XElement fieldTemplate, FieldDefinition fieldModel)
        {
            base.ProcessSPFieldXElement(fieldTemplate, fieldModel);

            var typedFieldModel = fieldModel.WithAssertAndCast<ComputedFieldDefinition>("model", value => value.RequireNotNull());

            if (typedFieldModel.EnableLookup.HasValue)
                fieldTemplate.SetAttribute(BuiltInFieldAttributes.EnableLookup, typedFieldModel.EnableLookup.ToString().ToUpper());
        }
开发者ID:karayakar,项目名称:spmeta2,代码行数:9,代码来源:ComputedFieldModelHandler.cs

示例11: ProcessSPFieldXElement

        protected override void ProcessSPFieldXElement(XElement fieldTemplate, FieldDefinition fieldModel)
        {
            base.ProcessSPFieldXElement(fieldTemplate, fieldModel);

            var typedFieldModel = fieldModel.WithAssertAndCast<DateTimeFieldDefinition>("model", value => value.RequireNotNull());

            if (!string.IsNullOrEmpty(typedFieldModel.CalendarType))
            {
                var value = (CalendarType)Enum.Parse(typeof(CalendarType), typedFieldModel.CalendarType);
                fieldTemplate.SetAttribute(BuiltInFieldAttributes.CalType, (int)value);
            }

            if (!string.IsNullOrEmpty(typedFieldModel.DisplayFormat))
                fieldTemplate.SetAttribute(BuiltInFieldAttributes.Format, typedFieldModel.DisplayFormat);

            if (!string.IsNullOrEmpty(typedFieldModel.FriendlyDisplayFormat))
                fieldTemplate.SetAttribute(BuiltInFieldAttributes.FriendlyDisplayFormat, typedFieldModel.FriendlyDisplayFormat);
        }
开发者ID:karayakar,项目名称:spmeta2,代码行数:18,代码来源:DateTimeFieldModelHandler.cs

示例12: ProcessSPFieldXElement

        protected override void ProcessSPFieldXElement(XElement fieldTemplate, FieldDefinition fieldModel)
        {
            base.ProcessSPFieldXElement(fieldTemplate, fieldModel);

            var typedFieldModel = fieldModel.WithAssertAndCast<URLFieldDefinition>("model", value => value.RequireNotNull());

            if (!string.IsNullOrEmpty(typedFieldModel.DisplayFormat))
                fieldTemplate.SetAttribute(BuiltInFieldAttributes.Format, typedFieldModel.DisplayFormat);
        }
开发者ID:karayakar,项目名称:spmeta2,代码行数:9,代码来源:URLFieldModelHandler.cs

示例13: ToXml

        /// <summary>
        /// Emits WiX XML.
        /// </summary>
        /// <returns></returns>
        public override XContainer[] ToXml()
        {
            XNamespace bal = "http://schemas.microsoft.com/wix/BalExtension";

            var root = new XElement("BootstrapperApplicationRef");

            var app = new XElement(bal + "WixStandardBootstrapperApplication");

            app.Add(this.MapToXmlAttributes());

            if (LicensePath.IsNotEmpty() && LicensePath.EndsWith(".rtf", StringComparison.OrdinalIgnoreCase))
            {
                root.SetAttribute("Id", "WixStandardBootstrapperApplication.RtfLicense");
                app.SetAttribute("LicenseFile", LicensePath);
            }
            else
            {
                root.SetAttribute("Id", "WixStandardBootstrapperApplication.HyperlinkLicense");

                if (LicensePath.IsEmpty())
                {
                    //cannot use SetAttribute as we want to preserve empty attrs
                    app.Add(new XAttribute("LicenseUrl", ""));
                }
                else
                {
                    if (LicensePath.StartsWith("http")) //online HTML file
                    {
                        app.SetAttribute("LicenseUrl", LicensePath);
                    }
                    else
                    {
                        app.SetAttribute("LicenseUrl", System.IO.Path.GetFileName(LicensePath));
                        root.AddElement("Payload").AddAttributes("SourceFile=" + LicensePath);
                    }
                }
            }

            root.Add(app);

            return new[] { root };
        }
开发者ID:Eun,项目名称:WixSharp,代码行数:46,代码来源:BootstrapperApplication.cs

示例14: ProcessSPFieldXElement

        protected override void ProcessSPFieldXElement(XElement fieldTemplate, FieldDefinition fieldModel)
        {
            base.ProcessSPFieldXElement(fieldTemplate, fieldModel);

            var typedFieldModel = fieldModel.WithAssertAndCast<CalculatedFieldDefinition>("model", value => value.RequireNotNull());

            if (typedFieldModel.CurrencyLocaleId.HasValue)
                fieldTemplate.SetAttribute(BuiltInFieldAttributes.LCID, typedFieldModel.CurrencyLocaleId);

            // should be a new XML node
            var formulaNode = new XElement(BuiltInFieldAttributes.Formula, typedFieldModel.Formula);
            fieldTemplate.Add(formulaNode);

            fieldTemplate.SetAttribute(BuiltInFieldAttributes.Format, (int)Enum.Parse(typeof(DateTimeFieldFormatType), typedFieldModel.DateFormat));

            if (typedFieldModel.ShowAsPercentage.HasValue)
                fieldTemplate.SetAttribute(BuiltInFieldAttributes.Percentage, typedFieldModel.ShowAsPercentage.Value.ToString().ToUpper());

            if (!string.IsNullOrEmpty(typedFieldModel.DisplayFormat))
                fieldTemplate.SetAttribute(BuiltInFieldAttributes.Decimals, NumberFieldModelHandler.GetDecimalsValue(typedFieldModel.DisplayFormat));

            fieldTemplate.SetAttribute(BuiltInFieldAttributes.ResultType, typedFieldModel.OutputType);

            if (typedFieldModel.FieldReferences.Count > 0)
            {
                var fieldRefsNode = new XElement("FieldRefs");

                foreach (var fieldRef in typedFieldModel.FieldReferences)
                {
                    var fieldRefNode = new XElement("FieldRef");

                    fieldRefNode.SetAttribute("Name", fieldRef);
                    fieldRefsNode.Add(fieldRefNode);
                }

                fieldTemplate.Add(fieldRefsNode);
            }
        }
开发者ID:Uolifry,项目名称:spmeta2,代码行数:38,代码来源:CalculatedFieldModelHandler.cs

示例15: ProcessSPFieldXElement

        protected override void ProcessSPFieldXElement(XElement fieldTemplate, FieldDefinition fieldModel)
        {
            base.ProcessSPFieldXElement(fieldTemplate, fieldModel);

            var typedFieldModel = fieldModel.WithAssertAndCast<MultiChoiceFieldDefinition>("model", value => value.RequireNotNull());

            fieldTemplate.SetAttribute(BuiltInFieldAttributes.FillInChoice, typedFieldModel.FillInChoice);

            if (typedFieldModel.Choices.Count > 0)
            {
                var choicesNode = new XElement("CHOICES");

                foreach (var choice in typedFieldModel.Choices)
                {
                    choicesNode.Add(new XElement("CHOICE", choice));
                }

                fieldTemplate.Add(choicesNode);
            }

            if (typedFieldModel.Mappings.Count > 0)
            {
                var mappingsNode = new XElement("MAPPINGS");
                var currentValueIndex = 1;

                foreach (var mappingValue in typedFieldModel.Mappings)
                {
                    var mappingValueNode = new XElement("MAPPING", mappingValue);
                    mappingValueNode.SetAttributeValue("Value", currentValueIndex);

                    mappingsNode.Add(mappingValueNode);

                    currentValueIndex++;
                }

                fieldTemplate.Add(mappingsNode);
            }
        }
开发者ID:karayakar,项目名称:spmeta2,代码行数:38,代码来源:MultiChoiceFieldModelHandler.cs


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