Skip to content

Instantly share code, notes, and snippets.

@togakangaroo
Created July 25, 2014 17:05
Show Gist options
  • Save togakangaroo/ae6fb297e5dd78f15a07 to your computer and use it in GitHub Desktop.
Save togakangaroo/ae6fb297e5dd78f15a07 to your computer and use it in GitHub Desktop.
Demonstration of things you can do with inner classes
public class Presentation
{
public class PackageResult
{
public string Name;
public Stream Stream;
}
//PackageResult as an inner clas can be a good idea since its really just a Tuple and has no reusability value
public PackageResult Package()
{
//...
}
}
public class PresentationTemplate
{
public string Id { get; private set; }
public IEnumerable<PresentationTemplate.Slide> Slides { get; private set; }
private readonly FileInfo templateFile;
protected virtual PresentationTemplate.Slide CreateSlide(CM.Slide s, PresentationExporter exporter, CM.Presentation preso)
{
return new PresentationTemplate.Slide(
this,
Int32.Parse(s.Id),
() => exporter.Export(preso, s)
);
}
public class Slide
{
public string Id { get; private set; }
public void DoStuff()
{
//Note that this also has access to the internals of its parent
doStuffWith(this.Template.templateFile)
}
public Slide(PresentationTemplate vpt, int originalSlideId, Func<XDocument> getSvg)
{
this.Template = vpt;
this.OriginalSlideId = originalSlideId;
this.Id = SlideDelimitorUtils.AssembleSlideId(vpt.Id, originalSlideId);
this.getSvg = getSvg;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment