private string Format(ControlObject controlObject) { string data = $"{(controlObject.IsStatic ? "static " : "")}" + $"{(controlObject.IsConst ? "const " : "")}" + $"{controlObject.Type} {controlObject.Name} <"; foreach (Annotation annotation in controlObject.ControlObjects) { data += Environment.NewLine + $"\t{annotation.Type} {annotation.Name} = {(annotation.Type == "string" ? $"\"{annotation.Value}\"" : annotation.Value)};"; } data += $"{Environment.NewLine}> = {controlObject.Value};"; return(data); }
public ObjectFX Import(string path) { if (!IsImportable(path)) { throw new Exception(Resources.Msg_FormatException); } UIObjectFX obj = new UIObjectFX("MMEffectUI") { OriginalText = File.ReadAllText(path, Encoding), }; obj.Data.Add("IMPORTPLUGIN", Name); obj.Data.Add("IMPORTPLUGIN_VERSION", Version); obj.Data.Add("IMPORTPLUGIN_GUID", Guid); foreach (Match match in regex.Matches(obj.OriginalText)) { ControlObject controlObject = new ControlObject() { Type = match.Groups["type"].Value, Name = match.Groups["name"].Value, Value = match.Groups["value"].Value }; for (int i = 0; i < match.Groups["a_type"].Captures.Count; i++) { ControlObject co = new ControlObject() { Type = match.Groups["a_type"].Captures[i].Value, Name = match.Groups["a_name"].Captures[i].Value, Value = match.Groups["a_value"].Captures[i].Value.Replace("\"", ""), }; controlObject.ControlObjects.Add(co); } controlObject.IsStatic = match.Groups["static"].Success; controlObject.IsConst = match.Groups["const"].Success; controlObject._Index = match.Index; controlObject._Length = match.Length; obj.ControlObjects.Add(controlObject); } return(obj); }