public static bool IsChanged(HaxxisPackage currentPackage, string fullPathToOriginal) { if (String.IsNullOrEmpty(fullPathToOriginal)) { if (currentPackage.Chain.RootGroup.Nodes.Count > 0) { return(true); } if (currentPackage.Choreography != null) { return(true); } return(false); } if (!File.Exists(fullPathToOriginal)) { return(true); } var originalPackageJsonString = File.ReadAllText(fullPathToOriginal); var currentPackageJsonString = ToJsonString(currentPackage); var hasChanged = !currentPackageJsonString.Equals(originalPackageJsonString); return(hasChanged); }
private void HandleGroupReplacementRequested(ChainGroup original, HaxxisPackage replacement) { AddGroup(replacement.Chain.RootGroup, isTransfer: false); var newGroupView = ChainView.Instance.GetGroupViewForGroup(replacement.Chain.RootGroup); newGroupView.ViewModel = replacement.ChainViewModel.RootGroupViewModel; RelinkRouters(original, replacement.Chain.RootGroup); original.DestroyNodes(); RemoveGroup(original); }
private static void LoadJsonJob(string filename) { //RealtimeLogger.Log( "Beginning LoadJson." ); //RealtimeLogger.Log( "Read Text." ); var serializer = JsonSerializer.Create(GetSerializationSettings()); serializer.Error += (sender, args) => { if (args.CurrentObject != args.ErrorContext.OriginalObject) { return; } ExceptionUtility.LogException("Serializer error callback hit. ", args.ErrorContext.Error); }; HaxxisPackage haxxisPackage; //RealtimeLogger.Log( "Starting Deserialize." ); using (Stream s = new FileStream(filename, FileMode.Open, FileAccess.Read)) using (StreamReader sr = new StreamReader(s)) using (JsonReader jsonReader = new JsonTextReader(sr)) { haxxisPackage = serializer.Deserialize <HaxxisPackage>(jsonReader); if (jsonReader.Read() && jsonReader.TokenType != JsonToken.Comment) { throw new JsonSerializationException("Additional text found in JSON string after finishing deserializing object."); } } //RealtimeLogger.Log( "Returning HaxxisPackage." ); JobLoadedPackage = haxxisPackage; }
public void RequestReplacement(HaxxisPackage replacement) { ReplacementRequested(this, replacement); }
private static string ToJsonString(HaxxisPackage package) { var indentSize = (Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl)) ? 1 : 0; return(JsonConvert.SerializeObject(package, Formatting.Indented, GetSerializationSettings(), ' ', indentSize)); // Use indentation to keep things on separate lines, but with zero indentation }
public static void SaveJson(HaxxisPackage package, string filename) { var contents = ToJsonString(package); File.WriteAllText(filename, contents); }