Пример #1
0
            /// <summary>
            /// 字符串
            /// </summary>
            /// <returns>字符串</returns>
            public override string ToString()
            {
                if (toString == null)
                {
                    list <string> .unsafer errorString = new list <string>(2).Unsafer;
                    if (Message != null)
                    {
                        errorString.Add("附加信息 : " + Message);
                    }
                    if (StackFrame != null)
                    {
                        errorString.Add("堆栈帧信息 : " + StackFrame.toString());
                    }
                    if (StackTrace != null)
                    {
                        errorString.Add("堆栈信息 : " + StackTrace.ToString());
                    }
                    if (Exception != null)
                    {
                        errorString.Add("异常信息 : " + Exception.ToString());
                    }
                    if (Type != exceptionType.None)
                    {
                        errorString.Add("异常类型 : " + Type.ToString());
                    }
                    toString = errorString[0] + @"
" + errorString[1];
                }
                return(toString);
            }
Пример #2
0
 public void Add(FieldInfo field)
 {
     if (Fields == null)
     {
         Fields = new list <FieldInfo>();
     }
     Fields.Add(field);
 }
Пример #3
0
        /// <summary>
        /// 获取枚举数组
        /// </summary>
        /// <typeparam name="enumType">枚举类型</typeparam>
        /// <returns>枚举数组</returns>
        public static enumType[] Array <enumType>()
        {
            Array array = System.Enum.GetValues(typeof(enumType));

            list <enumType> .unsafer values = new list <enumType>(array.Length).Unsafer;
            foreach (enumType value in array)
            {
                values.Add(value);
            }
            return(values.Array);
        }
Пример #4
0
 /// <summary>
 /// 创建静态类型信息
 /// </summary>
 private void buildStatic()
 {
     foreach (FieldInfo field in currentType.GetFields(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.DeclaredOnly))
     {
         if (!(fieldType = field.FieldType).IsPrimitive && !fieldType.IsPointer && !fieldType.IsEnum &&
             (currentValue = field.GetValue(null)) != null)
         {
             currentType = currentValue.GetType();
             if (currentType.IsClass || currentType.IsInterface)
             {
                 value = null;
                 if (values.TryGetValue(new objectReference {
                     Value = currentValue
                 }, out value))
                 {
                     staticValues.Add(new staticValue {
                         Name = field.Name, Value = value
                     });
                 }
                 else
                 {
                     values.Add(new objectReference {
                         Value = currentValue
                     }, value = new value());
                     staticValues.Add(new staticValue {
                         Name = field.Name, Value = value
                     });
                     buildValue();
                 }
             }
             else
             {
                 staticValues.Add(new staticValue {
                     Name = field.Name, Value = new value()
                 });
                 buildValue();
             }
         }
     }
 }
Пример #5
0
 /// <summary>
 /// 建图
 /// </summary>
 public unsafe void Build()
 {
     Writer.Empty();
     fixed(int *readerFixed = reader)
     {
         while (startIndex != endIndex)
         {
             node fatherNode = pool[readerFixed[startIndex++]];
             if (fatherNode.Link == 0)
             {
                 foreach (KeyValuePair <keyType, int> nextNode in fatherNode.Nodes)
                 {
                     if (pool[nextNode.Value].GetNodeCount(Boot, nextNode.Key) != 0)
                     {
                         Writer.Add(nextNode.Value);
                     }
                 }
             }
             else
             {
                 foreach (KeyValuePair <keyType, int> nextNode in fatherNode.Nodes)
                 {
                     int link = fatherNode.Link, linkNode = 0;
                     while (pool[link].GetLinkWhereNull(nextNode.Key, ref linkNode, ref link) != 0)
                     {
                         ;
                     }
                     if (linkNode == 0)
                     {
                         Boot.TryGetValue(nextNode.Key, out linkNode);
                     }
                     if (pool[nextNode.Value].GetNodeCount(linkNode) != 0)
                     {
                         Writer.Add(nextNode.Value);
                     }
                 }
             }
         }
     }
 }
Пример #6
0
 /// <summary>
 /// 连接字符串
 /// </summary>
 /// <param name="values">数据集合</param>
 /// <returns>字符串</returns>
 public static list <string> getString(this System.Collections.Generic.IEnumerable </*Type[0]*/ ulong /*Type[0]*/> values)
 {
     if (values != null)
     {
         list <string> newValues = new list <string>();
         foreach (/*Type[0]*/ ulong /*Type[0]*/ nextValue in values)
         {
             newValues.Add(number.toString(nextValue));
         }
         return(newValues);
     }
     return(null);
 }
Пример #7
0
 /// <summary>
 /// 添加新的日志
 /// </summary>
 /// <param name="value">日志信息</param>
 private void add(debug value)
 {
     if (!isStop)
     {
         Monitor.Enter(logLock);
         try
         {
             newDebugs.Add(value);
             Monitor.Pulse(logLock);
         }
         finally { Monitor.Exit(logLock); }
     }
 }
