public void AppendBaseClasses(Type type) { if (((type.BaseType == null) || (type.BaseType == typeof(object))) && (type.GetInterfaces().Length == 0)) { return; } // Dont use base types in comparing declarations.. someday, would be good to do a more intelligent compare (implemented interfaces removed is possibly a breaking change?) AppendMode restore = _mode; _mode &= ~AppendMode.Text; AppendText(" : "); if ((type.BaseType != null) && (type.BaseType != typeof(object))) { AppendType(type.BaseType); AppendText(", "); } foreach (Type intf in type.GetInterfaces()) { AppendType(intf); AppendText(", "); } RemoveCharsFromEnd(2); _mode = restore; }
public void AppendType(Type type, bool includeNamespace) { string typeAsKeyword = GetTypeNameAsKeyword(type); if (typeAsKeyword != null) { AppendKeyword(typeAsKeyword); return; } if (type.IsGenericParameter && !type.IsGenericType) { AppendText(type.Name); return; } // Dont show the namespaces on user types in the UI - but keep them in text, for comparison and reports if (includeNamespace) { AppendMode restore = _mode; _mode &= ~AppendMode.Html; AppendText(type.Namespace); AppendText("."); _mode = restore; } if (type.IsGenericType) { AppendGeneric(type.Name, type.GetGenericArguments(), "usertype"); } else { AppendText(type.Name, "usertype"); } }
private void InsertObject(TKey key, TValue value, AppendMode appendMode, out TValue oldValue) { oldValue = default(TValue); if (key == null) { throw new ArgumentNullException(nameof(key)); } TValue item; if (Dictionary.TryGetValue(key, out item)) { if (appendMode == AppendMode.Add) { throw new ArgumentException("Item with the same key has already been added"); } if (Equals(item, value)) { return; } Dictionary[key] = value; oldValue = item; } else { Dictionary[key] = value; } }
public override void LoadState() { base.LoadState(); normalMode = (NormalMode)LoadInt("normalMode"); placementMode = (PlacementMode)LoadInt("placementMode"); appendMode = (AppendMode)LoadInt("appendMode"); offset = LoadFloat("offset"); surfaceLayerMask = LoadInt("surfaceLayerMask", ~0); }
public BigIntMatrix Append(BigIntMatrix c2, AppendMode appendMode) { BigIntMatrix result; if (appendMode == AppendMode.Beside) { result = new BigIntMatrix(this.rowsCount, this.colsCount + c2.colsCount); if (this.rowsCount == c2.rowsCount) { for (int i = 0; i < this.rowsCount; i++) { for (int j = 0; j < this.colsCount; j++) { result.Mat[i, j] = this.Mat[i, j]; } for (int j = 0; j < c2.colsCount; j++) { result.Mat[i, j + c2.colsCount] = c2.Mat[i, j]; } } } else { throw new System.ArgumentException("Matrices have no equal rows", "original"); } } else { result = new BigIntMatrix(this.rowsCount + c2.rowsCount, this.colsCount); if (this.colsCount == c2.colsCount) { for (int j = 0; j < this.colsCount; j++) { for (int i = 0; i < this.rowsCount; i++) { result.Mat[i, j] = this.Mat[i, j]; } for (int i = 0; i < c2.rowsCount; i++) { result.Mat[i + this.rowsCount, j] = c2.Mat[i, j]; } } } else { throw new System.ArgumentException("Matrices have no equal columns", "original"); } } return(result); }
/// <summary> /// Inspector/Constructor - Appends a set of arcs to a current shape. /// </summary> /// <param name="arcs">The set of arcs you are appending to the end of the shape.</param> /// <param name="permanence">Are the changes permanent?</param> /// <returns>A shape with a new set of arcs appended.</returns> public void append(List <SerializedArc> arcs, AppendMode permanence = AppendMode.OverwriteWithPermanent) { // "arcs" can contain ephemeral or permanent edges if (permanence == AppendMode.OverwriteWithEphemeral || permanence == AppendMode.OverwriteWithPermanent) { serialized_arc_list.RemoveRange(serialized_arc_list.Count - ephemeral_arcs, ephemeral_arcs); ephemeral_arcs = 0; } serialized_arc_list.AddRange(arcs); int ephemeral_arcs_added = (permanence == AppendMode.OverwriteWithPermanent ? 0 : arcs.Count); ephemeral_arcs += ephemeral_arcs_added; initialize(); }
protected virtual void AppendAttributesDeclaration(CodeStringBuilder csb) { AppendMode oldMode = csb.Mode; csb.Mode = AppendMode.Html; foreach (AttributeDetail ad in FilterChildren <AttributeDetail>()) { csb.AppendText("["); csb.AppendRawHtml(ad.GetHtmlDeclaration()); csb.AppendText("]"); csb.AppendNewline(); } csb.Mode = oldMode; }
public MergeInfo(TextReader content, String file = null) { this.File = file; AppendMode appendMode = AppendMode.All; String line; StringBuilder merged = new StringBuilder(); StringBuilder theirs = new StringBuilder(); StringBuilder mine = new StringBuilder(); while ((line = content.ReadLine()) != null) { if (line.StartsWith("<<<<<<<")) { appendMode = topHalfMode; } else if (line.StartsWith("=======")) { appendMode = bottomHalfMode; } else if (line.StartsWith(">>>>>>>")) { appendMode = AppendMode.All; } else //This skips the control lines from the file. { if ((appendMode & AppendMode.Merged) != AppendMode.None) { merged.AppendLine(line); } if ((appendMode & AppendMode.Theirs) != AppendMode.None) { theirs.AppendLine(line); } if ((appendMode & AppendMode.Mine) != AppendMode.None) { mine.AppendLine(line); } } } Merged = merged.ToString(); Theirs = theirs.ToString(); Mine = mine.ToString(); }
protected virtual void AppendAttributesDeclaration(CodeStringBuilder csb) { AppendMode oldMode = csb.Mode; csb.Mode = AppendMode.NonText; foreach (AttributeDetail ad in FilterChildren <AttributeDetail>()) { if (ad.AppendInCode) { csb.AppendText("["); csb.AppendRaw(html: ad.GetHtmlDeclaration(), markdown: ad.GetMarkdownDeclaration()); csb.AppendText("]"); csb.AppendNewline(); } } csb.Mode = oldMode; }
public void AppendParameter(ParameterInfo pi) { AppendParameterType(pi); // Dont use parameter names in comparing declarations AppendMode restore = _mode; _mode &= ~AppendMode.Text; if (pi.Name != null) { AppendText(" "); AppendText(pi.Name); } AppendParameterValue(pi.RawDefaultValue); _mode = restore; }
public override void DrawInspector() { placementMode = (PlacementMode)EditorGUILayout.EnumPopup("Placement Mode", placementMode); if (placementMode != PlacementMode.Insert) { normalMode = (NormalMode)EditorGUILayout.EnumPopup("Normal Mode", normalMode); appendMode = (AppendMode)EditorGUILayout.EnumPopup("Append To", appendMode); } string offsetLabel = "Grid Offset"; if (placementMode == PlacementMode.CameraPlane) { offsetLabel = "Far Plane"; } if (placementMode == PlacementMode.Surface) { offsetLabel = "Surface Offset"; } offset = EditorGUILayout.FloatField(offsetLabel, offset); if (placementMode == PlacementMode.Surface) { surfaceLayerMask = DreamteckEditorGUI.LayermaskField("Surface Mask", surfaceLayerMask); } }
/// <summary> /// Inspector/Constructor - Creates a copy of the shape then sets closed=true /// </summary> /// <returns>A closed shape mirroring all properties of original but with closed=true.</returns> public void close(optional <Vector3> slope = new optional <Vector3>(), AppendMode permanence = AppendMode.OverwriteWithPermanent) { if (permanence == AppendMode.OverwriteWithEphemeral || permanence == AppendMode.OverwriteWithPermanent) { serialized_arc_list.RemoveRange(serialized_arc_list.Count - ephemeral_arcs, ephemeral_arcs); ephemeral_arcs = 0; } // Add last edge! (if not already closed and Dot of last/first point is != 1) if (!closed()) { Arc first_arc = serialized_arc_list[0]; Arc last_arc = serialized_arc_list[serialized_arc_list.Count - 1]; if (!slope.exists) { slope = first_arc.begin(); } append(ArcFactory.curve(last_arc.end(), slope.data, first_arc.begin()), permanence); } initialize(); // TODO: if field, make this a convex_hull() // TODO: add convex property }
public void AppendType(Type type, bool includeNamespace) { if (type.IsArray) { // simplify arrays Type elementType = type.GetElementType(); if (elementType != null) { OpenText("usertype"); AppendType(elementType, includeNamespace); AppendText("[]"); CloseText("usertype"); return; } } if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable <>)) { OpenText("usertype"); AppendType(Nullable.GetUnderlyingType(type), includeNamespace); AppendText("?"); CloseText("usertype"); return; } string typeAsKeyword = GetTypeNameAsKeyword(type); if (typeAsKeyword != null) { AppendKeyword(typeAsKeyword); return; } if (type.IsGenericParameter && !type.IsGenericType) { AppendText(type.Name); return; } string typeName = type.Name; // UI only: cut out "Attribute" part if (typeof(Attribute).IsAssignableFrom(type)) { typeName = typeName.Substring(0, typeName.Length - 9); // 9 == length of "Attribute" } // Dont show the namespaces on user types in the UI - but keep them in text, for comparison and reports if (includeNamespace) { AppendMode restore = _mode; _mode &= ~AppendMode.NonText; AppendText(type.Namespace); AppendText("."); AppendTypeName(type, type.Name); // Now non-text _mode |= AppendMode.NonText; _mode &= ~AppendMode.Text; AppendTypeName(type, typeName); _mode = restore; } else { AppendTypeName(type, typeName); } }
public CodeStringBuilder(AppendMode mode) { _mode = mode; }
/// <summary> /// Inspector/Constructor - Appends a new arc to a current shape. /// </summary> /// <param name="arc">The arc you are appending to the end of the shape.</param> /// <param name="permanence">Are the changes permanent?</param> /// <returns>A shape with a new arc appended.</returns> public void append(SerializedArc arc, AppendMode permanence = AppendMode.OverwriteWithPermanent) { append(new List <SerializedArc> { arc }, permanence); }
private void InsertObject(TKey key, TValue value, AppendMode appendMode) { TValue trash; InsertObject(key, value, appendMode, out trash); }