示例#1
0
 /// <summary>
 /// 常量转换
 /// </summary>
 protected constantConverter()
 {
     list<keyValue<hashCode<Type>, func<object, string>>> values = new list<keyValue<hashCode<Type>, func<object, string>>>();
     values.Add(new keyValue<hashCode<Type>, func<object, string>>(typeof(bool), convertConstantBoolTo01));
     values.Add(new keyValue<hashCode<Type>, func<object, string>>(typeof(bool?), convertConstantBoolNullable));
     values.Add(new keyValue<hashCode<Type>, func<object, string>>(typeof(byte), convertConstantByte));
     values.Add(new keyValue<hashCode<Type>, func<object, string>>(typeof(byte?), convertConstantByteNullable));
     values.Add(new keyValue<hashCode<Type>, func<object, string>>(typeof(sbyte), convertConstantSByte));
     values.Add(new keyValue<hashCode<Type>, func<object, string>>(typeof(sbyte?), convertConstantSByteNullable));
     values.Add(new keyValue<hashCode<Type>, func<object, string>>(typeof(short), convertConstantShort));
     values.Add(new keyValue<hashCode<Type>, func<object, string>>(typeof(short?), convertConstantShortNullable));
     values.Add(new keyValue<hashCode<Type>, func<object, string>>(typeof(ushort), convertConstantUShort));
     values.Add(new keyValue<hashCode<Type>, func<object, string>>(typeof(ushort?), convertConstantUShortNullable));
     values.Add(new keyValue<hashCode<Type>, func<object, string>>(typeof(int), convertConstantInt));
     values.Add(new keyValue<hashCode<Type>, func<object, string>>(typeof(int?), convertConstantIntNullable));
     values.Add(new keyValue<hashCode<Type>, func<object, string>>(typeof(uint), convertConstantUInt));
     values.Add(new keyValue<hashCode<Type>, func<object, string>>(typeof(uint?), convertConstantUIntNullable));
     values.Add(new keyValue<hashCode<Type>, func<object, string>>(typeof(long), convertConstantLong));
     values.Add(new keyValue<hashCode<Type>, func<object, string>>(typeof(long?), convertConstantLongNullable));
     values.Add(new keyValue<hashCode<Type>, func<object, string>>(typeof(ulong), convertConstantULong));
     values.Add(new keyValue<hashCode<Type>, func<object, string>>(typeof(ulong?), convertConstantULongNullable));
     values.Add(new keyValue<hashCode<Type>, func<object, string>>(typeof(float), convertConstantFloat));
     values.Add(new keyValue<hashCode<Type>, func<object, string>>(typeof(float?), convertConstantFloatNullable));
     values.Add(new keyValue<hashCode<Type>, func<object, string>>(typeof(double), convertConstantDouble));
     values.Add(new keyValue<hashCode<Type>, func<object, string>>(typeof(double?), convertConstantDoubleNullable));
     values.Add(new keyValue<hashCode<Type>, func<object, string>>(typeof(decimal), convertConstantDecimal));
     values.Add(new keyValue<hashCode<Type>, func<object, string>>(typeof(decimal?), convertConstantDecimalNullable));
     values.Add(new keyValue<hashCode<Type>, func<object, string>>(typeof(DateTime), convertConstantDateTimeMillisecond));
     values.Add(new keyValue<hashCode<Type>, func<object, string>>(typeof(DateTime?), convertConstantDateTimeMillisecondNullable));
     values.Add(new keyValue<hashCode<Type>, func<object, string>>(typeof(string), null));
     converters = new staticDictionary<hashCode<Type>, func<object, string>>(values);
 }
示例#2
0
     protected override void OnAfterUsingDirectiveParse(
   Location location,
   list<string> name,
   list<Location> nameLocations,
   string alias,
   Location aliasLocation,
   GlobalEnv beforeEnv,
   GlobalEnv afterEnv
 )
     {
         // do not notify Manager
     }
示例#3
0
     protected override void OnAfterNamespaceParse(
   Location location,
   list<string> name,
   list<Location> nameLocations,
   GlobalEnv outsideEnv,
   GlobalEnv insideEnv,
   Location headerLocation,
   Location bodyOpenTokenLocation,
   Location bodyCloseTokenLocation
 )
     {
         // do not notify Manager
     }
        public House createHouse(string housename, string password, int userID, string _addr, string _city, string _state)
        {
            using (var context = new houseMateEntities01())
            {
                if (!houseExists(housename))
                {
                    if (getTID(userID) <= 0)
                    {
                        // create the new house
                        house newHouse = new house
                        {
                            houseName = housename,
                            password = password,
                            address = _addr,
                            city = _city,
                            state = _state
                        };
                        context.houses.Add(newHouse);
                        context.SaveChanges();

                        // create the list for that house
                        list newList = new list
                        {
                            FK_houseID = newHouse.PK_houseID
                        };
                        context.lists.Add(newList);
                        context.SaveChanges();

                        // create the notice board for that house
                        notice_board newNBoard = new notice_board
                        {
                            FK_houseID = newHouse.PK_houseID
                        };
                        context.notice_board.Add(newNBoard);
                        context.SaveChanges();

                        return joinHouse(housename, password, userID);
                    }
                    else
                    {
                        return new House(-1, "already in a house");
                    }
                }
                else
                {
                    return new House(-1, "house doesn't exist");
                }
            }
        }
示例#5
0
文件: log.cs 项目: khaliyo/fastCSharp
            /// <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;
            }
示例#6
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");

            Console.ReadLine();

            Console.WriteLine("\nSoftware Engineering is fun!");

            list<string> dayList = new list();
            dayList.add("Tuesday");
            dayList.add("Thursday");

            Console.Write(dayList[0]);
            Console.Write(" and ");
            Console.write(dayList[1]);
            Console.Writeline(" are the days I have CS2450.");

            Console.WriteLine("Press the Enter key to continue...");
        }
示例#7
0
 public bool Load()
 {
     try
     {
         Core.RecoverFile(Variables.ConfigurationDirectory + Path.DirectorySeparatorChar + channel.Name + ".statistics", channel.Name);
         if (File.Exists(Variables.ConfigurationDirectory + Path.DirectorySeparatorChar + channel.Name + ".statistics"))
         {
             lock (data)
             {
                 data = new List<list>();
                 XmlDocument stat = new XmlDocument();
                 stat.Load(Variables.ConfigurationDirectory + Path.DirectorySeparatorChar + channel.Name + ".statistics");
                 if (stat.ChildNodes[0].ChildNodes.Count > 0)
                 {
                     foreach (XmlNode curr in stat.ChildNodes[0].ChildNodes)
                     {
                         list item = new list
                         {
                             user = curr.Attributes[0].Value,
                             messages = int.Parse(curr.Attributes[1].Value),
                             logging_since = DateTime.FromBinary(long.Parse(curr.Attributes[3].Value))
                         };
                         if (curr.Attributes.Count > 4)
                         {
                             item.URL = curr.Attributes[4].Value;
                         }
                         data.Add(item);
                     }
                 }
             }
         }
     }
     catch (Exception f)
     {
         Core.HandleException(f, "statistics");
     }
     return false;
 }
    public list<Vector2>[] calculateTurnSequence(list<Vector2> movement1,list<Vector2> movement2)
    {
        list<Vector2>[] velocitySequences= new list<Vector2>[2];
        for(int i=1; i<Math.Max(movement1.Count, movement2.Count); i++)
        {
            Vector2 vel1, vel2;
            bool recheck=false;
            if(i<movement1.Count) vel1=movement1[i]-movement1[i-1];  //If either player stops moving, add zero vectors to their velocity sequence
            else vel1=Vector2.zero;
            if(i<movement2.Count) vel2=movement2[i]-movement2[i-1];
            else vel2=Vector2.zero;
            if(boardManager.isOccupied(movement1[i])){
                velocitySequences[0][i]=0-vel1;
                recheck=true;
            }  //If collides with obstacle, reverse velocity vector
            else velocitySequences[0][i]=vel1;
            if(boardManager.isOccupied(movement2[i])){
                velocitySequences[1][i]=0-vel2;
                recheck=true;
            }
            else velocitySequences[1][i]=vel2;

            movement1[i]=movement1[i-1]+vel1;  //update position vectors according to velocity vector
            movement2[i]=movement2[i-1]+vel2;

            if(movement1[i]==movement2[i]){  //If collides with other player, swap velocity vector
                Vector2 temp=velocitySequences[0][i];
                velocitySequences[0][i]=velocitySequences[1][i];
                velocitySequences[1][i]=temp;
                recheck=true;
            }
            movement1[i]=movement1[i-1]+vel1;  //update position vectors according to velocity vector
            movement2[i]=movement2[i-1]+vel2;  //how should the remaining movement positions be updated?

            if(recheck) i--; //rechecks for collisions if changes were made
        }
        return velocitySequences;
    }
示例#9
0
 ElementChanged?.Invoke(this, value, list[index], index);
