Exemplo n.º 1
0
        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");
            }
        }
        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;
        }
Exemplo n.º 4
0
        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;
            }
        }
Exemplo n.º 5
0
 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);
 }
Exemplo n.º 6
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);
        }
Exemplo n.º 7
0
        /// <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();
        }
Exemplo n.º 8
0
        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;
        }
Exemplo n.º 9
0
        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();
        }
Exemplo n.º 10
0
        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;
        }
Exemplo n.º 12
0
        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);
            }
        }
Exemplo n.º 13
0
        /// <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
        }
Exemplo n.º 14
0
        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);
            }
        }
Exemplo n.º 15
0
 public CodeStringBuilder(AppendMode mode)
 {
     _mode = mode;
 }
Exemplo n.º 16
0
        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");
            }
        }
Exemplo n.º 17
0
        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;
        }
Exemplo n.º 18
0
 /// <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);
 }
Exemplo n.º 19
0
        private void InsertObject(TKey key, TValue value, AppendMode appendMode)
        {
            TValue trash;

            InsertObject(key, value, appendMode, out trash);
        }
 public CodeStringBuilder(AppendMode mode)
 {
     _mode = mode;
 }