public void SetFloat(GMKeyCode code, float value) { FieldSet set = codeMap[code]; int intValue = GmUtil.FloatToInt(value); SetUserValue(set, intValue); }
/// <summary> /// This method loads a 'FieldSet' object /// from the dataRow passed in. /// </summary> /// <param name='dataRow'>The 'DataRow' to load from.</param> /// <returns>A 'FieldSet' DataObject.</returns> public static FieldSet Load(DataRow dataRow) { // Initial Value FieldSet fieldSet = new FieldSet(); // Create field Integers int databaseIdfield = 0; int fieldSetIdfield = 1; int namefield = 2; int orderByModefield = 3; int parameterModefield = 4; int projectIdfield = 5; int readerModefield = 6; int tableIdfield = 7; try { // Load Each field fieldSet.DatabaseId = DataHelper.ParseInteger(dataRow.ItemArray[databaseIdfield], 0); fieldSet.UpdateIdentity(DataHelper.ParseInteger(dataRow.ItemArray[fieldSetIdfield], 0)); fieldSet.Name = DataHelper.ParseString(dataRow.ItemArray[namefield]); fieldSet.OrderByMode = DataHelper.ParseBoolean(dataRow.ItemArray[orderByModefield], false); fieldSet.ParameterMode = DataHelper.ParseBoolean(dataRow.ItemArray[parameterModefield], false); fieldSet.ProjectId = DataHelper.ParseInteger(dataRow.ItemArray[projectIdfield], 0); fieldSet.ReaderMode = DataHelper.ParseBoolean(dataRow.ItemArray[readerModefield], false); fieldSet.TableId = DataHelper.ParseInteger(dataRow.ItemArray[tableIdfield], 0); } catch { } // return value return(fieldSet); }
private void CustomizeCompomentForComponentLinkIgnoreCase(Component component) { component.Schema.RootElementName = "RootA"; Field headingField = new Field() { Name = "Heading", Values = new List <string> { "some heading" } }; FieldSet fieldsForLinkedComponent = new FieldSet(); fieldsForLinkedComponent.Add(headingField.Name, headingField); Field linkField = new Field() { Name = "Link", LinkedComponentValues = new List <Component> { new Component() { Title = Randomizer.AnyString(16), Id = Randomizer.AnyUri(16), Schema = new Schema() { Title = Randomizer.AnyString(10), RootElementName = "RootB" }, Fields = fieldsForLinkedComponent } } }; component.Fields.Add(linkField.Name, linkField); }
/// <summary> /// This method finds a 'FieldSet' object. /// This method uses the 'FieldSet_Find' procedure. /// </summary> /// <returns>A 'FieldSet' object.</returns> /// </summary> public FieldSet FindFieldSet(FindFieldSetStoredProcedure findFieldSetProc, DataConnector databaseConnector) { // Initial Value FieldSet fieldSet = null; // Verify database connection is connected if ((databaseConnector != null) && (databaseConnector.Connected)) { // First Get Dataset DataSet fieldSetDataSet = this.DataHelper.LoadDataSet(findFieldSetProc, databaseConnector); // Verify DataSet Exists if (fieldSetDataSet != null) { // Get DataTable From DataSet DataRow row = this.DataHelper.ReturnFirstRow(fieldSetDataSet); // if row exists if (row != null) { // Load FieldSet fieldSet = FieldSetReader.Load(row); } } } // return value return(fieldSet); }
private void FieldMatchingClick(object sender, RoutedEventArgs e) { for (int i = 1; i <= this._fieldsImported.Count; i++) { FieldSet fieldChoice = (FieldSet)((ComboBox)this.FindName(COMBOBOX_NAME + i)).SelectedItem; string choice = string.Empty; if (fieldChoice != null) { choice = fieldChoice.Name; } string labelChoice = ((Label)this.FindName(LABEL_NAME + i)).Content.ToString(); string finalChoice = choice.Equals(string.Empty) ? labelChoice : choice; this.FieldsAccepted.Add(labelChoice, finalChoice); bool isCheck = ((CheckBox)this.FindName(CHECKBOX_NAME + i)).IsChecked.Value; if (isCheck) { this.FieldsToShow.Add(finalChoice); } } this.DialogResult = true; }
/// <summary> /// Saves a 'FieldSet' object into the database. /// This method calls the 'Insert' or 'Update' method. /// </summary> /// <param name='fieldSet'>The 'FieldSet' object to save.</param> /// <returns>True if successful or false if not.</returns> public bool Save(ref FieldSet fieldSet) { // Initial value bool saved = false; // If the fieldSet exists. if (fieldSet != null) { // Is this a new FieldSet if (fieldSet.IsNew) { // Insert new FieldSet int newIdentity = this.Insert(fieldSet); // if insert was successful if (newIdentity > 0) { // Update Identity fieldSet.UpdateIdentity(newIdentity); // Set return value saved = true; } } else { // Update FieldSet saved = this.Update(fieldSet); } } // return value return(saved); }
private void CustomizeCompomentForKeywordField(Component component) { component.Schema.RootElementName = "hasKeyword"; Field headingField = new Field() { Name = "heading", Values = new List <string> { "some heading" } }; FieldSet metadataFields = new FieldSet(); metadataFields.Add(headingField.Name, headingField); Field keywordField = new Field() { Name = "keyword", KeywordValues = new List <Keyword>() { new Keyword() { MetadataFields = metadataFields, Id = Randomizer.AnyUri(1024), Title = Randomizer.AnyString(33), Description = Randomizer.AnyString(33) } } }; component.Fields.Add(keywordField.Name, keywordField); }
private bool UseField(Entity entity, Field field) { if (!field.FieldType.ExcludeFromDefaultView) { return(true); } List <FieldSet> otherFieldSets = entity.EntityType.FieldSets.Where(fs => !fs.Id.Equals(entity.FieldSetId)).ToList(); if (otherFieldSets.Count == 0) { return(true); } FieldSet fieldSet = entity.EntityType.FieldSets.Find(fs => fs.Id.Equals(entity.FieldSetId)); if (fieldSet != null) { if (fieldSet.FieldTypes.Contains(field.FieldType.Id)) { return(true); } } foreach (FieldSet fs in otherFieldSets) { if (fs.FieldTypes.Contains(field.FieldType.Id)) { return(false); } } return(true); }
/// <summary> /// Reorders the fields in a field set. /// </summary> /// <param name="fieldSet">The fieldset to reorder.</param> /// <param name="customFields">The fields of the field set in their new order.</param> /// <returns>The request status.</returns> public RequestResponse <ApiObject> Reorder(FieldSet fieldSet, ICollection <CustomField> customFields) { var arr = new CustomField[customFields.Count]; customFields.CopyTo(arr, 0); return(Reorder(fieldSet, arr)); }
public StringBuilder NotAbsFieldSet(List <FieldSet> fieldSets, int i, StringBuilder sb) { FieldSet fieldSet = fieldSets[i]; sb.Append("{" + "xtype: 'fieldset'," + string.Format(@" columnsPerRow: {0}, title: '{1}', collapsible: {2}, collapsed: {3}, border: {4}, listeners: {{ afterrender: function (me, eOpts ) {{ if ({5}) {{ me.collapse(); }} }} }}, ", fieldSet.ColumnsPerRow, fieldSet.Title, fieldSet.Collapsible.Equals(true) ? "true" : "false", "false", fieldSet.Border.Equals(true) ? "true" : "false", fieldSet.Collapsed.Equals(true) ? "true" : "false")); sb.Append(@" fieldDefaults: { margin: '0 10 8 0', anchor: '100%', msgTarget: 'side' }, fieldRows: ["); return(sb); }
public static void Main() { var an = new AssemblyName() { Version = new Version(1, 0, 0, 0), Name = "QuoteOfTheDay" }; var ab = AppDomain.CurrentDomain.DefineDynamicAssembly(an, AssemblyBuilderAccess.Save); var modBuilder = ab.DefineDynamicModule("QuoteOfTheDay", "QuoteOftheDay.dll"); var tb = modBuilder.DefineType("QuoteOfTheDay.QuoteOfTheDay", TypeAttributes.Class | TypeAttributes.Public); var fields = new FieldSet(tb); fields.DefinePrivateField<ArrayList>("_quotes"); fields.DefinePrivateField<Random>("_random"); var ilgen = Generate_Constructor(tb, fields); ////////////////////////////////////////////////// Generate_GetRandomQuote(ilgen, tb, fields); tb.CreateType(); ab.Save("QuoteOfTheDay.dll"); }
//返回金格fieldset public FieldSet GetBlobdoc(PbBillInfo billInfo) { //含有金格控件 if (billInfo.OfficeInfo.Visible) { FieldSet fieldSet = new FieldSet(); fieldSet.X = billInfo.OfficeInfo.XPos; fieldSet.Y = billInfo.OfficeInfo.YPos; fieldSet.Width = billInfo.OfficeInfo.Width; fieldSet.Height = billInfo.OfficeInfo.Height; fieldSet.Title = string.IsNullOrEmpty(billInfo.BlobdocName) ? "文档控件" : billInfo.BlobdocName; //判断金格控件在tab中位置 foreach (var tabinfo in billInfo.PbTabInfos) { for (int i = 0; i < tabinfo.GridIds.Count; i++) { if (tabinfo.GridIds[i] == "blobdoc") //不是金格控件和进度控件才是grid { fieldSet.Region = Convert.ToString(i); break; } } } return(fieldSet); } else { return(null); } }
public ActionResult DeleteFieldSet(int id) { var datasource = new DataSource <FieldSetViewModel>(); //var pageDiv = _hrUnitOfWork.PageEditorRepository.GetPageObject(models.FirstOrDefault().PageId, "FieldSet"); //string key = string.Format("{0}{1}{2}", pageDiv.Id, pageDiv.CompanyId, Language); if (ModelState.IsValid) { var field = new FieldSet { Id = id }; _hrUnitOfWork.PageEditorRepository.Remove(field); datasource.Errors = SaveChanges(Language); } if (datasource.Errors.Count() > 0) { return(Json(datasource)); } else { return(Json("OK")); } }
private void CustomizeCompomentForKeywordField(Component component) { component.Schema.RootElementName = "hasKeyword"; Field headingField = new Field() { Name = "heading", Values = new List<string> { "some heading" } }; FieldSet metadataFields = new FieldSet(); metadataFields.Add(headingField.Name, headingField); Field keywordField = new Field() { Name = "keyword", KeywordValues = new List<Keyword>() { new Keyword() { MetadataFields = metadataFields, Id = Randomizer.AnyUri(1024), Title = Randomizer.AnyString(33), Description = Randomizer.AnyString(33) } } }; component.Fields.Add(keywordField.Name, keywordField); }
private void CustomizeCompomentForEmbeddedField(Component component) { component.Schema.RootElementName = "rootEmbedding"; Field headingField = new Field() { Name = "heading", Values = new List <string> { "some heading" } }; FieldSet embeddedFields = new FieldSet(); embeddedFields.Add(headingField.Name, headingField); Field embeddedField = new Field() { Name = "embedded", EmbeddedSchema = new Schema() { Title = "EmbeddedSchema", RootElementName = "embeddedRoot", Id = Randomizer.AnyUri(8) }, EmbeddedValues = new List <FieldSet>() { embeddedFields } }; component.Fields.Add(embeddedField.Name, embeddedField); }
public void InsertNewField(string field) { FieldSet f = new FieldSet(); f.Name = field; InsertInFieldTable(f); }
public float GetFloat(GMKeyCode code) { FieldSet set = codeMap[code]; int value = GetUserValue(set.gmField); return(GmUtil.IntToFloat(value)); }
public void SetBool(GMKeyCode code, bool value) { FieldSet set = codeMap[code]; int intValue = (value == true ? 1 : 0); SetUserValue(set, intValue); }
/// <summary> /// This method returns a list of Field Set Fields View /// </summary> public static List <DTNField> LoadFieldSetFields(int fieldSetId) { // initial value List <DTNField> fields = null; // locals List <FieldSetFieldView> fieldSetFields = null; // If the value for fieldSetId is greater than zero if (fieldSetId > 0) { // Create a new instance of a 'Gateway' object. Gateway gateway = new Gateway(); // find the fieldSet FieldSet fieldSet = gateway.FindFieldSet(fieldSetId); // If the fieldSet object exists if (NullHelper.Exists(fieldSet)) { // load the field set field view for this fieldSetId fieldSetFields = gateway.LoadFieldSetFieldViewsByFieldSetId(fieldSetId); // If the fieldSetFields collection exists and has one or more items if (ListHelper.HasOneOrMoreItems(fieldSetFields)) { // convert the fields to a view fields = DataConverter.ConvertDataFields(fieldSetFields, fieldSet.DatabaseId, fieldSet.ProjectId, fieldSet.TableId); } } } // return value return(fields); }
public bool GetBool(GMKeyCode code) { FieldSet set = codeMap[code]; int value = GetUserValue(set.gmField); return(value == 0 ? false : true); }
/// <summary> /// Gets the raw string (xml) from the broker db by URL /// </summary> /// <param name="Url">URL of the page</param> /// <returns>String with page xml or empty string if no page was found</returns> public string GetContentByUrl(string Url) { Page page = new Page(); page.Title = Randomizer.AnyString(15); page.Id = Randomizer.AnyUri(64); page.Filename = Randomizer.AnySafeString(8) + ".html"; PageTemplate pt = new PageTemplate(); pt.Title = Randomizer.AnyString(20); Field ptfieldView = new Field(); ptfieldView.Name = "view"; ptfieldView.Values.Add("Standard"); pt.MetadataFields = new FieldSet(); pt.MetadataFields.Add(ptfieldView.Name, ptfieldView); page.PageTemplate = pt; Schema schema = new Schema(); schema.Title = Randomizer.AnyString(10); Component component = new Component(); component.Title = Randomizer.AnyString(30); component.Id = Randomizer.AnyUri(16); component.Schema = schema; Field field1 = Randomizer.AnyTextField(6, 120, true); Field field2 = Randomizer.AnyTextField(8, 40, false); FieldSet fieldSet = new FieldSet(); fieldSet.Add(field1.Name, field1); fieldSet.Add(field2.Name, field2); component.Fields = fieldSet; ComponentTemplate ct = new ComponentTemplate(); ct.Title = Randomizer.AnyString(20); Field fieldView = new Field(); fieldView.Name = "view"; fieldView.Values.Add("DefaultComponentView"); ct.MetadataFields = new FieldSet(); ct.MetadataFields.Add(fieldView.Name, fieldView); ComponentPresentation cp = new ComponentPresentation(); cp.Component = component; cp.ComponentTemplate = ct; page.ComponentPresentations = new List<ComponentPresentation>(); page.ComponentPresentations.Add(cp); FieldSet metadataFields = new FieldSet(); page.MetadataFields = metadataFields; var serializer = new XmlSerializer(typeof(Page)); StringBuilder builder = new StringBuilder(); StringWriter writer = new StringWriter(builder); //XmlTextWriter writer = new XmlTextWriter(page.Filename, Encoding.UTF8); //serializer.Serialize(writer, page); serializer.Serialize(writer, page); string pageAsString = builder.ToString(); return pageAsString; }
protected static void AssertScalarField(FieldSet fieldSet, int fieldIndex, Type type, String name, Operator operator_ren) { var field = (Scalar)fieldSet.GetField(fieldIndex); AssertScalarField(field, type, name); Assert.AreEqual(operator_ren, field.Operator); }
public void FieldSet_Com_Inputs_Text_E_Checkbox_E_Radio_E_Select_E_Submit() { XControl Fieldset = new FieldSet(new Legend("Titulo"), new InputText("nome-inputtext"), new Checkbox("nome-checkbox", "0", "solteiro?"), new Radio("nome-radio", "1", "desenvolvedor"), new Select("name", new Option("value-option", "item1"), new Option("value-option", "item2"))) .Add(new Submit("enviar")); string expected = "<fieldset>"; expected += "<legend>Titulo</legend>"; expected += "<input type=\"text\" name=\"nome-inputtext\" />"; expected += "<input type=\"checkbox\" name=\"nome-checkbox\" value=\"0\" />solteiro?"; expected += "<input type=\"radio\" name=\"nome-radio\" value=\"1\" />desenvolvedor"; expected += "<select name=\"name\">"; expected += "<option value=\"value-option\">item1</option>"; expected += "<option value=\"value-option\">item2</option>"; expected += "</select>"; expected += "<input type=\"submit\" value=\"enviar\" />"; expected += "</fieldset>"; Assert.AreEqual(expected, Fieldset.ToString()); }
/// <summary> /// Gets the raw string (xml) from the broker db by URL /// </summary> /// <param name="Url">URL of the page</param> /// <returns>String with page xml or empty string if no page was found</returns> public string GetContentByUrl(string Url) { Page page = new Page(); page.Title = Randomizer.AnyString(15); page.Id = Randomizer.AnyUri(64); page.Filename = Randomizer.AnySafeString(8) + ".html"; PageTemplate pt = new PageTemplate(); pt.Title = Randomizer.AnyString(20); Field ptfieldView = new Field(); ptfieldView.Name = "view"; ptfieldView.Values.Add("Standard"); pt.MetadataFields = new FieldSet(); pt.MetadataFields.Add(ptfieldView.Name, ptfieldView); page.PageTemplate = pt; page.ComponentPresentations = new List <ComponentPresentation>(); string cpString = ComponentPresentationProvider.GetContent(""); page.ComponentPresentations.Add(SerializerService.Deserialize <ComponentPresentation>(cpString)); FieldSet metadataFields = new FieldSet(); page.MetadataFields = metadataFields; return(SerializerService.Serialize <Page>(page)); }
/// <summary> /// Gets the raw string (xml) from the broker db by URL /// </summary> /// <param name="Url">URL of the page</param> /// <returns>String with page xml or empty string if no page was found</returns> public string GetContentByUrl(string Url) { Page page = new Page(); page.Title = Randomizer.AnyString(15); page.Id = Randomizer.AnyUri(64); page.Filename = Randomizer.AnySafeString(8) + ".html"; PageTemplate pt = new PageTemplate(); pt.Title = Randomizer.AnyString(20); Field ptfieldView = new Field(); ptfieldView.Name = "view"; ptfieldView.Values.Add("Standard"); pt.MetadataFields = new FieldSet(); pt.MetadataFields.Add(ptfieldView.Name, ptfieldView); page.PageTemplate = pt; page.ComponentPresentations = new List<ComponentPresentation>(); string cpString = ComponentPresentationProvider.GetContent(""); page.ComponentPresentations.Add(SerializerService.Deserialize<ComponentPresentation>(cpString)); FieldSet metadataFields = new FieldSet(); page.MetadataFields = metadataFields; return SerializerService.Serialize<Page>(page); }
internal protected Row(Guid rowUid, FieldSet primaryKey, IImmutableDictionary <Guid, RowField <object?> > fields) { RowUid = rowUid; PrimaryKey = primaryKey; _dictionary = new(fields); }
/// <summary> /// Creates a lightweight DD4T Component that contains enough information such that the semantic model builder can cope and build a strongly typed model from it. /// </summary> /// <param name="componentMeta">A <see cref="DD4T.ContentModel.IComponentMeta"/> instance obtained from CD API.</param> /// <returns>A DD4T Component.</returns> private static IComponent CreateComponent(IComponentMeta componentMeta) { Component component = new Component { Id = $"tcm:{componentMeta.PublicationId}-{componentMeta.Id}", LastPublishedDate = componentMeta.LastPublicationDate, RevisionDate = componentMeta.ModificationDate, Schema = new Schema { PublicationId = componentMeta.PublicationId.ToString(), Id = $"tcm:{componentMeta.PublicationId}-{componentMeta.SchemaId}" }, MetadataFields = new FieldSet() }; FieldSet metadataFields = new FieldSet(); component.MetadataFields.Add("standardMeta", new Field { EmbeddedValues = new List <FieldSet> { metadataFields } }); foreach (DictionaryEntry de in componentMeta.CustomMeta.NameValues) { object v = ((NameValuePair)de.Value).Value; if (v == null) { continue; } string k = de.Key.ToString(); metadataFields.Add(k, new Field { Name = k, Values = new List <string> { v.ToString() } }); } // The semantic mapping requires that some metadata fields exist. This may not be the case so we map some component meta properties onto them // if they don't exist. if (!metadataFields.ContainsKey("dateCreated")) { metadataFields.Add("dateCreated", new Field { Name = "dateCreated", DateTimeValues = new List <DateTime> { componentMeta.LastPublicationDate } }); } if (!metadataFields.ContainsKey("name")) { metadataFields.Add("name", new Field { Name = "name", Values = new List <string> { componentMeta.Title } }); } return(component); }
/// <summary> /// This method creates the sql Parameters[] needed for /// update an existing fieldSet. /// </summary> /// <param name="fieldSet">The 'FieldSet' to update.</param> /// <returns></returns> internal static SqlParameter[] CreateUpdateParameters(FieldSet fieldSet) { // Initial Values SqlParameter[] parameters = new SqlParameter[8]; SqlParameter param = null; // verify fieldSetexists if (fieldSet != null) { // Create parameter for [DatabaseId] param = new SqlParameter("@DatabaseId", fieldSet.DatabaseId); // set parameters[0] parameters[0] = param; // Create parameter for [Name] param = new SqlParameter("@Name", fieldSet.Name); // set parameters[1] parameters[1] = param; // Create parameter for [OrderByMode] param = new SqlParameter("@OrderByMode", fieldSet.OrderByMode); // set parameters[2] parameters[2] = param; // Create parameter for [ParameterMode] param = new SqlParameter("@ParameterMode", fieldSet.ParameterMode); // set parameters[3] parameters[3] = param; // Create parameter for [ProjectId] param = new SqlParameter("@ProjectId", fieldSet.ProjectId); // set parameters[4] parameters[4] = param; // Create parameter for [ReaderMode] param = new SqlParameter("@ReaderMode", fieldSet.ReaderMode); // set parameters[5] parameters[5] = param; // Create parameter for [TableId] param = new SqlParameter("@TableId", fieldSet.TableId); // set parameters[6] parameters[6] = param; // Create parameter for [FieldSetId] param = new SqlParameter("@FieldSetId", fieldSet.FieldSetId); parameters[7] = param; } // return value return(parameters); }
public ILContext(FieldSet fields) : this() { foreach (var field in fields.Fields) { Fields.Add(field.Name, field); } }
public void Remove(FieldSet fieldset) { if (Context.Entry(fieldset).State == EntityState.Detached) { context.FieldSets.Attach(fieldset); } context.FieldSets.Remove(fieldset); }
/// <inheritdoc /> protected override void ProcessRecord() { var item = new FieldSet { Name = this.Name }; //TODO: error handling WriteObject(ApiHelper.Instance.FieldSets.Create(item)); }
/// <summary> /// This method deletes a 'FieldSet' object. /// </summary> /// <param name='List<PolymorphicObject>'>The 'FieldSet' to delete. /// <returns>A PolymorphicObject object with a Boolean value. internal PolymorphicObject DeleteFieldSet(List <PolymorphicObject> parameters, DataConnector dataConnector) { // Initial Value PolymorphicObject returnObject = new PolymorphicObject(); // If the data connection is connected if ((dataConnector != null) && (dataConnector.Connected == true)) { // Create Delete StoredProcedure DeleteFieldSetStoredProcedure deleteFieldSetProc = null; // verify the first parameters is a(n) 'FieldSet'. if (parameters[0].ObjectValue as FieldSet != null) { // Create FieldSet FieldSet fieldSet = (FieldSet)parameters[0].ObjectValue; // verify fieldSet exists if (fieldSet != null) { // Now create deleteFieldSetProc from FieldSetWriter // The DataWriter converts the 'FieldSet' // to the SqlParameter[] array needed to delete a 'FieldSet'. deleteFieldSetProc = FieldSetWriter.CreateDeleteFieldSetStoredProcedure(fieldSet); } } // Verify deleteFieldSetProc exists if (deleteFieldSetProc != null) { // Execute Delete Stored Procedure bool deleted = this.DataManager.FieldSetManager.DeleteFieldSet(deleteFieldSetProc, dataConnector); // Create returnObject.Boolean returnObject.Boolean = new NullableBoolean(); // If delete was successful if (deleted) { // Set returnObject.Boolean.Value to true returnObject.Boolean.Value = NullableBooleanEnum.True; } else { // Set returnObject.Boolean.Value to false returnObject.Boolean.Value = NullableBooleanEnum.False; } } } else { // Raise Error Data Connection Not Available throw new Exception("The database connection is not available."); } // return value return(returnObject); }
protected static void AssertScalarField(FieldSet fieldSet, int fieldIndex, Type type, String name, OperatorCodec operator_ren, ScalarValue defaultValue) { var field = (Scalar)fieldSet.GetField(fieldIndex); AssertScalarField(field, type, name); Assert.AreEqual(operator_ren, field.OperatorCodec); Assert.AreEqual(defaultValue, field.DefaultValue); }
void OnEnable() { _target = (FieldSet)target; if (_target.target == null || System.Array.IndexOf(TargetFields(), _target.fieldName) == -1) { _target.fieldID = 0; _target.fieldName = ""; } }
public static IFieldSet ToFieldSet(this IEnumerable<KeyValuePair<string, IField>> ie) { IFieldSet set = new FieldSet(); foreach (KeyValuePair<string, IField> pair in ie) { set.Add(pair); } return set; }
/// <summary>Adds the fieldset to a parent container and returns it.</summary> /// <param name="container">The parent container onto which to add the container defined by this interface.</param> /// <returns>The newly added fieldset.</returns> public override Control AddTo(Control container) { FieldSet fieldSet = new FieldSet(); fieldSet.ID = Name; fieldSet.Legend = GetLocalizedText("Legend") ?? Legend; container.Controls.Add(fieldSet); return(fieldSet); }
public string GetContent(string uri, string templateUri = "") { Schema schema = new Schema(); schema.Title = Randomizer.AnyString(10); Component component = new Component(); component.Title = Randomizer.AnyString(30); component.Id = Randomizer.AnyUri(16); component.Schema = schema; Field field1 = Randomizer.AnyTextField(6, 120, true); Field field2 = Randomizer.AnyTextField(8, 40, false); FieldSet fieldSet = new FieldSet(); fieldSet.Add(field1.Name, field1); fieldSet.Add(field2.Name, field2); component.Fields = fieldSet; if (templateUri == "componentlink") { CustomizeCompomentForComponentLink(component); } if (templateUri == "embedded") { CustomizeCompomentForEmbeddedField(component); } if (templateUri == "keyword") { CustomizeCompomentForKeywordField(component); } if(templateUri == "componentIgnoreCase") { CustomizeCompomentForComponentLinkIgnoreCase(component); } if (uri == "component") { return SerializerService.Serialize<Component>(component); } ComponentTemplate ct = new ComponentTemplate(); ct.Title = Randomizer.AnyString(20); Field fieldView = new Field(); fieldView.Name = "view"; fieldView.Values.Add("DefaultComponentView"); ct.MetadataFields = new FieldSet(); ct.MetadataFields.Add(fieldView.Name, fieldView); ComponentPresentation cp = new ComponentPresentation(); cp.Component = component; cp.ComponentTemplate = ct; Condition condition = new KeywordCondition() { Keyword = new Keyword() { Id = "tcm:2-123-1024", Key = "test", Title = "Test" }, Operator = NumericalConditionOperator.Equals, Value = 1 }; cp.Conditions = new List<Condition>() { condition }; return SerializerService.Serialize<ComponentPresentation>(cp); }
public Maybe<object> For(object instance) { var fieldSet = new FieldSet(); var members = instance.GetType().FieldsAndProperties(Flags.InstancePublic); foreach (var member in members) { var view = memberViewProviders.For(instance, member); fieldSet.Add(view.IsJust() ? view.FromJust() : member.Get(instance)); } return fieldSet; }
protected static void AssertComposedScalarField(FieldSet fieldSet, int fieldIndex, Type type, String name, Operator exponentOp, ScalarValue exponentValue, Operator mantissaOp, ScalarValue mantissaValue) { var field = (ComposedScalar)fieldSet.GetField(fieldIndex); Assert.AreEqual(type, field.Type); Assert.AreEqual(name, field.Name); Scalar[] fields = field.Fields; Assert.AreEqual(exponentOp, fields[0].Operator); Assert.AreEqual(exponentValue, fields[0].DefaultValue); Assert.AreEqual(mantissaOp, fields[1].Operator); Assert.AreEqual(mantissaValue, fields[1].DefaultValue); }
private static ILGenerator Generate_Constructor(TypeBuilder tb, FieldSet fields) { var cb = tb.DefineConstructor(MethodAttributes.Public, CallingConventions.Standard, new Type[] { typeof(string) }); var ilgen = cb.GetILGenerator(); ilgen.PushContext(new ILContext(fields)); // --- DECLARE PARAMETERS --- ilgen.DeclareParameter("filename"); // --- DECLARE LOCALS --- ilgen.DeclareLocal<TextReader>("tr"); ilgen.DeclareLocal<string>("quote"); ilgen.EmitCallToBaseConstructor(); // base(); ilgen.ConstructVariable<ArrayList>("_quotes"); // _quotes = new ArrayList(); ilgen.ConstructVariable<Random>("_random"); // _random = new Random(); ilgen.EmitLoadVariable("filename"); // "filename" - first constructor parameter ilgen.EmitCall(typeof(File), "OpenText"); // invoke File.OpenText with "filename" parameter ilgen.EmitStoreVariable("tr"); // Mark the loop label ilgen.EmitLoop((gen, exit) => { gen.EmitLoadVariable("tr"); // load local "tr" gen.EmitCallvirt<TextReader>("ReadLine"); // call tr.ReadLine() (virtual) gen.EmitStoreVariable("quote"); // store the result in the local "quote" gen.EmitLoadVariable("quote"); // load the local "quote" gen.Emit(OpCodes.Brfalse_S, exit); // branch to the exit label if "quote" is null gen.EmitLoadVariable("_quotes"); // load "_quotes" field gen.EmitLoadVariable("quote"); // load local "quote" gen.EmitCallvirt<ArrayList, object>("Add"); // call _quotes.Add(object) (virtual) gen.Emit(OpCodes.Pop); // pop the result of _quotes.Add(object) (unused) }); ilgen.EmitLoadVariable("tr"); // load local "tr" ilgen.EmitCallvirt<TextReader>("Close"); // call tr.Close() (virtual) ilgen.Emit(OpCodes.Ret); // emit return opcode ilgen.PopContext(); return ilgen; }
private void CustomizeCompomentForComponentLinkIgnoreCase(Component component) { component.Schema.RootElementName = "RootA"; Field headingField = new Field() { Name = "Heading", Values = new List<string> { "some heading" } }; FieldSet fieldsForLinkedComponent = new FieldSet(); fieldsForLinkedComponent.Add(headingField.Name, headingField); Field linkField = new Field() { Name = "Link", LinkedComponentValues = new List<Component> { new Component() { Title = Randomizer.AnyString(16), Id = Randomizer.AnyUri(16), Schema = new Schema() { Title = Randomizer.AnyString(10), RootElementName = "RootB" }, Fields = fieldsForLinkedComponent } } }; component.Fields.Add(linkField.Name, linkField); }
private void CustomizeCompomentForEmbeddedField(Component component) { component.Schema.RootElementName = "rootEmbedding"; Field headingField = new Field() { Name = "heading", Values = new List<string> { "some heading" } }; FieldSet embeddedFields = new FieldSet(); embeddedFields.Add(headingField.Name, headingField); Field embeddedField = new Field() { Name = "embedded", EmbeddedSchema = new Schema() { Title = "EmbeddedSchema", RootElementName = "embeddedRoot", Id = Randomizer.AnyUri(8) }, EmbeddedValues = new List<FieldSet>() { embeddedFields } }; component.Fields.Add(embeddedField.Name, embeddedField); }
private static void Generate_GetRandomQuote(ILGenerator ilgen, TypeBuilder tb, FieldSet fields) { var mb = tb.DefineMethod<string>("GetRandomQuote", MethodAttributes.Public, CallingConventions.Standard); ilgen = mb.GetILGenerator(); ilgen.PushContext(new ILContext(fields)); // --- DECLARE LOCALS --- ilgen.DeclareLocal<int>("count"); ilgen.EmitLoadVariable("_quotes"); // load field "m_Quotes" ilgen.EmitCallvirt<ArrayList>("get_Count"); // call _quotes.get_Count() (virtual) ilgen.EmitStoreVariable("count"); // store in local "count" ilgen.EmitLoadVariable("count"); // load local "count" ilgen.EmitIfFalse(gen => { ilgen.Emit(OpCodes.Ldstr, ""); // load the string "" ilgen.Emit(OpCodes.Ret); // return }); ilgen.EmitLoadVariable("_quotes"); // load field "_quotes" ilgen.EmitLoadVariable("_random"); // load field "_random" ilgen.EmitLoadVariable("count"); // load local "count" ilgen.EmitCallvirt<Random, int>("Next"); // call _random.Next(int) (virtual) ilgen.EmitCallvirt<ArrayList>("get_Item"); // call _quotes.get_Item(int) (virtual) ilgen.Emit(OpCodes.Castclass, typeof(string)); // cast the result to string ilgen.Emit(OpCodes.Ret); // return ilgen.PopContext(); }
public override void Write(IO.EndianWriter stream) { Compiler comp = stream.Owner as Compiler; #region FieldSets uint fieldSetsAddress = stream.PositionUnsigned; FieldSet temp = new FieldSet(); Import.FieldSet fs; int x; for (x = 0; x < tagBlock.FieldSets.Count - 1; x++) { fs = tagBlock.FieldSets[x]; temp.Reset(fs); temp.Write(stream); } uint fieldSetLatestAddress = stream.PositionUnsigned; fs = tagBlock.FieldSets[x]; temp.Reset(fs); temp.Write(stream); #endregion comp.MarkLocationFixup(tagBlock.Name, stream, false); RuntimeAddress = stream.PositionUnsigned; stream.Write(tagBlock.Name); stream.Write(tagBlock.DisplayName); stream.Write((int)0); stream.Write(tagBlock.MaxElements); stream.Write(comp.Strings.GetNull()); stream.WritePointer(fieldSetsAddress); stream.Write(tagBlock.FieldSets.Count); stream.WritePointer(fieldSetLatestAddress); stream.Write((int)0); stream.Write((int)0); stream.Write((int)0); stream.Write((int)0); stream.Write((int)0); stream.Write((int)0); stream.Write((int)0); }
void ProcessFields(List<Field> field_list, List<FieldSet> field_sets) { // 分组并限制最长10个 Field field; FieldSet fset; for (int index = 0; index < field_list.Count; ++index) { field = field_list[index]; if (field.deprecated) continue; fset = new FieldSet(); field_sets.Add(fset); fset.beg_index = index; if (field.tag > 1) { fset.streamed = false; fset.end_index = index; } else { fset.streamed = true; // 查找结束位置 int next_range = Math.Min(field_list.Count, index + 10); int end_index = index + 1; for (; end_index < next_range; ++end_index) { field = field_list[end_index]; if (field.deprecated || field.tag > 1) break; } fset.end_index = end_index - 1; } // 移动索引 index = fset.end_index; } }
public void run(PerSecurityWSDL.PerSecurityWS ps) { //Setting request header information GetCompanyHeaders gtCompHdrs = new GetCompanyHeaders(); gtCompHdrs.creditrisk = true; //Setting instruments Instrument ticker = new Instrument(); ticker.id = "AAPL US"; ticker.yellowkey = MarketSector.Equity; ticker.yellowkeySpecified = true; //Setting the get Company request parameter SubmitGetCompanyRequest sbmtGtCompReq = new SubmitGetCompanyRequest(); sbmtGtCompReq.headers = gtCompHdrs; Instruments instrs = new Instruments(); instrs.instrument = new Instrument[] { ticker }; sbmtGtCompReq.instruments = instrs; //Setting fields for the request FieldSet fieldSet = new FieldSet(); fieldSet.fieldmacro = FieldMacro.BO_CREDIT_RISK_COMPANY; sbmtGtCompReq.fieldset = fieldSet; try { Console.WriteLine("Submit Get Company Request"); SubmitGetCompanyResponse sbmtGtCompResp = ps.submitGetCompanyRequest(sbmtGtCompReq); System.Console.WriteLine("status " + sbmtGtCompResp.statusCode.description); System.Console.WriteLine("Submit Get Company request - response ID = " + sbmtGtCompResp.responseId); //retrieve get company request. The response ID sent for the request is the response ID //received from SubmitGetCompanyRequest() Console.WriteLine("Retrieve Company request"); RetrieveGetCompanyRequest rtvGrCompReq = new RetrieveGetCompanyRequest(); rtvGrCompReq.responseId = sbmtGtCompResp.responseId; RetrieveGetCompanyResponse rtrvGtCompResp = new RetrieveGetCompanyResponse(); //Keep sending the request if status is 100 do { System.Threading.Thread.Sleep(PerSecurity.POLL_INTERVAL); rtrvGtCompResp = ps.retrieveGetCompanyResponse(rtvGrCompReq); } while (rtrvGtCompResp.statusCode.code == PerSecurity.DATA_NOT_AVAILABLE); if (rtrvGtCompResp.statusCode.code == PerSecurity.SUCCESS) { //Displaying the rtrvGtCompResp for (int i = 0; i < rtrvGtCompResp.instrumentDatas.Length; i++) { Console.WriteLine("Data for :" + rtrvGtCompResp.instrumentDatas[i].instrument.id + " " + rtrvGtCompResp.instrumentDatas[i].instrument.yellowkey); for (int j = 0; j < rtrvGtCompResp.instrumentDatas[i].data.Length; j++) { if (rtrvGtCompResp.instrumentDatas[i].data[j].isArray == true) { //In case this is a bulk field request for (int k = 0; k < rtrvGtCompResp.instrumentDatas[i].data[j].bulkarray.Length; k++) { Console.WriteLine("-------------------------_"); for (int l = 0; l < rtrvGtCompResp.instrumentDatas[i].data[j]. bulkarray[k].data.Length; l++) Console.WriteLine(rtrvGtCompResp.instrumentDatas[i].data[j].bulkarray[k].data[l].value); } } else Console.WriteLine(" " + rtrvGtCompResp.fields[j] + " : " + rtrvGtCompResp.instrumentDatas[i].data[j].value); } } } else if (rtrvGtCompResp.statusCode.code == PerSecurity.REQUEST_ERROR) Console.WriteLine("Error in the submitted request"); } catch (Exception e) { Console.WriteLine(e.Message); } }
public static Dynamic.Field BuildField(TCM.Fields.ItemField tcmItemField, int currentLinkLevel, BuildManager manager) { Dynamic.Field f = new Dynamic.Field(); if (tcmItemField == null && manager.BuildProperties.PublishEmptyFields) { f.Values.Add(""); return f; } else if (tcmItemField == null && !manager.BuildProperties.PublishEmptyFields) { throw new FieldHasNoValueException(); } f.Name = tcmItemField.Name; if (tcmItemField is TCM.Fields.XhtmlField) { TCM.Fields.XhtmlField sField = (TCM.Fields.XhtmlField)tcmItemField; if (sField.Values.Count == 0 && manager.BuildProperties.PublishEmptyFields) { f.Values.Add(""); } else if (sField.Values.Count == 0 && !manager.BuildProperties.PublishEmptyFields) { throw new FieldHasNoValueException(); } else { foreach (string v in sField.Values) { f.Values.Add(manager.PublishBinariesInRichTextField(v)); } } f.FieldType = FieldType.Xhtml; return f; } if (tcmItemField is TCM.Fields.MultiLineTextField) { TCM.Fields.TextField sField = (TCM.Fields.MultiLineTextField)tcmItemField; if (sField.Values.Count == 0 && manager.BuildProperties.PublishEmptyFields) { f.Values.Add(""); } else if (sField.Values.Count == 0 && !manager.BuildProperties.PublishEmptyFields) { throw new FieldHasNoValueException(); } else { foreach (string v in sField.Values) { f.Values.Add(v); } } f.FieldType = FieldType.MultiLineText; return f; } if (tcmItemField is TCM.Fields.TextField) { TCM.Fields.TextField sField = (TCM.Fields.TextField)tcmItemField; if (sField.Values.Count == 0 && manager.BuildProperties.PublishEmptyFields) { f.Values.Add(""); } else if (sField.Values.Count == 0 && !manager.BuildProperties.PublishEmptyFields) { throw new FieldHasNoValueException(); } else { foreach (string v in sField.Values) { f.Values.Add(v); } } f.FieldType = FieldType.Text; return f; } if (tcmItemField is TCM.Fields.KeywordField) { TCM.Fields.KeywordField sField = (TCM.Fields.KeywordField)tcmItemField; if (sField.Values.Count == 0 && manager.BuildProperties.PublishEmptyFields) { f.Values.Add(""); } else if (sField.Values.Count == 0 && !manager.BuildProperties.PublishEmptyFields) { throw new FieldHasNoValueException(); } else { // add keyword values f.Keywords = new List<Keyword>(); // we will wrap each linked component in a ContentModel component foreach (TCM.Keyword kw in sField.Values) { f.Keywords.Add(manager.BuildKeyword(kw)); } if (!manager.BuildProperties.OmitValueLists) { f.Values = new List<string>(); foreach (TCM.Keyword kw in sField.Values) { f.Values.Add(kw.Title); } } KeywordFieldDefinition fieldDef = (KeywordFieldDefinition)sField.Definition; f.CategoryId = fieldDef.Category.Id; f.CategoryName = fieldDef.Category.Title; } f.FieldType = FieldType.Keyword; return f; } if (tcmItemField is TCM.Fields.NumberField) { TCM.Fields.NumberField sField = (TCM.Fields.NumberField)tcmItemField; if (sField.Values.Count == 0 && manager.BuildProperties.PublishEmptyFields) { f.Values.Add(""); } else if (sField.Values.Count == 0 && !manager.BuildProperties.PublishEmptyFields) { throw new FieldHasNoValueException(); } else { f.NumericValues = (List<double>)sField.Values; if (!manager.BuildProperties.OmitValueLists) { f.Values = new List<string>(); foreach (double d in f.NumericValues) { f.Values.Add(Convert.ToString(d)); } } } f.FieldType = FieldType.Number; return f; } if (tcmItemField is TCM.Fields.DateField) { TCM.Fields.DateField sField = (TCM.Fields.DateField)tcmItemField; if (sField.Values.Count == 0 && manager.BuildProperties.PublishEmptyFields) { f.Values.Add(""); } else if (sField.Values.Count == 0 && !manager.BuildProperties.PublishEmptyFields) { throw new FieldHasNoValueException(); } else { f.DateTimeValues = (List<DateTime>)sField.Values; if (!manager.BuildProperties.OmitValueLists) { f.Values = new List<string>(); foreach (DateTime dt in f.DateTimeValues) { f.Values.Add(Convert.ToString(dt)); } } } f.FieldType = FieldType.Date; return f; } if (tcmItemField is TCM.Fields.MultimediaLinkField) { TCM.Fields.MultimediaLinkField sField = (TCM.Fields.MultimediaLinkField)tcmItemField; if (sField.Values.Count == 0 && manager.BuildProperties.PublishEmptyFields) { f.Values.Add(tcmItemField.Name); } else if (sField.Values.Count == 0 && !manager.BuildProperties.PublishEmptyFields) { throw new FieldHasNoValueException(); } else { // we will wrap each linked component in a ContentModel component f.LinkedComponentValues = new List<Dynamic.Component>(); int nextLinkLevel = currentLinkLevel - 1; if (MustFollowField(sField, manager)) { log.Debug(string.Format("found component link field named {0} with global followLinksPerField property set to false OR followLink set to true for this field", sField.Name)); } else { log.Debug(string.Format("found component link field named {0} with followLink set to false for this field", sField.Name)); nextLinkLevel = 0; } foreach (TCM.Component comp in sField.Values) { f.LinkedComponentValues.Add(manager.BuildComponent(comp, nextLinkLevel)); } if (!manager.BuildProperties.OmitValueLists) { f.Values = new List<string>(); foreach (Dynamic.Component c in f.LinkedComponentValues) { f.Values.Add(c.Id); } } } f.FieldType = FieldType.MultiMediaLink; return f; } if (tcmItemField is TCM.Fields.ComponentLinkField) { TCM.Fields.ComponentLinkField sField = (TCM.Fields.ComponentLinkField)tcmItemField; if (sField.Values.Count == 0 && manager.BuildProperties.PublishEmptyFields) { f.Values.Add(tcmItemField.Name); } else if (sField.Values.Count == 0 && !manager.BuildProperties.PublishEmptyFields) { throw new FieldHasNoValueException(); } else { // we will wrap each linked component in a ContentModel component f.LinkedComponentValues = new List<Dynamic.Component>(); int nextLinkLevel = currentLinkLevel - 1; if (MustFollowField(sField, manager)) { log.Debug(string.Format("found component link field named {0} with global followLinksPerField property set to false OR followLink set to true for this field", sField.Name)); } else { log.Debug(string.Format("found component link field named {0} with followLink set to false for this field", sField.Name)); nextLinkLevel = 0; } foreach (TCM.Component comp in sField.Values) { f.LinkedComponentValues.Add(manager.BuildComponent(comp, nextLinkLevel)); } if (!manager.BuildProperties.OmitValueLists) { f.Values = new List<string>(); foreach (Dynamic.Component c in f.LinkedComponentValues) { f.Values.Add(c.Id); } } } f.FieldType = FieldType.ComponentLink; return f; } if (tcmItemField is TCM.Fields.EmbeddedSchemaField) { TCM.Fields.EmbeddedSchemaField sField = (TCM.Fields.EmbeddedSchemaField)tcmItemField; f.FieldType = FieldType.Embedded; f.EmbeddedValues = new List<Dynamic.FieldSet>(); bool hasValues = CheckIfEmbeddedFieldHasValues(sField); if (!hasValues && manager.BuildProperties.PublishEmptyFields) { Dynamic.FieldSet fields = new FieldSet(); Dynamic.Field fe = new Dynamic.Field(); f.EmbeddedSchema = manager.BuildSchema(((EmbeddedSchemaFieldDefinition)sField.Definition).EmbeddedSchema); EmbeddedSchemaFieldDefinition linksFieldDefinition = sField.Definition as EmbeddedSchemaFieldDefinition; ItemFields newItemField = new ItemFields(linksFieldDefinition.EmbeddedSchema); for (int i = 0; i < newItemField.Count; i++) { if (newItemField[i] is TCM.Fields.EmbeddedSchemaField) { TCM.Fields.EmbeddedSchemaField innerField = (TCM.Fields.EmbeddedSchemaField)newItemField[i]; if (innerField.Values.Count == 0) { Dynamic.FieldSet fieldsinner = new FieldSet(); Dynamic.Field fin = new Dynamic.Field(); fe.EmbeddedSchema = manager.BuildSchema(((EmbeddedSchemaFieldDefinition)innerField.Definition).EmbeddedSchema); EmbeddedSchemaFieldDefinition inlinksFieldDefinition = innerField.Definition as EmbeddedSchemaFieldDefinition; ItemFields newinItemField = new ItemFields(inlinksFieldDefinition.EmbeddedSchema); for (int n = 0; n < newinItemField.Count; n++) { fin.Name = newItemField[n].Name; fieldsinner.Add(newinItemField[n].Name, fin); } fe.EmbeddedValues.Add(fieldsinner); fe.Values.Add(""); } fe.Name = newItemField[i].Name; fields.Add(newItemField[i].Name, fe); } else { Dynamic.Field fein = manager.BuildField(newItemField[i], currentLinkLevel); fein.Values.Clear(); fields.Add(newItemField[i].Name, fein); } } f.EmbeddedValues.Add(fields); f.Values.Add(""); } else if (!hasValues && !manager.BuildProperties.PublishEmptyFields) { throw new FieldHasNoValueException(); } else { // we will wrap each linked component in a ContentModel component f.EmbeddedValues = new List<Dynamic.FieldSet>(); f.EmbeddedSchema = manager.BuildSchema(((EmbeddedSchemaFieldDefinition)sField.Definition).EmbeddedSchema); foreach (TCM.Fields.ItemFields embeddedFields in sField.Values) { f.EmbeddedValues.Add(manager.BuildFields(embeddedFields, currentLinkLevel)); } } return f; } throw new FieldTypeNotDefinedException(); }
public static Dynamic.Field BuildField(TCM.Fields.ItemField tcmItemField, int linkLevels, bool resolveWidthAndHeight, bool publishEmptyFields, BuildManager manager) { Dynamic.Field f = new Dynamic.Field(); if (tcmItemField == null&&publishEmptyFields) { GeneralUtils.TimedLog("item field is null"); //throw new FieldHasNoValueException(); f.Values.Add(""); return f; } else if (tcmItemField == null && !publishEmptyFields) { throw new FieldHasNoValueException(); } f.Name = tcmItemField.Name; if (tcmItemField is TCM.Fields.XhtmlField) { TCM.Fields.XhtmlField sField = (TCM.Fields.XhtmlField)tcmItemField; GeneralUtils.TimedLog(string.Format("item field {0} has {1} values", tcmItemField.Name, sField.Values.Count)); if (sField.Values.Count == 0 && publishEmptyFields) { //throw new FieldHasNoValueException(); f.Values.Add(""); } else if (sField.Values.Count == 0 && !publishEmptyFields) { throw new FieldHasNoValueException(); } else { foreach (string v in sField.Values) { f.Values.Add(v); } } f.FieldType = FieldType.Xhtml; return f; } if (tcmItemField is TCM.Fields.MultiLineTextField) { TCM.Fields.TextField sField = (TCM.Fields.MultiLineTextField)tcmItemField; GeneralUtils.TimedLog(string.Format("item field {0} has {1} values", tcmItemField.Name, sField.Values.Count)); //if (sField.Values.Count == 0) // throw new FieldHasNoValueException(); if (sField.Values.Count == 0 && publishEmptyFields) { //throw new FieldHasNoValueException(); f.Values.Add(""); } else if (sField.Values.Count == 0 && !publishEmptyFields) { throw new FieldHasNoValueException(); } else { foreach (string v in sField.Values) { f.Values.Add(v); } } f.FieldType = FieldType.MultiLineText; return f; } if (tcmItemField is TCM.Fields.TextField) { TCM.Fields.TextField sField = (TCM.Fields.TextField)tcmItemField; GeneralUtils.TimedLog(string.Format("item field {0} has {1} values", tcmItemField.Name, sField.Values.Count)); //if (sField.Values.Count == 0) // throw new FieldHasNoValueException(); if (sField.Values.Count == 0 && publishEmptyFields) { //throw new FieldHasNoValueException(); f.Values.Add(""); } else if (sField.Values.Count == 0 && !publishEmptyFields) { throw new FieldHasNoValueException(); } else { foreach (string v in sField.Values) { f.Values.Add(v); } } f.FieldType = FieldType.Text; return f; } if (tcmItemField is TCM.Fields.KeywordField) { TCM.Fields.KeywordField sField = (TCM.Fields.KeywordField)tcmItemField; GeneralUtils.TimedLog(string.Format("item field {0} has {1} values", tcmItemField.Name, sField.Values.Count)); //if (sField.Values.Count == 0) // throw new FieldHasNoValueException(); if (sField.Values.Count == 0 && publishEmptyFields) { //throw new FieldHasNoValueException(); f.Values.Add(""); } else if (sField.Values.Count == 0 && !publishEmptyFields) { throw new FieldHasNoValueException(); } else { // add keyword values f.Keywords = new List<Keyword>(); // we will wrap each linked component in a ContentModel component f.Values = new List<string>(); foreach (TCM.Keyword kw in sField.Values) { // todo: add binary to package, and add BinaryUrl property to the component f.Values.Add(kw.Title); f.Keywords.Add(manager.BuildKeyword(kw)); } KeywordFieldDefinition fieldDef = (KeywordFieldDefinition)sField.Definition; f.CategoryId = fieldDef.Category.Id; f.CategoryName = fieldDef.Category.Title; } f.FieldType = FieldType.Keyword; return f; } if (tcmItemField is TCM.Fields.NumberField) { TCM.Fields.NumberField sField = (TCM.Fields.NumberField)tcmItemField; GeneralUtils.TimedLog(string.Format("item field {0} has {1} values", tcmItemField.Name, sField.Values.Count)); //if (sField.Values.Count == 0) // throw new FieldHasNoValueException(); if (sField.Values.Count == 0 && publishEmptyFields) { //throw new FieldHasNoValueException(); f.Values.Add(""); } else if (sField.Values.Count == 0 && !publishEmptyFields) { throw new FieldHasNoValueException(); } else { f.NumericValues = (List<double>)sField.Values; f.Values = new List<string>(); foreach (double d in f.NumericValues) { f.Values.Add(Convert.ToString(d)); } } f.FieldType = FieldType.Number; return f; } if (tcmItemField is TCM.Fields.DateField) { TCM.Fields.DateField sField = (TCM.Fields.DateField)tcmItemField; GeneralUtils.TimedLog(string.Format("item field {0} has {1} values", tcmItemField.Name, sField.Values.Count)); //if (sField.Values.Count == 0) // throw new FieldHasNoValueException(); if (sField.Values.Count == 0 && publishEmptyFields) { //throw new FieldHasNoValueException(); f.Values.Add(""); } else if (sField.Values.Count == 0 && !publishEmptyFields) { throw new FieldHasNoValueException(); } else { f.DateTimeValues = (List<DateTime>)sField.Values; f.Values = new List<string>(); foreach (DateTime dt in f.DateTimeValues) { f.Values.Add(Convert.ToString(dt)); } } f.FieldType = FieldType.Date; return f; } if (tcmItemField is TCM.Fields.MultimediaLinkField) { TCM.Fields.MultimediaLinkField sField = (TCM.Fields.MultimediaLinkField)tcmItemField; GeneralUtils.TimedLog(string.Format("item field {0} has {1} values", tcmItemField.Name, sField.Values.Count)); if (sField.Values.Count == 0 && publishEmptyFields) { f.Values.Add(tcmItemField.Name); } else if (sField.Values.Count == 0 && !publishEmptyFields) { throw new FieldHasNoValueException(); } else { // we will wrap each linked component in a ContentModel component f.LinkedComponentValues = new List<Dynamic.Component>(); foreach (TCM.Component comp in sField.Values) { // todo: add binary to package, and add BinaryUrl property to the component f.LinkedComponentValues.Add(manager.BuildComponent(comp, linkLevels - 1, resolveWidthAndHeight, publishEmptyFields)); } f.Values = new List<string>(); foreach (Dynamic.Component c in f.LinkedComponentValues) { f.Values.Add(c.Id); } } f.FieldType = FieldType.MultiMediaLink; return f; } if (tcmItemField is TCM.Fields.ComponentLinkField) { TCM.Fields.ComponentLinkField sField = (TCM.Fields.ComponentLinkField)tcmItemField; GeneralUtils.TimedLog(string.Format("item field {0} has {1} values", tcmItemField.Name, sField.Values.Count)); //if (sField.Values.Count == 0) // throw new FieldHasNoValueException(); if (sField.Values.Count == 0 && publishEmptyFields) { f.Values.Add(tcmItemField.Name); } else if (sField.Values.Count == 0 && !publishEmptyFields) { throw new FieldHasNoValueException(); } else { // we will wrap each linked component in a ContentModel component f.LinkedComponentValues = new List<Dynamic.Component>(); foreach (TCM.Component comp in sField.Values) { f.LinkedComponentValues.Add(manager.BuildComponent(comp, linkLevels - 1, resolveWidthAndHeight, publishEmptyFields)); } f.Values = new List<string>(); foreach (Dynamic.Component c in f.LinkedComponentValues) { f.Values.Add(c.Id); } } f.FieldType = FieldType.ComponentLink; return f; } if (tcmItemField is TCM.Fields.EmbeddedSchemaField) { TCM.Fields.EmbeddedSchemaField sField = (TCM.Fields.EmbeddedSchemaField)tcmItemField; GeneralUtils.TimedLog(string.Format("item field {0} has {1} values", tcmItemField.Name, sField.Values.Count)); //if (sField.Values.Count == 0) //throw new FieldHasNoValueException(); f.FieldType = FieldType.Embedded; f.EmbeddedValues = new List<Dynamic.FieldSet>(); if (sField.Values.Count == 0 && publishEmptyFields) { Dynamic.FieldSet fields = new FieldSet(); Dynamic.Field fe = new Dynamic.Field(); f.EmbeddedSchema = manager.BuildSchema(((EmbeddedSchemaFieldDefinition)sField.Definition).EmbeddedSchema); EmbeddedSchemaFieldDefinition linksFieldDefinition = sField.Definition as EmbeddedSchemaFieldDefinition; ItemFields newItemField = new ItemFields(linksFieldDefinition.EmbeddedSchema); for (int i = 0; i < newItemField.Count; i++) { if (newItemField[i] is TCM.Fields.EmbeddedSchemaField) { TCM.Fields.EmbeddedSchemaField innerField = (TCM.Fields.EmbeddedSchemaField)newItemField[i]; if (innerField.Values.Count == 0) { Dynamic.FieldSet fieldsinner = new FieldSet(); Dynamic.Field fin = new Dynamic.Field(); fe.EmbeddedSchema = manager.BuildSchema(((EmbeddedSchemaFieldDefinition)innerField.Definition).EmbeddedSchema); EmbeddedSchemaFieldDefinition inlinksFieldDefinition = innerField.Definition as EmbeddedSchemaFieldDefinition; ItemFields newinItemField = new ItemFields(inlinksFieldDefinition.EmbeddedSchema); for (int n = 0; n < newinItemField.Count; n++) { fin.Name = newItemField[n].Name; fieldsinner.Add(newinItemField[n].Name, fin); } fe.EmbeddedValues.Add(fieldsinner); fe.Values.Add(""); } fe.Name = newItemField[i].Name; fields.Add(newItemField[i].Name, fe); } else { Dynamic.Field fein = manager.BuildField(newItemField[i], linkLevels, resolveWidthAndHeight, publishEmptyFields); fein.Values.Clear(); fields.Add(newItemField[i].Name, fein); } } f.EmbeddedValues.Add(fields); f.Values.Add(""); } else if (sField.Values.Count == 0 && !publishEmptyFields) { throw new FieldHasNoValueException(); } else { // we will wrap each linked component in a ContentModel component f.EmbeddedValues = new List<Dynamic.FieldSet>(); f.EmbeddedSchema = manager.BuildSchema(((EmbeddedSchemaFieldDefinition)sField.Definition).EmbeddedSchema); foreach (TCM.Fields.ItemFields embeddedFields in sField.Values) { f.EmbeddedValues.Add(manager.BuildFields(embeddedFields, linkLevels, resolveWidthAndHeight, publishEmptyFields)); } } return f; } throw new FieldTypeNotDefinedException(); }
public static Dynamic.FieldSet BuildFields(TCM.Fields.ItemFields tcmItemFields, int linkLevels, bool resolveWidthAndHeight, bool publishEmptyFields, BuildManager manager) { Dynamic.FieldSet fields = new FieldSet(); AddFields(fields, tcmItemFields, linkLevels, resolveWidthAndHeight,publishEmptyFields, Dynamic.MergeAction.Replace, manager); return fields; }
public void Builder_Can_Build_A_Carousel_Using_The_Embedded_Component_Attribute() { var slide1 = new FieldSet(); slide1.Add("heading", new Field() { Values = { "Slide 1" } }); slide1.Add("summary", new Field() { Values = { "Slide 1 Summary" } }); slide1.Add("image", new Field() { LinkedComponentValues = { new Component() { Multimedia = new Multimedia() { Url = "_images/asd.png" } } } }); var slide2 = new FieldSet(); slide2.Add("heading", new Field() { Values = { "Slide 2" } }); slide2.Add("summary", new Field() { Values = { "Slide 2 Summary" } }); slide2.Add("image", new Field() { LinkedComponentValues = { new Component() { Multimedia = new Multimedia() { Url = "_images/asdc.png" } } } }); var embeddedList = new List<FieldSet>(); embeddedList.Add(slide1); embeddedList.Add(slide2); var carousel = new Component(); carousel.Fields.Add("title", new Field() { Values = { "My Carousel" } }); carousel.Fields.Add("embedded_list", new Field() { EmbeddedValues = embeddedList }); var carouselModel = ComponentViewModelBuilder.Build<CarouselViewModel>(carousel); Assert.That(carouselModel.EmbeddedCarouselItemViewModels.Count(), Is.EqualTo(2)); Assert.That(carouselModel.EmbeddedCarouselItemViewModels.First().Heading, Is.EqualTo("Slide 1")); Assert.That(carouselModel.EmbeddedCarouselItemViewModels.Skip(1).First().Heading, Is.EqualTo("Slide 2")); }
protected void Page_Load(object sender, EventArgs e) { SuperForm1 = new SuperForm(); SuperForm1.ID = "SuperForm1"; SuperForm1.DataSourceID = "SqlDataSource1"; SuperForm1.AutoGenerateRows = false; SuperForm1.AutoGenerateInsertButton = true; SuperForm1.AutoGenerateEditButton = true; SuperForm1.AutoGenerateDeleteButton = true; SuperForm1.DataKeyNames = new string[] { "OrderID" }; SuperForm1.AllowPaging = true; SuperForm1.DefaultMode = DetailsViewMode.Edit; SuperForm1.Width = Unit.Pixel(600); Obout.SuperForm.BoundField field1 = new Obout.SuperForm.BoundField(); field1.DataField = "OrderID"; field1.HeaderText = "Order ID"; field1.ReadOnly = true; field1.InsertVisible = false; field1.FieldSetID = "FieldSet2"; Obout.SuperForm.BoundField field2 = new Obout.SuperForm.BoundField(); field2.DataField = "ShipName"; field2.HeaderText = "Ship Name"; field2.FieldSetID = "FieldSet2"; Obout.SuperForm.BoundField field3 = new Obout.SuperForm.BoundField(); field3.DataField = "ShipCity"; field3.HeaderText = "Ship City"; field3.FieldSetID = "FieldSet2"; Obout.SuperForm.DateField field4 = new Obout.SuperForm.DateField(); field4.DataField = "OrderDate"; field4.HeaderText = "Order Date"; field4.DataFormatString = "{0:MM/dd/yyyy}"; field4.ApplyFormatInEditMode = true; field4.FieldSetID = "FieldSet3"; Obout.SuperForm.DateField field5 = new Obout.SuperForm.DateField(); field5.DataField = "ShippedDate"; field5.HeaderText = "Shipped Date"; field5.DataFormatString = "{0:MM/dd/yyyy}"; field5.ApplyFormatInEditMode = true; field5.FieldSetID = "FieldSet3"; Obout.SuperForm.DateField field6 = new Obout.SuperForm.DateField(); field6.DataField = "RequiredDate"; field6.HeaderText = "Required Date"; field6.DataFormatString = "{0:MM/dd/yyyy}"; field6.ApplyFormatInEditMode = true; field6.FieldSetID = "FieldSet3"; SuperForm1.Fields.Add(field1); SuperForm1.Fields.Add(field2); SuperForm1.Fields.Add(field3); SuperForm1.Fields.Add(field4); SuperForm1.Fields.Add(field5); SuperForm1.Fields.Add(field6); Obout.SuperForm.FieldSetRow row2 = new Obout.SuperForm.FieldSetRow(); FieldSet fieldSet2 = new FieldSet(); fieldSet2.ID = "FieldSet2"; fieldSet2.CssClass = "field-set"; fieldSet2.Title = "Shipping Information"; FieldSet fieldSet3 = new FieldSet(); fieldSet3.ID = "FieldSet3"; fieldSet3.CssClass = "field-set"; fieldSet3.Title = "Timeline Information"; row2.Items.Add(fieldSet2); row2.Items.Add(fieldSet3); SuperForm1.FieldSets.Add(row2); SuperForm1Container.Controls.Add(SuperForm1); }