本文整理汇总了C#中IModel.SetParsed方法的典型用法代码示例。如果您正苦于以下问题:C# IModel.SetParsed方法的具体用法?C# IModel.SetParsed怎么用?C# IModel.SetParsed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IModel
的用法示例。
在下文中一共展示了IModel.SetParsed方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Parse
void Parse(IModel model, int charIndex, System.Action callback)
{
var text = model.Content;
ThreadPool.QueueUserWorkItem(o =>
{
try
{
var parseInfo = new ParseInfo();
parseInfo.Content = text;
parseInfo.Index = charIndex;
parseInfo.Type = model.ParseType;
var parseInfo_json = Newtonsoft.Json.JsonConvert.SerializeObject(parseInfo);
string json = null;
lock (this.syncObj)
{
if (!ConnectProxy.Instance().Send(parseInfo_json))
{
model.SetParsed(false);
return;
}
json = ConnectProxy.Instance().Read();
}
if (json == null)
{
model.SetParsed(false);
return;
}
IParseModule module = null;
try
{
if (model.ParseType == CodeHelper.Core.Parser.ParseType.XmlModel)
{
module = JsonConvert.DeserializeObject<XmModelDB>(json);
}
else if (model.ParseType == CodeHelper.Core.Parser.ParseType.DataModel)
{
var program = JsonConvert.DeserializeObject<DbProgram>(json);
module = new DmModelDB();
((DmModelDB)module).Program = program;
module.Name = System.IO.Path.GetFileNameWithoutExtension(model.File);
}
else if (model.ParseType == Core.Parser.ParseType.DataView)
{
module = JsonConvert.DeserializeObject<DataViewDB>(json);
}
else if (model.ParseType == Core.Parser.ParseType.ViewModel)
{
module = JsonConvert.DeserializeObject<ViewModelDB>(json);
ViewModelDB.Current = module as ViewModelDB;
}
else if (model.ParseType == Core.Parser.ParseType.WorkFlow)
{
var program = JsonConvert.DeserializeObject<Program>(json);
module = new WorkflowDB();
((WorkflowDB)module).Program = program;
WorkflowDB.Current = module as WorkflowDB;
module.Name = System.IO.Path.GetFileNameWithoutExtension(model.File);
}
}
catch (Exception e)
{
this.AddError(new Core.Error.ParseErrorInfo()
{
FileId = model.FileId,
File = model.File,
ErrorType = Core.Error.ErrorType.Error,
Message = "模块解析错误: " + e.Message
});
}
if (module == null)
{
//this.IsWiseCompleted = true;
model.SetParsed(false);
OnRemoveModule(model.FileId);
return;
}
module.Initialize();
module.FileId = model.FileId;
model.SetParsed(true);
module.Errors.ForEach(x => { x.File = model.File; x.FileId = model.FileId; });
//OnUpdateModule(model.FileId, module);
this.waitingWiseModules.Add(module);
if (module.Errors != null)
{
module.Errors.ForEach(x => AddError(x));
}
}
catch (Exception e)
{
//.........这里部分代码省略.........
示例2: Parse
public void Parse(IModel model, InputCharInfo inputChar, System.Action callback)
{
var text = model.Content;
try
{
var parseInfo = new ParseInfo();
parseInfo.Content = text;
parseInfo.Index = 0;
parseInfo.Type = model.ParseType;
var parseInfo_json = Newtonsoft.Json.JsonConvert.SerializeObject(parseInfo);
string json = null;
if (!ConnectProxy.Instance().Send(parseInfo_json))
{
model.SetParsed(false);
return;
}
json = ConnectProxy.Instance().Read();
if (json == null)
{
model.SetParsed(false);
return;
}
IParseModule module = null;
try
{
if (model.ParseType == CodeHelper.Core.Parser.ParseType.XmlModel)
{
module = JsonConvert.DeserializeObject<XmModelDB>(json);
//XmModelDB.Current.InputChar = inputChar;
}
else if (model.ParseType == CodeHelper.Core.Parser.ParseType.DataModel)
{
module = JsonConvert.DeserializeObject<DmModelDB>(json);
//DmModelDB.Current.InputChar = inputChar;
}
else if (model.ParseType == Core.Parser.ParseType.DataView)
{
module = JsonConvert.DeserializeObject<DataViewDB>(json);
//DataViewDB.Current.InputChar = inputChar;
}
else if (model.ParseType == Core.Parser.ParseType.ViewModel)
{
module = JsonConvert.DeserializeObject<ViewModelDB>(json);
ViewModelDB.Current = module as ViewModelDB;
ViewModelDB.Current.InputChar = inputChar;
}
else if (model.ParseType == Core.Parser.ParseType.WorkFlow)
{
var program = JsonConvert.DeserializeObject<Program>(json);
module = new WorkflowDB();
((WorkflowDB)module).Program = program;
WorkflowDB.Current = module as WorkflowDB;
WorkflowDB.Current.InputChar = inputChar;
module.Name = System.IO.Path.GetFileNameWithoutExtension(model.File);
}
}
catch (Exception e)
{
this.Errors.Add(new Core.Error.ParseErrorInfo()
{
FileId = model.FileId,
File = model.File,
ErrorType = Core.Error.ErrorType.Error,
Message = "模块解析错误: " + e.Message
});
}
if (module == null)
{
model.SetParsed(false);
return;
}
module.File = model.File;
module.FileId = model.FileId;
module.Initialize();
module.Wise();
module.FileId = model.FileId;
model.SetParsed(true);
module.Errors.ForEach(x => { x.File = model.File; x.FileId = model.FileId; });
if (module.Errors != null)
{
module.Errors.ForEach(x => Errors.Add(x));
}
}
catch (Exception e)
{
this.Errors.Add(new Core.Error.ParseErrorInfo()
{
//.........这里部分代码省略.........