本文整理汇总了C#中Content类的典型用法代码示例。如果您正苦于以下问题:C# Content类的具体用法?C# Content怎么用?C# Content使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Content类属于命名空间,在下文中一共展示了Content类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Initialize
public override void Initialize(Content context, string backUri, Application application, object parameters)
{
base.Initialize(context, backUri, application, parameters);
if (!SecurityHandler.HasPermission(NodeHead.Get("/Root/System/WebRoot/Explore.html"), PermissionType.Open))
this.Forbidden = true;
}
示例2: OnContentRestored
public void OnContentRestored(Content category)
{
if (ContentRestored != null)
{
ContentRestored(new SingleItemEventArgs<Content>(category));
}
}
示例3: HxS
public HxS(string workingDir, string hxsFile,
string title, string copyright, string locale,
TreeNodeCollection nodes,
Content contentDataSet,
Dictionary<string, string> links)
{
this.locale = locale;
this.title = title;
this.copyright = copyright;
this.nodes = nodes;
this.contentDataSet = contentDataSet;
this.links = links;
this.outputFile = Path.GetFullPath(hxsFile);
this.rawDir = Path.Combine(workingDir, "raw");
// The source shouldn't be hidden away. If an error happens (likely) the user needs to check logs etc.
//this.hxsDir = Path.Combine(workingDir, "hxs");
this.hxsDir = GetUniqueDir(hxsFile);
this.withinHxsDir = Path.Combine(hxsDir, hxsSubDir);
this.baseFilename = Path.GetFileNameWithoutExtension(hxsFile);
this.baseFilename = this.baseFilename.Replace(" ", "_"); //replace spaces with _ otherwise we get compile errors
this.logFile = Path.Combine(hxsDir, this.baseFilename + ".log");
this.projectFile = Path.Combine(hxsDir, baseFilename + ".hxc");
if (xform == null)
{
xform = new XslCompiledTransform(true);
xform.Load(transformFile);
}
}
示例4: ContentDeserializationTest_DeserializeFromJson_Success
public void ContentDeserializationTest_DeserializeFromJson_Success()
{
var valuesToFill = new Content(
// Add field.
new FieldContent("Report date", new DateTime(2000, 01, 01).ToShortDateString()),
// Add table.
new TableContent("Team Members Table")
.AddRow(
new FieldContent("Name", "Eric"),
new FieldContent("Role", "Program Manager"))
.AddRow(
new FieldContent("Name", "Bob"),
new FieldContent("Role", "Developer")),
// Add nested list.
new ListContent("Team Members Nested List")
.AddItem(new ListItemContent("Role", "Program Manager")
.AddNestedItem(new FieldContent("Name", "Eric"))
.AddNestedItem(new FieldContent("Name", "Ann")))
.AddItem(new ListItemContent("Role", "Developer")
.AddNestedItem(new FieldContent("Name", "Bob"))
.AddNestedItem(new FieldContent("Name", "Richard"))),
// Add image
new ImageContent("photo", new byte[] { 1, 2, 3 })
);
const string serialized = "{\"Tables\":[{\"Name\":\"Team Members Table\",\"Rows\":[{\"Tables\":[],\"Lists\":[],\"Fields\":[{\"Name\":\"Name\",\"Value\":\"Eric\"},{\"Name\":\"Role\",\"Value\":\"Program Manager\"}],\"Images\":[]},{\"Tables\":[],\"Lists\":[],\"Fields\":[{\"Name\":\"Name\",\"Value\":\"Bob\"},{\"Name\":\"Role\",\"Value\":\"Developer\"}],\"Images\":[]}],\"FieldNames\":[\"Name\",\"Role\"]}],\"Lists\":[{\"Name\":\"Team Members Nested List\",\"Items\":[{\"NestedFields\":[{\"NestedFields\":null,\"Tables\":[],\"Lists\":[],\"Fields\":[{\"Name\":\"Name\",\"Value\":\"Eric\"}],\"Images\":[]},{\"NestedFields\":null,\"Tables\":[],\"Lists\":[],\"Fields\":[{\"Name\":\"Name\",\"Value\":\"Ann\"}],\"Images\":[]}],\"Tables\":[],\"Lists\":[],\"Fields\":[{\"Name\":\"Role\",\"Value\":\"Program Manager\"}],\"Images\":[]},{\"NestedFields\":[{\"NestedFields\":null,\"Tables\":[],\"Lists\":[],\"Fields\":[{\"Name\":\"Name\",\"Value\":\"Bob\"}],\"Images\":[]},{\"NestedFields\":null,\"Tables\":[],\"Lists\":[],\"Fields\":[{\"Name\":\"Name\",\"Value\":\"Richard\"}],\"Images\":[]}],\"Tables\":[],\"Lists\":[],\"Fields\":[{\"Name\":\"Role\",\"Value\":\"Developer\"}],\"Images\":[]}],\"FieldNames\":[\"Role\",\"Name\"]}],\"Fields\":[{\"Name\":\"Report date\",\"Value\":\"01.01.2000\"}],\"Images\":[{\"Name\":\"photo\",\"Binary\":\"AQID\"}]}";
var deserialized = JsonConvert.DeserializeObject<Content>(serialized);
Assert.IsTrue(valuesToFill.Equals(deserialized));
}
示例5: CreateAgreementDoc
public static byte[] CreateAgreementDoc(string WebPath, string AgreementNumber, string AgreementDate, string UserName, string SignerName, string TargetPosition, string TargetDepartment, string SignerShortName, string SignerPositionWithDepartment, string UserShortName)
{
FileInfo file = new FileInfo(Path.Combine(WebPath, @"StaffMovements\Dogovor.docx"));
string newfilename = Path.Combine(WebPath,Guid.NewGuid().ToString()+".docx");
var newfile = file.CopyTo(newfilename,true);
using (var outputDocument = new TemplateProcessor(newfilename)
.SetRemoveContentControls(true))
{
var documentenc = Encoding.GetEncoding(outputDocument.Document.Declaration.Encoding);
var valuesToFill = new Content(
new FieldContent("AgreementNumber", AgreementNumber),
new FieldContent("AgreementDate", AgreementDate),
new FieldContent("UserName", UserName),
new FieldContent("Signer", SignerName),
new FieldContent("TargetPosition", TargetPosition),
new FieldContent("TargetDepartment", TargetDepartment),
new FieldContent("SignerShortName", SignerShortName),
new FieldContent("SignerPositionWithDepartment", SignerPositionWithDepartment),
new FieldContent("UserShortName", UserShortName)
);
outputDocument.FillContent(valuesToFill);
outputDocument.SaveChanges();
}
StreamReader reader = new StreamReader(newfilename);
var result = NoteCreator.ReadFull(reader.BaseStream);
//newfile.Delete();
return result;
}
示例6: Markup_client_retrieves_last_known_good_content_from_local_cache_if_service_throws_exception
public void Markup_client_retrieves_last_known_good_content_from_local_cache_if_service_throws_exception()
{
// Arrange
var service = new Mock<IContentService>();
service.Setup(x => x.Get(ContentTypes.Intranet_FatFooter)).Throws(new Exception("Unit test exception"));
var cache = new Mock<ILocalCache<Content>>();
cache.Setup(x => x.WriteToCache(ContentTypes.Intranet_FatFooter, It.IsAny<Content>(), It.IsAny<DateTime>()));
var content = new Content
{
RefreshDate = DateTime.Now,
Sections = new List<ContentSection>
{
new ContentSection
{
Id = ContentTypes.Intranet_FatFooter.ToString()
}
}
};
cache.Setup(x => x.ReadFromCache(ContentTypes.Intranet_FatFooter)).Returns(content);
var client = new ContentClient(service.Object, cache.Object);
// Act
client.Get(ContentTypes.Intranet_FatFooter);
// Assert
service.Verify(x => x.Get(ContentTypes.Intranet_FatFooter), Times.Once);
cache.Verify(x => x.ReadFromCache(ContentTypes.Intranet_FatFooter), Times.Once);
cache.Verify(x => x.WriteToCache(ContentTypes.Intranet_FatFooter, It.IsAny<Content>(), It.IsAny<DateTime>()), Times.Never);
}
示例7: SetupTestContentData
public static Content SetupTestContentData(Guid newGuid, Guid newGuidRedHerring, ProviderSetup providerSetup)
{
var baseEntity = HiveModelCreationHelper.MockTypedEntity();
var entity = new Content(baseEntity);
entity.Id = new HiveId(newGuid);
entity.EntitySchema.Alias = "schema-alias1";
var existingDef = entity.EntitySchema.AttributeDefinitions[0];
var newDef = HiveModelCreationHelper.CreateAttributeDefinition("aliasForQuerying", "", "", existingDef.AttributeType, existingDef.AttributeGroup, true);
entity.EntitySchema.AttributeDefinitions.Add(newDef);
entity.Attributes.Add(new TypedAttribute(newDef, "my-new-value"));
entity.Attributes[1].DynamicValue = "not-on-red-herring";
entity.Attributes[NodeNameAttributeDefinition.AliasValue].Values["UrlName"] = "my-test-route";
var redHerringEntity = HiveModelCreationHelper.MockTypedEntity();
redHerringEntity.Id = new HiveId(newGuidRedHerring);
redHerringEntity.EntitySchema.Alias = "redherring-schema";
using (var uow = providerSetup.UnitFactory.Create())
{
var publishedRevision = new Revision<TypedEntity>(entity)
{ MetaData = { StatusType = FixedStatusTypes.Published } };
uow.EntityRepository.Revisions.AddOrUpdate(publishedRevision);
// Only add extra entity if caller wants it
if (newGuidRedHerring != Guid.Empty) uow.EntityRepository.AddOrUpdate(redHerringEntity);
uow.Complete();
}
return entity;
}
示例8: Add_AddOneBookWithParamsNull
public void Add_AddOneBookWithParamsNull()
{
string[] testContentParams = new string[] { null };
IContent testContent = new Content(ContentType.Book, testContentParams);
ICatalog currentCatalog = new Catalog();
currentCatalog.Add(testContent);
}
示例9: Add_AddTwoIndenticalBooksAndThreeOtherItems
public void Add_AddTwoIndenticalBooksAndThreeOtherItems()
{
string[] testBookContentParams = new string[] { "Intro C#", "S.Nakov", "12763892", "http://www.introprogramming.info" };
IContent testBookContent = new Content(ContentType.Book, testBookContentParams);
ICatalog currentCatalog = new Catalog();
currentCatalog.Add(testBookContent);
currentCatalog.Add(testBookContent);
string[] testMovieContentParams = new string[] { "The Secret", "Drew Heriot, Sean Byrne & others (2006)", "832763834", "http://t.co/dNV4d" };
IContent testMovieContent = new Content(ContentType.Book, testMovieContentParams);
currentCatalog.Add(testMovieContent);
string[] testApplicationContentParams = new string[] { "Firefox v.11.0", "Mozilla", "16148072", "http://www.mozilla.org" };
IContent testApplicationContent = new Content(ContentType.Book, testApplicationContentParams);
currentCatalog.Add(testApplicationContent);
string[] testSongContentParams = new string[] { "One", "Metallica", "8771120", "http://goo.gl/dIkth7gs" };
IContent testSongContent = new Content(ContentType.Book, testSongContentParams);
currentCatalog.Add(testSongContent);
IEnumerable<IContent> currentContent = currentCatalog.GetListContent("One", 10);
int numberOfRenurnedResults = currentContent.Count();
Assert.AreEqual(1, numberOfRenurnedResults);
}
示例10: Create
public Content Create(Content content, HttpPostedFileBase picture)
{
try
{
if (picture != null && picture.ContentLength > 0)
{
string ext = VirtualPathUtility.GetExtension(picture.FileName);
MemoryStream ms = new MemoryStream();
Image bitmap = Image.FromStream(picture.InputStream);
string filename = content.UniqueKey + ".jpg";
bitmap.Save(Path.Combine(DBNLConfigurationManager.FileResponsity.PictureFolder, filename), ImageFormat.Jpeg);
content.Picture = filename;
bitmap.Dispose();
ms.Close();
}
}
catch (IOException ex)
{
}
//content.CreatedDate = DateTime.Now;
content.UpdatedDate = DateTime.Now;
Contents.InsertOnSubmit(content);
Commit();
return content;
}
示例11: IsInvalidVersioningAction
private static bool IsInvalidVersioningAction(Content context, string actionName)
{
if (string.IsNullOrEmpty(actionName) || context == null)
return false;
actionName = actionName.ToLower();
var generic = context.ContentHandler as GenericContent;
if (generic == null)
return false;
switch (actionName)
{
case "checkin":
return !SavingAction.HasCheckIn(generic);
case "checkout":
return (generic.VersioningMode <= VersioningType.None && !(generic is IFile || generic.NodeType.IsInstaceOfOrDerivedFrom("Page"))) || !SavingAction.HasCheckOut(generic);
case "undocheckout":
return !SavingAction.HasUndoCheckOut(generic);
case "forceundocheckout":
return !SavingAction.HasForceUndoCheckOutRight(generic);
case "publish":
return (generic.VersioningMode <= VersioningType.None || !SavingAction.HasPublish(generic));
case "approve":
case "reject":
return !generic.Approvable;
default:
return false;
}
}
示例12: IsEqual
public static HtmlString IsEqual(this Content content, Content comparer, string valueIfTrue, string valueIfFalse)
{
if (comparer.Id == content.Id)
return new HtmlString(valueIfTrue);
else
return new HtmlString(valueIfFalse);
}
示例13: IsDescendantOrSelf
public static HtmlString IsDescendantOrSelf(this Content content, Content ancestor, string valueIfTrue, string valueIfFalse)
{
if (ancestor.AllDescendantIdsOrSelf().Contains(content.Id))
return new HtmlString(valueIfTrue);
else
return new HtmlString(valueIfFalse);
}
示例14: IsAncestorOrSelf
public static HtmlString IsAncestorOrSelf(this Content content, Content child, string valueIfTrue, string valueIfFalse)
{
if (child.AllAncestorIdsOrSelf().Contains(content.Id))
return new HtmlString(valueIfTrue);
else
return new HtmlString(valueIfFalse);
}
示例15: AttachButtonEvent
private void AttachButtonEvent(Content.TowerSelectionPanel buttonName, TowerType type)
{
var button = (InteractiveButton)GetSceneControl(buttonName.ToString());
button.AddTag(type.ToString());
button.Clicked += () => BuildTower(type);
towerButtonPanel.Add(button);
}