Date post: | 04-Jan-2016 |
Category: |
Documents |
Upload: | april-merritt |
View: | 218 times |
Download: | 2 times |
Developing Office Client Solutions Using LINQ and Open XML Eric White
Technical EvangelistMicrosoft CorporationSession Code: OFC403
REDUCE# LINES
OF CODE
Actually, it's about reducing Cyclomatic Complexity
But Why?
REDUCEPOINTS OF POSSIBLE
FAILURE(More robust code)
Session Objectives and Takeaways
Session Objective(s): Benefits of “Pure FP”3 Approaches: LINQ / Open XMLTools and Resources
It's All About Transformations
ProjectionComposabilityPurityTuplesAggregation
More FP
Extension MethodsLazy EvaluationClosuresMethod Syntax
Open XML
Zip Files (called Packages)Packages contain Parts (files in the Zip file)Package has relationship to PartsParts have relationship to other PartsContent Type tells what the XML is
PowerTools for Visual Studio Rock!Open XML Diff is your friend
Open XML SDK
V1Strongly Typed access to PartsNo help with the XML
V2Strongly Typed access to XmlValidationHelper Functions
LtxOpenXml Class
XDocument Annotations on PartsExtension methods on MainDocumentPartLazyProjects collections of Named Tuple Types
LINQ to XML Tips
Pre-atomize XName and XNamespaceUse Extension methods to find optional Elements/Attributes
LINQ to Excel Tables
Use friendly names of Tables and ColumnsBased on LtxOpenXml ClassLazy
Modifying XML Trees
“Halloween Problem”Accept RevisionsRemove Personal InformationRemove CommentsSee OpenXmlInfo class on my blog
Annotations / Events
Use Annotations and Events to determine if tree changedCan implement “Flush” – get list of all parts
In-Memory Open XML Documents
Web application serversSharePointSharePoint Web Services
Transforming in XSLT Style
Annotate the tree with new nodesQuery to find nodes == XPath patternReplacement node == Sequence ConstructorApplyTransforms node == xsd:apply-templates
Example uses extension methods to reduce syntactic noiseSupports Mode
Recap: Three Approaches
1) Pure Functional Transforms2) “Imperative” Document Modification3) XSLT Style
DocProc
An “imperative” approach to document assemblyPart of PowerTools for Open XML ProjectAlternative to altChunk
Document Reflector
“Build a document assembly solution in 5 minutes”Functional Construction in“Expression Context”
Open XML Code Tester
Content Controls are KeyUses Title of Content ControlPuts XML in Content Controls
Next Steps
Go through the Functional Programming TutorialDownload, run the samples
Modify them for your scenarioGet involved in the community
question & answer
Key Resources
Open XML SDK V1http://go.microsoft.com/fwlink/?LinkId=120908
Open XML SDK V2http://go.microsoft.com/fwlink/?LinkId=127912
MSDNContains how-to articles and documentationForums related to SDKhttp://msdn.microsoft.com/office/xml
Key Resources
ConnectAccess to more articles and forumsAbility to log bugs and vote for featureshttp://connect.microsoft.com
Key Resources
Blogsblogs.msdn.com/ericwhiteblogs.msdn.com/brian_jonesblogs.msdn.com/dmahugh
PowerTools for Visual Studiohttp://www.microsoft.com/downloads/details.aspx?FamilyId=46B6BF86-E35D-4870-B214-4D7B72B02BF9&displaylang=en
PowerTools for Open XMLwww.codeplex.com/powertools
www.microsoft.com/teched
Sessions On-Demand & Community
http://microsoft.com/technet
Resources for IT Professionals
http://microsoft.com/msdn
Resources for Developers
www.microsoft.com/learningMicrosoft Certification and Training Resources
www.microsoft.com/learning
Microsoft Certification & Training Resources
Resources
Complete an evaluation on CommNet and enter to win!
© 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS,
IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.