示例#10
0
文件: log.cs 项目: khaliyo/fastCSharp
        /// <summary>
        /// 日志信息写文件
        /// </summary>
        private void output()
        {
            while (!isStop)
            {
                Monitor.Enter(logLock);
                try
                {
                    if (newDebugs.Count == 0) Monitor.Wait(logLock);
                    list<debug> oldDebugs = currentDebugs;
                    currentDebugs = newDebugs;
                    newDebugs = oldDebugs;
                }
                finally { Monitor.Exit(logLock); }
                output(string.Join(@"
- - - - - - - - - -
", currentDebugs.GetArray(error => error.ToString())));
                currentDebugs.Empty();
            }
            newDebugs = null;
        }
示例#11
0
 AssertEquals(list.message, "Some example message");
示例#12
0
 /// <summary>
 /// 根据筛选路径值匹配HTML节点集合
 /// </summary>
 /// <param name="path">筛选路径</param>
 /// <param name="nodes">筛选节点集合</param>
 /// <returns>匹配的HTML节点集合</returns>
 public static list<htmlNode> Get(string path, list<htmlNode> nodes)
 {
     if (path != null && path.Length != 0)
     {
         return get(path).get(new keyValue<list<htmlNode>, bool>(nodes, true)) ?? new list<htmlNode>();
     }
     return null;
 }
示例#13
0
        /// <summary>
        /// 解析HTML节点
        /// </summary>
        /// <param name="html"></param>
        private void create(string html)
        {
            int length = html.Length;
            children = new list<htmlNode>();
            if (length < 2)
            {
                children.Add(new htmlNode { nodeText = new htmlText { FormatHtml = html }, Parent = this });
            }
            else
            {
                int nextIndex, nodeCount;
                htmlNode nextNode;
                fixed (char* htmlFixed = html + "<")
                {
                    fixedMap spaceFixedMap = new fixedMap(spaceMap.Map);
                    fixedMap spaceSplitFixedMap = new fixedMap(spaceSplitMap);
                    fixedMap tagNameFixedMap = new fixedMap(tagNameMap);
                    fixedMap tagNameSplitFixedMap = new fixedMap(tagNameSplitMap);
                    fixedMap attributeSplitFixedMap = new fixedMap(attributeSplitMap);
                    fixedMap attributeNameSplitFixedMap = new fixedMap(attributeNameSplitMap);
                    int startIndex, tagNameLength;
                    string name, htmlValue;
                    char* startChar = htmlFixed, currentChar = htmlFixed, endChar = htmlFixed + length, scriptChar;
                    char splitChar;
                    while (currentChar != endChar)
                    {
                        for (*endChar = '<'; *currentChar != '<'; ++currentChar) ;
                        if (currentChar != endChar)
                        {
                            if ((*++currentChar & 0xff80) == 0)
                            {
                                if (tagNameFixedMap.Get(*currentChar))
                                {
                                    while ((*startChar & 0xffc0) == 0 && spaceFixedMap.Get(*startChar)) ++startChar;
                                    if (startChar != currentChar - 1)
                                    {
                                        for (scriptChar = currentChar - 2; (*scriptChar & 0xffc0) == 0 && spaceFixedMap.Get(*scriptChar); --scriptChar) ;
                                        children.Add(new htmlNode { nodeText = new htmlText { FormatHtml = html.Substring((int)(startChar - htmlFixed), (int)(scriptChar - startChar) + 1) } });
                                    }
                                    if (*currentChar == '/')
                                    {
                                        #region 标签回合
                                        startChar = currentChar - 1;
                                        if (++currentChar != endChar)
                                        {
                                            while ((*currentChar & 0xffc0) == 0 && spaceFixedMap.Get(*currentChar)) ++currentChar;
                                            if (currentChar != endChar)
                                            {
                                                if ((uint)((*currentChar | 0x20) - 'a') <= 26)
                                                {
                                                    for (*endChar = '>'; (*currentChar & 0xffc0) != 0 || !tagNameSplitFixedMap.Get(*currentChar); ++currentChar) ;
                                                    TagName = html.Substring((int)((startChar += 2) - htmlFixed), (int)(currentChar - startChar)).toLower();
                                                    for (startIndex = children.Count - 1; startIndex >= 0 && (children[startIndex].nodeText.FormatHtml != null || children[startIndex].TagName != TagName); --startIndex) ;
                                                    if (startIndex != -1)
                                                    {
                                                        for (nextIndex = children.Count - 1; nextIndex != startIndex; --nextIndex)
                                                        {
                                                            nextNode = children[nextIndex];
                                                            if (nextNode.nodeText.FormatHtml == null)
                                                            {
                                                                if (web.html.MustRoundTagNames.Contains(nextNode.TagName) && (nodeCount = (children.Count - nextIndex - 1)) != 0)
                                                                {
                                                                    nextNode.children = new list<htmlNode>(children.GetSub(nextIndex + 1, nodeCount), true);
                                                                    children.RemoveRange(nextIndex + 1, nodeCount);
                                                                    foreach (htmlNode value in nextNode.children) value.Parent = nextNode;
                                                                }
                                                            }
                                                            else if (nextNode.nodeText.FormatHtml.Length == 0) nextNode.nodeText.FormatHtml = null;
                                                        }
                                                        nextNode = children[startIndex];
                                                        if ((nodeCount = children.Count - ++startIndex) != 0)
                                                        {
                                                            nextNode.children = new list<htmlNode>(children.GetSub(startIndex, nodeCount), true);
                                                            children.RemoveRange(startIndex, nodeCount);
                                                            foreach (htmlNode value in nextNode.children) value.Parent = nextNode;
                                                        }
                                                        nextNode.nodeText.FormatHtml = string.Empty;//已回合标识
                                                    }
                                                    while (*currentChar != '>') ++currentChar;
                                                    if (currentChar != endChar) ++currentChar;
                                                }
                                                else
                                                {
                                                    for (*endChar = '>'; *currentChar != '>'; ++currentChar) ;
                                                    if (currentChar != endChar) ++currentChar;
                                                    htmlValue = html.Substring((int)(startChar - htmlFixed), (int)(currentChar - startChar));
                                                    children.Add(new htmlNode { TagName = "/", nodeText = new htmlText { FormatHtml = htmlValue, FormatText = htmlValue } });
                                                }
                                                startChar = currentChar;
                                            }
                                        }
                                        #endregion
                                    }
                                    else if (*currentChar != '!')
                                    {
                                        #region 标签开始
                                        startChar = currentChar;
                                        children.Add(nextNode = new htmlNode());
                                        for (*endChar = '>'; (*currentChar & 0xffc0) != 0 || !tagNameSplitFixedMap.Get(*currentChar); ++currentChar) ;
                                        nextNode.TagName = html.Substring((int)(startChar - htmlFixed), (int)(currentChar - startChar)).toLower();
                                        if (currentChar == endChar) startChar = endChar;
                                        else
                                        {
                                            #region 属性解析
                                            if (*currentChar != '>')
                                            {
                                                startChar = ++currentChar;
                                                while (currentChar != endChar)
                                                {
                                                    while ((*currentChar & 0xffc0) == 0 && attributeSplitFixedMap.Get(*currentChar)) ++currentChar;
                                                    if (*currentChar == '>')
                                                    {
                                                        if (currentChar != endChar)
                                                        {
                                                            if (*(currentChar - 1) == '/') nextNode.nodeText.FormatHtml = string.Empty;
                                                            startChar = ++currentChar;
                                                        }
                                                        break;
                                                    }
                                                    else
                                                    {
                                                        for (startChar = currentChar++; (*currentChar & 0xffc0) != 0 || !tagNameSplitFixedMap.Get(*currentChar); ++currentChar) ;
                                                        htmlValue = name = checkName(html.Substring((int)(startChar - htmlFixed), (int)(currentChar - startChar)).toLower());
                                                        if (currentChar != endChar && ((*currentChar & 0xffc0) != 0 || !attributeNameSplitFixedMap.Get(*currentChar)))
                                                        {
                                                            if (*currentChar != '=')
                                                            {
                                                                while ((*currentChar & 0xffc0) == 0 && spaceFixedMap.Get(*currentChar)) ++currentChar;
                                                            }
                                                            if (*currentChar == '=')
                                                            {
                                                                while ((*++currentChar & 0xffc0) == 0 && spaceFixedMap.Get(*currentChar)) ;
                                                                if ((splitChar = *currentChar) != '>')
                                                                {
                                                                    if (splitChar == '"' || splitChar == '\'')
                                                                    {
                                                                        for (startChar = ++currentChar, *endChar = splitChar; *currentChar != splitChar; ++currentChar) ;
                                                                        *endChar = '>';
                                                                    }
                                                                    else
                                                                    {
                                                                        for (startChar = currentChar++; (*currentChar & 0xffc0) != 0 || !spaceSplitFixedMap.Get(*currentChar); ++currentChar) ;
                                                                    }
                                                                    htmlValue = html.Substring((int)(startChar - htmlFixed), (int)(currentChar - startChar));
                                                                }
                                                            }
                                                        }
                                                        if (nextNode.attributes == null) nextNode.attributes = new Dictionary<string, htmlText>();
                                                        nextNode.attributes[name] = new htmlText { FormatHtml = htmlValue };
                                                        if (currentChar != endChar)
                                                        {
                                                            if (*currentChar == '>')
                                                            {
                                                                if (*(currentChar - 1) == '/') nextNode.nodeText.FormatHtml = string.Empty;
                                                                startChar = ++currentChar;
                                                                break;
                                                            }
                                                            startChar = ++currentChar;
                                                        }
                                                    }
                                                }
                                            }
                                            else startChar = ++currentChar;
                                            #endregion

                                            #region 非解析标签
                                            if (currentChar == endChar) startChar = endChar;
                                            else if (web.html.NonanalyticTagNames.Contains(TagName = nextNode.TagName))
                                            {
                                                scriptChar = endChar;
                                                tagNameLength = TagName.Length + 2;
                                                fixed (char* tagNameFixed = TagName)
                                                {
                                                    while ((int)(endChar - currentChar) > tagNameLength)
                                                    {
                                                        for (currentChar += tagNameLength; *currentChar != '>'; ++currentChar) ;
                                                        if (currentChar != endChar && *(int*)(currentChar - tagNameLength) == (('/' << 16) + '<'))
                                                        {
                                                            if (unsafer.String.EqualCase(currentChar - TagName.Length, tagNameFixed, TagName.Length))
                                                            {
                                                                scriptChar = currentChar - tagNameLength;
                                                                if (currentChar != endChar) ++currentChar;
                                                                break;
                                                            }
                                                        }
                                                    }
                                                }
                                                if (startChar != scriptChar)
                                                {
                                                    nextNode.nodeText.FormatHtml = nextNode.nodeText.FormatText = html.Substring((int)(startChar - htmlFixed), (int)(scriptChar - startChar));
                                                }
                                                if (scriptChar == endChar) currentChar = endChar;
                                                startChar = currentChar;
                                            }
                                            #endregion
                                        }
                                        #endregion
                                    }
                                    else
                                    {
                                        #region 注释
                                        startChar = currentChar - 1;
                                        if (++currentChar != endChar)
                                        {
                                            *endChar = '>';
                                            if ((length = (int)(endChar - currentChar)) > 2 && *(int*)currentChar == (('-' << 16) + '-'))
                                            {
                                                for (currentChar += 2; *currentChar != '>'; ++currentChar) ;
                                                while (currentChar != endChar && *(int*)(currentChar - 2) != (('-' << 16) + '-'))
                                                {
                                                    if ((currentChar += 3) < endChar)
                                                    {
                                                        while (*currentChar != '>') ++currentChar;
                                                    }
                                                    else currentChar = endChar;
                                                }
                                            }
                                            else if (length > 9
                                                && (*(int*)currentChar & 0x200000) == ('[' + ('c' << 16))
                                                && (*(int*)(currentChar + 2) & 0x200020) == ('d' + ('a' << 16))
                                                && (*(int*)(currentChar + 4) & 0x200020) == ('t' + ('a' << 16))
                                                && *(currentChar + 6) == '[')
                                            {
                                                for (currentChar += 9; *currentChar != '>'; ++currentChar) ;
                                                while (currentChar != endChar && *(int*)(currentChar - 2) != ((']' << 16) + ']'))
                                                {
                                                    if ((currentChar += 3) < endChar)
                                                    {
                                                        while (*currentChar != '>') ++currentChar;
                                                    }
                                                    else currentChar = endChar;
                                                }
                                            }
                                            else
                                            {
                                                while (*currentChar != '>') ++currentChar;
                                            }
                                            if (currentChar != endChar) ++currentChar;
                                        }
                                        htmlValue = html.Substring((int)(startChar - htmlFixed), (int)(currentChar - startChar) + (*(currentChar - 1) == '>' ? 0 : 1));
                                        children.Add(new htmlNode { TagName = "!", nodeText = new htmlText { FormatHtml = htmlValue, FormatText = htmlValue } });
                                        startChar = currentChar;
                                        #endregion
                                    }
                                }
                            }
                            else ++currentChar;
                        }
                    }
                    if (startChar != endChar)
                    {
                        *endChar = '>';
                        while ((*startChar & 0xffc0) == 0 && spaceFixedMap.Get(*startChar)) ++startChar;
                        if (startChar != endChar)
                        {
                            for (scriptChar = endChar - 1; (*scriptChar & 0xffc0) == 0 && spaceFixedMap.Get(*scriptChar); --scriptChar) ;
                            children.Add(new htmlNode { nodeText = new htmlText { FormatHtml = html.Substring((int)(startChar - htmlFixed), (int)(scriptChar - startChar) + 1) } });
                        }
                    }
                }
                for (nextIndex = children.Count - 1; nextIndex != -1; nextIndex--)
                {
                    nextNode = children[nextIndex];
                    if (nextNode.nodeText.FormatHtml == null)
                    {
                        if (web.html.MustRoundTagNames.Contains(nextNode.TagName)
                            && (nodeCount = (children.Count - nextIndex - 1)) != 0)
                        {
                            nextNode.children = new list<htmlNode>(children.GetSub(nextIndex + 1, nodeCount), true);
                            children.RemoveRange(nextIndex + 1, nodeCount);
                            foreach (htmlNode value in children) value.Parent = nextNode;
                        }
                    }
                    else if (nextNode.nodeText.FormatHtml.Length == 0) nextNode.nodeText.FormatHtml = null;
                }
                foreach (htmlNode value in children) value.Parent = this;
            }
        }
示例#14
0
        public list <Sinhvien> SV()
        {
            list <Sinhvien> sv = DALSV.readlist("Data/Sinhvien.txt");

            return(sv);
        }
示例#15
0
    public String teste(int id, string j)
    {
        Product objProd = new Product();
        String  teste;

        teste = 20;
        List <Order>      listOrder = new List <Order>();
        List <int, float> listNumW  = new List <int, float>();
        List <String>     listNumW3 = new List <String>();

        list[] list2 = new list[2];
        listNumW3 = 3;
        listNumW3.Add(teste);
        teste = objProd.getNome();
        int z;

        z = 0;
        String using;

        while (z < listNumW3.Count)
        {
            using = listNumW3[2];
        }

        int z;

        for (z = 10; z < 1; z--)
        {
            if ((z == 2))
            {
                z = 9;
            }
            e = z + 1;
        }

        int x4;
        int v;

        for (v = 1; v > 10; v = v + 3)
        {
            x4 = x4 + 1;
        }


        while (z < 10)
        {
            e = 5 + 2;
        }


        do
        {
            e = 5 + 9;
        }while(z < 10);


        if (z < 10 && z < 20)
        {
            e = 200 + 20;
        }
        else if (z < 10)
        {
            e = 5 + 9;
        }
        else
        {
            e = 5 + 43;
        }

        return(teste);
    }
示例#16
0
 /// <summary>
 /// Remove list
 /// </summary>
 public static void RemoveList(list objList)
 {
     BrightPlatformEntities m_objBrightPlatformEntity = new BrightPlatformEntities(UserSession.EntityConnection);
     m_objBrightPlatformEntity.lists.DeleteObject(objList);
     m_objBrightPlatformEntity.SaveChanges();
 }
示例#17
0
        /// <summary>
        /// 搜索字符串分词
        /// </summary>
        /// <param name="text">搜索字符串</param>
        /// <returns>分词结果</returns>
        protected list <subString> getWords(string text)
        {
            if (text != null)
            {
                int length = text.Length;
                if (length != 0)
                {
                    list <subString> words = length <= maxSearchSize?getWords(text + " ", length) : getWords(text, maxSearchSize);

                    if (words != null)
                    {
                        int index = words.Count;
                        if (index > 1)
                        {
                            subString[] wordArray = words.UnsafeArray;
                            int         count     = 0;
                            if (words.Count <= 4)
                            {
                                foreach (subString word in wordArray)
                                {
                                    if (count == 0)
                                    {
                                        count = 1;
                                    }
                                    else
                                    {
                                        int nextIndex = count;
                                        foreach (subString cmpWord in wordArray)
                                        {
                                            if (cmpWord.Equals(word) || --nextIndex == 0)
                                            {
                                                break;
                                            }
                                        }
                                        if (nextIndex == 0)
                                        {
                                            wordArray[count++] = word;
                                        }
                                    }
                                    if (--index == 0)
                                    {
                                        break;
                                    }
                                }
                            }
                            else
                            {
                                HashSet <hashString> wordHash = typePool <HashSet <hashString> > .Pop();

                                if (wordHash == null)
                                {
                                    wordHash = hashSet.CreateHashString();
                                }
                                else if (wordHash.Count != 0)
                                {
                                    wordHash.Clear();
                                }
                                foreach (subString word in wordArray)
                                {
                                    if (count == 0)
                                    {
                                        wordHash.Add(word);
                                        count = 1;
                                    }
                                    else
                                    {
                                        hashString wordKey = word;
                                        if (!wordHash.Contains(wordKey))
                                        {
                                            wordArray[count++] = word;
                                            wordHash.Add(wordKey);
                                        }
                                    }
                                    if (--index == 0)
                                    {
                                        break;
                                    }
                                }
                                wordHash.Clear();
                                typePool <HashSet <hashString> > .PushNotNull(wordHash);
                            }
                            words.UnsafeAddLength(count - words.Count);
                        }
                    }
                    return(words);
                }
            }
            return(null);
        }
示例#18
0
 if (TryAddSuppressionOnMissingCloseBraceCase(list, node))
 {
     return;
示例#19
0
 /// <summary>
 /// Get value of Skill
 /// </summary>
 /// <param name="s">Skill to be viewed</param>
 /// <returns>0->10 value</returns>
 public float getValue(list s)
 {
     return(getValue((int)s));
 }
示例#20
0
 //add constructor
 public Ninja()
 {
     calorieIntake = 0;
     FoodHistory   = new List <Food>();
 }
示例#21
0
        /// <summary>
        /// 文本分词
        /// </summary>
        /// <param name="text">文本</param>
        /// <param name="length">文本长度</param>
        /// <returns>分词结果</returns>
        private unsafe list <subString> getWords(string text, int length)
        {
            fixed(char *textFixed = text)
            {
                simplified.Format(textFixed, length);
                int              count    = (length + 7) >> 3;
                byte *           match    = stackalloc byte[count];
                fixedMap         matchMap = new fixedMap(match, count, 0);
                list <subString> words    = typePool <list <subString> > .Pop();

                if (words == null)
                {
                    words = new list <subString>();
                }
                else if (words.Count != 0)
                {
                    words.Clear();
                }
                list <keyValue <int, int> > matchs = typePool <list <keyValue <int, int> > > .Pop() ?? new list <keyValue <int, int> >();

                byte *    charTypes = charTypePointer.Byte;
                subString matchWord = default(subString);

                for (char *start = textFixed, end = textFixed + length; start != end;)
                {
                    if (*start == ' ')
                    {
                        *end = '?';
                        while (*++start == ' ')
                        {
                            ;
                        }
                    }
                    else
                    {
                        *     end     = ' ';
                        char *segment = start;
                        if ((uint)(*start - 0x4E00) <= 0X9FA5 - 0x4E00)
                        {
                            while ((uint)(*++start - 0x4E00) <= 0X9FA5 - 0x4E00)
                            {
                                ;
                            }
                            if ((length = (int)(start - segment)) == 1)
                            {
                                words.Add(subString.Unsafe(text, (int)(segment - textFixed), 1));
                            }
                            else
                            {
                                int startIndex = (int)(segment - textFixed);
                                matchs.Empty();
                                matchWord.UnsafeSet(text, startIndex, length);
                                wordTrieGraph.LeftRightMatchs(ref matchWord, matchs);
                                if ((count = matchs.Count) != 0)
                                {
                                    foreach (keyValue <int, int> value in matchs.UnsafeArray)
                                    {
                                        words.Add(subString.Unsafe(text, value.Key, value.Value));
                                        matchMap.Set(value.Key, value.Value);
                                        if (--count == 0)
                                        {
                                            break;
                                        }
                                    }
                                }
                                int index = startIndex;
                                for (int endIndex = startIndex + length; index != endIndex; ++index)
                                {
                                    if (matchMap.Get(index))
                                    {
                                        if ((count = index - startIndex) != 1)
                                        {
                                            words.Add(subString.Unsafe(text, startIndex, count));
                                        }
                                        startIndex = index;
                                    }
                                    else
                                    {
                                        words.Add(subString.Unsafe(text, index, 1));
                                    }
                                }
                                if ((index -= startIndex) > 1)
                                {
                                    words.Add(subString.Unsafe(text, startIndex, index));
                                }
                            }
                        }
                        else
                        {
                            byte type = charTypes[*start];
                            if (type == (byte)charType.OtherLetter)
                            {
                                while (charTypes[*++start] == (byte)charType.OtherLetter)
                                {
                                    ;
                                }
                            }
                            else
                            {
                                char *word = start;
                                for (byte newType = charTypes[*++start]; newType >= (byte)charType.Letter; newType = charTypes[*++start])
                                {
                                    if (type != newType)
                                    {
                                        if (type != (byte)charType.Keep)
                                        {
                                            words.Add(subString.Unsafe(text, (int)(word - textFixed), (int)(start - word)));
                                        }
                                        type = newType;
                                        word = start;
                                    }
                                }
                            }
                            words.Add(subString.Unsafe(text, (int)(segment - textFixed), (int)(start - segment)));
                        }
                    }
                }
                typePool <list <keyValue <int, int> > > .PushNotNull(matchs);

                if ((count = words.Count) == 0)
                {
                    typePool <list <subString> > .PushNotNull(words);

                    return(null);
                }
                return(words);
            }
        }
示例#22
0
 AssertEquals(list.array[0].version, Version.ONE);
示例#23
0
 => AddRangeInternal(
     list,
     list.Count);
 private Composition convertFromList(list l)
 {
     Composition result = new Composition();
     if (l.property != null)
     {
         foreach (property p in l.property)
         {
             result.put(p.name, p.Value);
         }
     }
     if (l.list1 != null)
     {
         foreach (list l1 in l.list1)
         {
             result.properties.Add(l1.name, convertFromList(l1));
         }
     }
     return result;
 }
示例#25
0
        /// <summary>
        /// 写入文件数据
        /// </summary>
        internal void WriteFile()
        {
            try
            {
                do
                {
                    Monitor.Enter(bufferLock);
                    int bufferCount = buffers.length;
                    if (bufferCount == 0)
                    {
                        if ((flushCount | isFlush) == 0)
                        {
                            checkFlushTime = date.nowTime.Now.AddTicks(checkFlushTicks);
                            isWritting     = 0;
                            //if (currentIndex == startIndex) Monitor.Exit(bufferLock);
                            //else
                            //{
                            //    Monitor.Exit(bufferLock);
                            //    setCheckFlush();
                            //}
                            Monitor.Exit(bufferLock);
                            setCheckFlush();
                            return;
                        }
                        isFlush = 0;
                        int writeSize = currentIndex - startIndex;
                        if (writeSize == 0)
                        {
                            Monitor.Exit(bufferLock);
                            if (buffers.length == 0)
                            {
                                fileStream.Flush();
                                if (buffers.length == 0)
                                {
                                    flushWait.Set();
                                }
                            }
                            continue;
                        }
                        Monitor.Exit(bufferLock);
                        fileStream.Write(buffer, startIndex, writeSize);

                        Monitor.Enter(bufferLock);

                        fileLength += writeSize;
                        Monitor.Exit(bufferLock);
                        startIndex = currentIndex;
                        if (buffers.length == 0)
                        {
                            fileStream.Flush();
                            if (buffers.length == 0)
                            {
                                flushWait.Set();
                            }
                        }
                        continue;
                    }
                    list <memoryPool.pushSubArray> datas = buffers;
                    isCopyBuffer   = 0;
                    buffers        = currentBuffers;
                    bufferIndex    = fileBufferLength;
                    currentBuffers = datas;
                    Monitor.Exit(bufferLock);
                    foreach (memoryPool.pushSubArray data in datas.array)
                    {
                        int dataSize = data.Value.length, writeSize = writeFile(data.Value);
                        Monitor.Enter(bufferLock);
                        fileLength += writeSize;
                        bufferSize -= dataSize;
                        Monitor.Exit(bufferLock);
                        data.Push();
                        if (--bufferCount == 0)
                        {
                            break;
                        }
                    }
                    Array.Clear(datas.array, 0, datas.length);
                    datas.Empty();
                    if (isCopyBuffer != 0 && buffers.length == 0)
                    {
                        Thread.Sleep(0);
                    }
                }while (true);
            }
            catch (Exception error)
            {
                this.error(error);
            }
        }
示例#26
0
        private void ParseBuildOptions(list elements)
        {
            if (elements == null)
            {
                return;
            }

            foreach (xml element in elements)
            {
                var    attribute = element.Attributes[0];
                string value     = attribute.Value;

                switch (attribute.Name)
                {
                case A.Accessible: Accessible = Flag(value); break;

                case A.AdvancedTelemetry: AdvancedTelemetry = Flag(value); break;

                case A.AllowSourcePathOverlap: AllowSourcePathOverlap = Flag(value); break;

                case A.Benchmark: Benchmark = Flag(value); break;

                case A.Es: Es = Flag(value); break;

                case A.Inline: Inline = Flag(value); break;

                case A.Optimize: Optimize = Flag(value); break;

                case A.OmitTraces: OmitTraces = Flag(value); break;

                case A.ShowActionScriptWarnings: ShowActionScriptWarnings = Flag(value); break;

                case A.ShowBindingWarnings: ShowBindingWarnings = Flag(value); break;

                case A.ShowInvalidCss: ShowInvalidCss = Flag(value); break;

                case A.ShowDeprecationWarnings: ShowDeprecationWarnings = Flag(value); break;

                case A.ShowUnusedTypeSelectorWarnings: ShowUnusedTypeSelectorWarnings = Flag(value); break;

                case A.Strict: Strict = Flag(value); break;

                case A.UseNetwork: UseNetwork = Flag(value); break;

                case A.UseResourceBundleMetadata: UseResourceBundleMetadata = Flag(value); break;

                case A.Warnings: Warnings = Flag(value); break;

                case A.VerboseStackTraces: VerboseStackTraces = Flag(value); break;

                case A.StaticLinkRSL: StaticLinkRSL = Flag(value); break;

                case A.AdvancedTelemetryPassword: AdvancedTelemetryPassword = value; break;

                case A.Additional: Additional = value; break;

                case A.CompilerConstants: CompilerConstants = value; break;

                case A.Locale: Locale = value; break;

                case A.LoadConfig: LoadConfig = value; break;

                case A.MinorVersion: MinorVersion2 = value; break;
                }
            }
        }
示例#27
0
 AddAnchorIndentationOperationsSlow(list, node, ref nextOperationCopy);
示例#28
0
 /// <summary>
 /// 生成HTML
 /// </summary>
 /// <param name="isTag">是否包含当前标签</param>
 /// <returns>HTML</returns>
 public string Html(bool isTag)
 {
     if (TagName != null)
     {
         if (web.html.NonanalyticTagNames.Contains(TagName))
         {
             if (isTag && TagName.Length != 1)
             {
                 using (charStream strings = new charStream())
                 {
                     tagHtml(strings);
                     strings.Write(nodeText.Html);
                     tagRound(strings);
                     return strings.ToString();
                 }
             }
         }
         else
         {
             using (charStream strings = new charStream())
             {
                 if (isTag) tagHtml(strings);
                 if (children.count() != 0)
                 {
                     htmlNode node;
                     list<nodeIndex> values = new list<nodeIndex>();
                     nodeIndex index = new nodeIndex { Values = children };
                     while (true)
                     {
                         if (index.Values == null)
                         {
                             if (values.Count == 0) break;
                             {
                                 index = values.Pop();
                                 index.Values[index.Index].tagRound(strings);
                                 if (++index.Index == index.Values.Count)
                                 {
                                     index.Values = null;
                                     continue;
                                 }
                             }
                         }
                         node = index.Values[index.Index];
                         string nodeTagName = node.TagName;
                         bool isNonanalyticTagNames = nodeTagName != null && web.html.NonanalyticTagNames.Contains(nodeTagName);
                         if (node.children.count() == 0 || nodeTagName == null || isNonanalyticTagNames)
                         {
                             if (nodeTagName != null && nodeTagName.Length != 1) node.tagHtml(strings);
                             strings.Write(node.nodeText.Html);
                             if (nodeTagName != null && nodeTagName.Length != 1) node.tagRound(strings);
                             if (++index.Index == index.Values.Count) index.Values = null;
                         }
                         else
                         {
                             node.tagHtml(strings);
                             values.Add(index);
                             index.Values = node.children;
                             index.Index = 0;
                         }
                     }
                 }
                 if (isTag) tagRound(strings);
                 return strings.ToString();
             }
         }
     }
     return nodeText.Html;
 }
示例#29
0
        public list <Tangkt> LTANG()
        {
            list <Tangkt> lt = DALTANG.readlist("Data/Tangkituc.txt");

            return(lt);
        }
示例#30
0
 /// <summary>
 /// 根据筛选路径值匹配HTML节点集合
 /// </summary>
 /// <param name="path">筛选路径</param>
 /// <param name="node">筛选节点</param>
 /// <returns>匹配的HTML节点集合</returns>
 public static list<htmlNode> Get(string path, htmlNode node)
 {
     if (path != null && path.Length != 0)
     {
         list<htmlNode> nodes = new list<htmlNode>();
         nodes.Add(node);
         return get(path).get(new keyValue<list<htmlNode>, bool>(nodes, false));
     }
     return null;
 }
示例#31
0
        public void TestMethod1()
        {
            var driver = GetChromeDriver();

            //#Question 1
            //Wait for page to load for 10 seconds
            driver.Manage().Timeouts().ImplicitWait(10, TimeUnit.SECONDS);
            driver.Navigate().GoToUrl("https://www.valtech.com/");

            IWebElement LatestNewsText = driver.FindElement(By.XPath("//*[@id=" container "]/div[2]/div[3]/div[1]/header/h2")).Text;

            //IWebElement element = driver.FindElement(By.TagName("title"));
            Assert.Equals(LatestNewsText, "Latest news");

            //********************************************************************
            //Question 2

            IWebElement AboutMenu = driver.FindElement(By.XPath("//*[@id=" navigationMenuWrapper "]/div/ul/li[1]/a/span"));

            AboutMenu.Click();
            driver.Manage().Timeouts().ImplicitWait(10, TimeUnit.SECONDS);

            IWebElement AboutPageHeader = driver.FindElement(By.XPath("//*[@id=" container "]/div[1]/h1")).Text;

            Assert.IsTrue(AboutPageHeader.Text);

            //********************************************************************

            IWebElement WorkMenu = driver.FindElement(By.XPath("//*[@id=" navigationMenuWrapper "]/div/ul/li[2]/a/span"));

            WorkMenu.Click();

            driver.Manage().Timeouts().ImplicitWait(10, TimeUnit.SECONDS);
            IWebElement WorkPageHeader = driver.FindElement(By.XPath "//*[@id=" container "]/header/h1").Text;

            Assert.IsTrue(WorkPageHeader.Text);

            //********************************************************************

            IWebElement ServicesMenu = driver.FindElement(By.XPath("//*[@id=" navigationMenuWrapper "]/div/ul/li[3]/a/span"));

            ServicesMenu.Click();

            driver.Manage().Timeouts().ImplicitWait(10, TimeUnit.SECONDS);
            IWebElement ServicePageHeader = driver.FindElement(By.XPath "//*[@id=" container "]/section/header/h1").Text;

            Assert.IsTrue(ServicePageHeader.Text);

            //********************************************************************
            //Question 3
            //Find all countries
            list <string> allCountries = new list <string>();
            IWebElement   allCountries = driver.FindElements(By.ClassName("contactcountry"));

            System.Diagnostics.Debug.WriteLine("Total countries: {0}", allCountries);

            //Find all Cities within countries
            list <string> allCities = new list <string>();
            IWebElement   allCities = driver.FindElements(By.ClassName("contactcities"));

            System.Diagnostics.Debug.WriteLine("Total cities: {0}", allCities);
        }
示例#32
0
 /// <summary>
 /// 子孙节点筛选
 /// </summary>
 /// <param name="path">筛选器</param>
 /// <param name="value">筛选节点集合</param>
 /// <returns>匹配的HTML节点集合</returns>
 private static keyValue<list<htmlNode>, bool> filterNode(filter path, keyValue<list<htmlNode>, bool> value)
 {
     list<nodeIndex> values = new list<nodeIndex>();
     nodeIndex index = new nodeIndex { Values = value.Key.getList() };
     if (index.Values.Count != 0)
     {
         if (value.Value)
         {
             HashSet<htmlNode> newValues = new HashSet<htmlNode>(), historyNodes = new HashSet<htmlNode>();
             if (path.values == null)
             {
                 if (path.value != null)
                 {
                     string tagName = path.value;
                     while (true)
                     {
                         if (index.Values == null)
                         {
                             if (values.Count == 0) break;
                             else index = values.Pop();
                         }
                         htmlNode node = index.Values[index.Index];
                         if (node.TagName == tagName) newValues.Add(node);
                         if (node.children.count() == 0 || historyNodes.Contains(node))
                         {
                             if (++index.Index == index.Values.Count) index.Values = null;
                         }
                         else
                         {
                             if (++index.Index != index.Values.Count) values.Add(index);
                             historyNodes.Add(node);
                             index.Values = node.children;
                             index.Index = 0;
                         }
                     }
                 }
                 else
                 {
                     while (true)
                     {
                         if (index.Values == null)
                         {
                             if (values.Count == 0) break;
                             else index = values.Pop();
                         }
                         htmlNode node = index.Values[index.Index];
                         newValues.Add(node);
                         if (node.children.count() == 0 || historyNodes.Contains(node))
                         {
                             if (++index.Index == index.Values.Count) index.Values = null;
                         }
                         else
                         {
                             if (++index.Index != index.Values.Count) values.Add(index);
                             historyNodes.Add(node);
                             index.Values = node.children;
                             index.Index = 0;
                         }
                     }
                 }
             }
             else
             {
                 staticHashSet<string> tagNames = path.values;
                 while (true)
                 {
                     if (index.Values == null)
                     {
                         if (values.Count == 0) break;
                         else index = values.Pop();
                     }
                     htmlNode node = index.Values[index.Index];
                     if (tagNames.Contains(node.TagName)) newValues.Add(node);
                     if (node.children.count() == 0 || historyNodes.Contains(node))
                     {
                         if (++index.Index == index.Values.Count) index.Values = null;
                     }
                     else
                     {
                         if (++index.Index != index.Values.Count) values.Add(index);
                         historyNodes.Add(node);
                         index.Values = node.children;
                         index.Index = 0;
                     }
                 }
             }
             if (newValues.Count != 0)
             {
                 return new keyValue<list<htmlNode>, bool>(new list<htmlNode>(newValues), newValues.Count > 1);
             }
         }
         else
         {
             list<htmlNode> newValues = new list<htmlNode>();
             if (path.values == null)
             {
                 if (path.value != null)
                 {
                     string tagName = path.value;
                     while (true)
                     {
                         if (index.Values == null)
                         {
                             if (values.Count == 0) break;
                             else index = values.Pop();
                         }
                         htmlNode node = index.Values[index.Index];
                         if (node.TagName == tagName) newValues.Add(node);
                         if (node.children.count() == 0)
                         {
                             if (++index.Index == index.Values.Count) index.Values = null;
                         }
                         else
                         {
                             if (++index.Index != index.Values.Count) values.Add(index);
                             index.Values = node.children;
                             index.Index = 0;
                         }
                     }
                 }
                 else
                 {
                     while (true)
                     {
                         if (index.Values == null)
                         {
                             if (values.Count == 0) break;
                             else index = values.Pop();
                         }
                         htmlNode node = index.Values[index.Index];
                         newValues.Add(node);
                         if (node.children.count() == 0)
                         {
                             if (++index.Index == index.Values.Count) index.Values = null;
                         }
                         else
                         {
                             if (++index.Index != index.Values.Count) values.Add(index);
                             index.Values = node.children;
                             index.Index = 0;
                         }
                     }
                 }
             }
             else
             {
                 staticHashSet<string> tagNames = path.values;
                 while (true)
                 {
                     if (index.Values == null)
                     {
                         if (values.Count == 0) break;
                         else index = values.Pop();
                     }
                     htmlNode node = index.Values[index.Index];
                     if (tagNames.Contains(node.TagName)) newValues.Add(node);
                     if (node.children.count() == 0)
                     {
                         if (++index.Index == index.Values.Count) index.Values = null;
                     }
                     else
                     {
                         if (++index.Index != index.Values.Count) values.Add(index);
                         index.Values = node.children;
                         index.Index = 0;
                     }
                 }
             }
             if (newValues.Count != 0)
             {
                 return new keyValue<list<htmlNode>, bool>(newValues, newValues.Count > 1);
             }
         }
     }
     return new keyValue<list<htmlNode>, bool>(null, false);
 }
 public Foo(list <int> id, String x, someEnumType y) :
     base(id, x, sizeof(someEnumType), Convert(y))
 {
     //some functionality
 }
示例#34
0
 AssertEquals(list.version, Version.ONE);
 public bar(list <int> id, String x, int size, byte[] bytes)
 {
示例#36
0
 AssertEquals(list.Get(0).version, Version.ONE);
示例#37
0
        static void Main(string[] args)
        {
            List <Categoryz> categoryzs = new List <Categoryz>();

            categoryzs.Add(new Categoryz {
                Id = 1, Name = "Beverages"
            });
            categoryzs.Add(new Categoryz {
                Id = 2, Name = "Condiments"
            });
            categoryzs.Add(new Categoryz {
                Id = 3, Name = "Confections"
            });

            var server = new TcpListener(IPAddress.Parse("127.0.0.1"), 5000);

            server.Start();
            Console.WriteLine("Server started ...");

            while (true)
            {
                var client  = server.AcceptTcpClient();
                var request = client.ReadRequest();
                try{
                    switch (request.Method)
                    {
                    case "create":
                        Console.WriteLine("The client is requesting the method: Create");
                        if (!hasBody(request))
                        {
                            client.sendResponse(7, null);
                            break;
                        }
                        create(request, client);
                        break;

                    case "read":
                        Console.WriteLine("The client is requesting the method: Read");
                        read(request, client);
                        break;

                    case "update":
                        Console.WriteLine("The client is requesting the method: Update");
                        if (!hasBody(request))
                        {
                            client.sendResponse(8, null);
                            break;
                        }

                        update(request, client);
                        break;

                    case "delete":
                        Console.WriteLine("The client is requesting the method: Delete");
                        delete(request, client);
                        break;

                    case "echo":
                        Console.WriteLine("The client is requesting the method: Echo");
                        if (!hasBody(request))
                        {
                            client.sendResponse(7, null);
                            break;
                        }
                        echo(request, client);
                        break;

                    default:
                        errorFunction(request, 1);
                        break;
                    }
                }
                catch {
                    errorFunction(request, 2);
                }

                client.Close();
            }

            void create(Request request, TcpClient client)
            {
                Int32 newDate;

                try {
                    if (request.Path is string)
                    {
                        try {
                            if (Int32.TryParse(request.Date, out newDate))
                            {
                                categoryzs.Add(new Categoryz {
                                    Id = categoryzs.Count + 1, Name = request.Body
                                });
                            }
                            else
                            {
                                errorFunction(request, 0);
                            }
                        }
                        catch {
                            errorFunction(request, 0);
                        }
                    }
                    else
                    {
                        errorFunction(request, 0);
                    }
                }
                catch {
                    errorFunction(request, 0);
                }
            }

            void read(Request request, TcpClient client)
            {
                if (request.Path == "/api/categories")
                {
                    Console.WriteLine("Jeg kører!");
                    var responseObject = new Response {
                        Status = "1 Ok", Body = categoryzs.ToJson()
                    };
                    var responseSerialize = JsonConvert.SerializeObject(responseObject);
                    Console.WriteLine(responseSerialize.ToString());
                    client.SendAnswer(responseSerialize);
                }
                else
                {
                    try
                    {
                        Console.WriteLine("Trying to find readpath ...");
                        var requestPath = request.Path.Split('/')[3];
                        Console.WriteLine("Path found! \n" + requestPath);

                        var intRequestPath = Convert.ToInt32(requestPath);
                        Console.WriteLine("Converted string to integer: " + intRequestPath);

                        Console.WriteLine("Checking if the path exists ...");

                        var doesElementExists = false;
                        foreach (var element in categoryzs)
                        {
                            if (element.Id == intRequestPath)
                            {
                                doesElementExists = true;

                                client.sendResponse(1, categoryzs[0].ToJson());

                                Console.WriteLine("Found request!");
                                //Console.WriteLine(responseSerialize.ToString());
                                Console.WriteLine("Response sent!");
                                break;
                            }
                            else
                            {
                                Console.WriteLine("Request: " + requestPath + ", didn't match element: " + element.Id);
                            }
                        }
                        if (doesElementExists == false)
                        {
                            // Dette er blot en midlertidig måde at sende et response på.
                            client.sendResponse(5, null);
                            Console.WriteLine("Response status sent: 5 Not found\n");
                        }
                    }
                    catch
                    {
                        client.sendResponse(4, null);

                        Console.WriteLine("No path was found");
                        Console.WriteLine("Response status sent: 4 Bad Request\n");
                    }
                }
            }

            void update(Request request, TcpClient client)
            {
                if (request.Path.Contains("/api/categories/"))
                {
                    //Der er en gentagelse af splitmetode her også
                    var requestPathId = Convert.ToInt32(request.Path.Split('/')[3]);

                    //Hvis id som der requestes eksisterer i "categoryz"
                    if (requestPathId <= categoryzs.Count)
                    {
                        //id fra request og id fra category matcher og navnet skiftes med det fra request.
                        categoryzs[requestPathId].Name = request.Body.FromJson <Categoryz>().Name;
                        Console.WriteLine("request-id: " + requestPathId);

                        //Gentagelse af send response. (alle gentagelser skal lige fixes i én metode el. lign.)
                        var responseObject = new Response {
                            Status = "3 updated", Body = categoryzs[requestPathId].ToJson()
                        };
                        var responseSerialize = JsonConvert.SerializeObject(responseObject);
                        Console.WriteLine(responseSerialize.ToString());
                        client.SendAnswer(responseSerialize);
                    }

                    else
                    {
                        //Send fejlkode + Gentagelse af send response
                        var responseObject = new Response {
                            Status = "5 not found"
                        };
                        var responseSerialize = JsonConvert.SerializeObject(responseObject);
                        Console.WriteLine(responseSerialize.ToString());
                        client.SendAnswer(responseSerialize);
                    }
                }
                else
                {
                    Console.WriteLine("Missing Path");
                    //Send fejlkode + Gentagelse af send response
                    var responseObject = new Response {
                        Status = "4 bad request"
                    };
                    var responseSerialize = JsonConvert.SerializeObject(responseObject);
                    Console.WriteLine(responseSerialize.ToString());
                    client.SendAnswer(responseSerialize);
                }

                //Console.WriteLine("Can not handle request yet...");
            }

            void delete(Request request, TcpClient client)
            {
                Console.WriteLine("Methode is under construction..");
                try
                {
                    var requestPath = request.Path.Split('/')[3];
                }
                catch
                {
                    Console.WriteLine("No path wasfound");
                    client.sendResponse(4, null);
                }
            }

            void echo(Request request, TcpClient client, string path = "")
            {
                client.sendResponse(1, request.Body);
                Console.WriteLine("Can not handle request yet...");
            }

            bool hasBody(Request request)
            {
                var tempHasBody = true;

                if (request.Body == null)
                {
                    tempHasBody = false;
                }

                return(tempHasBody);
            }

            void errorFunction(Request request, int sender)
            {
                var errors = new list <string> {
                };

                if (sender == 1)
                {
                    errors.Add("illegal method");
                }
                if (sender == 2)
                {
                    errors.Add("missing method");
                }

                try{ if (request.Path is string)
                     {
                     }
                }
                catch { errors.Add("missing path"); }

                try{ if (request.Path is string)
                     {
                     }
                }
                catch { errors.Add("missing path"); }
            }
        }
示例#38
0
 /// <summary>
 /// GET查询字符串获取器
 /// </summary>
 /// <param name="encoding">编码格式</param>
 /// <param name="memberCount">成员数量</param>
 public reflectionQueryGetter(Encoding encoding, int memberCount)
 {
     this.encoding = encoding;
     querys        = new list <string>(memberCount).Unsafer;
 }
示例#39
0
 AddSuppressOperationsSlow(list, node, ref nextOperationCopy);
示例#40
0
 public void function()
 {
     int funnum, drinknum;
     string name, iden;
     list wow = new list();
     while(true){
         Console.WriteLine("할일 선택");
         Console.WriteLine("1.넣기");
         Console.WriteLine("2.빼기");
         Console.WriteLine("3.조회");
         Console.WriteLine("4.종료");
         funnum = Int32.Parse(Console.ReadLine());
         if (funnum == 1)
         {
             Console.WriteLine("넣을 술의 종류는?");
             Console.WriteLine("1. 와인, 2. 소주, 3. 맥주");
             drinknum = Int32.Parse(Console.ReadLine());
             if (drinknum == 1)
             {
                 Console.WriteLine("넣을 와인의 이름은?");
                 name="와인 :"+Console.ReadLine();
                 wow.Name=name;
                 Console.WriteLine("넣을 와인의 연식은?");
                 iden=Console.ReadLine();
                 wow.Iden = iden;
                 drinklist.Add(wow);
             }
             else if (drinknum == 2)
             {
                 Console.WriteLine("넣을 소주의 이름은?");
                 name ="소주 :" +Console.ReadLine();
                 wow.Name = name;
                 Console.WriteLine("넣을 소주의 도수는?");
                 iden = Console.ReadLine();
                 wow.Iden = iden;
                 drinklist.Add(wow); ;
             }
             else
             {
                 Console.WriteLine("넣을 맥주의 이름은?");
                 name ="맥주 :" +Console.ReadLine();
                 wow.Name = name;
                 Console.WriteLine("넣을 맥주의 종류는?");
                 iden = Console.ReadLine();
                 wow.Iden = iden;
                 drinklist.Add(wow);
             }
         }
         if (funnum == 2)
         {
                 Console.WriteLine("뺄 술의 이름은?");
                 name = Console.ReadLine();
                 for(int i=0;i<drinklist.Count;i++)
                 {
                     if (drinklist[i].Name == name)
                     {
                         drinklist.RemoveAt(i);
                     }
                     else
                     {
                         Console.WriteLine("냉장고에 없는 물건");
                         break;
                     }
                 }
         }
         else if (funnum == 3)
         {
             foreach (var item in drinklist)
             {
                 Console.WriteLine(item.Name + " " + item.Iden);
             }
         }
         else if (funnum == 4)
             break;
     }
 }
示例#41
0
 Walk(list[i]);
示例#42
0
 validate(list, serializer);
示例#43
0
 public void Reset()
 {
     _rest  = _list;
     _state = ListEnumState.BeforeFirst;
 }
示例#44
0
        /// <summary>
        /// Save list
        /// </summary>
        public static int SaveList(int CustomerId, string ListName)
        {
            BrightPlatformEntities m_objBrightPlatformEntity = new BrightPlatformEntities(UserSession.EntityConnection);
            list objList = new list() {
                customer_id = CustomerId,
                list_name = ListName,
                matched = false,
                created_by = UserSession.CurrentUser.UserId,
                created_on = DateTime.Now
            };

            m_objBrightPlatformEntity.lists.AddObject(objList);
            m_objBrightPlatformEntity.SaveChanges();

            return objList.id;
        }
示例#45
0
        private void ProcessManyToManyReference(
            Entity entity,
            DirectedReference directedReference,
            Action <object> addItem,
            Dictionary <ITable, int> manyToManySameTableProcessingCounts,
            string collectionCascade,
            string lazy,
            string orderByClause,
            bool inverse)
        {
            if (directedReference.FromEndEnabled == false)
            {
                return;
            }

            ITable referenceMappedTable = directedReference.Reference.MappedTable();

            ITable      fromPrimaryMappedTable = EntityMapper.GetPrimaryTable(entity);
            ITable      toPrimaryMappedTable   = EntityMapper.GetPrimaryTable(directedReference.ToEntity);
            Cardinality cardinalityPrimary;
            Cardinality cardinalityForeign;
            IKey        mainKey;
            IKey        associationKey;
            ITable      associationTable = entity.GetAssociationTable(directedReference.ToEntity, out cardinalityPrimary, out cardinalityForeign, out mainKey, out associationKey);

            key            keyNode          = new key();
            List <IColumn> fromInPrimaryKey = new List <IColumn>();
            List <IColumn> toInPrimaryKey   = new List <IColumn>();

            if (fromPrimaryMappedTable == toPrimaryMappedTable)
            {
                // This many-to-many relationship is to the same table
                if (manyToManySameTableProcessingCounts.ContainsKey(toPrimaryMappedTable))
                {
                    int index = manyToManySameTableProcessingCounts[toPrimaryMappedTable];
                    index++;
                    fromInPrimaryKey.AddRange(referenceMappedTable.Relationships.Where(t => t.PrimaryTable == fromPrimaryMappedTable).ElementAt(index).PrimaryKey.Columns);
                    toInPrimaryKey.AddRange(referenceMappedTable.Relationships.Where(t => t.PrimaryTable == toPrimaryMappedTable).ElementAt(index).ForeignKey.Columns);
                    manyToManySameTableProcessingCounts[toPrimaryMappedTable] = index;
                }
                else
                {
                    fromInPrimaryKey.AddRange(referenceMappedTable.Relationships.Where(t => t.PrimaryTable == fromPrimaryMappedTable).ElementAt(0).PrimaryKey.Columns);
                    toInPrimaryKey.AddRange(referenceMappedTable.Relationships.Where(t => t.PrimaryTable == toPrimaryMappedTable).ElementAt(0).ForeignKey.Columns);
                    manyToManySameTableProcessingCounts.Add(toPrimaryMappedTable, 0);
                }
            }
            else
            {
                foreach (var coll in referenceMappedTable.Relationships.Where(t => t.PrimaryTable == fromPrimaryMappedTable).Select(r => r.ForeignKey.Columns))
                {
                    foreach (var c in coll)
                    {
                        fromInPrimaryKey.Add(c);
                    }
                }

                foreach (var coll in referenceMappedTable.Relationships.Where(t => t.PrimaryTable == toPrimaryMappedTable).Select(r => r.ForeignKey.Columns))
                {
                    foreach (var c in coll)
                    {
                        toInPrimaryKey.Add(c);
                    }
                }
            }

            if (fromInPrimaryKey.Count() == 1)
            {
                keyNode.column1 = fromInPrimaryKey.First().Name.BackTick();
            }
            else
            {
                foreach (var columnNode in GetColumnNodes(fromInPrimaryKey))
                {
                    keyNode.AddColumn(columnNode);
                }
            }

            manytomany manyToManyNode = new manytomany();

            manyToManyNode.@class = directedReference.ToEntity.Name;

            if (toInPrimaryKey.Count() == 1)
            {
                manyToManyNode.column = toInPrimaryKey.First().Name.BackTick();
            }
            else
            {
                foreach (var columnNode in GetColumnNodes(toInPrimaryKey))
                {
                    keyNode.AddColumn(columnNode);
                }
            }

            collectionFetchMode collFetchMode;

            if (directedReference.Entity1IsFromEnd)
            {
                collFetchMode = (collectionFetchMode)Enum.Parse(typeof(collectionFetchMode), directedReference.Reference.GetReferenceEnd1CollectionFetchMode().ToString(), true);
            }
            else
            {
                collFetchMode = (collectionFetchMode)Enum.Parse(typeof(collectionFetchMode), directedReference.Reference.GetReferenceEnd2CollectionFetchMode().ToString(), true);
            }

            AssociationType type = NHCollections.GetAssociationType(directedReference);

            switch (type)
            {
            case AssociationType.None:
                Log.WarnFormat("No association type was set on reference {0} for the end {1}. This is usually an error.", directedReference.Reference.Name, directedReference.Entity1IsFromEnd ? "One" : "Two");
                return;

            case AssociationType.Set:
                set setNode = CreateSetNode(directedReference, keyNode, collectionCascade, collFetchMode, lazy, inverse);
                setNode.table = referenceMappedTable.Name.BackTick();
                setNode.Item  = manyToManyNode;

                if (orderByClause.Length > 0)
                {
                    setNode.orderby = orderByClause;
                }

                addItem(setNode);
                break;

            case AssociationType.Bag:
                bag bagNode = CreateBagNode(directedReference, keyNode, collectionCascade, collFetchMode, lazy, inverse);
                bagNode.table = referenceMappedTable.Name.BackTick();
                bagNode.Item  = manyToManyNode;

                if (orderByClause.Length > 0)
                {
                    bagNode.orderby = orderByClause;
                }

                addItem(bagNode);
                break;

            case AssociationType.Map:
                map mapNode = CreateMapNode(directedReference, keyNode, collectionCascade, collFetchMode, lazy, inverse);
                mapNode.table = referenceMappedTable.Name.BackTick();
                mapNode.Item  = new index
                {
                    column1 = NHCollections.GetIndexColumnName(directedReference),
                    type    = NHCollections.GetIndexColumnTypeName(directedReference, toPrimaryMappedTable /*fromPrimaryMappedTable*/)
                };
                mapNode.Item1 = manyToManyNode;

                if (orderByClause.Length > 0)
                {
                    mapNode.orderby = orderByClause;
                }

                addItem(mapNode);
                break;

            case AssociationType.List:
                list listNode = CreateListNode(directedReference, keyNode, collectionCascade, collFetchMode, lazy, inverse);
                listNode.table = referenceMappedTable.Name.BackTick();
                listNode.Item  = new index
                {
                    column1 = NHCollections.GetIndexColumnName(directedReference),
                };
                listNode.Item1 = manyToManyNode;

                if (orderByClause.Length > 0)
                {
                    listNode.orderby = orderByClause;
                }

                addItem(listNode);
                break;

            // case AssociationType.IDBag:
            //     throw new NotImplementedException(
            //         string.Format("Have not implemented {0} association type for Many To Many relationships", type));
            default:
                throw new NotImplementedException("AssociationType not handled yet: " + type.ToString());
            }
        }
示例#46
0
 public void Stat(string nick, string message, string host)
 {
     if (Module.GetConfig(channel, "Statistics.Enabled", false))
     {
         list user = null;
         lock (data)
         {
             foreach (list item in data)
             {
                 if (nick.ToUpper() == item.user.ToUpper())
                 {
                     user = item;
                     break;
                 }
             }
         }
         if (user == null)
         {
             user = new list();
             user.user = nick;
             user.logging_since = DateTime.Now;
             lock (data)
             {
                 data.Add(user);
             }
         }
         user.URL = core.Host.Host2Name(host);
         user.messages++;
         Module.SetConfig(channel, "HTML.Update", true);
         changed = true;
         Stored = false;
     }
 }
示例#47
0
 public static list ToDoubleList(list src)
 {
     list ret = new list();
     double entry;
     for (int i = 0; i < src.Data.Length - 1; i++)
     {
         if (double.TryParse(src.Data[i].ToString(), out entry))
         {
             ret.Add(entry);
         }
     }
     return ret;
 }
 /// <summary>
 /// 清除表单数据
 /// </summary>
 /// <param name="values">表单数据集合</param>
 private static void clear(list<value> values)
 {
     int count = values.Count;
     if (count != 0)
     {
         value[] formArray = values.array;
         for (int index = 0; index != count; ++index) formArray[index].Clear();
         values.Empty();
     }
 }
示例#49
0
 public static list ToDoubleList(list src)
 {
     list ret = new list();
     double entry;
     for (int i = 0; i < src.Data.Length - 1; i++)
     {
         if (double.TryParse(src.Data[i].ToString(), NumberStyles.Float, Culture.NumberFormatInfo, out entry))
         {
             ret.Add(entry);
         }
     }
     return ret;
 }
示例#50
0
        private void ProcessManyToOneReference(
            Entity entity,
            DirectedReference directedReference,
            Action <object> addItem,
            string cascade,
            string collectionCascade,
            string lazy,
            string orderByClause,
            bool inverse)
        {
            if (directedReference.FromEndEnabled == false)
            {
                return;
            }

            ITable referenceMappedTable = directedReference.Reference.MappedTable();
            DirectedRelationship directedRelationship = null;

            if (referenceMappedTable == null)
            {
                directedRelationship = GetDirectedMappedRelationship(entity, directedReference.Reference);
            }

            if (directedReference.FromEndCardinality == Cardinality.One)
            {
                fetchMode fetchMode;
                bool      insert;
                bool      update;

                if (directedReference.Entity1IsFromEnd)
                {
                    fetchMode = (fetchMode)Enum.Parse(typeof(fetchMode), directedReference.Reference.GetReferenceEnd1FetchMode().ToString(), true);
                    insert    = directedReference.Reference.GetReferenceEnd1Insert();
                    update    = directedReference.Reference.GetReferenceEnd1Update();
                }
                else
                {
                    fetchMode = (fetchMode)Enum.Parse(typeof(fetchMode), directedReference.Reference.GetReferenceEnd2FetchMode().ToString(), true);
                    insert    = directedReference.Reference.GetReferenceEnd2Insert();
                    update    = directedReference.Reference.GetReferenceEnd2Update();
                }
                manytoone manyToOneNode;

                if (referenceMappedTable == null)
                {
                    manyToOneNode = CreateManyToOneNode(directedReference, directedRelationship, cascade);
                }
                else
                {
                    manyToOneNode = CreateManyToOneNode(directedReference, referenceMappedTable);
                }

                manyToOneNode.fetch          = fetchMode;
                manyToOneNode.fetchSpecified = true;
                manyToOneNode.insert         = insert;
                manyToOneNode.update         = update;

                addItem(manyToOneNode);
            }
            else
            {
                key keyNode = new key();

                if (referenceMappedTable == null &&
                    directedRelationship.ToKey.Columns.Count > 1)
                {
                    foreach (var columnNode in GetColumnNodes(directedRelationship.ToKey.Columns))
                    {
                        keyNode.AddColumn(columnNode);
                    }
                }
                else if (referenceMappedTable != null)
                {
                    ITable toPrimaryMappedTable  = EntityMapper.GetPrimaryTable(directedReference.ToEntity);
                    var    toColumnsInPrimaryKey = referenceMappedTable.Relationships.First(t => t.PrimaryTable == toPrimaryMappedTable || t.ForeignTable == toPrimaryMappedTable).ForeignKey.Columns;

                    foreach (var columnNode in GetColumnNodes(toColumnsInPrimaryKey))
                    {
                        keyNode.AddColumn(columnNode);
                    }
                }
                else
                {
                    keyNode.column1 = directedRelationship.ToKey.Columns[0].Name.BackTick();
                }

                onetomany oneToManyNode = new onetomany();
                oneToManyNode.@class = directedReference.ToEntity.Name;

                collectionFetchMode collFetchMode;

                if (directedReference.Entity1IsFromEnd)
                {
                    collFetchMode = (collectionFetchMode)Enum.Parse(typeof(collectionFetchMode), directedReference.Reference.GetReferenceEnd1CollectionFetchMode().ToString(), true);
                }
                else
                {
                    collFetchMode = (collectionFetchMode)Enum.Parse(typeof(collectionFetchMode), directedReference.Reference.GetReferenceEnd2CollectionFetchMode().ToString(), true);
                }

                AssociationType type = NHCollections.GetAssociationType(directedReference);

                switch (type)
                {
                case AssociationType.None:
                    Log.WarnFormat("No association type was set on reference {0} for the end {1}. This is usually an error.", directedReference.Reference.Name, directedReference.Entity1IsFromEnd ? "1" : "2");
                    return;

                case AssociationType.Set:
                    var set = CreateSetNode(directedReference, keyNode, collectionCascade, collFetchMode, lazy, inverse);
                    set.Item = oneToManyNode;

                    if (orderByClause.Length > 0)
                    {
                        set.orderby = orderByClause;
                    }

                    addItem(set);
                    break;

                case AssociationType.Map:
                    var mapNode = CreateMapNode(directedReference, keyNode, collectionCascade, collFetchMode, lazy, inverse);
                    mapNode.Item = new index
                    {
                        column1 = NHCollections.GetIndexColumnName(directedReference),
                        type    = NHCollections.GetIndexColumnTypeName(directedReference, EntityMapper.GetPrimaryTable(directedReference.ToEntity))
                    };
                    mapNode.Item1 = oneToManyNode;

                    if (orderByClause.Length > 0)
                    {
                        mapNode.orderby = orderByClause;
                    }

                    addItem(mapNode);
                    break;

                case AssociationType.Bag:
                    var bag = CreateBagNode(directedReference, keyNode, collectionCascade, collFetchMode, lazy, inverse);
                    bag.Item = oneToManyNode;

                    if (orderByClause.Length > 0)
                    {
                        bag.orderby = orderByClause;
                    }

                    addItem(bag);
                    break;

                case AssociationType.List:
                    list listNode = CreateListNode(directedReference, keyNode, collectionCascade, collFetchMode, lazy, inverse);
                    listNode.Item = new index {
                        column1 = NHCollections.GetIndexColumnName(directedReference)
                    };
                    listNode.Item1 = oneToManyNode;

                    if (orderByClause.Length > 0)
                    {
                        listNode.orderby = orderByClause;
                    }

                    addItem(listNode);
                    break;

                case AssociationType.IDBag:
                    idbag idbagNode = CreateIdBagNode(directedReference, keyNode, collectionCascade, collFetchMode, lazy, inverse);
                    idbagNode.collectionid = new collectionid
                    {
                        column1   = NHCollections.GetIndexColumnName(directedReference),
                        generator = new generator {
                            @class = "sequence"
                        },
                        type = NHCollections.GetIndexColumnTypeName(directedReference, EntityMapper.GetPrimaryTable(directedReference.ToEntity))
                    };

                    addItem(idbagNode);
                    break;

                default:
                    throw new ArgumentOutOfRangeException("AssociationType not handled yet: " + type.ToString());
                }
            }
        }
示例#51
0
 public static void Main()
 {
     list <int>[,] x = new list <int> [10, 10];
     x[0, 0]         = Nil <int> .single;
 }
示例#52
0
 /// <summary>
 /// 解析HTML节点并插入
 /// </summary>
 /// <param name="index">插入位置</param>
 /// <param name="html"></param>
 /// <returns>是否插入成功</returns>
 public bool InsertChild(int index, string html)
 {
     bool isInsert = false;
     if (TagName != null && !web.html.NonanalyticTagNames.Contains(TagName))
     {
         htmlNode value = new htmlNode(html);
         if (value.children != null)
         {
             foreach (htmlNode child in value.children) child.Parent = this;
             if (children == null) children = value.children;
             else if (index >= children.Count) children.Add(value.children);
             else children.Insert(index < 0 ? 0 : index, value.children);
         }
         isInsert = true;
     }
     return isInsert;
 }
示例#53
0
 /// <summary>
 /// 替换子节点
 /// </summary>
 /// <param name="oldNode">待替换的子节点</param>
 /// <param name="newNode">新的子节点</param>
 /// <returns>是否存在待替换的子节点</returns>
 public bool ReplaceChild(htmlNode oldNode, htmlNode newNode)
 {
     bool isReplace = false;
     if (oldNode != null && newNode != null)
     {
         int oldIndex = this[oldNode];
         if (oldIndex != -1)
         {
             if (newNode.TagName == string.Empty)
             {
                 oldNode.Parent = null;
                 if (newNode.children == null) children.RemoveAt(oldIndex);
                 else
                 {
                     foreach (htmlNode value in newNode.children) value.Parent = this;
                     if (newNode.children.Count == 1) children[oldIndex] = newNode.children[0];
                     else if (oldIndex == children.Count - 1)
                     {
                         children.RemoveAt(oldIndex);
                         children.Add(newNode.children);
                     }
                     else
                     {
                         list<htmlNode>.unsafer values = new list<htmlNode>(children.Count + newNode.children.Count).Unsafer;
                         int newIndex = 0;
                         while (newIndex != oldIndex) values.Add(children[newIndex++]);
                         values.List.Add(newNode.children);
                         for (oldIndex = children.Count; ++newIndex != oldIndex; values.Add(children[newIndex])) ;
                         children = values.List;
                     }
                 }
                 newNode.children = null;
                 isReplace = true;
             }
             else if (!newNode.IsNode(this))
             {
                 int newIndex = this[newNode];
                 if (newIndex == -1)
                 {
                     if (newNode.Parent != null) newNode.Parent.RemoveChild(newNode);
                     newNode.Parent = this;
                     children[oldIndex] = newNode;
                     oldNode.Parent = null;
                 }
                 else
                 {
                     children[oldIndex] = newNode;
                     oldNode.Parent = null;
                     children.RemoveAt(newIndex);
                 }
                 isReplace = true;
             }
         }
     }
     return isReplace;
 }
示例#54
0
            public list GetSublist(int start, int end)
            {

                object[] ret;

                // Take care of neg start or end's
                // NOTE that either index may still be negative after
                // adding the length, so we must take additional
                // measures to protect against this. Note also that
                // after normalisation the negative indices are no
                // longer relative to the end of the list.

                if (start < 0)
                {
                    start = m_data.Length + start;
                }

                if (end < 0)
                {
                    end = m_data.Length + end;
                }

                // The conventional case is start <= end
                // NOTE that the case of an empty list is
                // dealt with by the initial test. Start
                // less than end is taken to be the most
                // common case.

                if (start <= end)
                {

                    // Start sublist beyond length
                    // Also deals with start AND end still negative
                    if (start >= m_data.Length || end < 0)
                    {
                        return new list();
                    }

                    // Sublist extends beyond the end of the supplied list
                    if (end >= m_data.Length)
                    {
                        end = m_data.Length - 1;
                    }

                    // Sublist still starts before the beginning of the list
                    if (start < 0)
                    {
                        start = 0;
                    }

                    ret = new object[end - start + 1];

                    Array.Copy(m_data, start, ret, 0, end - start + 1);

                    return new list(ret);

                }

                // Deal with the segmented case: 0->end + start->EOL

                else
                {

                    list result = null;

                    // If end is negative, then prefix list is empty
                    if (end < 0)
                    {
                        result = new list();
                        // If start is still negative, then the whole of
                        // the existing list is returned. This case is
                        // only admitted if end is also still negative.
                        if (start < 0)
                        {
                            return this;
                        }

                    }
                    else
                    {
                        result = GetSublist(0,end);
                    }

                    // If start is outside of list, then just return
                    // the prefix, whatever it is.
                    if (start >= m_data.Length)
                    {
                        return result;
                    }

                    return result + GetSublist(start, Data.Length);

                }
            }
示例#55
0
 doGetTypes(list, root);