本文整理汇总了C#中SPMeta2.Definitions.DefinitionBase类的典型用法代码示例。如果您正苦于以下问题:C# DefinitionBase类的具体用法?C# DefinitionBase怎么用?C# DefinitionBase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DefinitionBase类属于SPMeta2.Definitions命名空间,在下文中一共展示了DefinitionBase类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DeployModel
public override void DeployModel(object modelHost, DefinitionBase model)
{
var definition = model.WithAssertAndCast<FieldDefinition>("model", value => value.RequireNotNull());
var spObject = GetField(modelHost, definition);
var assert = ServiceFactory.AssertService.NewAssert(model, definition, spObject);
ValidateField(assert, spObject, definition);
var textField = spObject as SPFieldMultiLineText;
var textDefinition = model.WithAssertAndCast<NoteFieldDefinition>("model", value => value.RequireNotNull());
var textFieldAssert = ServiceFactory.AssertService.NewAssert(model, textDefinition, textField);
textFieldAssert.ShouldBeEqual(m => m.NumberOfLines, o => o.NumberOfLines);
textFieldAssert.ShouldBeEqual(m => m.RichText, o => o.RichText);
textFieldAssert.ShouldBeEqual(m => m.AppendOnly, o => o.AppendOnly);
textFieldAssert.ShouldBeEqual(m => m.RichText, o => o.RichText);
textFieldAssert.ShouldBeEqual(m => m.UnlimitedLengthInDocumentLibrary, o => o.UnlimitedLengthInDocumentLibrary);
if (!string.IsNullOrEmpty(textDefinition.RichTextMode))
textFieldAssert.ShouldBeEqual(m => m.RichTextMode, o => o.GetRichTextMode());
else
textFieldAssert.SkipProperty(m => m.RichTextMode);
}
示例2: DeployModel
public override void DeployModel(object modelHost, DefinitionBase model)
{
var list = modelHost.WithAssertAndCast<SPList>("modelHost", value => value.RequireNotNull());
var listItemModel = model.WithAssertAndCast<ListItemDefinition>("model", value => value.RequireNotNull());
DeployInternall(list, listItemModel);
}
示例3: DeployModel
public override void DeployModel(object modelHost, DefinitionBase model)
{
var typedModelHost = modelHost.WithAssertAndCast<WebModelHost>("modelHost", value => value.RequireNotNull());
var typedDefinition = model.WithAssertAndCast<DeleteTopNavigationNodesDefinition>("model", value => value.RequireNotNull());
DeployDefinition(modelHost, typedModelHost, typedDefinition);
}
示例4: DeployModel
public override void DeployModel(object modelHost, DefinitionBase model)
{
var webAppModelHost = modelHost.WithAssertAndCast<WebApplicationModelHost>("modelHost", value => value.RequireNotNull());
var definition = model.WithAssertAndCast<PeoplePickerSettingsDefinition>("model", value => value.RequireNotNull());
DeployPeoplePickerSettings(modelHost, webAppModelHost.HostWebApplication, definition);
}
示例5: DeployModel
public override void DeployModel(object modelHost, DefinitionBase model)
{
// base validation
base.DeployModel(modelHost, model);
// web specific validation
var host = modelHost.WithAssertAndCast<WebpartPageModelHost>("modelHost", value => value.RequireNotNull());
var definition = model.WithAssertAndCast<PageViewerWebPartDefinition>("model", value => value.RequireNotNull());
var item = host.PageListItem;
WebPartExtensions.WithExistingWebPart(item, definition, (spWebPartManager, spObject) =>
{
var web = spWebPartManager.Web;
var typedObject = spObject as PageViewerWebPart;
var assert = ServiceFactory.AssertService
.NewAssert(definition, typedObject)
.ShouldNotBeNull(typedObject);
if (!string.IsNullOrEmpty(definition.ContentLink))
assert.ShouldBeEqual(m => m.ContentLink, o => o.ContentLink);
else
assert.SkipProperty(m => m.ContentLink);
if (!string.IsNullOrEmpty(definition.SourceType))
assert.ShouldBeEqual(m => m.SourceType, o => o.GetSourceType());
else
assert.SkipProperty(m => m.SourceType);
});
}
示例6: WithResolvingModelHost
public override void WithResolvingModelHost(object modelHost, DefinitionBase model, Type childModelType, Action<object> action)
{
var quickLaunchNode = model as QuickLaunchNavigationNodeDefinition;
if (modelHost is WebModelHost)
{
var webModelHost = modelHost as WebModelHost;
var currentNode = EnsureRootQuickLaunchNavigationNode(webModelHost, quickLaunchNode);
var nodeHost = ModelHostBase.Inherit<NavigationNodeModelHost>(webModelHost, host =>
{
host.HostNavigationNode = currentNode;
});
action(nodeHost);
}
else if (modelHost is NavigationNodeModelHost)
{
var nodeModelHost = modelHost as NavigationNodeModelHost;
var currentNode = EnsureQuickLaunchNavigationNode(nodeModelHost, quickLaunchNode);
var nodeHost = ModelHostBase.Inherit<NavigationNodeModelHost>(nodeModelHost, host =>
{
host.HostNavigationNode = currentNode;
});
action(nodeHost);
}
else
{
action(modelHost);
}
}
示例7: DeployModel
public override void DeployModel(object modelHost, DefinitionBase model)
{
var modelHostContext = modelHost.WithAssertAndCast<ModelHostContext>("modelHost", value => value.RequireNotNull());
var fieldlinkModel = model.WithAssertAndCast<ContentTypeFieldLinkDefinition>("model", value => value.RequireNotNull());
var site = modelHostContext.Site;
var contentType = modelHostContext.ContentType;
var context = site.Context;
context.Load(contentType, ct => ct.FieldLinks);
context.ExecuteQuery();
var spFieldLink = FindFieldLinkById(contentType.FieldLinks, fieldlinkModel.FieldId);
TraceUtils.WithScope(traceScope =>
{
Trace.WriteLine(string.Format("Validate model: {0} ContentType:{1}", fieldlinkModel, contentType));
// assert base properties
traceScope.WithTraceIndent(trace =>
{
trace.WriteLine(string.Format("Validate FieldId: model:[{0}] ct field link:[{1}]", fieldlinkModel.FieldId, spFieldLink.Id));
Assert.AreEqual(fieldlinkModel.FieldId, spFieldLink.Id);
});
});
}
示例8: WithResolvingModelHost
public override void WithResolvingModelHost(object modelHost, DefinitionBase model, Type childModelType, Action<object> action)
{
var web = ExtractWeb(modelHost);
if (web != null)
{
string securityGroupName;
if (model is SecurityGroupLinkDefinition)
securityGroupName = (model as SecurityGroupLinkDefinition).SecurityGroupName;
else if (model is SecurityGroupDefinition)
securityGroupName = (model as SecurityGroupDefinition).Name;
else
{
throw new ArgumentException("model has to be SecurityGroupDefinition or SecurityGroupLinkDefinition");
}
var securityGroup = web.SiteGroups[securityGroupName];
var newModelHost = new SecurityGroupModelHost
{
SecurityGroup = securityGroup,
SecurableObject = modelHost as SPSecurableObject
};
action(newModelHost);
}
else
{
action(modelHost);
}
}
示例9: DeployModel
public override void DeployModel(object modelHost, DefinitionBase model)
{
var farmModelHost = modelHost.WithAssertAndCast<FarmModelHost>("modelHost", value => value.RequireNotNull());
var managedAccountDefinition = model.WithAssertAndCast<ManagedAccountDefinition>("model", value => value.RequireNotNull());
DeployManagedAccount(modelHost, farmModelHost.HostFarm, managedAccountDefinition);
}
示例10: DeployModel
public override void DeployModel(object modelHost, DefinitionBase model)
{
var webModelHost = modelHost.WithAssertAndCast<WebModelHost>("modelHost", value => value.RequireNotNull());
var navigationModel = model.WithAssertAndCast<WebNavigationSettingsDefinition>("model", value => value.RequireNotNull());
DeployNavigationSettings(modelHost, webModelHost, navigationModel);
}
示例11: DeployModel
public override void DeployModel(object modelHost, DefinitionBase model)
{
var list = ExtractListFromHost(modelHost);
var hideContentTypeLinksDefinition = model.WithAssertAndCast<RemoveContentTypeLinksDefinition>("model", value => value.RequireNotNull());
DeployHideContentTypeLinks(modelHost, list, hideContentTypeLinksDefinition);
}
示例12: Validate
public override void Validate(DefinitionBase definition, List<ValidationResult> result)
{
Validate<ListDefinition>(definition, model =>
{
model
.NotNullString(m => m.Title, result)
.NotEmptyString(m => m.Title, result)
.NoSpacesBeforeOrAfter(m => m.Title, result)
.NotNullString(m => m.Description, result)
.NotEmptyString(m => m.Description, result)
.NoSpacesBeforeOrAfter(m => m.Description, result)
.NotNullString(m => m.Url, result)
.NotEmptyString(m => m.Url, result)
.NoSpacesBeforeOrAfter(m => m.Url, result);
if (model.TemplateType == 0)
{
model
.NotNullString(m => m.TemplateName, result)
.NotEmptyString(m => m.TemplateName, result)
.NoSpacesBeforeOrAfter(m => m.TemplateName, result);
}
if (string.IsNullOrEmpty(model.TemplateName))
{
model
.NotEqual(m => m.TemplateType, 0, result);
}
});
}
示例13: DeployModel
public override void DeployModel(object modelHost, DefinitionBase model)
{
var definition = model.WithAssertAndCast<EventReceiverDefinition>("model", value => value.RequireNotNull());
Microsoft.SharePoint.Client.EventReceiverDefinition spObject = null;
if (modelHost is ListModelHost)
spObject = FindEventReceiverDefinition((modelHost as ListModelHost).HostList.EventReceivers, definition);
else if (modelHost is WebModelHost)
spObject = FindEventReceiverDefinition((modelHost as WebModelHost).HostWeb.EventReceivers, definition);
else if (modelHost is SiteModelHost)
spObject = FindEventReceiverDefinition((modelHost as SiteModelHost).HostSite.EventReceivers, definition);
else
{
throw new SPMeta2UnsupportedModelHostException("model host should be ListModelHost or WebModelHost");
}
var assert = ServiceFactory.AssertService
.NewAssert(definition, spObject)
.ShouldNotBeNull(spObject)
.ShouldBeEqual(m => m.Name, o => o.ReceiverName)
.ShouldBeEqual(m => m.Class, o => o.ReceiverClass)
.ShouldBeEqual(m => m.Assembly, o => o.ReceiverAssembly)
.SkipProperty(m => m.Data, "Data property is not supported by CSOM. SKipping.")
.ShouldBeEqual(m => m.SequenceNumber, o => o.SequenceNumber)
.ShouldBeEqual(m => m.Synchronization, o => o.GetSynchronization())
.ShouldBeEqual(m => m.Type, o => o.GetEventReceiverType());
}
示例14: DeployModel
public override void DeployModel(object modelHost, DefinitionBase model)
{
var webModelHost = modelHost.WithAssertAndCast<WebModelHost>("modelHost", value => value.RequireNotNull());
var definition = model.WithAssertAndCast<MasterPageSettingsDefinition>("model", value => value.RequireNotNull());
var spObject = webModelHost.HostWeb;
var assert = ServiceFactory.AssertService
.NewAssert(model, definition, spObject)
.ShouldNotBeNull(spObject);
if (!string.IsNullOrEmpty(definition.SiteMasterPageUrl))
{
assert.ShouldBeEndOf(m => m.SiteMasterPageUrl, o => o.CustomMasterUrl);
}
else
{
assert.SkipProperty(m => m.SiteMasterPageUrl, "SiteMasterPageUrl is NULL or empty");
}
if (!string.IsNullOrEmpty(definition.SystemMasterPageUrl))
{
assert.ShouldBeEndOf(m => m.SystemMasterPageUrl, o => o.MasterUrl);
}
else
{
assert.SkipProperty(m => m.SystemMasterPageUrl, "SystemMasterPageUrl is NULL or empty");
}
}
示例15: DeployModelInternal
protected override void DeployModelInternal(object modelHost, DefinitionBase model)
{
var siteModelHost = modelHost.WithAssertAndCast<SiteModelHost>("modelHost", value => value.RequireNotNull());
var definitionModel = model.WithAssertAndCast<ContentTypeDefinition>("model", value => value.RequireNotNull());
var site = siteModelHost.HostSite;
var rootWeb = site.RootWeb;
var contentTypes = rootWeb.AvailableContentTypes;
var spModel = contentTypes[definitionModel.Name];
TraceUtils.WithScope(traceScope =>
{
Trace.WriteLine(string.Format("Validate model: {0} ContentType:{1}", definitionModel, spModel));
// assert base properties
traceScope.WithTraceIndent(trace =>
{
trace.WriteLine(string.Format("Validate Name: model:[{0}] ct:[{1}]", definitionModel.Name, spModel.Name));
Assert.AreEqual(definitionModel.Name, spModel.Name);
trace.WriteLine(string.Format("Validate Description: model:[{0}] ct:[{1}]", definitionModel.Description, spModel.Description));
Assert.AreEqual(definitionModel.Description, spModel.Description);
trace.WriteLine(string.Format("Validate Id: model:[{0}] ct:[{1}]", definitionModel.GetContentTypeId(), spModel.Id));
Assert.AreEqual(new SPContentTypeId(definitionModel.GetContentTypeId()), spModel.Id);
trace.WriteLine(string.Format("Validate Group: model:[{0}] ct:[{1}]", definitionModel.Group, spModel.Group));
Assert.AreEqual(definitionModel.Group, spModel.Group);
});
});
}