本文整理汇总了C#中PageTypeBuilder.Discovery.PageTypeDefinition类的典型用法代码示例。如果您正苦于以下问题:C# PageTypeDefinition类的具体用法?C# PageTypeDefinition怎么用?C# PageTypeDefinition使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PageTypeDefinition类属于PageTypeBuilder.Discovery命名空间,在下文中一共展示了PageTypeDefinition类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdatePageDefinitionsLocalPropertySettings
void UpdatePageDefinitionsLocalPropertySettings(PageTypePropertyDefinition propertyDefinition, PageTypeDefinition pageTypeDefinition, PropertySettingsContainer container)
{
List<PropertySettingsUpdater> settingsUpdaters = GetPropertySettingsUpdaters(pageTypeDefinition, propertyDefinition);
settingsUpdaters.ForEach(updater =>
{
var wrapper = container.GetSetting(updater.SettingsType);
if (wrapper == null)
{
wrapper = new PropertySettingsWrapper();
container.Settings[updater.SettingsType.FullName] = wrapper;
//TODO: Add spec validating that exception is thrown with the below uncommented (An item with the same key has already been added.)
//container.Settings.Add(updater.SettingsType.FullName, wrapper);
}
bool settingsAlreadyExists = true;
if (wrapper.PropertySettings == null)
{
wrapper.PropertySettings = ((IPropertySettings)Activator.CreateInstance(updater.SettingsType)).GetDefaultValues();
settingsAlreadyExists = false;
}
if (settingsAlreadyExists && !updater.OverWriteExisting)
return;
int hashBeforeUpdate = updater.GetSettingsHashCode(wrapper.PropertySettings);
updater.UpdateSettings(wrapper.PropertySettings);
int hashAfterUpdate = updater.GetSettingsHashCode(wrapper.PropertySettings);
if (hashBeforeUpdate != hashAfterUpdate || !settingsAlreadyExists)
{
propertySettingsRepository.Save(container);
}
});
}
开发者ID:stefanforsberg,项目名称:Page-Type-Builder,代码行数:33,代码来源:PageDefinitionSpecificPropertySettingsUpdater.cs
示例2: UpdatePageTypePropertyDefinitions
protected internal virtual void UpdatePageTypePropertyDefinitions(IPageType pageType, PageTypeDefinition pageTypeDefinition)
{
IEnumerable<PageTypePropertyDefinition> definitions =
pageTypePropertyDefinitionLocator.GetPageTypePropertyDefinitions(pageType, pageTypeDefinition.Type);
foreach (PageTypePropertyDefinition propertyDefinition in definitions)
{
PageDefinition pageDefinition = GetExistingPageDefinition(pageType, propertyDefinition);
if (pageDefinition == null)
{
using (new TimingsLogger(string.Format("Creating new page definition '{0}' for page type {1}: ", propertyDefinition.Name, pageType.Name)))
{
pageDefinitionUpdater.CreateNewPageDefinition(propertyDefinition);
pageDefinition = GetExistingPageDefinition(pageType, propertyDefinition);
}
}
else
{
pageDefinitionUpdater.UpdateExistingPageDefinition(pageDefinition, propertyDefinition);
}
pageDefinitionSpecificPropertySettingsUpdater.UpdatePropertySettings(pageTypeDefinition, propertyDefinition, pageDefinition);
}
}
示例3: UpdatePropertySettings
protected internal virtual void UpdatePropertySettings(PageTypeDefinition pageTypeDefinition, PageTypePropertyDefinition propertyDefinition, PageDefinition pageDefinition)
{
PropertySettingsContainer container = GetPropertySettingsContainer(pageDefinition);
UpdatePageDefinitionsGlobalPropertySettings(propertyDefinition, pageTypeDefinition, container);
UpdatePageDefinitionsLocalPropertySettings(propertyDefinition, pageTypeDefinition, container);
}
开发者ID:stefanforsberg,项目名称:Page-Type-Builder,代码行数:7,代码来源:PageDefinitionSpecificPropertySettingsUpdater.cs
示例4: CreateNewPageType
protected internal virtual IPageType CreateNewPageType(PageTypeDefinition definition)
{
IPageType pageType = PageTypeRepository.CreateNew();
PageTypeAttribute attribute = definition.Attribute;
string name = attribute.Name;
if (name == null)
{
name = definition.Type.Name;
}
pageType.Name = name;
if (definition.Attribute.Guid.HasValue)
pageType.GUID = definition.Attribute.Guid.Value;
string filename = attribute.Filename;
if (string.IsNullOrEmpty(filename))
{
filename = DefaultFilename;
}
pageType.FileName = filename;
PageTypeRepository.Save(pageType);
return pageType;
}
示例5: CreateNewPageType
protected internal virtual IPageType CreateNewPageType(PageTypeDefinition definition)
{
IPageType pageType = PageTypeRepository.CreateNew();
PageTypeAttribute attribute = definition.Attribute;
string name = attribute.Name;
if (name == null)
{
name = definition.Type.Name;
}
pageType.Name = name;
if (definition.Attribute.Guid.HasValue)
pageType.GUID = definition.Attribute.Guid.Value;
string filename = attribute.Filename;
Version version = typeof(PageData).Assembly.GetName().Version;
bool cms6R2AndAbove = version.Major >= 6 && version.Minor >= 1;
if (string.IsNullOrEmpty(filename) && cms6R2AndAbove)
filename = DefaultFilename;
pageType.FileName = filename;
PageTypeRepository.Save(pageType);
NewlyCreatedPageTypes.Add(pageType);
return pageType;
}
示例6: ValidatePageTypeDefinition
public virtual void ValidatePageTypeDefinition(PageTypeDefinition definition, IEnumerable<PageTypeDefinition> allPageTypeDefinitions)
{
ValidateNameLength(definition);
ValidateInheritsFromBasePageType(definition);
ValidateAvailablePageTypes(definition, allPageTypeDefinitions);
ValidateExcludedPageTypes(definition, allPageTypeDefinitions);
PropertiesValidator.ValidatePageTypeProperties(definition);
}
示例7: ValidateNameLength
protected internal virtual void ValidateNameLength(PageTypeDefinition definition)
{
if(definition.GetPageTypeName().Length <= MaximumPageTypeNameLength)
return;
string errorMessage = "The page type class {0} has a name that is longer than {1}. EPiServer does not save more than {1} characters and the name is often used to identify page types.";
errorMessage = string.Format(CultureInfo.InvariantCulture, errorMessage, definition.Type.Name, MaximumPageTypeNameLength);
throw new PageTypeBuilderException(errorMessage);
}
示例8: ValidatePageTypeProperties
protected internal virtual void ValidatePageTypeProperties(PageTypeDefinition definition)
{
ValidateNoClashingPropertiesFromInterfaces(definition.Type);
IEnumerable<PropertyInfo> propertiesForPageType = definition.Type.GetAllValidPageTypePropertiesFromClassAndImplementedInterfaces();
foreach (PropertyInfo propertyInfo in propertiesForPageType)
{
ValidatePageTypeProperty(propertyInfo);
}
}
示例9: ValidateInheritsFromBasePageType
protected internal virtual void ValidateInheritsFromBasePageType(PageTypeDefinition definition)
{
Type typeToCheck = definition.Type;
if (!baseTypeForPageTypes.IsAssignableFrom(typeToCheck))
{
string errorMessage = "The type {0} has a {1} attribute but does not inherit from {2}";
errorMessage = string.Format(CultureInfo.InvariantCulture, errorMessage, typeToCheck.FullName, typeof(PageTypeAttribute).FullName,
baseTypeForPageTypes.FullName);
throw new PageTypeBuilderException(errorMessage);
}
}
示例10: GivenPageType_UpdatePageTypePropertyDefinitions_CallsGetPageTypePropertyDefinitions
public void GivenPageType_UpdatePageTypePropertyDefinitions_CallsGetPageTypePropertyDefinitions()
{
List<PageTypePropertyDefinition> definitions = new List<PageTypePropertyDefinition>();
PageTypePropertyUpdater pageTypePropertyUpdater = CreatePageTypePropertyUpdater(definitions);
IPageType pageType = new NativePageType();
PageTypeDefinition pageTypeDefinition = new PageTypeDefinition();
pageTypePropertyUpdater.UpdatePageTypePropertyDefinitions(pageType, pageTypeDefinition);
pageTypePropertyUpdater.PageTypePropertyDefinitionLocator.AssertWasCalled(
locator => locator.GetPageTypePropertyDefinitions(
pageType, pageTypeDefinition.Type));
}
示例11: typeof
public void GivenPageTypeDefinition_ValidatePageTypeProperties_ValidatesOk_WhenCollissionsExistsInInterfaceDefinitionsButIsTrumpedByDefinitionInPageTypeDefinition()
{
PageTypeDefinition definition = new PageTypeDefinition
{
Type = typeof(TestPageTypeWithClashingInterfacesWhichAlsoDefinesProperty),
Attribute = new PageTypeAttribute()
};
MockRepository fakes = new MockRepository();
PageTypeDefinitionPropertiesValidator propertiesValidator = fakes.PartialMock<PageTypeDefinitionPropertiesValidator>((PageDefinitionTypeMapper)null);
propertiesValidator.Stub(
validator => validator.ValidatePageTypePropertyType(Arg<PropertyInfo>.Is.Anything));
propertiesValidator.Replay();
propertiesValidator.ValidatePageTypeProperties(definition);
}
开发者ID:stefanforsberg,项目名称:Page-Type-Builder,代码行数:14,代码来源:PageTypeDefinitionPropertiesValidatorTests.cs
示例12: typeof
public void GivenPageTypeDefinition_ValidatePageTypeProperties_ValidatesNotOk_WhenCollissionsExistsInInterfaceDefinitions()
{
PageTypeDefinition definition = new PageTypeDefinition
{
Type = typeof(TestPageTypeWithClashingInterfaces),
Attribute = new PageTypeAttribute()
};
MockRepository fakes = new MockRepository();
PageTypeDefinitionPropertiesValidator propertiesValidator = fakes.PartialMock<PageTypeDefinitionPropertiesValidator>((PageDefinitionTypeMapper)null);
propertiesValidator.Stub(
validator => validator.ValidatePageTypePropertyType(Arg<PropertyInfo>.Is.Anything));
propertiesValidator.Replay();
Assert.Throws(typeof(PageTypeBuilderException), () => propertiesValidator.ValidatePageTypeProperties(definition));
}
示例13: GivenDefinitionWithASpecifiedGuid_CreateNewPageType_ReturnsPageTypeWithThatGuid
public void GivenDefinitionWithASpecifiedGuid_CreateNewPageType_ReturnsPageTypeWithThatGuid()
{
PageTypeDefinition definition = new PageTypeDefinition
{
Type = typeof(object),
Attribute = new PageTypeAttribute(Guid.NewGuid().ToString())
};
PageTypeUpdater pageTypeUpdater = CreatePageTypeUpdater();
SetupPageTypeUpdaterWithFakePageTypeFactory(pageTypeUpdater);
IPageType returnedPageType = pageTypeUpdater.CreateNewPageType(definition);
Assert.Equal<Guid?>(definition.Attribute.Guid, returnedPageType.GUID);
}
示例14: UpdatePageTypePropertyDefinitions
protected internal virtual void UpdatePageTypePropertyDefinitions(IPageType pageType, PageTypeDefinition pageTypeDefinition)
{
IEnumerable<PageTypePropertyDefinition> definitions =
PageTypePropertyDefinitionLocator.GetPageTypePropertyDefinitions(pageType, pageTypeDefinition.Type);
foreach (PageTypePropertyDefinition propertyDefinition in definitions)
{
PageDefinition pageDefinition = GetExistingPageDefinition(pageType, propertyDefinition);
if (pageDefinition == null)
pageDefinition = CreateNewPageDefinition(propertyDefinition);
UpdatePageDefinition(pageDefinition, propertyDefinition);
}
}
示例15: UpdatePropertySettings
protected internal virtual void UpdatePropertySettings(PageTypeDefinition pageTypeDefinition, PageTypePropertyDefinition propertyDefinition, PageDefinition pageDefinition)
{
PropertySettingsContainer container = GetPropertySettingsContainer(pageDefinition);
object[] attributes = GetPropertyAttributes(propertyDefinition, pageTypeDefinition);
var useGlobalSettingsAttribute = attributes.OfType<UseGlobalSettingsAttribute>().FirstOrDefault();
if(useGlobalSettingsAttribute != null)
{
//TODO: Should validate not null and valid type at startup
var globalSettingsUpdater = globalPropertySettingsLocator.GetGlobalPropertySettingsUpdaters().Where(u => u.WrappedInstanceType == useGlobalSettingsAttribute.Type).First();
var wrapper =_propertySettingsRepository.GetGlobals(globalSettingsUpdater.SettingsType)
.Where(w => globalSettingsUpdater.Match(w))
.First();
container.Settings[globalSettingsUpdater.SettingsType.FullName] = wrapper;
//TODO: Add spec validating that exception is thrown with the below uncommented (An item with the same key has already been added.)
//container.Settings.Add(globalSettingsUpdater.SettingsType.FullName, wrapper);
_propertySettingsRepository.Save(container);
}
List<PropertySettingsUpdater> settingsUpdaters = GetPropertySettingsUpdaters(pageTypeDefinition, propertyDefinition, pageDefinition);
settingsUpdaters.ForEach(updater =>
{
var wrapper = container.GetSetting(updater.SettingsType);
if (wrapper == null)
{
wrapper = new PropertySettingsWrapper();
container.Settings[updater.SettingsType.FullName] = wrapper;
//TODO: Add spec validating that exception is thrown with the below uncommented (An item with the same key has already been added.)
//container.Settings.Add(updater.SettingsType.FullName, wrapper);
}
bool settingsAlreadyExists = true;
if (wrapper.PropertySettings == null)
{
wrapper.PropertySettings = ((IPropertySettings)Activator.CreateInstance(updater.SettingsType)).GetDefaultValues();
settingsAlreadyExists = false;
}
if (settingsAlreadyExists && !updater.OverWriteExisting)
return;
int hashBeforeUpdate = updater.GetSettingsHashCode(wrapper.PropertySettings);
updater.UpdateSettings(wrapper.PropertySettings);
int hashAfterUpdate = updater.GetSettingsHashCode(wrapper.PropertySettings);
if (hashBeforeUpdate != hashAfterUpdate || !settingsAlreadyExists)
{
_propertySettingsRepository.Save(container);
}
});
}