本文整理汇总了C#中DataObject.Validate方法的典型用法代码示例。如果您正苦于以下问题:C# DataObject.Validate方法的具体用法?C# DataObject.Validate怎么用?C# DataObject.Validate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataObject
的用法示例。
在下文中一共展示了DataObject.Validate方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ValidationTest
public static void ValidationTest()
{
TypeSet ts = new TypeSet();
StructDef sd = new StructDef();
sd.ParentTypeSet = ts;
sd.Name = "T1";
sd.Members.Add(new MemberDef("F1", "string", false, false));
sd.Members.Add(new MemberDef("F2", "int", true, true));
DataObject dob = new DataObject();
dob["F1"] = 399;
List<int> lst = new List<int>();
lst.AddRange(new int[] {1, 2, 3, 4});
dob["F2"] = lst;
dob["F3"] = null;
dob.Validate(sd);
}
示例2: SetTaskInputData
/// <summary>
/// Set task input data (validation included)
/// </summary>
/// <param name="inputData"></param>
public virtual void SetTaskInputData(IDataObject inputData)
{
StructDef sd = ProcessTask.GetTaskInputDataSchema();
inputData.Validate(sd);
DataObject taskData = new DataObject();
IScriptContext ctx = CreateTaskScriptContext();
ctx.SetItem("data", ContextItem.Variable, new DOBMutant(taskData));
foreach (VariableDef vd in ProcessTask.TaskVariables)
{
if (vd.VariableDir == VariableDef.Dir.In ||
vd.VariableDir == VariableDef.Dir.InOut)
{
taskData[vd.Name] = inputData[vd.Name];
}
else
{
if (vd.DefaultValueExpr != null && vd.DefaultValueExpr.Length > 0)
{
taskData[vd.Name] = Script.RunCode(vd.DefaultValueExpr, ctx);
}
}
}
StructDef internalSchema = GetTaskInternalDataSchema();
taskData.Validate(internalSchema);
_taskData = taskData;
}
示例3: GetTaskOutputData
/// <summary>
/// Return task output data
/// </summary>
/// <returns></returns>
public virtual IDataObject GetTaskOutputData()
{
StructDef sd = ProcessTask.GetTaskOutputDataSchema();
DataObject dob = new DataObject(sd);
IDataObject src = GetTaskVariablesContainer();
foreach (VariableDef vd in this.ProcessTask.TaskVariables)
{
if (vd.VariableDir == VariableDef.Dir.InOut || vd.VariableDir == VariableDef.Dir.Out)
{
object obj = src[vd.Name];
dob.Set(vd.Name, null, obj);
}
}
dob.Validate();
return dob;
}
示例4: SetProcessInputData
/// <summary>
/// Set process input data
/// </summary>
/// <param name="data"></param>
public void SetProcessInputData(IDataObject data)
{
StructDef procInput = Definition.GetProcessInputDataSchema();
data.Validate(procInput);
DataObject dob = new DataObject();
IProcessScript ctx = CreateProcessScriptContext();
foreach (VariableDef vd in Definition.ProcessVariables)
{
if (data.ContainsKey(vd.Name))
{
dob[vd.Name] = data[vd.Name];
}
else
{
if (vd.DefaultValueExpr == null || vd.DefaultValueExpr.Length == 0)
{
if (vd.IsRequired && (vd.VariableDir == VariableDef.Dir.In || vd.VariableDir == VariableDef.Dir.InOut))
throw new ApplicationException("Missing required input variable: " + vd.Name);
}
else
{
object val = ctx.GetDefaultVariableValue(vd.Name);
dob[vd.Name] = val;
}
}
}
StructDef internalSchema = GetProcessInternalDataSchema();
dob.Validate(internalSchema);
_processInstanceData = new DataObject();
_processInstanceData["variables"] = dob;
_processInstanceData["instanceInfo"] = new DataObject();
}
示例5: GetProcessOutputData
/// <summary>
/// Return process instance output data
/// Can be called only if Status == Finished
/// </summary>
/// <returns></returns>
public DataObject GetProcessOutputData()
{
if (Status != ProcessStatus.Finished) throw new ApplicationException("Process must be finished to get output data");
if (!_activated) throw new ApplicationException("Not activated");
StructDef sd = this.Definition.GetProcessOutputDataSchema();
DataObject dob = new DataObject(sd);
IDataObject src = this.GetProcessVariablesContainer();
foreach (VariableDef vd in Definition.ProcessVariables)
{
if (vd.VariableDir == VariableDef.Dir.InOut || vd.VariableDir == VariableDef.Dir.Out)
{
object obj = src[vd.Name];
dob.Set(vd.Name, null, obj);
}
}
dob.Validate();
return dob;
}
示例6: InitializeTaskData
/// <summary>
/// Prepare task data - validate the input and initialize task variables. Throws exception if input data structure
/// does not validate against task data schema.
/// </summary>
/// <param name="inputData"></param>
protected void InitializeTaskData(IDataObject inputData)
{
StructDef sd = Context.TaskDefinition.GetTaskInputDataSchema();
inputData.Validate(sd);
DataObject taskData = new DataObject();
ITaskScript ts = CreateScriptContext(taskData);
foreach (VariableDef vd in Context.TaskDefinition.TaskVariables)
{
if (vd.VariableDir == VariableDef.Dir.In ||
vd.VariableDir == VariableDef.Dir.InOut)
{
taskData[vd.Name] = inputData[vd.Name];
}
else
{
if (vd.DefaultValueExpr != null && vd.DefaultValueExpr.Length > 0)
{
object defVal = ts.GetDefaultVariableValue(vd.Name);
taskData[vd.Name] = defVal;
}
}
}
StructDef internalSchema = Context.TaskDefinition.GetTaskInternalDataSchema();
taskData.Validate(internalSchema);
this._taskData = taskData;
}