Пример #8
0
        /// <summary>
        /// 获取匹配的数据集合
        /// </summary>
        /// <typeparam name="listType">目标数据类型</typeparam>
        /// <param name="getValue">数据转换器</param>
        /// <returns>匹配的数据集合</returns>
        protected unsafe list <listType> getList <listType>(func <valueType, listType> getValue)
        {
            list <listType> .unsafer values = new list <listType>(array.Length).Unsafer;
            fixed(range *indexFixed = indexs)
            {
                for (range *index = indexFixed + indexs.Length; index != indexFixed;)
                {
                    for (range range = *--index; range.StartIndex != range.EndIndex; ++range.StartIndex)
                    {
                        values.Add(getValue(array[range.StartIndex]));
                    }
                }
            }

            return(values.List);
        }
Пример #9
0
        /// <summary>
        /// 数据转换成单向动态数组
        /// </summary>
        /// <returns>单向动态数组</returns>
        public unsafe list <valueType> GetList()
        {
            list <valueType> .unsafer values = new list <valueType>(array.Length).Unsafer;
            fixed(range *indexFixed = indexs)
            {
                for (range *index = indexFixed + indexs.Length; index != indexFixed;)
                {
                    for (range range = *--index; range.StartIndex != range.EndIndex; ++range.StartIndex)
                    {
                        values.Add(array[range.StartIndex]);
                    }
                }
            }

            return(values.List);
        }
Пример #10
0
        /// <summary>
        /// 多线程并行建图
        /// </summary>
        /// <param name="threadCount">并行线程数量</param>
        private unsafe void buildGraph(int threadCount)
        {
            node bootNode = NodePool[boot];

            Monitor.Enter(nodeLock);
            try
            {
                list <int> reader = getBuildGraphReader(ref bootNode);
                if (reader.Count != 0)
                {
                    int            taskCount = threadCount - 1;
                    graphBuilder[] builders  = new graphBuilder[threadCount];
                    for (int builderIndex = 0; builderIndex != builders.Length; builders[builderIndex++].Set(ref bootNode))
                    {
                        ;
                    }
                    using (fastCSharp.threading.task task = new fastCSharp.threading.task(taskCount))
                    {
                        do
                        {
                            int[] readerArray = reader.UnsafeArray;
                            int   count = reader.Count / threadCount, index = 0;
                            for (int builderIndex = 0; builderIndex != taskCount; ++builderIndex)
                            {
                                builders[builderIndex].Set(readerArray, index, index += count);
                                task.Add(builders[builderIndex].Build);
                            }
                            builders[taskCount].Set(readerArray, index, reader.Count);
                            builders[taskCount].Build();
                            task.WaitFree();
                            reader.Empty();
                            for (int builderIndex = 0; builderIndex != builders.Length; ++builderIndex)
                            {
                                list <int> writer = builders[builderIndex].Writer;
                                if (writer.Count != 0)
                                {
                                    reader.Add(writer.UnsafeArray, 0, writer.Count);
                                }
                            }
                        }while (reader.Count != 0);
                    }
                }
            }
            finally { Monitor.Exit(nodeLock); }
        }
Пример #11
0
 /// <summary>
 /// 调用堆栈函数转字符串
 /// </summary>
 /// <param name="value">调用堆栈函数</param>
 /// <returns>字符串</returns>
 public static string toString(this StackFrame value)
 {
     if (value != null)
     {
         list <string> .unsafer values = new list <string>(9).Unsafer;
         MethodBase             method = value.GetMethod();
         values.Add(method.ReflectedType.FullName);
         values.Add(" + ");
         values.Add(method.ToString());
         string file = value.GetFileName();
         if (file != null)
         {
             values.Add(" in ");
             values.Add(file);
             values.Add(" line ");
             values.Add(value.GetFileLineNumber().toString());
             values.Add(" col ");
             values.Add(value.GetFileColumnNumber().toString());
         }
         return(string.Concat(values.List.ToArray()));
     }
     return(null);
 }
Пример #12
0
 /// <summary>
 /// 搜索对象
 /// </summary>
 private void searchValue()
 {
     if (OnValue != null)
     {
         OnValue();
         if (IsStop)
         {
             return;
         }
     }
     if (!values.Contains(Value))
     {
         values.Add(Value);
         if (OnNewValue != null)
         {
             OnNewValue();
             if (IsStop)
             {
                 return;
             }
         }
         hashString typeKey = Value.Type.FullName;
         if (!types.Contains(typeKey))
         {
             types.Add(typeKey);
             if (OnType != null)
             {
                 OnType();
                 if (IsStop)
                 {
                     return;
                 }
             }
         }
         if (Value.Values != null)
         {
             field[] fields = Value.Type.Fields;
             int     index  = 0;
             if (fields == null)
             {
                 foreach (value value in Value.Values)
                 {
                     if (IsStop)
                     {
                         break;
                     }
                     if (value != null)
                     {
                         path.Add(index.toString());
                         Value = value;
                         searchValue();
                         path.UnsafePop();
                     }
                     ++index;
                 }
             }
             else
             {
                 foreach (value value in Value.Values)
                 {
                     if (IsStop)
                     {
                         break;
                     }
                     if (value != null)
                     {
                         path.Add(fields[index].Name);
                         Value = value;
                         searchValue();
                         path.UnsafePop();
                     }
                     ++index;
                 }
             }
         }
     }
 }
Пример #13
0
 private static void freeNodeNoLock(int node)
 {
     NodePool[node].Free();
     freeNodes.Add(node);
 }