/// <summary> /// Replaces author name in document using custom ReplaceHandler /// </summary> public static void ReplaceMetadataProperties(string filePath) { try { //ExStart:ReplaceMetadataProperties // replace 'author' value SearchFacade.ReplaceInDocument(Common.MapSourceFilePath(filePath), "Author", "Jack London", SearchCondition.Matches, Common.MapDestinationFilePath(filePath)); // replace all properties contained 'co' to 'some value' SearchFacade.ReplaceInDocument(Common.MapSourceFilePath(filePath), "co", "some value", SearchCondition.Contains, Common.MapDestinationFilePath(filePath)); //ExEnd:ReplaceMetadataProperties } catch (Exception exp) { Console.WriteLine("Exception occurred: " + exp.Message); } }
/// <summary> /// Replaces author name in document using custom ReplaceHandler /// </summary> public static void ReplaceAuthorName(string filePath) { try { //ExStart:ReplaceAuthorName // initialize custom handler, send output path using constructor IReplaceHandler <MetadataProperty> replaceHandler = new AuthorReplaceHandler(Common.MapDestinationFilePath(filePath)); // replace author int affectedPropertiesCount = SearchFacade.ReplaceInDocument(Common.MapSourceFilePath(filePath), replaceHandler); //ExEnd:ReplaceAuthorName } catch (Exception exp) { Console.WriteLine("Exception occurred: " + exp.Message); } }