private async Task <Dictionary <string, object> > PopulateLogContextForError(HttpContext httpContext, MemoryStream responseBody) { var request = httpContext.Request; var props = new Props { [HEADERS] = request.Headers.Where(h => h.Key != AUTHORIZATION) .ToDictionary(h => h.Key, h => h.Value.ToString()) }; if (request.HasFormContentType) { props.Add(FORM, request.Form.ToDictionary(v => v.Key, v => v.Value.ToString())); } if (request.Body != null) { try { request.Body.Seek(0, SeekOrigin.Begin); using (var streamReader = new StreamReader(request.Body)) { var body = await streamReader.ReadToEndAsync(); props.Add(BODY, body); } } catch (Exception e) { _logger.Error(e, "Failed to read http stream body."); } } var responseProps = new Props(); try { // Note: This is not our stream, leave it open. using (var streamReader = new StreamReader(responseBody, Encoding.UTF8, true, 1024, true)) { responseBody.Seek(0, SeekOrigin.Begin); var body = await streamReader.ReadToEndAsync(); responseProps.Add(BODY, body); } } catch (Exception e) { _logger.Error(e, "Failed to read http stream body."); } props.Add(RESPONSE, responseProps); return(props); }
public TheCloset() : base("the Closet") { Instance = this; Props.Add(new Shelf(this)); Props.Add(new Toolbox(this)); Props.Add(new BlindFold(this)); Props.Add(new Rope(this)); Props.Add(new Box(this)); DoorToHallway = new Door(this, new Hallway(), "the door", 2, 3, lockMsg: "There is no handle. You could probably open it from the other side...") { Locked = true }; //DoorToHallway.DoorUsed += door => { if (!door.Locked) Player.Instance.ChangeLocation(Hallway.Instance); }; Props.Add(DoorToHallway); InternalVerbs.Add(new Verb("Look around", s => { var props = Props.Select(o => o.Name).ToArray(); if (props.Length > 0) { Game.Instace.OutputPane.Write("You are next to "); if (props.Length == 1) { Game.Instace.OutputPane.Write(props.First() + ". "); } else { Game.Instace.OutputPane.Write(FormattedString.Join(", ", props.WithoutLast())); Game.Instace.OutputPane.Write(new FormattedString(", and ") + props.Last() + ". "); } } })); }
public void AddProperty(BasePropertyChanger propertyChanger) { InitializePropertyVars(); RemoveExistingProperty(propertyChanger.FullPropertyPath); properties.Add(propertyChanger); Props.Add(propertyChanger.ToPropertyChangerDto()); }
public TheVents(TheCloset.OnTheBox closet) : base("the Vents") { Props.Add(new Vent(this, closet, "first vent", false, 3, 2, new FormattedString("You are in a ", "Utility Closet".Yellow(), "."))); Props.Add(new Vent(this, Hallway.Instance, "second vent", false, 3, 5, new FormattedString("You are in a ", "Hallway".Yellow(), "."))); }
public Office(string name, OfficeType type, bool top, int x, int y) : base(name) { Props.Add(new Desk(this, type, x - 1, top ? y - 3 : y + 3)); DoorToHallway = new Door(this, Hallway.Instance, "the door", x, y); //DoorToHallway.DoorUsed += door => Player.Instance.ChangeLocation(door.To); Props.Add(DoorToHallway); InternalVerbs.Add(new Verb("Look around", s => { var props = Props.Select(o => o.Name).ToArray(); if (props.Length <= 0) { return; } Game.Instace.OutputPane.Write("You are next to "); if (props.Length == 1) { Game.Instace.OutputPane.Write(props.First() + "."); } else { Game.Instace.OutputPane.Write(FormattedString.Join(", ", props.WithoutLast())); Game.Instace.OutputPane.Write(new FormattedString(", and ") + props.Last() + "."); } })); }
public Database() { Props.Add(new DbProp("COMPATIBILITY_LEVEL", "")); Props.Add(new DbProp("COLLATE", "")); Props.Add(new DbProp("AUTO_CLOSE", "")); Props.Add(new DbProp("AUTO_SHRINK", "")); Props.Add(new DbProp("ALLOW_SNAPSHOT_ISOLATION", "")); Props.Add(new DbProp("READ_COMMITTED_SNAPSHOT", "")); Props.Add(new DbProp("RECOVERY", "")); Props.Add(new DbProp("PAGE_VERIFY", "")); Props.Add(new DbProp("AUTO_CREATE_STATISTICS", "")); Props.Add(new DbProp("AUTO_UPDATE_STATISTICS", "")); Props.Add(new DbProp("AUTO_UPDATE_STATISTICS_ASYNC", "")); Props.Add(new DbProp("ANSI_NULL_DEFAULT", "")); Props.Add(new DbProp("ANSI_NULLS", "")); Props.Add(new DbProp("ANSI_PADDING", "")); Props.Add(new DbProp("ANSI_WARNINGS", "")); Props.Add(new DbProp("ARITHABORT", "")); Props.Add(new DbProp("CONCAT_NULL_YIELDS_NULL", "")); Props.Add(new DbProp("NUMERIC_ROUNDABORT", "")); Props.Add(new DbProp("QUOTED_IDENTIFIER", "")); Props.Add(new DbProp("RECURSIVE_TRIGGERS", "")); Props.Add(new DbProp("CURSOR_CLOSE_ON_COMMIT", "")); Props.Add(new DbProp("CURSOR_DEFAULT", "")); Props.Add(new DbProp("TRUSTWORTHY", "")); Props.Add(new DbProp("DB_CHAINING", "")); Props.Add(new DbProp("PARAMETERIZATION", "")); Props.Add(new DbProp("DATE_CORRELATION_OPTIMIZATION", "")); }
public HttpResponse(JProperty property, Action parent, int current, int children) : base(property, parent, current, children, "HttpAction") { Props.Add(XElement.Parse("<Row N='ActionName'> <Cell N='Value' V='" + PropertyName + "' U='STR'/></Row>")); Props.Add(XElement.Parse("<Row N='ActionType'> <Cell N='Value' V='HTTP Response' U='STR'/></Row>")); var sb = new StringBuilder("Status Code: "); sb.AppendLine((property.Value["inputs"] as JObject)["statusCode"].ToString()); // sb.AppendLine("URI: " + (property.Value["inputs"] as JObject)["uri"].ToString()); if (property.Value["inputs"]["headers"] != null) { sb.AppendLine("Headers:"); foreach (var header in property.Value["inputs"]["headers"] as JObject) { sb.AppendLine(header.Key + " : " + header.Value); } } if (property.Value["inputs"]["body"] != null) { sb.AppendLine("Body:"); foreach (var header in property.Value["inputs"]["body"] as JObject) { sb.AppendLine(header.Key + " : " + header.Value); } } AddText(sb); }
public Center(Vector3 p) { Point = p; Neighbours = new Dictionary <Vector3, Center>(new Vector3Comparer()); Borders = new Dictionary <Vector3, Edge>(new Vector3Comparer()); Corners = new Dictionary <Vector3, Corner>(new Vector3Comparer()); Props.Add(ObjectProp.Water); }
public Corner(Vector3 p) { Point = p; Touches = new Dictionary <Vector3, Center>(new Vector3Comparer()); Protrudes = new Dictionary <Vector3, Edge>(new Vector3Comparer()); Adjacents = new Dictionary <Vector3, Corner>(new Vector3Comparer()); Props.Add(ObjectProp.Water); }
/// <summary> /// Load existing nflavor props /// </summary> /// <param name="buffer"></param> public void Load(byte[] buffer) { try { using (MemoryReader mem = new MemoryReader(buffer)) { /* Sign = Encoding.Default.GetString()*/ mem.ReadBytes(18); Version = mem.ReadUInt32(); #if DEBUG == false if (!SupportedVersion.Contains(Version)) { Parent.Log(Levels.Error, "Failed\n"); Parent.Log(Levels.Fatal, $"Incompatible version {Version} is not supported or not implemented.\n"); return; } #endif var PropCount = mem.ReadInt32(); for (int i = 0; i < PropCount; i++) { var prop = new QuestProp(); prop.QuestPropID = mem.ReadInt32(); var vector = new Vector { X = mem.ReadSingle() / 7.875f, Y = mem.ReadSingle() / 7.875f }; prop.Position = vector.Rotate180FlipY(); prop.OffSet = mem.ReadSingle(); prop.RotateX = mem.ReadSingle(); prop.RotateY = mem.ReadSingle(); prop.RotateZ = mem.ReadSingle(); prop.ScaleX = mem.ReadSingle(); prop.ScaleY = (Version >= 3) ? mem.ReadSingle() : prop.ScaleX; prop.ScaleZ = (Version >= 3) ? mem.ReadSingle() : prop.ScaleX; prop.PropNum = mem.ReadUInt16(); prop.LockedHeight = (Version >= 3) ? mem.ReadBoolean() : false; prop.LockHeight = (Version >= 3) ? mem.ReadSingle() : 0f; prop.TextureGroupIndex = (Version >= 3) ? mem.ReadInt16() : (short)-1; Props.Add(prop); } } Render(); Parent.Log(Levels.Success, "Ok\n"); } catch (Exception exception) { Dispose(); Parent.Log(Levels.Error, "Failed\n"); Parent.Log(Levels.Fatal, $"Qpf::Load<Exception> -> {exception}\n"); } }
public Edge(Corner begin, Corner end, Center left, Center right) { VoronoiStart = begin; VoronoiEnd = end; DelaunayStart = left; DelaunayEnd = right; Midpoint = (begin.Point + end.Point) / 2f; Props.Add(ObjectProp.Water); }
/// <summary> /// Add prop script /// </summary> /// <param name="propScript"></param> public void Add(PointF point) { var propScript = new PropScriptInfo(); propScript.X = point.X; propScript.Y = point.Y; Props.Add(propScript); AddedPropScript?.Invoke(this, propScript); }
public SetVariable(JProperty property, Action parent, int current, int children) : base(property, parent, current, children, "VariableAction") { Props.Add(XElement.Parse("<Row N='ActionName'> <Cell N='Value' V='" + PropertyName + "' U='STR'/></Row>")); Props.Add(XElement.Parse("<Row N='ActionType'> <Cell N='Value' V='Set Variable' U='STR'/></Row>")); var sb = new StringBuilder("Variable Name: "); sb.AppendLine(property.Value["inputs"]["name"].ToString()); sb.AppendLine("Value: " + property.Value["inputs"]["value"]); AddText(sb); }
/// <summary> /// Add new prop /// </summary> /// <param name="location"></param> public void Add(PointF point) { var prop = new Prop(); prop.X = point.X; prop.Y = point.Y; Props.Add(prop); Added?.Invoke(this, prop); }
public IfAction(JProperty property, Action parent, int current, int children) : base(property, parent, current, children, "condition") { Props.Add(XElement.Parse("<Row N='ActionName'> <Cell N='Value' V='" + PropertyName + "' U='STR'/></Row>")); Props.Add(XElement.Parse("<Row N='ActionType'> <Cell N='Value' V='If' U='STR'/></Row>")); var sb = new StringBuilder("Expression: "); var condition = ((JObject)property.Value["expression"]).Children <JProperty>().First(); sb.Append(condition.Value.First() + " " + condition.Name + " " + condition.Value.Last()); AddText(sb); CreateYesNo(); }
/// <summary> /// Add prop script /// </summary> /// <param name="vector"></param> public void AddNpc(Vector vector) { var propScript = new NpcProp { Position = vector }; Props.Add(propScript); Added?.Invoke(this, new AddedArgs(propScript, typeof(NpcProp))); }
/// <summary> /// Add new prop /// </summary> /// <param name="vector"></param> public void Add(Vector vector) { var prop = new QuestProp { Position = vector }; Props.Add(prop); Added?.Invoke(this, new AddedArgs(prop, typeof(QuestProp))); }
public static void C_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (e.AddedItems.Count == 0) { return; } ; var q = e.AddedItems[0]; if (q is Team) { Props.Clear(); var tt = (Team)q; var ttt = tt.Table.GetType(); PropertyInfo[] properties = ttt.GetProperties(); foreach (PropertyInfo property in properties) { string displayName = property.Name; try { var attribute = property.GetCustomAttributes(typeof(DisplayNameAttribute), true) .Cast <DisplayNameAttribute>().Single(); displayName = attribute.DisplayName; } catch (Exception exception) { } try { var attribute = property.GetCustomAttributes(typeof(BrowsableAttribute), true) .Cast <BrowsableAttribute>().Single(); if (!attribute.Browsable) { continue; } } catch (Exception exception) { } string value = property.GetValue(tt.Table).ToString(); var z = new Prop() { Property = displayName, Value = value }; Props.Add(z); } Dg.Items = null; Dg.Items = Props; } }
private void UnscrewVerb(string s) { if (Player.Instance.Items.All(o => o.Name.ToString() != "Screwdriver")) { Game.Instace.OutputPane.Write(new FormattedString("You do not have a ", "Screwdriver".Cyan(), ".")); return; } Game.Instace.OutputPane.Write(new FormattedString("You use the ", "Screwdriver".Cyan(), " to open the ", "vent".Magenta(), ".")); InternalVerbs.Remove(_unscrewVerb); Props.Add(new TheVents.Vent(this, new TheVents(this), "vent", true, 3, 2)); }
public PlanetModel() { Props.Add(R.Altitude, new PlanetProperty(0.5f, 1)); Props.Add(R.Temperature, new PlanetProperty(0, 0)); Props.Add(R.Pressure, new PlanetProperty(0, 0)); Props.Add(R.Humidity, new PlanetProperty(0, 0)); Props.Add(R.Radiation, new PlanetProperty(0, 0)); Impact.Add(R.Temperature, new IntReactiveProperty(0)); Impact.Add(R.Pressure, new IntReactiveProperty(0)); Impact.Add(R.Humidity, new IntReactiveProperty(0)); Impact.Add(R.Radiation, new IntReactiveProperty(0)); }
public InitVariable(JProperty property, Action parent, int current, int children) : base(property, parent, current, children, "VariableAction") { Props.Add(XElement.Parse("<Row N='ActionName'> <Cell N='Value' V='" + PropertyName + "' U='STR'/></Row>")); Props.Add(XElement.Parse("<Row N='ActionType'> <Cell N='Value' V='Initialize Variable' U='STR'/></Row>")); // var textElement = Shape.Descendants().Where(el => el.Name.LocalName == "Text").First(); var sb = new StringBuilder("Variable Name: "); sb.AppendLine((property.Value["inputs"] as JObject)["variables"][0]["name"].ToString()); sb.AppendLine("Type: " + (property.Value["inputs"] as JObject)["variables"][0]["type"]); AddText(sb); }
public SwitchAction(JProperty property, Action parent, int current, int children) : base(property, parent, current, children, "condition") { AddFillColour("234,237,239"); Props.Add(XElement.Parse("<Row N='ActionName'> <Cell N='Value' V='" + PropertyName + "' U='STR'/></Row>")); Props.Add(XElement.Parse("<Row N='ActionType'> <Cell N='Value' V='Switch' U='STR'/></Row>")); var sb = new StringBuilder("Expression: "); // var condition = ((JObject)property.Value["expression"]).Children<JProperty>().First(); sb.Append(property.Value["expression"]); AddText(sb); CreateCases(); }
/// <summary> /// Load existing nflavor props /// </summary> /// <param name="buffer"></param> public void Load(byte[] buffer) { try { using (BinaryReader b = new BinaryReader(new MemoryStream(buffer))) { Sign = Encoding.Default.GetString(b.ReadBytes(18)); Version = b.ReadUInt32(); #if DEBUG == false if (!SupportedVersion.Contains(Version)) { XLog.WriteLine(Levels.Error, $"Failed"); XLog.WriteLine(Levels.Fatal, "QpfManager::Load<Version> -> Incompatible version {0} is not supported", Version); return; } #endif var PropCount = b.ReadInt32(); for (int i = 0; i < PropCount; i++) { var prop = new Prop(); prop.QuestPropID = b.ReadInt32(); prop.X = b.ReadSingle(); prop.Y = b.ReadSingle(); prop.OffSet = b.ReadSingle(); prop.RotateX = b.ReadSingle(); prop.RotateY = b.ReadSingle(); prop.RotateZ = b.ReadSingle(); prop.ScaleX = b.ReadSingle(); prop.ScaleY = (Version >= 3) ? b.ReadSingle() : prop.ScaleX; prop.ScaleZ = (Version >= 3) ? b.ReadSingle() : prop.ScaleX; prop.PropNum = b.ReadUInt16(); prop.LockedHeight = (Version >= 3) ? b.ReadBoolean() : false; prop.LockHeight = (Version >= 3) ? b.ReadSingle() : 0f; prop.TextureGroupIndex = (Version >= 3) ? b.ReadInt16() : (short)-1; Props.Add(prop); } } XLog.WriteLine(Levels.Good, "Ok"); } catch (Exception exception) { Blank(); XLog.WriteLine(Levels.Error, "Failed"); XLog.WriteLine(Levels.Fatal, "QpfManager::Load<Exception> -> {0}", exception); } }
void LoadVals() { Props.Add(PropMethods.GetHostName()); Props.Add(PropMethods.GetName()); Props.Add(PropMethods.GetModel()); Props.Add(PropMethods.GetDeviceType()); Props.Add(PropMethods.GetIdiom()); Props.Add(PropMethods.GetManufacturer()); Props.Add(PropMethods.GetPlatform()); Props.Add(PropMethods.GetVersion()); Props.Add(PropMethods.GetSerialNumber()); Props.Add(PropMethods.GetBuildVersion()); WiFi.Add(PropMethods.GetIpAddress()); }
public ForEachAction(JProperty property, Action parent, int current, int children) : base(property, parent, current, children, "condition") { Props.Add(XElement.Parse("<Row N='ActionName'> <Cell N='Value' V='" + PropertyName + "' U='STR'/></Row>")); Props.Add(XElement.Parse("<Row N='ActionType'> <Cell N='Value' V='For Each' U='STR'/></Row>")); var sb = new StringBuilder("On: "); // var condition = ((JObject)property.Value["expression"]).Children<JProperty>().First(); sb.Append(property.Value["foreach"]); AddText(sb); FinalActions.Add(this); AddChildActions(((JObject)Property.Value["actions"]).Children <JProperty>().Where(el => !el.Value["runAfter"].HasValues), this, 0); EndAction = new CaseAction(this, "For Each"); EndAction.AddFillColour("234,237,239"); }
/// <summary> /// Set/Override value for property /// </summary> /// <param name="PropertyName"></param> /// <param name="PropertyValue"></param> public void SetProperty(string PropertyName, object PropertyValue) { if (Props == null) { return; } if (Props.ContainsKey(PropertyName)) { Props[PropertyName] = PropertyValue; } else { Props.Add(PropertyName, PropertyValue); } }
public CaseAction(ConditionAction conditionAction, string type) : base() { Shape = new XElement(GetTemplateShape("case")); current = 1; children = 1; Shape.SetAttributeValue("NameU", conditionAction.PropertyName + ".End"); Props.Add(XElement.Parse("<Row N='ActionCase'> <Cell N='Value' V='End " + type + " : " + conditionAction.PropertyName + "' U='STR'/></Row>")); PinY = conditionAction.FinalActions.Min(el => el.PinY) - offsetY; //Double.Parse(Parent.Shape.Elements().Where(el => el.Attribute("N").Value == "PinY").First().Attribute("V").Value) - offsetY); PinX = conditionAction.PinX; // Double.Parse(Parent.Shape.Elements().Where(el => el.Attribute("N").Value == "PinX").First().Attribute("V").Value) - CalcX; SetPosition(); foreach (var parentAction in conditionAction.FinalActions) { Line line = new Line(); line.Connect(parentAction, this, current, children); } }
/// <summary> /// Finds the prop of the given name and will spawn it. /// </summary> /// <param name="name"></param> protected void SpawnProp(string name) { PropDefinition pDef = PropManifest.GetPropDefinition(name); if (pDef == null) { return; // If the propDefintion is null, we just return here. We will have already logged an error in PropManifest's function which will have our stack trace. } Prop p = Instantiate(pDef.Actor, inputPosition, Quaternion.identity, transform); Props.Add(p); p.Definition = pDef; pickedActor = p; pickedActor.transform.position = inputPosition; }
private void CreateProp(MapObject mapObject, Model model) { var prop = new Prop(Function.Call <int>(Hash.CREATE_OBJECT_NO_OFFSET, model.Hash, mapObject.Position.X, mapObject.Position.Y, mapObject.Position.Z, true, true, mapObject.Dynamic)); if (!Entity.Exists(prop)) { return; } prop.Rotation = mapObject.Rotation; if (!mapObject.Dynamic && !mapObject.Door) { prop.FreezePosition = true; } prop.Quaternion = mapObject.Quaternion; prop.Position = mapObject.Position; model.MarkAsNoLongerNeeded(); Props.Add(prop); }
private void PropiedadesIni() { Props.Add("msj", messageFormatted()); Props.Add("dato", e.Data); Props.Add("hResult", e.HResult); Props.Add("source", e.Source); //Props.Add("stackTrace", e.StackTrace); //Props.Add("targetSite", e.Target); if (e.InnerException != null) { Props.Add("innerException_tipo", e.InnerException.GetType().Name); Props.Add("innerException_msj", innerMessageFormatted()); Props.Add("innerException_dato", e.InnerException.Data); Props.Add("innerException_hResult", e.InnerException.HResult); Props.Add("innerException_source", e.InnerException.Source); Props.Add("innerException_stackTrace", e.InnerException.StackTrace); //Props.Add("innerException_targetSite", e.InnerException.TargetSite); } }