This project is read-only.
IScriptCommands that marked serializable are serializable to xml. These commands use keys to get value from ParameterDic, e.g.

public class ParsePath : ScriptCommandBase
{
/// Profile to parse path (IProfile), default = Profile
public string ProfileKey { get; set; }
/// Required, path to parse, default = {Path} or C:\\Temp
public string PathKey { get; set; }
/// Where to store after parse completed, default = Entry
public string DestinationKey { get; set; }
/// If the path is not found, command to execute. Optional, return ResultCommand.Error if not specified.
public ScriptCommandBase NotFoundCommand { get; set; }
....
}
}}

One can use ScriptCommandSerializer do the xml serialization, IScriptCommands defined in different assemblies are XmlIncluded in "{AssemblyName}Commands" class, e.g. FileExplorer3Commands for FileExplorer3 library.

IScriptCommand copyCommand =
               CoreScriptCommands.ParsePath("{Profile}","{SourceFile}", "{Source}",
               CoreScriptCommands.DiskParseOrCreateFile("{Profile}","{DestinationFile}", "{Destination}",
               CoreScriptCommands.DiskOpenStream("{Source}", "{SourceStream}", FileExplorer.Defines.FileAccess.Read,
               CoreScriptCommands.DiskOpenStream("{Destination}", "{DestinationStream}", FileExplorer.Defines.FileAccess.Write,
               CoreScriptCommands.CopyStream("{SourceStream}", "{DestinationStream}")))),
               ResultCommand.Error(new FileNotFoundException()));		


new ScriptCommandSerializer(new Type[]  
         {typeof(FileExplorer3Commands)}).SerializeScriptCommand(copyCommand );



<ScriptCommandBase xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:type="ParsePath">
  <NextCommand xsi:type="ParsePath">
    <NextCommand xsi:type="DiskOpenStream">
      <NextCommand xsi:type="DiskOpenStream">
        <NextCommand xsi:type="CopyStream">
          <SourceKey>{SourceStream}</SourceKey>
          <DestinationKey>{DestinationStream}</DestinationKey>
        </NextCommand>
        <EntryKey>{Destination}</EntryKey>
        <StreamKey>{DestinationStream}</StreamKey>
        <Access>Write</Access>
      </NextCommand>
      <EntryKey>{Source}</EntryKey>
      <StreamKey>{SourceStream}</StreamKey>
      <Access>Read</Access>
    </NextCommand>
    <ProfileKey>{Profile}</ProfileKey>
    <PathKey>{DestinationFile}</PathKey>
    <DestinationKey>{Destination}</DestinationKey>
    <NotFoundCommand xsi:type="DiskCreatePath">
      <NextCommand xsi:type="DiskOpenStream">
        <NextCommand xsi:type="DiskOpenStream">
          <NextCommand xsi:type="CopyStream">
            <SourceKey>{SourceStream}</SourceKey>
            <DestinationKey>{DestinationStream}</DestinationKey>
          </NextCommand>
          <EntryKey>{Destination}</EntryKey>
          <StreamKey>{DestinationStream}</StreamKey>
          <Access>Write</Access>
        </NextCommand>
        <EntryKey>{Source}</EntryKey>
        <StreamKey>{SourceStream}</StreamKey>
        <Access>Read</Access>
      </NextCommand>
      <ProfileKey>{Profile}</ProfileKey>
      <PathKey>{DestinationFile}</PathKey>
      <IsFolder>false</IsFolder>
      <DestinationKey>{Destination}</DestinationKey>
      <NameGenerationMode>NoRename</NameGenerationMode>
    </NotFoundCommand>
  </NextCommand>
  <ProfileKey>{Profile}</ProfileKey>
  <PathKey>{SourceFile}</PathKey>
  <DestinationKey>{Source}</DestinationKey>
  <NotFoundCommand xsi:type="ResultCommand">
    <NextCommand xsi:type="ResultCommand">
      <MarkHandled>false</MarkHandled>
      <ErrorMessage />
    </NextCommand>
    <MarkHandled>true</MarkHandled>
    <ErrorMessage>Unable to find the specified file.</ErrorMessage>
  </NotFoundCommand>
</ScriptCommandBase>

Last edited Jul 25, 2014 at 4:12 PM by lycj, version 2

Comments

No comments yet.