public static Operation FromTemplate(OperationTemplate template) { Operation op = null; if (template.op == "add") { op = new AddOperation(); } else if (template.op == "remove") { op = new RemoveOperation(); } else if (template.op == "test") { op = new TestOperation(); } else if (template.op == "move") { op = new MoveOperation(); } else if (template.op == "copy") { op = new CopyOperation(); } else if (template.op == "replace") { op = new ReplaceOperation(); } op.CopyPropertiesFrom(template); return op; }
public OperationTemplate ToTemplate() { OperationTemplate template = new OperationTemplate(); template.op = this.Name; template.path = this.Path; template.from = this.From; template.value = this.Value; return template; }
private void CopyPropertiesFrom(OperationTemplate template) { this.Name = template.op; this.Path = template.path; this.From = template.from; this.Value = template.value; }