public static IScript GetScript(string scriptID, string scriptCollection) { IScript script = null; MongoCollection collection = MongoUtils.MongoData.GetCollection("Scripts", scriptCollection); BsonDocument doc = collection.FindOneAs <BsonDocument>(Query.EQ("_id", scriptID)); if (doc != null && doc["Bytes"].AsBsonBinaryData != null) { ScriptTypes scriptType = (ScriptTypes)Enum.Parse(typeof(ScriptTypes), doc["Type"].ToString()); switch (scriptType) { case ScriptTypes.Lua: script = new LuaScript((byte[])doc["Bytes"].AsBsonBinaryData); break; case ScriptTypes.Roslyn: script = new RoslynScript((byte[])doc["Bytes"].AsBsonBinaryData); break; default: break; } } return(script); }
public static IScript CreateScript(ScriptTypes type) { IScript newScript; switch (type) { case ScriptTypes.Roslyn: newScript = new RoslynScript(); break; case ScriptTypes.Lua: default: newScript = new LuaScript(); break; } return newScript; }
public static IScript GetScript(byte[] scriptBytes, ScriptTypes scriptType) { IScript script = null; if (scriptBytes != null) { switch (scriptType) { case ScriptTypes.Lua: script = new LuaScript(scriptBytes); break; case ScriptTypes.Roslyn: script = new RoslynScript(scriptBytes); break; default: break; } } return script; }
public static IScript GetScript(string scriptID, string scriptCollection) { IScript script = null; MongoCollection collection = MongoUtils.MongoData.GetCollection("Scripts", scriptCollection); BsonDocument doc = collection.FindOneAs<BsonDocument>(Query.EQ("_id", scriptID)); if (doc != null && doc["Bytes"].AsBsonBinaryData != null) { ScriptTypes scriptType = (ScriptTypes)Enum.Parse(typeof (ScriptTypes), doc["Type"].ToString()); switch (scriptType) { case ScriptTypes.Lua: script = new LuaScript((byte[])doc["Bytes"].AsBsonBinaryData); break; case ScriptTypes.Roslyn: script = new RoslynScript((byte[])doc["Bytes"].AsBsonBinaryData); break; default: break; } } return script; }