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); }
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()); }
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")); }
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)); }
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); }
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); } }
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); }
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); }
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); }
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()); }
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); }
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); }
/// <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 }; }
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); } }
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); } }
protected virtual void ProcessSPFieldXElement(XElement fieldTemplate, FieldDefinition fieldModel) { // minimal set fieldTemplate .SetAttribute(BuiltInFieldAttributes.ID, fieldModel.Id.ToString("B")) .SetAttribute(BuiltInFieldAttributes.DisplayName, fieldModel.Title) .SetAttribute(BuiltInFieldAttributes.Title, fieldModel.Title) .SetAttribute(BuiltInFieldAttributes.Name, fieldModel.InternalName) .SetAttribute(BuiltInFieldAttributes.Type, fieldModel.FieldType) .SetAttribute(BuiltInFieldAttributes.Group, fieldModel.Group ?? string.Empty); // static name is by defaul gets InternalName if (!string.IsNullOrEmpty(fieldModel.StaticName)) fieldTemplate.SetAttribute(BuiltInFieldAttributes.StaticName, fieldModel.StaticName); else fieldTemplate.SetAttribute(BuiltInFieldAttributes.StaticName, fieldModel.InternalName); // additions if (!String.IsNullOrEmpty(fieldModel.JSLink)) fieldTemplate.SetAttribute(BuiltInFieldAttributes.JSLink, fieldModel.JSLink); if (!string.IsNullOrEmpty(fieldModel.DefaultValue)) fieldTemplate.SetSubNode("Default", fieldModel.DefaultValue); fieldTemplate.SetAttribute(BuiltInFieldAttributes.Hidden, fieldModel.Hidden.ToString().ToUpper()); // ShowIn* settings if (fieldModel.ShowInDisplayForm.HasValue) fieldTemplate.SetAttribute(BuiltInFieldAttributes.ShowInDisplayForm, fieldModel.ShowInDisplayForm.Value.ToString().ToUpper()); if (fieldModel.ShowInEditForm.HasValue) fieldTemplate.SetAttribute(BuiltInFieldAttributes.ShowInEditForm, fieldModel.ShowInEditForm.Value.ToString().ToUpper()); if (fieldModel.ShowInListSettings.HasValue) fieldTemplate.SetAttribute(BuiltInFieldAttributes.ShowInListSettings, fieldModel.ShowInListSettings.Value.ToString().ToUpper()); if (fieldModel.ShowInNewForm.HasValue) fieldTemplate.SetAttribute(BuiltInFieldAttributes.ShowInNewForm, fieldModel.ShowInNewForm.Value.ToString().ToUpper()); if (fieldModel.ShowInVersionHistory.HasValue) fieldTemplate.SetAttribute(BuiltInFieldAttributes.ShowInVersionHistory, fieldModel.ShowInVersionHistory.Value.ToString().ToUpper()); if (fieldModel.ShowInViewForms.HasValue) fieldTemplate.SetAttribute(BuiltInFieldAttributes.ShowInViewForms, fieldModel.ShowInViewForms.Value.ToString().ToUpper()); // misc if (fieldModel.AllowDeletion.HasValue) fieldTemplate.SetAttribute(BuiltInFieldAttributes.AllowDeletion, fieldModel.AllowDeletion.Value.ToString().ToUpper()); // TODO: maybe this can be done in a generic way? if (!(fieldModel is DependentLookupFieldDefinition)) { fieldTemplate.SetAttribute(BuiltInFieldAttributes.Indexed, fieldModel.Indexed.ToString().ToUpper()); } // Enhance FieldDefinition provision - investigate DefaultFormula property support for CSOM #842 // https://github.com/SubPointSolutions/spmeta2/issues/842 if (!string.IsNullOrEmpty(fieldModel.DefaultFormula)) { var defaultFormulaNode = new XElement("DefaultFormula"); defaultFormulaNode.Value = fieldModel.DefaultFormula; fieldTemplate.Add(defaultFormulaNode); } }
public static SoftwareIdentity LoadJson(string swidTagJson) { var swidTag = new SoftwareIdentity(); Meta meta = null; var expanded = Normalize(swidTagJson); foreach (var member in expanded) { var memberName = member.Key; if (member.Value.Type == JTokenType.Array) { foreach (var element in member.Value.Cast<JObject>()) { var index = element.Index(); var value = element.Val(); if (index != null) { if (value != null) { if (memberName == JSonMembers.Meta) { meta = meta ?? swidTag.AddMeta(); meta.SetAttribute(index, value); } } else { var identity = IdentityIndex[memberName]; if (memberName == identity.JsonName || memberName == identity.ProperName ) { try { // create the new element var e = new XElement(identity.XmlName); swidTag.Element.Add(e); foreach (var property in element.Properties().Where(each => each.Name != "@index")) { e.SetAttribute(IdentityIndex[property.Name].XmlName, property.PropertyValue()); } // set the index of the element if (identity.Index != null) { e.SetAttribute(identity.Index, index); } } catch (Exception e) { e.Dump(); } } } } else { swidTag.SetAttribute(memberName.ToXName(), value); } } continue; } // Console.WriteLine("'{0}' -- '{1}'", memberName, member.Value.Type); } return swidTag; }
/// <summary> /// Emits WiX XML. /// </summary> /// <returns></returns> public virtual XContainer[] ToXml() { var result = new XElement("MajorUpgrade"); result.SetAttribute("AllowDowngrades", AllowDowngrades) .SetAttribute("AllowSameVersionUpgrades", AllowSameVersionUpgrades) .SetAttribute("Disallow", Disallow) .SetAttribute("DisallowUpgradeErrorMessage", DisallowUpgradeErrorMessage) .SetAttribute("DowngradeErrorMessage", DowngradeErrorMessage) .SetAttribute("IgnoreRemoveFailure", IgnoreRemoveFailure) .SetAttribute("MigrateFeatures", MigrateFeatures) .SetAttribute("RemoveFeatures", RemoveFeatures) .SetAttribute("Schedule", Schedule); return new XContainer[] { result }; }
static void InsertCreateFolder(XElement xComponent) { //"Empty Directories" sample demonstrates the need for CreateFolder if (!DisableAutoCreateFolder) { //prevent adding more than 1 CreateFolder elements - elements that don't specify @Directory if (xComponent.Elements("CreateFolder") .All(element => element.HasAttribute("Directory"))) xComponent.Add(new XElement("CreateFolder")); } if (!DisableAutoKeyPath) { //a component must have KeyPath set on itself or on a single (just one) nested element if (!xComponent.HasKeyPathElements()) xComponent.SetAttribute("KeyPath=yes"); } }
/// <summary> /// Deinitialize activity members. /// </summary> public void ActivityClosed() { if (_activityStamp != null) { // When closing the form, inform the server that the activity is closing. XElement closeElement = new XElement(Common.Requests.ActivityClose); closeElement.SetAttribute(Common.ActivityHandle, _activityStamp); SendServerMessage(closeElement); if (ApplicationEx.Instance.OpenActivities.ContainsKey(_activityStamp)) ApplicationEx.Instance.OpenActivities.Remove(_activityStamp); } _schema = null; _activityStamp = null; if (ApplicationEx.Instance.CurrentActivity == this) ApplicationEx.Instance.CurrentActivity = null; }
/// <summary> /// Emits WiX XML. /// </summary> /// <returns></returns> public XContainer[] ToXml() { var element = new XElement(WixExtension.IIs.ToXNamespace() + "Certificate"); element.SetAttribute("Id", Id) .SetAttribute("BinaryKey", BinaryKey) .SetAttribute("CertificatePath", CertificatePath) .SetAttribute("Name", Name) .SetAttribute("Overwrite", Overwrite) .SetAttribute("PFXPassword", PFXPassword) .SetAttribute("Request", Request) .SetAttribute("StoreLocation", Enum.GetName(typeof(StoreLocation), StoreLocation)) .SetAttribute("StoreName", Enum.GetName(typeof(StoreName), StoreName)); return new[] { element }; }
/// <summary> /// Emits WiX XML. /// </summary> /// <returns></returns> public override XContainer[] ToXml() { string winInstaller = typeof(Session).Assembly.Location; var root = new XElement("BootstrapperApplicationRef"); root.SetAttribute("Id", "ManagedBootstrapperApplicationHost"); List<string> files = new List<string> { rawAppAssembly, bootstrapperCoreConfig }; files.AddRange(Payloads.Distinct()); //note %this% it already resolved at this stage into an absolutepath if(!Payloads.Where(x=>Path.GetFileName(x).SameAs(Path.GetFileName(winInstaller))).Any()) files.Add(winInstaller); if (files.Any()) files.Distinct().ForEach(p => root.Add(new XElement("Payload", new XAttribute("SourceFile", p)))); return new[] { root }; }
/// <summary> /// Emits WiX XML. /// </summary> /// <returns></returns> public override XContainer[] ToXml() { var root = new XElement("MsiPackage"); root.SetAttribute("Name", Name); //will respect null if (this.IsIdSet()) root.SetAttribute("Id", Id); root.AddAttributes(this.Attributes) .Add(this.MapToXmlAttributes()); if (Payloads.Any()) Payloads.ForEach(p => root.Add(new XElement("Payload", new XAttribute("SourceFile", p)))); if (MsiProperties.IsNotEmpty()) MsiProperties.ToDictionary().ForEach(p => { root.Add(new XElement("MsiProperty").AddAttributes("Name={0};Value={1}".FormatInline(p.Key, p.Value))); }); return new[] { root }; }
protected virtual void setDeltaText(XElement xml) { xml.SetAttribute(Common.PublishFieldValue, IntValue.ToString()); }
private static XElement WriteLink(Link link) { var element = new XElement(LinkName); element.SetAttribute(NameAttr, link.Name); element.SetAttribute(PathAttr, link.Path); element.SetAttribute(UserAttr, link.User); element.SetAttribute(PWdAttr, link.Password); return element; }
private static XElement WriteCategory(Category category) { var element = new XElement(CategoryName); element.SetAttribute(NameAttr, category.Name); foreach (var documentItem in category.Items) { element.Add(WriteItem(documentItem)); } return element; }
protected virtual void ProcessSPFieldXElement(XElement fieldTemplate, FieldDefinition fieldModel) { // minimal set fieldTemplate .SetAttribute(BuiltInFieldAttributes.ID, fieldModel.Id.ToString("B")) .SetAttribute(BuiltInFieldAttributes.DisplayName, fieldModel.Title) .SetAttribute(BuiltInFieldAttributes.Title, fieldModel.Title) .SetAttribute(BuiltInFieldAttributes.Name, fieldModel.InternalName) .SetAttribute(BuiltInFieldAttributes.Required, fieldModel.Required.ToString().ToUpper()) .SetAttribute(BuiltInFieldAttributes.Description, fieldModel.Description) .SetAttribute(BuiltInFieldAttributes.Type, fieldModel.FieldType) .SetAttribute(BuiltInFieldAttributes.Group, fieldModel.Group ?? string.Empty); // static name is by defaul gets InternalName if (!string.IsNullOrEmpty(fieldModel.StaticName)) fieldTemplate.SetAttribute(BuiltInFieldAttributes.StaticName, fieldModel.StaticName); else fieldTemplate.SetAttribute(BuiltInFieldAttributes.StaticName, fieldModel.InternalName); // additions #if !NET35 if (!String.IsNullOrEmpty(fieldModel.JSLink)) fieldTemplate.SetAttribute(BuiltInFieldAttributes.JSLink, fieldModel.JSLink); #endif if (!string.IsNullOrEmpty(fieldModel.DefaultValue)) fieldTemplate.SetSubNode("Default", fieldModel.DefaultValue); fieldTemplate.SetAttribute(BuiltInFieldAttributes.Hidden, fieldModel.Hidden.ToString().ToUpper()); // ShowIn* settings if (fieldModel.ShowInDisplayForm.HasValue) fieldTemplate.SetAttribute(BuiltInFieldAttributes.ShowInDisplayForm, fieldModel.ShowInDisplayForm.Value.ToString().ToUpper()); if (fieldModel.ShowInEditForm.HasValue) fieldTemplate.SetAttribute(BuiltInFieldAttributes.ShowInEditForm, fieldModel.ShowInEditForm.Value.ToString().ToUpper()); if (fieldModel.ShowInListSettings.HasValue) fieldTemplate.SetAttribute(BuiltInFieldAttributes.ShowInListSettings, fieldModel.ShowInListSettings.Value.ToString().ToUpper()); if (fieldModel.ShowInNewForm.HasValue) fieldTemplate.SetAttribute(BuiltInFieldAttributes.ShowInNewForm, fieldModel.ShowInNewForm.Value.ToString().ToUpper()); if (fieldModel.ShowInVersionHistory.HasValue) fieldTemplate.SetAttribute(BuiltInFieldAttributes.ShowInVersionHistory, fieldModel.ShowInVersionHistory.Value.ToString().ToUpper()); if (fieldModel.ShowInViewForms.HasValue) fieldTemplate.SetAttribute(BuiltInFieldAttributes.ShowInViewForms, fieldModel.ShowInViewForms.Value.ToString().ToUpper()); // misc if (fieldModel.AllowDeletion.HasValue) fieldTemplate.SetAttribute(BuiltInFieldAttributes.AllowDeletion, fieldModel.AllowDeletion.Value.ToString().ToUpper()); fieldTemplate.SetAttribute(BuiltInFieldAttributes.Indexed, fieldModel.Indexed.ToString().ToUpper()); // add up additional attributes if (fieldModel.AdditionalAttributes.Any()) foreach (var fieldAttr in fieldModel.AdditionalAttributes) fieldTemplate.SetAttribute(fieldAttr.Name, fieldAttr.Value); }
/// <summary> /// Emits WiX XML. /// </summary> /// <returns></returns> public override XContainer[] ToXml() { var root = new XElement("ExePackage"); root.SetAttribute("Name", Name); //will respect null if (this.IsIdSet()) root.SetAttribute("Id", Id); root.AddAttributes(this.Attributes) .Add(this.MapToXmlAttributes()); if (Payloads.Any()) Payloads.ForEach(p => root.Add(new XElement("Payload", new XAttribute("SourceFile", p)))); return new[] { root }; }
internal XElement ToXml() { var element = new XElement("Feature"); element.SetAttribute("Id", Id) .SetAttribute("Title", Name) .SetAttribute("Absent", AllowChange ? "allow" : "disallow") .SetAttribute("Level", IsEnabled ? "1" : "2") .SetAttribute("Description", Description) .SetAttribute("ConfigurableDirectory", ConfigurableDir) .AddAttributes(Attributes); if (Condition != null) element.Add( //intentionally leaving out AddAttributes(...) as Level is the only valid attribute on */Feature/Condition new XElement("Condition", new XAttribute("Level", Condition.Level), new XCData(Condition.ToCData()))); return element; }
/// <summary> /// Emits WiX XML. /// </summary> /// <returns></returns> public override XContainer[] ToXml() { var root = new XElement("PackageGroupRef"); if (this.IsIdSet()) root.SetAttribute("Id", Id); root.AddAttributes(this.Attributes) .Add(this.MapToXmlAttributes()); return new[] { root }; }