일부 핵심 기능을 두 번째 코드 라이브러리로 분할하는 코드를 리팩터링했습니다. 이것의 일부로, 인터페이스를 2 개로 분할했습니다. 다음은 어떻게 사용했는지 보여줍니다.'IMyInterface'에 'MediaExists'에 대한 정의가 없습니다. 의미가 없습니다.
namespace Ministry.Ministryweb.Repositories
{
public interface IMinistrywebPublishedContentRepository
{
/// <summary>
/// Gets the media item.
/// </summary>
/// <param name="id">The id of the item.</param>
/// <returns></returns>
IPublishedContent MediaItem(int id);
/// <summary>
/// Gets the umbraco helper.
/// </summary>
UmbracoHelper Umbraco { get; }
/// <summary>
/// Determines if a piece of media exists.
/// </summary>
/// <param name="mediaId">The media id.</param>
/// <returns></returns>
bool MediaExists(int? mediaId);
/// <summary>
/// Gets the URL for some media content.
/// </summary>
/// <param name="mediaId">The media id.</param>
/// <returns>A nicely formed Url.</returns>
string MediaUrl(int? mediaId);
/// <summary>
/// Gets the content URL.
/// </summary>
/// <param name="nodeId">The node id.</param>
/// <returns>A nicely formed Url.</returns>
string ContentUrl(int nodeId);
/// <summary>
/// Returns the content at a specific node.
/// </summary>
/// <param name="id">The node id.</param>
/// <returns>Dynamic content.</returns>
dynamic Content(int? id);
/// <summary>
/// Gets the blog roll.
/// </summary>
IBlogRoll BlogRoll { get; }
/// <summary>
/// Gets the root ancestor.
/// </summary>
IPublishedContent RootAncestor { get; }
/// <summary>
/// Gets the consultancy URL.
/// </summary>
string ConsultancyUrl { get; }
/// <summary>
/// Gets the development URL.
/// </summary>
string DevelopmentUrl { get; }
/// <summary>
/// Gets the team management URL.
/// </summary>
string TeamManagementUrl { get; }
/// <summary>
/// Gets the name of the root ancestor.
/// </summary>
string RootAncestorName { get; }
/// <summary>
/// Gets an article with the specified ID.
/// </summary>
/// <param name="id">The id.</param>
/// <returns></returns>
Article Article(int id);
}
}
그리고 여기에 인터페이스가 두 개로 나뉘어져 있습니다. 첫 번째 인터페이스는 ... 교육부, Ministryweb 클래스 라이브러리에 정의되어
namespace Ministry.Ministryweb.Repositories
{
public interface IMinistrywebPublishedContentRepository : IPublishedContentRepository
{
/// <summary>
/// Gets the blog roll.
/// </summary>
IBlogRoll BlogRoll { get; }
/// <summary>
/// Gets the root ancestor.
/// </summary>
IPublishedContent RootAncestor { get; }
/// <summary>
/// Gets the consultancy URL.
/// </summary>
string ConsultancyUrl { get; }
/// <summary>
/// Gets the development URL.
/// </summary>
string DevelopmentUrl { get; }
/// <summary>
/// Gets the team management URL.
/// </summary>
string TeamManagementUrl { get; }
/// <summary>
/// Gets the name of the root ancestor.
/// </summary>
string RootAncestorName { get; }
/// <summary>
/// Gets an article with the specified ID.
/// </summary>
/// <param name="id">The id.</param>
/// <returns></returns>
Article Article(int id);
}
}
이 Umbraco.Pylon, 나의 새로운 라이브러리의 부모 인터페이스에서 이제 상속 ...
namespace Umbraco.Pylon
{
/// <summary>
/// An interface for accessing published content.
/// </summary>
public interface IPublishedContentRepository
{
/// <summary>
/// Gets the media item.
/// </summary>
/// <param name="id">The id of the item.</param>
/// <returns></returns>
IPublishedContent MediaItem(int id);
/// <summary>
/// Gets the umbraco helper.
/// </summary>
UmbracoHelper Umbraco { get; }
/// <summary>
/// Determines if a piece of media exists.
/// </summary>
/// <param name="mediaId">The media id.</param>
/// <returns></returns>
bool MediaExists(int? mediaId);
/// <summary>
/// Gets the URL for some media content.
/// </summary>
/// <param name="mediaId">The media id.</param>
/// <returns>A nicely formed Url.</returns>
string MediaUrl(int? mediaId);
/// <summary>
/// Gets the content URL.
/// </summary>
/// <param name="nodeId">The node id.</param>
/// <returns>A nicely formed Url.</returns>
string ContentUrl(int nodeId);
/// <summary>
/// Returns the content at a specific node.
/// </summary>
/// <param name="id">The node id.</param>
/// <returns>Dynamic content.</returns>
dynamic Content(int? id);
}
}
내 주요 웹 프로젝트는 두 도서관에 대한 언급으로 사역 웹이라는 세 번째 프로젝트입니다. Ministry.Ministryweb에는 또한 Umbraco.Pylon에 대한 언급이 있습니다. 나는이보기를로드 할 때이 설정의 모든 것을
@inherits MinistrywebViewPage
@{
Layout = "_Layout.cshtml";
ViewBag.Title = DynamicModel.Name + " - " + Ministryweb.Content.RootAncestorName;
}
@section PageTitle
{
@DynamicModel.PrimaryHeader
}
<section id="primary">
@if (Ministryweb.Content.MediaExists(DynamicModel.MainImage))
{
<div class="serviceImage">
<img src="@Ministryweb.Content.MediaUrl(DynamicModel.MainImage)" alt="@DynamicModel.Name" />
</div>
}
@DynamicModel.IntroText
@foreach (var service in DynamicModel.Children)
{
<h3><a href="@service.NiceUrl()">@service.Name</a></h3>
<p>@service.Summary</p>
<span class="linkButton"><a href="@service.NiceUrl()">@service.TagLine</a></span>
<br />
}
<div class="clearfix"></div>
</section>
<section id="asideContainer">
@Html.Partial("_SocialSidebar")
@Html.Partial("_LogosSidebar")
</section>
<section id="articles">
@Html.Partial("_LatestArticleForAll")
</section>
나는 다음과 같은 오류되게하고 ...
'Ministry.Ministryweb.Repositories.IMinistrywebPublishedContentRepository'가 포함되어 있지 않습니다 ... 잘 컴파일하지만, 'MediaExists'에 대한 정의
이것은 내게 전혀 의미가 없습니다.
처음에는 Ministryweb 웹 프로젝트에서 Umbraco.Pylon에 대한 직접적인 언급이 없었기 때문에 다른 게시물에 대한 제안에 따라 명시 적으로 포함 시켰지만 아무런 차이가 없었습니다.
미친 짓은 내가 IMinistrywbPublishedContentRepository 인터페이스의 IPublishedContentRepository 인터페이스에서 코드를 복제하면 모든 것이 제대로 작동한다는 것입니다. ReSharper는 저에게 신음합니다. 이 문제를 일으킬 수있는 것에 대한 생각은 내 리팩터링 작업이 중단됨에 따라 가장 환영받을 것입니다.
완전히 청소하고 재구성 해 보셨습니까? –
나는 재건을 시도했으나, 나는 편집증이 깨끗한 루틴을 다시 거쳐야한다고 생각한다. 이제 레퍼런스를 변경하고 그것이 도움이되는지 확인한다. –
새 버전과 충돌하는 어딘가에 남겨진'IMinistrywebPublishedContentRepository'의 중복 된 정의가 없는지 확인하고 싶습니다. –