本文整理汇总了C#中GSoft.Dynamite.Lists.ListInfo类的典型用法代码示例。如果您正苦于以下问题:C# ListInfo类的具体用法?C# ListInfo怎么用?C# ListInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ListInfo类属于GSoft.Dynamite.Lists命名空间,在下文中一共展示了ListInfo类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: EventReceiverInfo
/// <summary>
/// Event Receiver Info (List)
/// </summary>
/// <param name="list">The list</param>
/// <param name="type">The event receiver type</param>
/// <param name="syncType">The synchronization type</param>
public EventReceiverInfo(ListInfo list, SPEventReceiverType type, SPEventReceiverSynchronization syncType)
{
this.List = list;
this.EventOwner = EventReceiverOwner.List;
this.ReceiverType = type;
this.SynchronizationType = syncType;
}
开发者ID:ASAGARG,项目名称:Dynamite,代码行数:13,代码来源:EventReceiverInfo.cs
示例2: EnsureList_WhenNotAlreadyExists_ShouldCreateANewOneNOTListsPath
public void EnsureList_WhenNotAlreadyExists_ShouldCreateANewOneNOTListsPath()
{
// Arrange
using (var testScope = SiteTestScope.BlankSite())
{
var listInfo = new ListInfo("testUrl", "nameKey", "descriptionKey");
using (var injectionScope = IntegrationTestServiceLocator.BeginLifetimeScope())
{
var listHelper = injectionScope.Resolve<IListHelper>();
var testRootWeb = testScope.SiteCollection.RootWeb;
var numberOfListsBefore = testRootWeb.Lists.Count;
// Act
var list = listHelper.EnsureList(testRootWeb, listInfo);
// Assert
Assert.AreEqual(numberOfListsBefore + 1, testRootWeb.Lists.Count);
Assert.IsNotNull(list);
Assert.AreEqual(listInfo.DisplayNameResourceKey, list.TitleResource.Value);
Assert.AreEqual(listInfo.DescriptionResourceKey, list.DescriptionResource.Value);
// Fetch the list on the root web to make sure it was created and that it persists at the right location
var newlyCreatedList = testRootWeb.GetList("testUrl");
Assert.IsNotNull(newlyCreatedList);
Assert.AreEqual(listInfo.DisplayNameResourceKey, newlyCreatedList.TitleResource.Value);
}
}
}
开发者ID:andresglx,项目名称:Dynamite,代码行数:30,代码来源:ListHelperTest.cs
示例3: SyncList
/// <summary>
/// Sync a SPList for multiple target labels
/// </summary>
/// <param name="web">The web</param>
/// <param name="listInfo">The source list metadata</param>
/// <param name="labels">The destination labels</param>
public void SyncList(SPWeb web, ListInfo listInfo, IList<VariationLabelInfo> labels)
{
var list = this._listHelper.EnsureList(web, listInfo);
foreach (VariationLabelInfo label in labels)
{
// Synchronize only target labels
if (!label.IsSource)
{
this.SyncList(list, label.Title);
}
}
}
开发者ID:andresglx,项目名称:Dynamite,代码行数:19,代码来源:VariationSyncHelper.cs
示例4: MetadataNavigationSettingsInfo
/// <summary>
/// Creates a new instance of MetadataNavigationSettingsInfo. Use this constructor if you don't have any custom configurations
/// </summary>
/// <param name="list">The associated list</param>
/// <param name="addFolderDefaultHierarchy">True to view the folder hierachy in the treeview. False otherwise</param>
/// <param name="addContentTypeDefaultHierarchy">True to view the content type hierachy in the treeview. False otherwise</param>
/// <param name="addContentTypeDefaultKeyFilter">True to view the content type key filter. False otherwise</param>
public MetadataNavigationSettingsInfo(
ListInfo list,
bool addFolderDefaultHierarchy,
bool addContentTypeDefaultHierarchy,
bool addContentTypeDefaultKeyFilter)
: this(
list,
addFolderDefaultHierarchy,
addContentTypeDefaultHierarchy,
addContentTypeDefaultKeyFilter,
null,
null)
{
}
开发者ID:andresglx,项目名称:Dynamite,代码行数:21,代码来源:MetadataNavigationSettingsInfo.cs
示例5: EnsureList_AListWithSameNameExistsOnDifferentWeb_ShouldCreateListAtSpecifiedWebAndURL
public void EnsureList_AListWithSameNameExistsOnDifferentWeb_ShouldCreateListAtSpecifiedWebAndURL()
{
// Arrange
const string Url = "testUrl";
const string NameKey = "NameKey";
const string DescKey = "DescriptionKey";
using (var testScope = SiteTestScope.BlankSite())
{
// Let's first create a list on the root web
var listInfo = new ListInfo(Url, NameKey, DescKey);
using (var injectionScope = IntegrationTestServiceLocator.BeginLifetimeScope())
{
var listHelper = injectionScope.Resolve<IListHelper>();
var rootWeb = testScope.SiteCollection.RootWeb;
var numberOfListsOnRootWebBefore = rootWeb.Lists.Count;
var listRootWeb = listHelper.EnsureList(rootWeb, listInfo);
Assert.AreEqual(numberOfListsOnRootWebBefore + 1, rootWeb.Lists.Count);
Assert.IsNotNull(listRootWeb);
Assert.AreEqual(listInfo.DisplayNameResourceKey, listRootWeb.TitleResource.Value);
// Now let's create a sub web under root, and try to ensure the "same" list there. It should create a new one.
var subWeb = rootWeb.Webs.Add("subweb");
var numberOfListsOnSubWebBefore = subWeb.Lists.Count;
// Act
var listSubWeb = listHelper.EnsureList(subWeb, listInfo);
// Assert
Assert.AreEqual(numberOfListsOnSubWebBefore + 1, subWeb.Lists.Count);
Assert.IsNotNull(listSubWeb);
Assert.AreEqual(listInfo.DisplayNameResourceKey, listSubWeb.TitleResource.Value);
// Finally, try to get both lists to make sure everything is right
var firstList = rootWeb.GetList(Url);
Assert.IsNotNull(firstList);
Assert.AreEqual(listInfo.DisplayNameResourceKey, firstList.TitleResource.Value);
var secondList = subWeb.GetList(SPUtility.ConcatUrls(subWeb.ServerRelativeUrl, Url));
Assert.IsNotNull(secondList);
Assert.AreEqual(listInfo.DisplayNameResourceKey, secondList.TitleResource.Value);
}
}
}
开发者ID:NunoEdgarGub1,项目名称:Dynamite,代码行数:47,代码来源:ListHelperTest.cs
示例6: using
//.........这里部分代码省略.........
"NameKeyMulti",
"DescriptionKey",
"GroupKey")
{
TermStoreMapping = new TaxonomyContext(levelOneTermA) // choices limited to children of a specific term, instead of having full term set choices
};
var fieldsToEnsure = new List<BaseFieldInfo>()
{
integerFieldInfo,
numberFieldInfo,
currencyFieldInfo,
boolFieldInfoBasic,
boolFieldInfoDefaultTrue,
boolFieldInfoDefaultFalse,
dateTimeFieldInfoFormula,
dateTimeFieldInfoDefault,
textFieldInfo,
noteFieldInfo,
htmlFieldInfo,
imageFieldInfo,
urlFieldInfo,
urlFieldInfoImage,
lookupFieldInfo,
lookupFieldInfoAlt,
lookupMultiFieldInfo,
userFieldInfo,
userMultiFieldInfo,
mediaFieldInfo,
taxoFieldInfo,
taxoMultiFieldInfo
};
ListInfo lookupListInfo = new ListInfo("sometestlistpathlookup", "DynamiteTestListNameKeyLookup", "DynamiteTestListDescriptionKeyLookup");
ListInfo listInfo = new ListInfo("sometestlistpath", "DynamiteTestListNameKey", "DynamiteTestListDescriptionKey")
{
FieldDefinitions = fieldsToEnsure
};
// Note how we need to specify SPSite for injection context - ISharePointEntityBinder's implementation
// is lifetime-scoped to InstancePerSite.
using (var injectionScope = IntegrationTestServiceLocator.BeginLifetimeScope(testScope.SiteCollection))
{
var listHelper = injectionScope.Resolve<IListHelper>();
// Lookup field ListId setup
SPList lookupList = listHelper.EnsureList(testScope.SiteCollection.RootWeb, lookupListInfo);
lookupFieldInfo.ListId = lookupList.ID;
lookupFieldInfoAlt.ListId = lookupList.ID;
lookupMultiFieldInfo.ListId = lookupList.ID;
// Create the looked-up items
var lookupItem1 = lookupList.Items.Add();
lookupItem1["Title"] = "Test Item 1";
lookupItem1.Update();
var lookupItem2 = lookupList.Items.Add();
lookupItem2["Title"] = "Test Item 2";
lookupItem2.Update();
// Create the first test list
SPList list = listHelper.EnsureList(testScope.SiteCollection.RootWeb, listInfo);
list.EnableVersioning = true;
list.Update();
开发者ID:andresglx,项目名称:Dynamite,代码行数:66,代码来源:SharePointEntityBinderTest.cs
示例7: FromEntityToEntityRoundTrip_ShouldEndUpWithIdenticalEntities
//.........这里部分代码省略.........
"NameKeyMulti",
"DescriptionKey",
"GroupKey")
{
TermStoreMapping = new TaxonomyContext(levelOneTermA) // choices limited to children of a specific term, instead of having full term set choices
};
var fieldsToEnsure = new List<BaseFieldInfo>()
{
integerFieldInfo,
numberFieldInfo,
currencyFieldInfo,
boolFieldInfoBasic,
boolFieldInfoDefaultTrue,
boolFieldInfoDefaultFalse,
dateTimeFieldInfoFormula,
dateTimeFieldInfo,
textFieldInfo,
noteFieldInfo,
htmlFieldInfo,
imageFieldInfo,
urlFieldInfo,
urlFieldInfoImage,
lookupFieldInfo,
lookupFieldInfoAlt,
lookupMultiFieldInfo,
userFieldInfo,
userMultiFieldInfo,
mediaFieldInfo,
taxoFieldInfo,
taxoMultiFieldInfo
};
ListInfo lookupListInfo = new ListInfo("sometestlistpathlookup", "DynamiteTestListNameKeyLookup", "DynamiteTestListDescriptionKeyLookup");
ListInfo listInfo = new ListInfo("sometestlistpath", "DynamiteTestListNameKey", "DynamiteTestListDescriptionKey")
{
FieldDefinitions = fieldsToEnsure
};
// Note how we need to specify SPSite for injection context - ISharePointEntityBinder's implementation
// is lifetime-scoped to InstancePerSite.
using (var injectionScope = IntegrationTestServiceLocator.BeginLifetimeScope(testScope.SiteCollection))
{
var listHelper = injectionScope.Resolve<IListHelper>();
// Lookup field ListId setup
SPList lookupList = listHelper.EnsureList(testScope.SiteCollection.RootWeb, lookupListInfo);
lookupFieldInfo.ListId = lookupList.ID;
lookupFieldInfoAlt.ListId = lookupList.ID;
lookupMultiFieldInfo.ListId = lookupList.ID;
// Create the looked-up items
var lookupItem1 = lookupList.Items.Add();
lookupItem1["Title"] = "Test Item 1";
lookupItem1.Update();
var lookupItem2 = lookupList.Items.Add();
lookupItem2["Title"] = "Test Item 2";
lookupItem2.Update();
// Create the first test list
SPList list = listHelper.EnsureList(testScope.SiteCollection.RootWeb, listInfo);
// Initialize the entity object with all the property values we want to apply on the new list item
var entityBinder = injectionScope.Resolve<ISharePointEntityBinder>();
开发者ID:andresglx,项目名称:Dynamite,代码行数:67,代码来源:SharePointEntityBinderTest.cs
示例8: using
public void EnsureField_WhenTaxonomySingleOrMultiAndListField_AndSiteCollectionSpecificTermSet_ShouldApplyTermSetMappingToListColumn()
{
using (var testScope = SiteTestScope.BlankSite())
{
// Arrange
var testTermSet = new TermSetInfo(Guid.NewGuid(), "Test Term Set"); // keep Ids random because, if this test fails midway, the term
// set will not be cleaned up and upon next test run we will
// run into a term set and term ID conflicts.
var levelOneTermA = new TermInfo(Guid.NewGuid(), "Term A", testTermSet);
var levelOneTermB = new TermInfo(Guid.NewGuid(), "Term B", testTermSet);
var levelTwoTermAA = new TermInfo(Guid.NewGuid(), "Term A-A", testTermSet);
var levelTwoTermAB = new TermInfo(Guid.NewGuid(), "Term A-B", testTermSet);
TaxonomySession session = new TaxonomySession(testScope.SiteCollection);
TermStore defaultSiteCollectionTermStore = session.DefaultSiteCollectionTermStore;
Group defaultSiteCollectionGroup = defaultSiteCollectionTermStore.GetSiteCollectionGroup(testScope.SiteCollection);
TermSet newTermSet = defaultSiteCollectionGroup.CreateTermSet(testTermSet.Label, testTermSet.Id);
Term createdTermA = newTermSet.CreateTerm(levelOneTermA.Label, Language.English.Culture.LCID, levelOneTermA.Id);
Term createdTermB = newTermSet.CreateTerm(levelOneTermB.Label, Language.English.Culture.LCID, levelOneTermB.Id);
Term createdTermAA = createdTermA.CreateTerm(levelTwoTermAA.Label, Language.English.Culture.LCID, levelTwoTermAA.Id);
Term createdTermAB = createdTermA.CreateTerm(levelTwoTermAB.Label, Language.English.Culture.LCID, levelTwoTermAB.Id);
defaultSiteCollectionTermStore.CommitAll();
TaxonomyFieldInfo taxoFieldInfo = new TaxonomyFieldInfo(
"TestInternalNameTaxo",
new Guid("{0C58B4A1-B360-47FE-84F7-4D8F58AE80F6}"),
"NameKey",
"DescriptionKey",
"GroupKey")
{
TermStoreMapping = new TaxonomyContext(testTermSet) // choices limited to all terms in test term set
};
TaxonomyMultiFieldInfo taxoMultiFieldInfo = new TaxonomyMultiFieldInfo(
"TestInternalNameTaxoMulti",
new Guid("{B2517ECF-819E-4F75-88AF-18E926AD30BD}"),
"NameKeyMulti",
"DescriptionKey",
"GroupKey")
{
TermStoreMapping = new TaxonomyContext(levelOneTermA) // choices limited to children of a specific term, instead of having full term set choices
};
ListInfo listInfo = new ListInfo("sometestlistpath", "DynamiteTestListNameKey", "DynamiteTestListDescriptionKey");
using (var injectionScope = IntegrationTestServiceLocator.BeginLifetimeScope())
{
IListHelper listHelper = injectionScope.Resolve<IListHelper>();
var list = listHelper.EnsureList(testScope.SiteCollection.RootWeb, listInfo);
IFieldHelper fieldHelper = injectionScope.Resolve<IFieldHelper>();
var fieldsCollection = list.Fields;
// Ensure one of the two on the root web (tweak the definition a little bit on the list def)
fieldHelper.EnsureField(testScope.SiteCollection.RootWeb.Fields, taxoMultiFieldInfo);
taxoMultiFieldInfo.Required = RequiredType.Required;
taxoMultiFieldInfo.TermStoreMapping = new TaxonomyContext(levelTwoTermAB);
// Act
TaxonomyField fieldSingle = (TaxonomyField)fieldHelper.EnsureField(fieldsCollection, taxoFieldInfo);
TaxonomyField fieldMulti = (TaxonomyField)fieldHelper.EnsureField(fieldsCollection, taxoMultiFieldInfo);
// Assert
Assert.AreEqual(testTermSet.Id, fieldSingle.TermSetId);
Assert.AreEqual(defaultSiteCollectionTermStore.Id, fieldSingle.SspId);
Assert.AreEqual(Guid.Empty, fieldSingle.AnchorId); // choices should not be constrained to a child term
Assert.IsTrue(fieldSingle.IsTermSetValid);
Assert.AreEqual(testTermSet.Id, fieldMulti.TermSetId);
Assert.AreEqual(defaultSiteCollectionTermStore.Id, fieldMulti.SspId);
Assert.AreEqual(levelTwoTermAB.Id, fieldMulti.AnchorId); // choices should be constrained to a 2nd level child term
Assert.IsTrue(fieldMulti.IsTermSetValid);
Assert.IsTrue(fieldMulti.IsAnchorValid);
Assert.IsTrue(fieldMulti.Required);
// Gotta also make sure (by fetching the fields again) that the field properties were all persisted
TaxonomyField fieldSingleFetchedAgain = (TaxonomyField)testScope.SiteCollection.RootWeb.Lists[list.ID].Fields[taxoFieldInfo.Id];
TaxonomyField fieldMultiFetchedAgain = (TaxonomyField)testScope.SiteCollection.RootWeb.Lists[list.ID].Fields[taxoMultiFieldInfo.Id];
Assert.AreEqual(testTermSet.Id, fieldSingleFetchedAgain.TermSetId);
Assert.AreEqual(defaultSiteCollectionTermStore.Id, fieldSingleFetchedAgain.SspId);
Assert.AreEqual(Guid.Empty, fieldSingleFetchedAgain.AnchorId); // choices should not be constrained to a child term
Assert.IsTrue(fieldSingleFetchedAgain.IsTermSetValid);
Assert.AreEqual(testTermSet.Id, fieldMultiFetchedAgain.TermSetId);
Assert.AreEqual(defaultSiteCollectionTermStore.Id, fieldMultiFetchedAgain.SspId);
Assert.AreEqual(levelTwoTermAB.Id, fieldMultiFetchedAgain.AnchorId); // choices should be constrained to a 2nd level child term
Assert.IsTrue(fieldMultiFetchedAgain.IsTermSetValid);
Assert.IsTrue(fieldMultiFetchedAgain.IsAnchorValid);
Assert.IsTrue(fieldMultiFetchedAgain.Required);
}
// Cleanup term set so that we don't pollute the metadata store
newTermSet.Delete();
defaultSiteCollectionTermStore.CommitAll();
}
}
开发者ID:ASAGARG,项目名称:Dynamite,代码行数:97,代码来源:FieldHelperTest.cs
示例9: SetTitleAndDescriptionValues
private void SetTitleAndDescriptionValues(SPWeb web, ListInfo listInfo, SPList list)
{
// end with the main language
var availableLanguages = web.SupportedUICultures.Reverse();
foreach (var availableLanguage in availableLanguages)
{
if (!string.IsNullOrEmpty(listInfo.DisplayNameResourceKey))
{
var title = this.resourceLocator.Find(listInfo.ResourceFileName, listInfo.DisplayNameResourceKey, availableLanguage.LCID);
list.TitleResource.SetValueForUICulture(availableLanguage, title);
list.TitleResource.Update();
}
if (!string.IsNullOrEmpty(listInfo.DescriptionResourceKey))
{
var description = this.resourceLocator.Find(listInfo.ResourceFileName, listInfo.DescriptionResourceKey, availableLanguage.LCID);
list.DescriptionResource.SetValueForUICulture(availableLanguage, description);
list.DescriptionResource.Update();
}
}
}
开发者ID:ASAGARG,项目名称:Dynamite,代码行数:21,代码来源:ListHelper.cs
示例10: GetMetadataNavigationSettingsInfo
/// <summary>
/// Gets the metadata navigation settings information by list information from this configuration.
/// </summary>
/// <param name="list">The list information.</param>
/// <returns>
/// The Managed navigation settings
/// </returns>
public MetadataNavigationSettingsInfo GetMetadataNavigationSettingsInfo(ListInfo list)
{
return this.MetadataNavigationSettings.Single(s => s.List.WebRelativeUrl.Equals(list.WebRelativeUrl));
}
开发者ID:GSoft-SharePoint,项目名称:Dynamite-Components,代码行数:11,代码来源:PublishingMetadataNavigationSettingsConfig.cs
示例11: EnsureField_WhenLookupSingleOrMultiField_ShouldApplyLookupFieldDefinitionAndDefaultValue
public void EnsureField_WhenLookupSingleOrMultiField_ShouldApplyLookupFieldDefinitionAndDefaultValue()
{
using (var testScope = SiteTestScope.BlankSite())
{
// Gotta create the list before we even think about provisioning a lookup
ListInfo listInfo = new ListInfo("sometestlistpath", "DynamiteTestListNameKey", "DynamiteTestListDescriptionKey");
LookupFieldInfo lookupFieldInfo = new LookupFieldInfo(
"TestInternalNameLookup",
new Guid("{0C58B4A1-B360-47FE-84F7-4D8F58AE80F6}"),
"NameKey",
"DescriptionKey",
"GroupKey")
{
// ShowField should be Title by default
// ListId will be known only once the SPList is created
};
LookupFieldInfo lookupFieldInfoWithDefault = new LookupFieldInfo(
"TestInternalNameLookupD",
new Guid("{0F413213-9B75-49AD-850E-38EF551B1D1F}"),
"NameKeyDef",
"DescriptionKeyDef",
"GroupKey")
{
// Default value will be assigned below once the list and the lookup item are created
ShowField = "ID"
};
LookupMultiFieldInfo lookupMultiFieldInfo = new LookupMultiFieldInfo(
"TestInternalNameLookupM",
new Guid("{2A3DAD08-F9F7-4BF7-82D5-9E490DAEC242}"),
"NameKeyMulti",
"DescriptionKeyMulti",
"GroupKey")
{
ShowField = "ID"
};
LookupMultiFieldInfo lookupMultiFieldInfoWithDefault = new LookupMultiFieldInfo(
"TestInternalNameLookupMD",
new Guid("{9ACF13BF-F42C-4488-AE54-5E971B7619AB}"),
"NameKeyMultiDef",
"DescriptionKeyMultiDef",
"GroupKey")
{
// ShowField should be Title by default
// Default value will be assigned below once the list and the lookup items are created
};
using (var injectionScope = IntegrationTestServiceLocator.BeginLifetimeScope())
{
// Create the lookup list
IListHelper listHelper = injectionScope.Resolve<IListHelper>();
SPList list = listHelper.EnsureList(testScope.SiteCollection.RootWeb, listInfo);
// Add an item to lookup list to act as default lookup field value
SPListItem item1 = list.Items.Add();
item1["Title"] = "Test Item 1";
item1.Update();
SPListItem item2 = list.Items.Add();
item2["Title"] = "Test Item 2";
item2.Update();
// Add the list ID to the Lookup field definitions
lookupFieldInfo.ListId = list.ID;
lookupFieldInfoWithDefault.ListId = list.ID;
lookupFieldInfoWithDefault.DefaultValue = new LookupValue(item1.ID, item1.ID.ToString());
lookupMultiFieldInfo.ListId = list.ID;
lookupMultiFieldInfoWithDefault.ListId = list.ID;
lookupMultiFieldInfoWithDefault.DefaultValue = new LookupValueCollection() { new LookupValue(item1.ID, "Test Item 1"), new LookupValue(item2.ID, "Test Item 2") };
IFieldHelper fieldHelper = injectionScope.Resolve<IFieldHelper>();
var fieldsCollection = testScope.SiteCollection.RootWeb.Fields;
// 1) Basic lookup field (no default value)
SPFieldLookup lookupField = (SPFieldLookup)fieldHelper.EnsureField(fieldsCollection, lookupFieldInfo);
this.ValidateFieldBasicValues(lookupFieldInfo, lookupField);
Assert.IsTrue(string.IsNullOrEmpty(lookupField.DefaultValue));
Assert.AreEqual("Title", lookupField.LookupField);
Assert.AreEqual(list.ID, new Guid(lookupField.LookupList));
Assert.IsFalse(lookupField.AllowMultipleValues);
SPFieldLookup lookupFieldRefetched = (SPFieldLookup)testScope.SiteCollection.RootWeb.Fields[lookupFieldInfo.Id]; // refetch to make sure .Update() was properly called on SPField
this.ValidateFieldBasicValues(lookupFieldInfo, lookupFieldRefetched);
Assert.IsTrue(string.IsNullOrEmpty(lookupFieldRefetched.DefaultValue));
Assert.AreEqual("Title", lookupFieldRefetched.LookupField);
Assert.AreEqual(list.ID, new Guid(lookupFieldRefetched.LookupList));
Assert.IsFalse(lookupFieldRefetched.AllowMultipleValues);
// 2) Basic lookup field (with default value)
lookupField = (SPFieldLookup)fieldHelper.EnsureField(fieldsCollection, lookupFieldInfoWithDefault);
this.ValidateFieldBasicValues(lookupFieldInfoWithDefault, lookupField);
Assert.AreEqual("ID", lookupField.LookupField);
Assert.AreEqual(list.ID, new Guid(lookupField.LookupList));
Assert.IsFalse(lookupField.AllowMultipleValues);
Assert.AreEqual("1;#1", lookupField.DefaultValue);
//.........这里部分代码省略.........
开发者ID:ASAGARG,项目名称:Dynamite,代码行数:101,代码来源:FieldHelperTest.cs
示例12: EnsureField_WhenOnListInFrenchSubWeb_ShouldCreateListFieldWithFrenchDisplayName
public void EnsureField_WhenOnListInFrenchSubWeb_ShouldCreateListFieldWithFrenchDisplayName()
{
// English root web
using (var testScope = SiteTestScope.BlankSite(Language.English.Culture.LCID))
{
var fieldId = new Guid("{0C58B4A1-B360-47FE-84F7-4D8F58AE80F6}");
TextFieldInfo textFieldInfo = new TextFieldInfo(
"TestInternalName",
fieldId,
"Test_FieldTitle",
"Test_FieldDescription",
"Test_ContentGroup")
{
MaxLength = 50,
Required = RequiredType.Required
};
ListInfo listInfo = new ListInfo("sometestlistpath", "DynamiteTestListNameKey", "DynamiteTestListDescriptionKey");
using (var injectionScope = IntegrationTestServiceLocator.BeginLifetimeScope())
{
SPWeb frenchSubWeb = testScope.SiteCollection.RootWeb.Webs.Add("subweb", "French sub-web", string.Empty, (uint)Language.French.Culture.LCID, "STS#1", false, false);
IListHelper listHelper = injectionScope.Resolve<IListHelper>();
SPList subWebList = listHelper.EnsureList(frenchSubWeb, listInfo);
IFieldHelper fieldHelper = injectionScope.Resolve<IFieldHelper>();
SPFieldCollection listFields = testScope.SiteCollection.RootWeb.Webs["subweb"].Lists[subWebList.ID].Fields;
SPField field = fieldHelper.EnsureField(listFields, textFieldInfo);
SPField fieldOnOldCollection = listFields[textFieldInfo.Id];
SPField fieldRefetched = testScope.SiteCollection.RootWeb.Webs["subweb"].Lists[subWebList.ID].Fields[textFieldInfo.Id];
// Set MUI to french
var ambientThreadCulture = Thread.CurrentThread.CurrentUICulture;
Thread.CurrentThread.CurrentUICulture = Language.French.Culture;
Assert.AreEqual("FR Nom de champ", field.Title);
Assert.AreEqual("FR Description de champ", field.Description);
Assert.AreEqual("FR Groupe de contenu", field.Group);
Assert.AreEqual("FR Nom de champ", fieldOnOldCollection.Title);
Assert.AreEqual("FR Description de champ", fieldOnOldCollection.Description);
Assert.AreEqual("FR Groupe de contenu", fieldOnOldCollection.Group);
Assert.AreEqual("FR Nom de champ", fieldRefetched.Title);
Assert.AreEqual("FR Description de champ", fieldRefetched.Description);
Assert.AreEqual("FR Groupe de contenu", fieldRefetched.Group);
// Reset MUI to its old abient value
Thread.CurrentThread.CurrentUICulture = ambientThreadCulture;
}
}
}
开发者ID:ASAGARG,项目名称:Dynamite,代码行数:54,代码来源:FieldHelperTest.cs
示例13: EnsureField_WhenListFieldCollection_AndSiteColumnDoesntExist_ShouldAddFieldToBothListAndParentRootWeb
public void EnsureField_WhenListFieldCollection_AndSiteColumnDoesntExist_ShouldAddFieldToBothListAndParentRootWeb()
{
using (var testScope = SiteTestScope.BlankSite())
{
var fieldId = new Guid("{0C58B4A1-B360-47FE-84F7-4D8F58AE80F6}");
TextFieldInfo textFieldInfo = new TextFieldInfo(
"TestInternalName",
fieldId,
"NameKey",
"DescriptionKey",
"GroupKey")
{
MaxLength = 50,
Required = RequiredType.Required
};
ListInfo listInfo = new ListInfo("sometestlistpath", "DynamiteTestListNameKey", "DynamiteTestListDescriptionKey");
using (var injectionScope = IntegrationTestServiceLocator.BeginLifetimeScope())
{
IListHelper listHelper = injectionScope.Resolve<IListHelper>();
SPList list = listHelper.EnsureList(testScope.SiteCollection.RootWeb, listInfo);
IFieldHelper fieldHelper = injectionScope.Resolve<IFieldHelper>();
var fieldsCollection = list.Fields;
SPField field = fieldHelper.EnsureField(fieldsCollection, textFieldInfo);
SPList testList = testScope.SiteCollection.RootWeb.Lists[list.ID];
Assert.IsNotNull(testList.Fields[fieldId]);
Assert.IsNotNull(testScope.SiteCollection.RootWeb.Fields[fieldId]); // would be null if we hadn't bothered ensuring the field on the root web
}
}
}
开发者ID:ASAGARG,项目名称:Dynamite,代码行数:35,代码来源:FieldHelperTest.cs
示例14: EnsureField_WhenFieldAddedToListWithDefaultValue_NewItemsCreatedOnListShouldHaveDefaultValues
//.........这里部分代码省略.........
{
new TaxonomyValue(levelTwoTermAA),
new TaxonomyValue(levelTwoTermAB)
}),
TermStoreMapping = new TaxonomyContext(levelOneTermA) // choices limited to children of a specific term, instead of having full term set choices
};
var fieldsToEnsure = new List<BaseFieldInfo>()
{
integerFieldInfo,
numberFieldInfo,
currencyFieldInfo,
boolFieldInfoBasic,
boolFieldInfoDefaultTrue,
boolFieldInfoDefaultFalse,
dateTimeFieldInfoFormula,
dateTimeFieldInfoDefault,
textFieldInfo,
noteFieldInfo,
htmlFieldInfo,
imageFieldInfo,
urlFieldInfo,
urlFieldInfoImage,
lookupFieldInfo,
lookupFieldInfoAlt,
lookupMultiFieldInfo,
userFieldInfo,
userMultiFieldInfo,
mediaFieldInfo,
taxoFieldInfo,
taxoMultiFieldInfo
};
ListInfo lookupListInfo = new ListInfo("sometestlistpathlookup", "DynamiteTestListNameKeyLookup", "DynamiteTestListDescriptionKeyLookup");
ListInfo listInfo1 = new ListInfo("sometestlistpath", "DynamiteTestListNameKey", "DynamiteTestListDescriptionKey");
ListInfo listInfo2 = new ListInfo("sometestlistpathalt", "DynamiteTestListNameKeyAlt", "DynamiteTestListDescriptionKeyAlt")
{
FieldDefinitions = fieldsToEnsure
};
using (var injectionScope = IntegrationTestServiceLocator.BeginLifetimeScope())
{
var listHelper = injectionScope.Resolve<IListHelper>();
// Lookup field ListId setup
SPList lookupList = listHelper.EnsureList(testScope.SiteCollection.RootWeb, lookupListInfo);
lookupFieldInfo.ListId = lookupList.ID;
lookupFieldInfoAlt.ListId = lookupList.ID;
lookupMultiFieldInfo.ListId = lookupList.ID;
// Create the looked-up items
var lookupItem1 = lookupList.Items.Add();
lookupItem1["Title"] = "Test Item 1";
lookupItem1.Update();
var lookupItem2 = lookupList.Items.Add();
lookupItem2["Title"] = "Test Item 2";
lookupItem2.Update();
// Create the first test list
SPList list1 = listHelper.EnsureList(testScope.SiteCollection.RootWeb, listInfo1);
var fieldHelper = injectionScope.Resolve<IFieldHelper>();
// we need to ensure all fields on first list directly
开发者ID:ASAGARG,项目名称:Dynamite,代码行数:67,代码来源:FieldHelperTest.cs
示例15: EnsureList
/// <summary>
/// Creates the list or returns the existing one.
/// </summary>
/// <remarks>The list name and description will not be translated</remarks>
/// <exception cref="SPException">If the list already exists but doesn't have the specified list template.</exception>
/// <param name="web">The current web</param>
/// <param name="listInfo">The list to create</param>
/// <returns>The new list or the existing list</returns>
public SPList EnsureList(SPWeb web, ListInfo listInfo)
{
// First, try to find an already existing list with the same name but at a different Web-relative URL
var list = this.listLocator.GetByNameResourceKey(web, listInfo.DisplayNameResourceKey);
if (list != null)
{
if (!list.RootFolder.Url.Equals(listInfo.WebRelativeUrl.ToString(), StringComparison.OrdinalIgnoreCase))
{
// A list with the same name already exists on a different web relative URL, throwing exception
throw new ArgumentException(
string.Format(CultureInfo.InvariantCulture, "A list with the name {0} already exists on a different web relative URL. Try using a different name.", listInfo.DisplayNameResourceKey));
}
}
list = this.listLocator.TryGetList(web, listInfo.WebRelativeUrl.ToString());
// Ensure the list
if (list == null)
{
list = this.CreateList(web, listInfo);
}
else
{
// If it isn't the pages library
if (string.CompareOrdinal(list.RootFolder.Name, PagesLibraryRootFolder) != 0)
{
this.logger.Info("List " + listInfo.WebRelativeUrl.ToString() + " already exists");
// If the Overwrite parameter is set to true, delete and recreate the catalog
if (listInfo.Overwrite)
{
this.logger.Info("Overwrite is set to true, recreating the list " + listInfo.WebRelativeUrl.ToString());
web.Lists.Delete(list.ID);
// gotta force a re-fetch on the parent SPWeb, otherwise the
// the new list will be create with the same ID as the old one (don't ask, weird SP API behavior).
using (var freshWebToMakeSureNewListGuidIsGiven = web.Site.OpenWeb(web.ID))
{
list = this.CreateList(freshWebToMakeSureNewListGuidIsGiven, listInfo);
}
}
}
}
// Update the display name and description, if need be
this.SetTitleAndDescriptionValues(web, listInfo, list);
// Remove Item Content Type
if (listInfo.RemoveDefaultContentType)
{
this.logger.Info("Removing the default Item Content Type");
// If content type is direct child of item, remove it
this.RemoveItemContentType(list);
}
// Add All Content Types
if (listInfo.ContentTypes != null && listInfo.ContentTypes.Count >= 1)
{
this.contentTypeBuilder.EnsureContentType(list.ContentTypes, listInfo.ContentTypes);
// Re-fetch, list was updated through another object instance, so we gotta refresh our object instance
list = web.Lists[list.ID];
// Set the unique content type order on the root folder.
IList<SPContentType> contentTypeOrder = new List<SPContentType>();
foreach (var contentTypeInfo in listInfo.ContentTypes)
{
var listContentType = GetListContentType(list, contentTypeInfo);
if (listContentType != null)
{
// If we find a content type on the list that matches the content type info in the list info we add it to the collection.
contentTypeOrder.Add(listContentType);
}
}
if (contentTypeOrder.Count >= 1)
{
// If we have content types in our new list, we set the new list.
list.RootFolder.UniqueContentTypeOrder = contentTypeOrder;
list.RootFolder.Update();
}
list.Update();
}
list = web.Lists[list.ID];
// Draft VisibilityType
if (listInfo.HasDraftVisibilityType)
//.........这里部分代码省略.........
开发者ID:ASAGARG,项目名称:Dynamite,代码行数:101,代码来源:ListHelper.cs
示例16: ListInfo
public void EnsureList_WhenEnsuringAnExistingListAndWithAWriteSecuritySpecified_ItShouldUpdateTheListWithTheRightPermission()
{
// Arrange
const string Url = "testUrl";
var listInfo = new ListInfo(Url, "NameKey", "DescriptionKey");
using (var testScope = SiteTestScope.BlankSite())
{
var rootWeb = testScope.SiteCollection.RootWeb;
using (var injectionScope = IntegrationTestServiceLocator.BeginLifetimeScope())
{
var listHelper = injectionScope.Resolve<IListHelper>();
var lis
|
请发表评论