0

Umbraco 6.1.5 および uSiteBuilder 3.0.0 での作業で問題が発生しました。ここContentHelperで、DocumentType で定義されたすべてのフィールドを使用して強く型付けされた DocumentType をインスタンス化すると、オブジェクトにロードされますが、 のようなフィールドNameまたはIdロードChildrenされません (それらの ' re null、空、または 0)。

私が言えることContentHelperは、インスタンス化を担当するメソッドが空のコンストラクターを呼び出しているためDynamicNodeです。足りないものはありますか?ドキュメント タイプでコンストラクタを定義する必要がありますか?

ここに私のDocumentTypeがあります:

namespace USiteBuilderTest.DocumentTypes
{
    [DocumentType]
    public class Home : DocumentTypeBase
    {
        [DocumentTypeProperty(Name = "Field 1")]
        public string Field1 { set; get; }

        [DocumentTypeProperty(Name = "Field 2")]
        public string Field2 { set; get; }

        [DocumentTypeProperty(Name = "Field 3")]
        public string Field3 { set; get; }
    }
}

参考までに、空のコンストラクターを呼び出しているコードの一部を次に示します。

Type typeDocType = DocumentTypeManager.GetDocumentTypeType(node.NodeTypeAlias);
    if (typeDocType != null)
    {
        ConstructorInfo constructorInfo = typeDocType.GetConstructor(new[] { typeof(int) });
        if (constructorInfo == null)
        {
            retVal = (DocumentTypeBase)Activator.CreateInstance(typeDocType);
        }
        else
        {
            retVal = (DocumentTypeBase)constructorInfo.Invoke(new object[] { node.Id });
        }
4

2 に答える 2

0

Codeplex プロジェクトの説明では、ブランチ「3.0.0」を Umbraco v6 で使用する必要があると明確に述べているにもかかわらず、実際には、代わりに使用する必要がある特定の v6 ブランチ (「version6API」とラベル付け) が存在するようです。

回答の功績は、Umbraco フォーラムで質問に回答した Vladan Ostojic に与えられます。

http://our.umbraco.org/projects/developer-tools/usitebuilder/usitebuilder-support/44774-uSiteBuilder-30-loads-DocumentType-fields-but-not-the-DynamicNode-fields?p=0#comment161011

于 2013-09-16T08:45:58.417 に答える
0

私もこの問題を経験しました。解決策は、空のコンストラクターとノード ID を入力として持つコンストラクターを追加することです。このような:

namespace USiteBuilderTest.DocumentTypes
{
    [DocumentType]
    public class Home : DocumentTypeBase
    {
        public Home() {}

        public Home(int nodeId) : base(nodeId) { }

        [DocumentTypeProperty(Name = "Field 1")]
        public string Field1 { set; get; }

        [DocumentTypeProperty(Name = "Field 2")]
        public string Field2 { set; get; }

        [DocumentTypeProperty(Name = "Field 3")]
        public string Field3 { set; get; }
    }
}

それは私のためにトリックをしました。

于 2015-01-05T15:31:39.697 に答える