Tridionにスキーマフィールドが埋め込まれており、そこにフィールドが埋め込まれている可能性があります。スキーマ内の各埋め込みスキーマフィールドを経由してリーフデータフィールドに到達するための再帰関数
最終的な葉のフィールドに到達したいので、値を割り当てることができます。そのためには、最終フィールドに達するまで各フィールドをループする再帰関数を作成したいと考えています。
私はSDL Tridionの中でコアサービスを使用して実装しています2011
マイコード:私はあなたが探している解決策を持っていないけれども
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.ServiceModel;
using System.Net;
using System.Xml;
using Tridion.ContentManager.CoreService.Client;
using System.Text;
using Tridion.ContentManager.CoreService;
using System.ServiceModel.Channels;
using System.IO;
using System.Collections;
using System.Text.RegularExpressions;
using System.Xml.Linq;
using System.Data.OleDb;
using System.Data;
using System.Configuration;
namespace Loading_Utility
{
public partial class TST : System.Web.UI.Page
{
Fields obj = new Fields();
protected void Page_Load(object sender, EventArgs e)
{
using (ChannelFactory<ISessionAwareCoreService> factory =
new ChannelFactory<ISessionAwareCoreService>("wsHttp_2011"))
{
ISessionAwareCoreService client = factory.CreateChannel();
var schemaFields = client.ReadSchemaFields("tcm:202-2242-8", true, new ReadOptions());
ComponentData component = (ComponentData)client.GetDefaultData(ItemType.Component, "tcm:202-638-2");
var fields = Fields.ForContentOf(schemaFields);
component.Schema.IdRef="tcm:202-2242-8";
}
}
public void fieldRecursion(Field field)
{
//var getFields = fields;
if (field.GetType() == typeof(EmbeddedSchemaFieldDefinitionData))
{
// code for checking further if field is embedded or not
//Field newField = field.GetSubFields().GetFieldElements(new ItemFieldDefinitionData() as Field)
//fieldRecursion(recursiveField);
}
//string fieldName = recursiveField.Name;
//fields[fieldName] = "HI";
}
}
}
あなたが試したコードとあなたが遭遇した問題を提供しますか? –
@ Nickoli私の編集したコードを参照してください... 私はそれにデータを割り当てることができるように埋め込まれていない最終的な葉のフィールドに達するまで、スキーマの各フィールドを再帰的な関数を書くしようとしています – Aquarius24