public bool SaveContext() { ErrorCodes.XMLParserError verifyResult = mContext.VarifyConsistencyOK(); if (verifyResult != ErrorCodes.XMLParserError.NoError) { mErrorCallback(verifyResult, ""); } ErrorCodes.XMLParserError writeResult = mWriter.WriteContext(mContext); if (writeResult != ErrorCodes.XMLParserError.NoError) { mErrorCallback(writeResult, mWriter.GetLastError()); } return(writeResult == ErrorCodes.XMLParserError.NoError); }
public ErrorCodes.XMLParserError ParseFile(ExcludeContext context) { if (File.Exists(mFileName)) { StreamReader file = null; try { file = new StreamReader(mFileName); bool excludeOpened = false; bool excludeClosed = false; bool includeOpened = false; bool includeClosed = false; List <string> excludeAssets = context.ExcludeClasses; List <string> includeAssets = context.IncludeClasses; while (file.Peek() != -1) { string line = file.ReadLine(); if (line == "<excludeAssets>") { excludeOpened = true; } else if (line == "</excludeAssets>") { excludeClosed = true; } else if (line == "<includeAssets>") { includeOpened = true; } else if (line == "</includeAssets>") { includeClosed = true; excludeAssets.Sort(); includeAssets.Sort(); // Export a sorted list, for flavour sake } else if (line.Contains(kAssetTag)) { int firstQuote = line.IndexOf('\"'); int lastQuote = line.LastIndexOf('\"'); int classNameLength = lastQuote - firstQuote; string className = line.Substring(firstQuote + 1, classNameLength - 1); if (excludeOpened && !excludeClosed && false == excludeAssets.Contains(className)) { excludeAssets.Add(className); } else if (includeOpened && !includeClosed && false == includeAssets.Contains(className)) { excludeAssets.Remove(className); // Dumbly call remove on this entry, just // in case it is on the exclude list too // Adds compelxity, but this will vanish // during the planned tree refactor... includeAssets.Add(className); } } } } catch (System.Exception ex) // Since this is not a proper XML file we can be pretty loose on error // handling, if there is any error, we'll just spit out this generic error message { // Close reader file.Close(); return(ErrorCodes.XMLParserError.TagReadError); } file.Close(); context.VarifyConsistencyOK(); } else { return(ErrorCodes.XMLParserError.InputFileDoesNotExist); } return(ErrorCodes.XMLParserError.NoError); }