public static object create(string cls_name, Lexer yyl) { TCreator cr = (TCreator)yyl.tokens.types[cls_name]; // Console.WriteLine("TCreating {0} <{1}>",cls_name,yyl.yytext); if (cr == null) { yyl.tokens.erh.Error(new CSToolsException(6, yyl, cls_name, String.Format("no factory for {0}", cls_name))); } try { return(cr(yyl)); } catch (CSToolsException x) { yyl.tokens.erh.Error(x); } catch (Exception e) { yyl.tokens.erh.Error(new CSToolsException(7, yyl, cls_name, String.Format("Line {0}: Create of {1} failed ({2})", yyl.Saypos(yyl.m_pch), cls_name, e.Message))); } int j = cls_name.LastIndexOf('_'); if (j > 0) { cr = (TCreator)yyl.tokens.types[cls_name.Substring(0, j)]; if (cr != null) { return(cr(yyl)); } } return(null); }
public static object create(string cls_name, Lexer yyl) { TCreator type1 = (TCreator)yyl.tokens.types[(object)cls_name]; if (type1 == null) { yyl.tokens.erh.Error(new CSToolsException(6, yyl, cls_name, string.Format("no factory for {0}", (object)cls_name))); } try { return(type1(yyl)); } catch (CSToolsException ex) { yyl.tokens.erh.Error(ex); } catch (Exception ex) { yyl.tokens.erh.Error(new CSToolsException(7, yyl, cls_name, string.Format("Line {0}: Create of {1} failed ({2})", (object)yyl.Saypos(yyl.m_pch), (object)cls_name, (object)ex.Message))); } int length = cls_name.LastIndexOf('_'); if (length > 0) { TCreator type2 = (TCreator)yyl.tokens.types[(object)cls_name.Substring(0, length)]; if (type2 != null) { return(type2(yyl)); } } return((object)null); }
//Inicializar um ficheiro a partir de um ficheiro local public FileModel(string NewFilePath, string OldFilePath, string NewNetID, bool NewWillDownload = true) { FileVersion = 1; FileName = NewFilePath.Substring(NewFilePath.LastIndexOf('\\') + 1); String PathPastaMae = NewFilePath.Remove(NewFilePath.LastIndexOf('\\')); if (!MainProps.EvryFolder.Exists(Obj => Obj.RelativePath == PathPastaMae)) { PastaRoot = new FolderModel(PathPastaMae); } else { PastaRoot = MainProps.EvryFolder.Find(Obj => Obj.RelativePath == PathPastaMae); } if (File.Exists(OldFilePath)) { File.Move(OldFilePath, Environment.CurrentDirectory + NewFilePath); } FilePath = NewFilePath; byte[] bytes = TCreator.GetBytesFromFile(NewFilePath); Torrent torrent = TCreator.GetTorrentFromByte(bytes); if (TorrentClientAPI.fastResume.ContainsKey(torrent.InfoHash.ToHex())) { Tmanager.LoadFastResume(new FastResume((BEncodedDictionary)TorrentClientAPI.fastResume[torrent.InfoHash.ToHex()])); } else { Tmanager = new TorrentManager(torrent, Environment.CurrentDirectory); } NetID = NewNetID; WillDownload = NewWillDownload; FileID = FSDatabaseFunctions.AddFileGetFileID(FilePath, NetID, bytes); ToggleWillDownload(); DEP = new SqlDependency(new SqlCommand("Select * FROM Files WHERE FileID = " + FileID, ConnectionStuff.con)); DEP.OnChange += new OnChangeEventHandler(FileChangedRemotelyEH); PastaRoot.ChildFiles.Add(this); }
//Inicializar ficheiro a partir de um ficheiro na base de dados public FileModel(int NewFileID, int NewFileVersion, byte[] TorrentBytes, string NewFilePath, string NewNetID, bool NewWillDownload = false) { FileID = NewFileID; FileVersion = NewFileVersion; FileName = NewFilePath.Substring(NewFilePath.LastIndexOf('\\') + 1); String PathPastaMae = NewFilePath.Remove(NewFilePath.LastIndexOf('\\')); if (!MainProps.EvryFolder.Exists(Obj => Obj.RelativePath == PathPastaMae)) { PastaRoot = new FolderModel(PathPastaMae); } else { PastaRoot = MainProps.EvryFolder.Find(Obj => Obj.RelativePath == PathPastaMae); } Tmanager = new TorrentManager(TCreator.GetTorrentFromByte(TorrentBytes), Environment.CurrentDirectory + PathPastaMae + "\\");; FilePath = NewFilePath; NetID = NewNetID; WillDownload = NewWillDownload; ToggleWillDownload(); DEP = new SqlDependency(new SqlCommand("Select * FROM Files WHERE FileId = " + FileID, ConnectionStuff.con)); DEP.OnChange += new OnChangeEventHandler(FileChangedRemotelyEH); PastaRoot.ChildFiles.Add(this); }
/// <summary> /// 注册类型创建函数 /// </summary> /// <typeparam name="T">要创建的实例类型</typeparam> /// <param name="_type_id">要创建的实例类型所对应的编号</param> public void Register <T>(TKey _type_id) where T : class, TBaseClass, new() { m_dictCreatableType[_type_id] = new TCreator <T>(); }
/// <summary> /// 注册类型创建函数 /// </summary> /// <typeparam name="T">要创建的实例类型</typeparam> /// <param name="_type_id">要创建的实例类型所对应的编号</param> public void Register <T>(TKey _type_id) where T : MonoBehaviour, TBaseClass { m_dictCreatableType[_type_id] = new TCreator <T>(); }
public Tfactory(YyLexer tks, string cls_name, TCreator cr) { tks.types[cls_name] = cr; }
/// <exclude/> public Tfactory(YyLexer tks,string cls_name,TCreator cr) { tks.types[cls_name] = cr; }
public Tfactory(Tokens tks, string cls_name, TCreator cr) { tks.types[cls_name] = cr; }
public Tfactory(YyLexer tks, string cls_name, TCreator cr) { tks.types[(object)cls_name] = (object)cr; }
public Tfactory(Tokens tks,string cls_name,TCreator cr) { tks.types[cls_name] = cr; }