public static T Evaluate <T, U, S>(this ScratchObject obj, string objectName, bool general = false) where T : IValoration, new() where U : ISpriteValoration, new() where S : IGeneralValoration, new() { if (obj.RawScripts == null) { return((T)ValorationHelper .Get_DefaultSingle <T, U>(objectName)); } return(Get_singleValoration <T, U>(obj.Scripts, obj.Blocks, obj.ScriptsString, objectName, obj.DeadCodeCount, obj.NestedControl, obj.NestedOperator, general)); }
public static T GeneralEvaluation <T, U, S>( this ScratchObject obj, string objectName, List <U> previousValorations) where T : IValoration, new() where U : ISpriteValoration, new() where S : IGeneralValoration, new() { if (obj.Children == null) { return((T)ValorationHelper .Get_DefaultSingle <T, U>(objectName)); } var blocks = new List <string>(); var scripts = new List <List <object> >(); var scriptList = new List <string>(); var messagesRecieved = new List <string>(); var messagesSent = new List <string>(); var deadCodeSums = 0; if (obj.RawScripts != null) { blocks.AddRange(obj.Blocks); scripts.AddRange(obj.Scripts); scriptList.AddRange(obj.ScriptsString); messagesRecieved.AddRange(obj.MessagesRecieved); messagesSent.AddRange(obj.MessagesSent); } foreach (var child in obj.Children) { deadCodeSums += child.DeadCodeCount; if (child.Blocks != null) { blocks.AddRange(child.Blocks); } if (child.Scripts != null) { scripts.AddRange(child.Scripts); } if (child.ScriptsString != null) { scriptList.AddRange(child.ScriptsString); } if (child.MessagesRecieved != null) { messagesRecieved.AddRange(child.MessagesRecieved); } if (child.MessagesSent != null) { messagesSent.AddRange(child.MessagesSent); } } var vars = obj.Variables != null?obj.Variables.ToList() : new List <Variable>(); var lists = obj.Lists != null?obj.Lists.ToList() : new List <ScratchList>(); return(Get_generalValoration <T, U, S>(scripts, blocks, scriptList, objectName, previousValorations, vars, lists, deadCodeSums, previousValorations.Count, messagesRecieved, messagesSent, true)); }