Beispiel #1
0
        void MasterExecSave()
        {
            int i = -1;

            _dataService.UpdateLightZone(MasterCurrentObject, (updatedCount, error) =>
            {
                if (error != null)
                {
                    return;
                }                              // Report error here
                i = updatedCount;
            });

            MasterObjectButtonsVisibility = Visibility.Collapsed;
            MasterListCurtainVisibility   = Visibility.Collapsed;
            DetailListCurtainVisibility   = Visibility.Collapsed;
            ProxyListCurtainVisibility    = Visibility.Collapsed;


            if (MasterAddMode)
            {
                MasterList.Add(MasterCurrentObject);
                MasterSelectedItem = MasterCurrentObject;
            }
            //    if (MasterEditMode) //in EditMode MasterSelectedItem always not null
            //    {
            //        if (!partitionChanged)
            //        {
            //            MasterList[msix] = MasterCurrentObject;
            //            //MasterSelectedItem.RaiseIsLinkedChanged();
            //            MasterSelectedItem = MasterCurrentObject;
            //            //if (savedDsix != -1)
            //            //    DetailSelectedItem = DetailList[savedDsix];
            //        }
            //        else
            //        {
            //            MasterList.Remove(MasterSelectedItem);
            //            //DetailContentVisibility = Visibility.Hidden;
            //            partitionChanged = false;
            //        }
            //    }

            MasterAddMode  = false;
            MasterEditMode = false;
            MasterRemoveCmd.RaiseCanExecuteChanged();
            MasterAddCmd.RaiseCanExecuteChanged();

            //    //if (DetailSelectedItem != null)
            //    //{
            //    //    // при выполнении Save происходит замена .net объекта в MasterList
            //    //    // необходимо восстановить Visual State
            //    //    LightElement letmp = MasterSelectedItem;
            //    //    ControlChannel tmp = DetailSelectedItem;
            //    //    DetailSelectedItem = null;
            //    //    DetailSelectedItem = tmp;
            //    //    MasterSelectedItem = letmp;
            //    //}
            //}
            MessengerInstance.Send("", AppContext.UnBlockUIMsg);
        }
        private void UpdateMastets()
        {
            var selectedMaster = SelectedMaster?.Id;

            MasterList.Clear();
            if (_showAllMasters)
            {
                foreach (var master in _requestService.GetMasters(null))
                {
                    MasterList.Add(master);
                }
                SelectedMaster = MasterList.FirstOrDefault(m => m.Id == selectedMaster);
            }
            else
            {
                if (_selectedHouseId.HasValue)
                {
                    foreach (var master in _requestService.GetWorkersByHouseAndService(_selectedHouseId.Value, SelectedParentService.Id))
                    {
                        MasterList.Add(master);
                    }
                    SelectedMaster = MasterList.FirstOrDefault();
                }
            }
        }
Beispiel #3
0
 /// <summary>
 /// Add package info without change Dirty state of itself
 /// </summary>
 /// <param name="info"></param>
 public void AddInSilence(PackageInfo info)
 {
     if (!Exists(info))
     {
         MasterList.Add(info);
     }
 }
Beispiel #4
0
 /// <summary>
 /// Add package info and set Dirty state to True
 /// </summary>
 /// <param name="info"></param>
 public void Add(PackageInfo info)
 {
     if (!Exists(info))
     {
         MasterList.Add(info);
         IsDirty = true;
     }
 }
Beispiel #5
0
        //AttentionVM attentionVM;

        void MasterExecSave()
        {
            int  i           = -1;
            bool modeChanged = false;

            if (MasterCurrentObject.Mode != MasterCurrentObject.OldMode)
            {
                modeChanged = true;
            }
            _dataService.UpdateEventDevice(MasterCurrentObject, (updatedCount, error) =>
            {
                if (error != null)
                {
                    return;
                }                              // Report error here
                i = updatedCount;
            });

            MasterObjectButtonsVisibility = Visibility.Collapsed;
            MasterListCurtainVisibility   = Visibility.Collapsed;
            DetailListCurtainVisibility   = Visibility.Collapsed;


            if (MasterAddMode)
            {
                MasterSelectorSelectedItem = null;

                MasterList.Add(MasterCurrentObject);
                MasterSelectedItem   = MasterCurrentObject;
                MasterListVisibility = Visibility.Visible;
            }
            if (MasterEditMode) //in EditMode MasterSelectedItem always not null
            {
                MasterList[msix]   = MasterCurrentObject;
                MasterSelectedItem = MasterCurrentObject;
                if (!modeChanged)
                {
                    if (savedDsix != -1)
                    {
                        DetailSelectedItem = DetailList[savedDsix];
                    }
                }
            }

            MasterAddMode  = false;
            MasterEditMode = false;
            MasterCurrentObject.IsEditMode = false;
            MasterCurrentObject.IsAddMode  = false;
            MasterRemoveCmd.RaiseCanExecuteChanged();
            MasterAddCmd.RaiseCanExecuteChanged();

            MessengerInstance.Send("", AppContext.UnBlockUIMsg);
        }
Beispiel #6
0
 public void RemovePunctuation(string[] stringArray)
 {
     foreach (string item in stringArray)
     {
         string[] newItem = item.Split(Punctuation);
         foreach (string foo in newItem)
         {
             if (foo != "." && foo != "," && foo != "(" && foo != ")" && foo != "!" && foo != "?" && foo != " " && foo != "")
             {
                 MasterList.Add(foo);
             }
         }
     }
 }
Beispiel #7
0
        void Load()
        {
            if (AppContext.ControlSpace != null)
            {
                _dataService.GetLE_TypeList(AppContext.ControlSpace, (data, error) =>
                {
                    if (error != null)
                    {
                        return;
                    }                              // Report error here
                    MasterSelectorList = data;
                });

                _dataService.GetPartitions((data, error) =>
                {
                    if (error != null)
                    {
                        return;
                    }                              // Report error here
                    Partitions = new List <Partition>(data);
                });

                _dataService.GetLightElements(AppContext.ControlSpace, AppContext.Partition, (data, error) =>
                {
                    if (error != null)
                    {
                        return;
                    }                              // Report error here
                    foreach (LightElement le in data)
                    {
                        LightElementVM leVM  = new LightElementVM(le);
                        leVM.IsLinked        = le.ControlChannel != null;
                        leVM.IsLinkedChanged = LinkingLogic;
                        MasterList.Add(leVM);
                    }
                });

                _dataService.GetControlChannelList(AppContext.ControlSpace, AppContext.Partition, (data, error) =>
                {
                    if (error != null)
                    {
                        return;
                    }                              // Report error here
                    DetailList = data;
                });
                MasterObjectPanelVisibility = Visibility.Collapsed;
            }
        }
        private void SlaveList_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            switch (e.Action)
            {
            case NotifyCollectionChangedAction.Add:
                foreach (var item in e.NewItems)
                {
                    MasterList.Add((T)item);
                }

                break;

            case NotifyCollectionChangedAction.Move:
                // We don't care if an item is moved.
                break;

            case NotifyCollectionChangedAction.Remove:
                foreach (var item in e.NewItems)
                {
                    MasterList.Remove((T)item);
                }

                break;

            case NotifyCollectionChangedAction.Replace:
                T   oldItem = (T)e.OldItems[0];
                T   newItem = (T)e.NewItems[0];
                int index   = MasterList.IndexOf(oldItem);

                MasterList[index] = newItem;

                break;

            case NotifyCollectionChangedAction.Reset:
                foreach (var item in e.NewItems)
                {
                    MasterList.Remove((T)item);
                }

                break;

            default:
                break;
            }
        }
        /// <summary>
        /// Gets a nullable type symbol for a type token, if one exists.
        /// </summary>
        /// <param name="typeTokenReference">A reference to the type token.</param>
        /// <param name="typeTokens">The tokens within the type token.</param>
        /// <param name="isExpression">Indicates whether this is in an is expression.</param>
        /// <param name="startIndex">The start index within the symbols.</param>
        private void GetTypeTokenNullableTypeSymbol(
            Reference<ICodePart> typeTokenReference, MasterList<CsToken> typeTokens, bool isExpression, ref int startIndex)
        {
            Param.AssertNotNull(typeTokenReference, "typeTokenReference");
            Param.AssertNotNull(typeTokens, "typeTokens");
            Param.Ignore(isExpression);
            Param.AssertGreaterThanOrEqualToZero(startIndex, "startIndex");

            // Look at the type of the next non-whitespace character and see if it is a nullable type symbol.
            int index = this.GetNextCodeSymbolIndex(startIndex);
            if (index == -1)
            {
                throw this.CreateSyntaxException();
            }

            Symbol symbol = this.symbols.Peek(index);
            if (symbol.SymbolType == SymbolType.QuestionMark)
            {
                // If this type token resides within an 'is' expression, check to make sure
                // that this is actually a nullable type symbol. In some cases, this can be a
                // conditional question mark, not a nullable type symbol.
                if (!isExpression || this.IsNullableTypeSymbolFromIsExpression(index))
                {
                    // Add any whitspace.
                    symbol = this.symbols.Peek(startIndex);
                    while (symbol != null &&
                        (symbol.SymbolType == SymbolType.WhiteSpace ||
                        symbol.SymbolType == SymbolType.EndOfLine ||
                        symbol.SymbolType == SymbolType.SingleLineComment ||
                        symbol.SymbolType == SymbolType.MultiLineComment ||
                        symbol.SymbolType == SymbolType.PreprocessorDirective))
                    {
                        typeTokens.Add(this.ConvertSymbol(symbol, TokenTypeFromSymbolType(symbol.SymbolType), typeTokenReference));
                        symbol = this.symbols.Peek(++startIndex);
                    }

                    // Add the nullable type symbol.
                    typeTokens.Add(new CsToken(
                        symbol.Text, CsTokenType.NullableTypeSymbol, symbol.Location, typeTokenReference, this.symbols.Generated));
                    ++startIndex;
                }
            }
        }
        /// <summary>
        /// Gets the dereference symbols from a type token.
        /// </summary>
        /// <param name="typeTokenReference">A reference to the type token.</param>
        /// <param name="typeTokens">The type tokens list.</param>
        /// <param name="startIndex">The start index within the symbols list.</param>
        /// <returns>Returns true if there were one or more dereference symbols.</returns>
        private bool GetTypeTokenDereferenceSymbols(Reference<ICodePart> typeTokenReference, MasterList<CsToken> typeTokens, ref int startIndex)
        {
            Param.AssertNotNull(typeTokenReference, "typeTokenReference");
            Param.AssertNotNull(typeTokens, "typeTokens");
            Param.AssertGreaterThanOrEqualToZero(startIndex, "startIndex");

            bool foundDereferenceSymbol = false;

            while (true)
            {
                // Look at the type of the next non-whitespace character.
                int index = this.GetNextCodeSymbolIndex(startIndex);
                if (index == -1)
                {
                    break;
                }

                // If the next character is not a deference, break now.
                Symbol symbol = this.symbols.Peek(index);
                if (symbol.SymbolType != SymbolType.Multiplication)
                {
                    break;
                }

                // Add any whitspace.
                symbol = this.symbols.Peek(startIndex);
                while (symbol != null &&
                    (symbol.SymbolType == SymbolType.WhiteSpace ||
                    symbol.SymbolType == SymbolType.EndOfLine ||
                    symbol.SymbolType == SymbolType.SingleLineComment ||
                    symbol.SymbolType == SymbolType.MultiLineComment ||
                    symbol.SymbolType == SymbolType.PreprocessorDirective))
                {
                    typeTokens.Add(this.ConvertSymbol(symbol, TokenTypeFromSymbolType(symbol.SymbolType), typeTokenReference));
                    symbol = this.symbols.Peek(++startIndex);
                }

                // Add the dereference symbol.
                typeTokens.Add(new OperatorSymbol(
                    symbol.Text, OperatorCategory.Reference, OperatorType.Dereference, symbol.Location, typeTokenReference, this.symbols.Generated));
                ++startIndex;

                // Nullable types are not allowed with dereferences.
                foundDereferenceSymbol = true;
            }

            return foundDereferenceSymbol;
        }
        /// <summary>
        /// Gets an xml header.
        /// </summary>
        /// <param name="elementReference">A reference to the element being created.</param>
        /// <returns>Returns the header or null if there is no header.</returns>
        private XmlHeader GetXmlHeader(Reference<ICodePart> elementReference)
        {
            Param.AssertNotNull(elementReference, "elementReference");

            // Get the first symbol and make sure it is the right type.
            int index = 1;
            Symbol firstSymbol = this.symbols.Peek(index);
            Debug.Assert(firstSymbol != null && firstSymbol.SymbolType == SymbolType.XmlHeaderLine, "Expected an xml documentation header line");

            // Marks the end of the header.
            int end = -1;
            int endOfLineCount = 0;

            var xmlHeaderReference = new Reference<ICodePart>();

            // Loop until the entire header is found.
            Symbol symbol = firstSymbol;
            while (symbol != null)
            {
                if (symbol.SymbolType == SymbolType.XmlHeaderLine)
                {
                    // This type of token belongs in the header.
                    end = index;
                    endOfLineCount = 0;
                }
                else if (symbol.SymbolType == SymbolType.EndOfLine)
                {
                    if (++endOfLineCount > 1)
                    {
                        // If there are two newlines in a row, this is the
                        // end of the Xml header.
                        break;
                    }
                }
                else if (symbol.SymbolType == SymbolType.WhiteSpace ||
                    symbol.SymbolType == SymbolType.SingleLineComment)
                {
                    endOfLineCount = 0;
                }
                else
                {
                    // This is the end of the header.
                    break;
                }

                // Advance the index and get the next symbol.
                symbol = this.symbols.Peek(++index);
            }

            // Make sure we've advanced at least one symbol.
            Debug.Assert(end != -1, "Should have advanced at least one symbol");

            // Add all of the symbols for the header to a token list.
            MasterList<CsToken> headerTokens = new MasterList<CsToken>();
            for (int i = 1; i <= end; ++i)
            {
                this.symbols.Advance();
                Debug.Assert(this.symbols.Current != null, "The current symbol should not be null");

                headerTokens.Add(this.ConvertSymbol(this.symbols.Current, TokenTypeFromSymbolType(this.symbols.Current.SymbolType), xmlHeaderReference));
            }

            // Get the location of the header.
            CodeLocation location = CodeLocation.Join(firstSymbol.Location, this.symbols.Current.Location);

            // Create the Xml header object.
            var xmlHeader = new XmlHeader(headerTokens, location, elementReference, this.symbols.Generated);
            xmlHeaderReference.Target = xmlHeader;

            return xmlHeader;
        }
Beispiel #12
0
 private void GetTypeTokenBaseName(ref MasterList<CsToken> typeTokens, ref int startIndex, out GenericType generic, bool unsafeCode)
 {
     generic = null;
     Symbol symbol = this.symbols.Peek(startIndex);
     int count = -1;
     Label_0045:
     while ((symbol != null) && ((((symbol.SymbolType == SymbolType.WhiteSpace) || (symbol.SymbolType == SymbolType.EndOfLine)) || ((symbol.SymbolType == SymbolType.SingleLineComment) || (symbol.SymbolType == SymbolType.MultiLineComment))) || (symbol.SymbolType == SymbolType.PreprocessorDirective)))
     {
         int num3;
         typeTokens.Add(this.ConvertSymbol(symbol, TokenTypeFromSymbolType(symbol.SymbolType)));
         startIndex = num3 = startIndex + 1;
         symbol = this.symbols.Peek(num3);
     }
     if ((symbol.SymbolType != SymbolType.Other) && (symbol.SymbolType != SymbolType.This))
     {
         throw new SyntaxException(this.document.SourceCode, symbol.LineNumber);
     }
     typeTokens.Add(new CsToken(symbol.Text, CsTokenType.Other, symbol.Location, this.symbols.Generated));
     startIndex++;
     count = this.GetNextCodeSymbolIndex(startIndex);
     if (count != -1)
     {
         if (this.symbols.Peek(count).SymbolType == SymbolType.LessThan)
         {
             int num2;
             MasterList<CsToken> items = this.GetGenericArgumentList(unsafeCode, null, startIndex, out num2);
             if (items != null)
             {
                 typeTokens.AddRange(items);
                 CodeLocation location = CodeLocation.Join<CsToken>(typeTokens.First, typeTokens.Last);
                 generic = new GenericType(typeTokens, location, this.symbols.Generated);
                 typeTokens = new MasterList<CsToken>();
                 typeTokens.Add(generic);
                 startIndex = num2 + 1;
                 count = this.GetNextCodeSymbolIndex(startIndex);
                 if (count == -1)
                 {
                     return;
                 }
             }
         }
         symbol = this.symbols.Peek(count);
         if ((symbol.SymbolType == SymbolType.Dot) || (symbol.SymbolType == SymbolType.QualifiedAlias))
         {
             int num5;
             symbol = this.symbols.Peek(startIndex);
             while ((symbol != null) && ((((symbol.SymbolType == SymbolType.WhiteSpace) || (symbol.SymbolType == SymbolType.EndOfLine)) || ((symbol.SymbolType == SymbolType.SingleLineComment) || (symbol.SymbolType == SymbolType.MultiLineComment))) || (symbol.SymbolType == SymbolType.PreprocessorDirective)))
             {
                 int num4;
                 typeTokens.Add(this.ConvertSymbol(symbol, TokenTypeFromSymbolType(symbol.SymbolType)));
                 startIndex = num4 = startIndex + 1;
                 symbol = this.symbols.Peek(num4);
             }
             if (symbol.SymbolType == SymbolType.Dot)
             {
                 typeTokens.Add(new OperatorSymbol(symbol.Text, OperatorCategory.Reference, OperatorType.MemberAccess, symbol.Location, this.symbols.Generated));
             }
             else
             {
                 typeTokens.Add(new OperatorSymbol(symbol.Text, OperatorCategory.Reference, OperatorType.QualifiedAlias, symbol.Location, this.symbols.Generated));
             }
             startIndex = num5 = startIndex + 1;
             symbol = this.symbols.Peek(num5);
             goto Label_0045;
         }
     }
 }
Beispiel #13
0
 private void GetTypeTokenArrayBrackets(MasterList<CsToken> typeTokens, ref int startIndex)
 {
     Symbol symbol;
     int nextCodeSymbolIndex = this.GetNextCodeSymbolIndex(startIndex);
     if ((nextCodeSymbolIndex == -1) || (this.symbols.Peek(nextCodeSymbolIndex).SymbolType != SymbolType.OpenSquareBracket))
     {
         return;
     }
     for (int i = startIndex; i <= (nextCodeSymbolIndex - 1); i++)
     {
         Symbol symbol2 = this.symbols.Peek(startIndex);
         typeTokens.Add(this.ConvertSymbol(symbol2, TokenTypeFromSymbolType(symbol2.SymbolType)));
         startIndex++;
     }
     Microsoft.StyleCop.Node<CsToken> node = null;
     Label_0067:
     symbol = this.symbols.Peek(startIndex);
     if (((symbol.SymbolType == SymbolType.WhiteSpace) || (symbol.SymbolType == SymbolType.EndOfLine)) || (((symbol.SymbolType == SymbolType.SingleLineComment) || (symbol.SymbolType == SymbolType.MultiLineComment)) || (symbol.SymbolType == SymbolType.PreprocessorDirective)))
     {
         typeTokens.Add(this.ConvertSymbol(symbol, TokenTypeFromSymbolType(symbol.SymbolType)));
         startIndex++;
         goto Label_0067;
     }
     if (symbol.SymbolType == SymbolType.Number)
     {
         typeTokens.Add(this.ConvertSymbol(symbol, CsTokenType.Number));
         startIndex++;
         goto Label_0067;
     }
     if (symbol.SymbolType == SymbolType.Other)
     {
         typeTokens.Add(this.ConvertSymbol(symbol, CsTokenType.Other));
         startIndex++;
         goto Label_0067;
     }
     if (symbol.SymbolType == SymbolType.Comma)
     {
         typeTokens.Add(this.ConvertSymbol(symbol, CsTokenType.Comma));
         startIndex++;
         goto Label_0067;
     }
     if (symbol.SymbolType == SymbolType.OpenSquareBracket)
     {
         if (node != null)
         {
             throw new SyntaxException(this.document.SourceCode, symbol.LineNumber);
         }
         Bracket item = new Bracket(symbol.Text, CsTokenType.OpenSquareBracket, symbol.Location, this.symbols.Generated);
         node = typeTokens.InsertLast(item);
         startIndex++;
         goto Label_0067;
     }
     if (symbol.SymbolType == SymbolType.CloseSquareBracket)
     {
         if (node == null)
         {
             throw new SyntaxException(this.document.SourceCode, symbol.LineNumber);
         }
         Bracket bracket2 = new Bracket(symbol.Text, CsTokenType.CloseSquareBracket, symbol.Location, this.symbols.Generated);
         Microsoft.StyleCop.Node<CsToken> node2 = typeTokens.InsertLast(bracket2);
         startIndex++;
         ((Bracket) node.Value).MatchingBracketNode = node2;
         bracket2.MatchingBracketNode = node;
         node = null;
         int count = this.GetNextCodeSymbolIndex(startIndex);
         if ((count != -1) && (this.symbols.Peek(count).SymbolType != SymbolType.OpenSquareBracket))
         {
             return;
         }
         goto Label_0067;
     }
     if (node != null)
     {
         throw new SyntaxException(this.document.SourceCode, symbol.LineNumber);
     }
 }
Beispiel #14
0
 private MasterList<CsToken> GetGenericArgumentList(bool unsafeCode, CsToken name, int startIndex, out int endIndex)
 {
     endIndex = -1;
     MasterList<CsToken> list = null;
     int count = startIndex;
     while (true)
     {
         Symbol symbol = this.symbols.Peek(count);
         if ((symbol == null) || (((symbol.SymbolType != SymbolType.WhiteSpace) && (symbol.SymbolType != SymbolType.EndOfLine)) && (((symbol.SymbolType != SymbolType.SingleLineComment) && (symbol.SymbolType != SymbolType.MultiLineComment)) && (symbol.SymbolType != SymbolType.PreprocessorDirective))))
         {
             break;
         }
         count++;
     }
     Symbol symbol2 = this.symbols.Peek(count);
     if ((symbol2 == null) || (symbol2.SymbolType != SymbolType.LessThan))
     {
         return list;
     }
     list = new MasterList<CsToken>();
     if (name != null)
     {
         list.Add(name);
     }
     Microsoft.StyleCop.Node<CsToken> node = null;
     for (int i = startIndex; i <= count; i++)
     {
         symbol2 = this.symbols.Peek(i);
         if (symbol2.SymbolType == SymbolType.LessThan)
         {
             if (node != null)
             {
                 return null;
             }
             Bracket item = new Bracket(symbol2.Text, CsTokenType.OpenGenericBracket, symbol2.Location, this.symbols.Generated);
             node = list.InsertLast(item);
         }
         else
         {
             list.Add(this.ConvertSymbol(symbol2, TokenTypeFromSymbolType(symbol2.SymbolType)));
         }
     }
     Label_00F4:
     symbol2 = this.symbols.Peek(++count);
     if (symbol2 == null)
     {
         throw new SyntaxException(this.document.SourceCode, name.LineNumber);
     }
     if (symbol2.SymbolType == SymbolType.GreaterThan)
     {
         if (node == null)
         {
             return null;
         }
         Bracket bracket2 = new Bracket(symbol2.Text, CsTokenType.CloseGenericBracket, symbol2.Location, this.symbols.Generated);
         Microsoft.StyleCop.Node<CsToken> node2 = list.InsertLast(bracket2);
         ((Bracket) node.Value).MatchingBracketNode = node2;
         bracket2.MatchingBracketNode = node;
         endIndex = count;
         return list;
     }
     if (symbol2.SymbolType == SymbolType.Other)
     {
         int num3 = 0;
         CsToken token = this.GetTypeTokenAux(unsafeCode, true, false, count, out num3);
         if (token == null)
         {
             throw new SyntaxException(this.document.SourceCode, symbol2.LineNumber);
         }
         count = num3;
         list.Add(token);
         goto Label_00F4;
     }
     if (((symbol2.SymbolType == SymbolType.WhiteSpace) || (symbol2.SymbolType == SymbolType.EndOfLine)) || (((symbol2.SymbolType == SymbolType.SingleLineComment) || (symbol2.SymbolType == SymbolType.MultiLineComment)) || (symbol2.SymbolType == SymbolType.PreprocessorDirective)))
     {
         list.Add(this.ConvertSymbol(symbol2, TokenTypeFromSymbolType(symbol2.SymbolType)));
         goto Label_00F4;
     }
     if (symbol2.SymbolType == SymbolType.Comma)
     {
         list.Add(this.ConvertSymbol(symbol2, CsTokenType.Comma));
         goto Label_00F4;
     }
     return null;
 }
        /// <summary>
        /// Gets array brackets symbol for a type token, if they exist.
        /// </summary>
        /// <param name="typeTokenReference">A reference to the type token.</param>
        /// <param name="typeTokens">The tokens within the type token.</param>
        /// <param name="startIndex">The start index within the symbols.</param>
        private void GetTypeTokenArrayBrackets(Reference<ICodePart> typeTokenReference, MasterList<CsToken> typeTokens, ref int startIndex)
        {
            Param.AssertNotNull(typeTokenReference, "typeTokenReference");
            Param.AssertNotNull(typeTokens, "typeTokens");
            Param.AssertGreaterThanOrEqualToZero(startIndex, "startIndex");

            int index = this.GetNextCodeSymbolIndex(startIndex);
            if (index != -1)
            {
                Symbol symbol = this.symbols.Peek(index);
                if (symbol.SymbolType == SymbolType.OpenSquareBracket)
                {
                    // Add the tokens up to this point.
                    for (int i = startIndex; i <= index - 1; ++i)
                    {
                        Symbol symbolToConvert = this.symbols.Peek(startIndex);
                        typeTokens.Add(this.ConvertSymbol(symbolToConvert, TokenTypeFromSymbolType(symbolToConvert.SymbolType), typeTokenReference));

                        ++startIndex;
                    }

                    // Now collect the brackets.
                    Node<CsToken> openingBracketNode = null;
                    while (true)
                    {
                        symbol = this.symbols.Peek(startIndex);
                        if (symbol.SymbolType == SymbolType.WhiteSpace ||
                            symbol.SymbolType == SymbolType.EndOfLine ||
                            symbol.SymbolType == SymbolType.SingleLineComment ||
                            symbol.SymbolType == SymbolType.MultiLineComment ||
                            symbol.SymbolType == SymbolType.PreprocessorDirective)
                        {
                            typeTokens.Add(this.ConvertSymbol(symbol, TokenTypeFromSymbolType(symbol.SymbolType), typeTokenReference));
                            ++startIndex;
                        }
                        else if (symbol.SymbolType == SymbolType.Number)
                        {
                            typeTokens.Add(this.ConvertSymbol(symbol, CsTokenType.Number, typeTokenReference));
                            ++startIndex;
                        }
                        else if (symbol.SymbolType == SymbolType.Other)
                        {
                            // A const used in place of a number.
                            typeTokens.Add(this.ConvertSymbol(symbol, CsTokenType.Other, typeTokenReference));
                            ++startIndex;
                        }
                        else if (symbol.SymbolType == SymbolType.Comma)
                        {
                            typeTokens.Add(this.ConvertSymbol(symbol, CsTokenType.Comma, typeTokenReference));
                            ++startIndex;
                        }
                        else if (symbol.SymbolType == SymbolType.OpenSquareBracket)
                        {
                            if (openingBracketNode != null)
                            {
                                throw new SyntaxException(this.document.SourceCode, symbol.LineNumber);
                            }

                            Bracket openingBracket = new Bracket(
                                symbol.Text, CsTokenType.OpenSquareBracket, symbol.Location, typeTokenReference, this.symbols.Generated);
                            openingBracketNode = typeTokens.InsertLast(openingBracket);
                            ++startIndex;
                        }
                        else if (symbol.SymbolType == SymbolType.CloseSquareBracket)
                        {
                            if (openingBracketNode == null)
                            {
                                throw new SyntaxException(this.document.SourceCode, symbol.LineNumber);
                            }

                            Bracket closingBracket = new Bracket(
                                symbol.Text, CsTokenType.CloseSquareBracket, symbol.Location, typeTokenReference, this.symbols.Generated);
                            Node<CsToken> closingBracketNode = typeTokens.InsertLast(closingBracket);
                            ++startIndex;

                            ((Bracket)openingBracketNode.Value).MatchingBracketNode = closingBracketNode;
                            closingBracket.MatchingBracketNode = openingBracketNode;

                            openingBracketNode = null;

                            // Check whether the next character is another opening bracket.
                            int temp = this.GetNextCodeSymbolIndex(startIndex);
                            if (temp != -1 && this.symbols.Peek(temp).SymbolType != SymbolType.OpenSquareBracket)
                            {
                                break;
                            }
                        }
                        else
                        {
                            if (openingBracketNode != null)
                            {
                                throw new SyntaxException(this.document.SourceCode, symbol.LineNumber);
                            }

                            break;
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Gets the base name and generic symbols for a type token.
        /// </summary>
        /// <param name="typeTokenReference">A reference to the type token.</param>
        /// <param name="typeTokens">The list of tokens in the type.</param>
        /// <param name="startIndex">The start index within the symbol list.</param>
        /// <param name="generic">Returns a value indicating whether the type is generic.</param>
        /// <param name="unsafeCode">Indicates whether the type is within a block of unsafe code.</param>
        private void GetTypeTokenBaseName(
            Reference<ICodePart> typeTokenReference, 
            ref MasterList<CsToken> typeTokens, 
            ref int startIndex, 
            out GenericType generic, 
            bool unsafeCode)
        {
            Param.AssertNotNull(typeTokenReference, "typeTokenReference");
            Param.AssertNotNull(typeTokens, "typeTokens");
            Param.AssertGreaterThanOrEqualToZero(startIndex, "startIndex");
            Param.Ignore(unsafeCode);

            generic = null;
            Symbol symbol = this.symbols.Peek(startIndex);

            // First get the full name of the type.
            int index = -1;
            while (true)
            {
                // Add any whitespace.
                while (symbol != null &&
                    (symbol.SymbolType == SymbolType.WhiteSpace ||
                     symbol.SymbolType == SymbolType.EndOfLine ||
                     symbol.SymbolType == SymbolType.SingleLineComment ||
                     symbol.SymbolType == SymbolType.MultiLineComment ||
                     symbol.SymbolType == SymbolType.PreprocessorDirective))
                {
                    typeTokens.Add(this.ConvertSymbol(symbol, TokenTypeFromSymbolType(symbol.SymbolType), typeTokenReference));
                    symbol = this.symbols.Peek(++startIndex);
                }

                // Add the next word. The type of the next word must either be an unknown
                // word type, which will be the name of the next item in the type, or else
                // it must be the 'this' keyword. This is used when implementing an explicit
                // interface member which is an indexer.
                if (symbol.SymbolType == SymbolType.Other || symbol.SymbolType == SymbolType.This)
                {
                    typeTokens.Add(new CsToken(symbol.Text, CsTokenType.Other, symbol.Location, typeTokenReference, this.symbols.Generated));
                }
                else
                {
                    throw new SyntaxException(this.document.SourceCode, symbol.LineNumber);
                }

                ++startIndex;

                // Look at the type of the next non-whitespace character.
                index = this.GetNextCodeSymbolIndex(startIndex);
                if (index == -1)
                {
                    break;
                }

                // If the next character is an opening generic bracket, get the generic.
                symbol = this.symbols.Peek(index);
                if (symbol.SymbolType == SymbolType.LessThan)
                {
                    int end;
                    MasterList<CsToken> genericTypeTokens = this.GetGenericArgumentList(
                        typeTokenReference, unsafeCode, null, startIndex, out end);

                    if (genericTypeTokens != null)
                    {
                        // Add the tokens from this generic into our token list.
                        typeTokens.AddRange(genericTypeTokens);

                        // Create a new GenericTypeToken which represents this generic type.
                        CodeLocation genericTypeLocation = CsToken.JoinLocations(typeTokens.First, typeTokens.Last);
                        generic = new GenericType(typeTokens, genericTypeLocation, typeTokenReference, this.symbols.Generated);

                        Reference<ICodePart> genericReference = new Reference<ICodePart>(generic);
                        foreach (CsToken token in typeTokens)
                        {
                            token.ParentRef = genericReference;
                        }

                        // Reset the token list and add this generic token as the first item in the list.
                        typeTokens = new MasterList<CsToken>();
                        typeTokens.Add(generic);

                        // Advance the symbol index.
                        startIndex = end + 1;

                        // Look at the type of the next non-whitespace character.
                        index = this.GetNextCodeSymbolIndex(startIndex);
                        if (index == -1)
                        {
                            break;
                        }
                    }
                }

                // If the next character is not a dot or a qualified alias, break now.
                symbol = this.symbols.Peek(index);
                if (symbol.SymbolType != SymbolType.Dot && symbol.SymbolType != SymbolType.QualifiedAlias)
                {
                    break;
                }

                // Add any whitspace.
                symbol = this.symbols.Peek(startIndex);
                while (symbol != null &&
                    (symbol.SymbolType == SymbolType.WhiteSpace ||
                     symbol.SymbolType == SymbolType.EndOfLine ||
                     symbol.SymbolType == SymbolType.SingleLineComment ||
                     symbol.SymbolType == SymbolType.MultiLineComment ||
                     symbol.SymbolType == SymbolType.PreprocessorDirective))
                {
                    typeTokens.Add(this.ConvertSymbol(symbol, TokenTypeFromSymbolType(symbol.SymbolType), typeTokenReference));
                    symbol = this.symbols.Peek(++startIndex);
                }

                // Add the dot or qualified alias.
                if (symbol.SymbolType == SymbolType.Dot)
                {
                    typeTokens.Add(new OperatorSymbol(
                        symbol.Text,
                        OperatorCategory.Reference,
                        OperatorType.MemberAccess,
                        symbol.Location,
                        typeTokenReference,
                        this.symbols.Generated));
                }
                else
                {
                    Debug.Assert(symbol.SymbolType == SymbolType.QualifiedAlias, "Expected a qualified alias keyword");

                    typeTokens.Add(new OperatorSymbol(
                        symbol.Text,
                        OperatorCategory.Reference,
                        OperatorType.QualifiedAlias,
                        symbol.Location,
                        typeTokenReference,
                        this.symbols.Generated));
                }

                // Get the next symbol.
                symbol = this.symbols.Peek(++startIndex);
            }
        }
Beispiel #17
0
 private bool GetTypeTokenDereferenceSymbols(MasterList<CsToken> typeTokens, ref int startIndex)
 {
     bool flag = false;
     while (true)
     {
         int nextCodeSymbolIndex = this.GetNextCodeSymbolIndex(startIndex);
         if ((nextCodeSymbolIndex == -1) || (this.symbols.Peek(nextCodeSymbolIndex).SymbolType != SymbolType.Multiplication))
         {
             return flag;
         }
         Symbol symbol = this.symbols.Peek(startIndex);
         while ((symbol != null) && ((((symbol.SymbolType == SymbolType.WhiteSpace) || (symbol.SymbolType == SymbolType.EndOfLine)) || ((symbol.SymbolType == SymbolType.SingleLineComment) || (symbol.SymbolType == SymbolType.MultiLineComment))) || (symbol.SymbolType == SymbolType.PreprocessorDirective)))
         {
             int num2;
             typeTokens.Add(this.ConvertSymbol(symbol, TokenTypeFromSymbolType(symbol.SymbolType)));
             startIndex = num2 = startIndex + 1;
             symbol = this.symbols.Peek(num2);
         }
         typeTokens.Add(new OperatorSymbol(symbol.Text, OperatorCategory.Reference, OperatorType.Dereference, symbol.Location, this.symbols.Generated));
         startIndex++;
         flag = true;
     }
 }
Beispiel #18
0
 private void GetTypeTokenNullableTypeSymbol(MasterList<CsToken> typeTokens, bool isExpression, ref int startIndex)
 {
     int nextCodeSymbolIndex = this.GetNextCodeSymbolIndex(startIndex);
     if (nextCodeSymbolIndex == -1)
     {
         throw this.CreateSyntaxException();
     }
     if ((this.symbols.Peek(nextCodeSymbolIndex).SymbolType == SymbolType.QuestionMark) && (!isExpression || this.IsNullableTypeSymbolFromIsExpression(nextCodeSymbolIndex)))
     {
         Symbol symbol = this.symbols.Peek(startIndex);
         while ((symbol != null) && ((((symbol.SymbolType == SymbolType.WhiteSpace) || (symbol.SymbolType == SymbolType.EndOfLine)) || ((symbol.SymbolType == SymbolType.SingleLineComment) || (symbol.SymbolType == SymbolType.MultiLineComment))) || (symbol.SymbolType == SymbolType.PreprocessorDirective)))
         {
             int num2;
             typeTokens.Add(this.ConvertSymbol(symbol, TokenTypeFromSymbolType(symbol.SymbolType)));
             startIndex = num2 = startIndex + 1;
             symbol = this.symbols.Peek(num2);
         }
         typeTokens.Add(new CsToken(symbol.Text, CsTokenType.NullableTypeSymbol, symbol.Location, this.symbols.Generated));
         startIndex++;
     }
 }
Beispiel #19
0
 private XmlHeader GetXmlHeader()
 {
     int count = 1;
     Symbol symbol = this.symbols.Peek(count);
     int num2 = -1;
     int num3 = 0;
     for (Symbol symbol2 = symbol; symbol2 != null; symbol2 = this.symbols.Peek(++count))
     {
         if (symbol2.SymbolType == SymbolType.XmlHeaderLine)
         {
             num2 = count;
             num3 = 0;
         }
         else if (symbol2.SymbolType == SymbolType.EndOfLine)
         {
             if (++num3 > 1)
             {
                 break;
             }
         }
         else
         {
             if ((symbol2.SymbolType != SymbolType.WhiteSpace) && (symbol2.SymbolType != SymbolType.SingleLineComment))
             {
                 break;
             }
             num3 = 0;
         }
     }
     MasterList<CsToken> childTokens = new MasterList<CsToken>();
     for (int i = 1; i <= num2; i++)
     {
         this.symbols.Advance();
         childTokens.Add(this.ConvertSymbol(this.symbols.Current, TokenTypeFromSymbolType(this.symbols.Current.SymbolType)));
     }
     return new XmlHeader(childTokens, CodeLocation.Join(symbol.Location, this.symbols.Current.Location), this.symbols.Generated);
 }
        /// <summary>
        /// Parses one or more type constraint clauses.
        /// </summary>
        /// <param name="elementReference">A reference to the element being created.</param>
        /// <param name="unsafeCode">Indicates whether the code is marked as unsafe.</param>
        /// <returns>Returns the clauses.</returns>
        private ICollection<TypeParameterConstraintClause> ParseTypeConstraintClauses(
            Reference<ICodePart> elementReference, bool unsafeCode)
        {
            Param.AssertNotNull(elementReference, "elementReference");
            Param.Ignore(unsafeCode);

            List<TypeParameterConstraintClause> constraintClauses = new List<TypeParameterConstraintClause>();

            Symbol symbol = this.GetNextSymbol(elementReference);

            while (symbol.Text == "where")
            {
                var constraintClauseReference = new Reference<ICodePart>();

                Node<CsToken> firstToken = this.tokens.InsertLast(this.GetToken(CsTokenType.Where, SymbolType.Other, constraintClauseReference));
                Node<CsToken> typeToken = this.tokens.InsertLast(this.GetToken(CsTokenType.Other, SymbolType.Other, constraintClauseReference));
                this.tokens.Add(this.GetToken(CsTokenType.WhereColon, SymbolType.Colon, constraintClauseReference));

                List<CsToken> constraints = new List<CsToken>();

                while (true)
                {
                    symbol = this.GetNextSymbol(constraintClauseReference);

                    CsToken constraintToken = null;

                    if (symbol.SymbolType == SymbolType.Class ||
                        symbol.SymbolType == SymbolType.Struct)
                    {
                        // A constraint of type class or struct.
                        constraintToken = this.GetToken(CsTokenType.Other, symbol.SymbolType, constraintClauseReference);
                    }
                    else if (symbol.SymbolType == SymbolType.New)
                    {
                        var constructorConstraintReference = new Reference<ICodePart>();

                        // A constructor constraint.
                        MasterList<CsToken> childTokens = new MasterList<CsToken>();
                        childTokens.Add(this.GetToken(CsTokenType.Other, SymbolType.New, constraintClauseReference));

                        Bracket openParenthesis = this.GetBracketToken(CsTokenType.OpenParenthesis, SymbolType.OpenParenthesis, constraintClauseReference);
                        Bracket closeParenthesis = this.GetBracketToken(CsTokenType.CloseParenthesis, SymbolType.CloseParenthesis, constraintClauseReference);

                        Node<CsToken> openParenthesisNode = childTokens.InsertLast(openParenthesis);
                        Node<CsToken> closeParenthesisNode = childTokens.InsertLast(closeParenthesis);

                        openParenthesis.MatchingBracketNode = closeParenthesisNode;
                        closeParenthesis.MatchingBracketNode = openParenthesisNode;

                        constraintToken = new ConstructorConstraint(
                            childTokens,
                            CsToken.JoinLocations(childTokens.First, childTokens.Last),
                            constraintClauseReference,
                            childTokens.First.Value.Generated);

                        constructorConstraintReference.Target = constraintToken;
                    }
                    else
                    {
                        // A type constraint.
                        constraintToken = this.GetTypeToken(constraintClauseReference, unsafeCode, true);
                    }

                    this.tokens.Add(constraintToken);
                    constraints.Add(constraintToken);

                    symbol = this.GetNextSymbol(constraintClauseReference);
                    if (symbol.SymbolType != SymbolType.Comma)
                    {
                        break;
                    }

                    this.tokens.Add(this.GetToken(CsTokenType.Comma, SymbolType.Comma, constraintClauseReference));
                }

                // Add the constraints as a read-only collection in a constraint clause.
                var constraintClause = new TypeParameterConstraintClause(
                    new CsTokenList(this.tokens, firstToken, this.tokens.Last), typeToken.Value, constraints.ToArray(), elementReference);

                constraintClauseReference.Target = constraintClause;
                constraintClauses.Add(constraintClause);

                symbol = this.GetNextSymbol(elementReference);
            }

            // Return the constraint clauses as a read-only collection.
            return constraintClauses.ToArray();
        }
Beispiel #21
0
 private ICollection<TypeParameterConstraintClause> ParseTypeConstraintClauses(bool unsafeCode)
 {
     List<TypeParameterConstraintClause> list = new List<TypeParameterConstraintClause>();
     for (Symbol symbol = this.GetNextSymbol(); symbol.Text == "where"; symbol = this.GetNextSymbol())
     {
         Microsoft.StyleCop.Node<CsToken> firstItemNode = this.tokens.InsertLast(this.GetToken(CsTokenType.Other, SymbolType.Other));
         Microsoft.StyleCop.Node<CsToken> node2 = this.tokens.InsertLast(this.GetToken(CsTokenType.Other, SymbolType.Other));
         this.tokens.Add(this.GetToken(CsTokenType.WhereColon, SymbolType.Colon));
         List<CsToken> list2 = new List<CsToken>();
     Label_005A:
         symbol = this.GetNextSymbol();
         CsToken item = null;
         if ((symbol.SymbolType == SymbolType.Class) || (symbol.SymbolType == SymbolType.Struct))
         {
             item = this.GetToken(CsTokenType.Other, symbol.SymbolType);
         }
         else if (symbol.SymbolType == SymbolType.New)
         {
             MasterList<CsToken> childTokens = new MasterList<CsToken>();
             childTokens.Add(this.GetToken(CsTokenType.Other, SymbolType.New));
             Bracket bracketToken = this.GetBracketToken(CsTokenType.OpenParenthesis, SymbolType.OpenParenthesis);
             Bracket bracket2 = this.GetBracketToken(CsTokenType.CloseParenthesis, SymbolType.CloseParenthesis);
             Microsoft.StyleCop.Node<CsToken> node3 = childTokens.InsertLast(bracketToken);
             Microsoft.StyleCop.Node<CsToken> node4 = childTokens.InsertLast(bracket2);
             bracketToken.MatchingBracketNode = node4;
             bracket2.MatchingBracketNode = node3;
             item = new ConstructorConstraint(childTokens, CodeLocation.Join<CsToken>(childTokens.First, childTokens.Last), childTokens.First.Value.Generated);
         }
         else
         {
             item = this.GetTypeToken(unsafeCode, true);
         }
         this.tokens.Add(item);
         list2.Add(item);
         if (this.GetNextSymbol().SymbolType == SymbolType.Comma)
         {
             this.tokens.Add(this.GetToken(CsTokenType.Comma, SymbolType.Comma));
             goto Label_005A;
         }
         list.Add(new TypeParameterConstraintClause(new CsTokenList(this.tokens, firstItemNode, this.tokens.Last), node2.Value, list2.ToArray()));
     }
     return list.ToArray();
 }
Beispiel #22
0
        //AttentionVM attentionVM;

        void MasterExecSave()
        {
            int  i = -1;
            bool partitionChanged = false;

            //int dsi = -1;
            if (MasterEditMode)
            {
                if (MasterCurrentObject.Partition.Id != MasterSelectedItem.Partition.Id)
                {
                    partitionChanged = true;
                    foreach (ControlChannel ch in MasterCurrentObject.ControlChannels)
                    {
                        ch.Partition = MasterCurrentObject.Partition;
                    }
                }
            }
            _dataService.UpdateControlDevice(MasterCurrentObject, (updatedCount, error) =>
            {
                if (error != null)
                {
                    return;
                }                              // Report error here
                i = updatedCount;
            });

            MasterObjectButtonsVisibility = Visibility.Collapsed;
            MasterListCurtainVisibility   = Visibility.Collapsed;
            DetailListCurtainVisibility   = Visibility.Collapsed;


            if (MasterAddMode)
            {
                MasterSelectorSelectedItem = null;

                MasterList.Add(MasterCurrentObject);
                MasterSelectedItem   = MasterCurrentObject;
                MasterListVisibility = Visibility.Visible;
            }
            if (MasterEditMode) //in EditMode MasterSelectedItem always not null
            {
                if (!partitionChanged)
                {
                    MasterList[msix]   = MasterCurrentObject;
                    MasterSelectedItem = MasterCurrentObject;
                    if (savedDsix != -1)
                    {
                        DetailSelectedItem = DetailList[savedDsix];
                    }
                }
                else
                {
                    MasterList.Remove(MasterSelectedItem);
                    DetailContentVisibility = Visibility.Hidden;
                    partitionChanged        = false;
                }
            }

            MasterAddMode  = false;
            MasterEditMode = false;
            MasterCurrentObject.IsEditMode = false;
            MasterRemoveCmd.RaiseCanExecuteChanged();
            MasterAddCmd.RaiseCanExecuteChanged();

            MessengerInstance.Send("", AppContext.UnBlockUIMsg);
        }
Beispiel #23
0
        private static bool BuildMasterCallback(IntPtr deviceInfoSet, int deviceindex, ref SetupApi.SP_DEVINFO_DATA deviceInfoData, object userData)
        {
            MasterList    deviceList = userData as MasterList;
            MasterItem    deviceItem = new MasterItem();
            StringBuilder sb         = new StringBuilder(256);

            if (SetupApi.CM_Get_Device_ID(deviceInfoData.DevInst, sb, sb.Capacity, 0) != SetupApi.CR.SUCCESS)
            {
                return(false);
            }

            deviceItem.Add(DEVICE_ID_KEY, sb.ToString());
            deviceList.Add(deviceItem);


            RegistryValueKind propertyType;

            byte[] propBuffer = new byte[256];
            int    requiredSize;
            bool   bSuccess = SetupApi.SetupDiGetCustomDeviceProperty(deviceInfoSet,
                                                                      ref deviceInfoData,
                                                                      UsbRegistry.DEVICE_INTERFACE_GUIDS,
                                                                      SetupApi.DICUSTOMDEVPROP.NONE,
                                                                      out propertyType,
                                                                      propBuffer,
                                                                      propBuffer.Length,
                                                                      out requiredSize);

            if (bSuccess)
            {
                string[] devInterfaceGuids = UsbRegistry.GetAsStringArray(propBuffer, requiredSize);

                deviceItem.Add(UsbRegistry.DEVICE_INTERFACE_GUIDS, devInterfaceGuids);
                foreach (string s in devInterfaceGuids)
                {
                    Guid          g = new Guid(s);
                    List <string> devicePathList;
                    if (WinUsb.WinUsbRegistry.GetDevicePathList(g, out devicePathList))
                    {
                        deviceItem.DevicePaths.Add(g, devicePathList);
                    }
                }
            }
            else
            {
                bSuccess = SetupApi.SetupDiGetCustomDeviceProperty(deviceInfoSet,
                                                                   ref deviceInfoData,
                                                                   UsbRegistry.LIBUSB_INTERFACE_GUIDS,
                                                                   SetupApi.DICUSTOMDEVPROP.NONE,
                                                                   out propertyType,
                                                                   propBuffer,
                                                                   propBuffer.Length,
                                                                   out requiredSize);
                if (bSuccess)
                {
                    string[] devInterfaceGuids = UsbRegistry.GetAsStringArray(propBuffer, requiredSize);

                    deviceItem.Add(UsbRegistry.LIBUSB_INTERFACE_GUIDS, devInterfaceGuids);
                }
            }

            bSuccess =
                SetupApi.SetupDiGetCustomDeviceProperty(deviceInfoSet,
                                                        ref deviceInfoData,
                                                        UsbRegistry.SYMBOLIC_NAME_KEY,
                                                        SetupApi.DICUSTOMDEVPROP.NONE,
                                                        out propertyType,
                                                        propBuffer,
                                                        propBuffer.Length,
                                                        out requiredSize);
            if (bSuccess)
            {
                string symbolicName = UsbRegistry.GetAsString(propBuffer, requiredSize);
                deviceItem.Add(UsbRegistry.SYMBOLIC_NAME_KEY, symbolicName);
            }
            SetupApi.getSPDRPProperties(deviceInfoSet, ref deviceInfoData, deviceItem);

            return(false);
        }
Beispiel #24
0
        private MasterList<CsToken> GetGenericArgumentList(Reference<ICodePart> genericTypeReference, bool unsafeCode, CsToken name, int startIndex, out int endIndex)
        {
            Param.AssertNotNull(genericTypeReference, "genericTypeReference");
            Param.Ignore(unsafeCode);
            Param.Ignore(name);
            Param.AssertGreaterThanOrEqualToZero(startIndex, "startIndex");

            endIndex = -1;
            MasterList<CsToken> genericArgumentListTokens = null;

            // Move past whitespace and comments.
            int index = startIndex;
            while (true)
            {
                Symbol next = this.symbols.Peek(index);
                if (next == null
                    || (next.SymbolType != SymbolType.WhiteSpace && next.SymbolType != SymbolType.EndOfLine && next.SymbolType != SymbolType.SingleLineComment
                        && next.SymbolType != SymbolType.MultiLineComment && next.SymbolType != SymbolType.PreprocessorDirective))
                {
                    break;
                }

                ++index;
            }

            // The next symbol should be an opening bracket, if this is a generic.
            Symbol symbol = this.symbols.Peek(index);
            if (symbol != null && symbol.SymbolType == SymbolType.LessThan)
            {
                // This might be a generic. Assume that it is and start creating tokens.
                genericArgumentListTokens = new MasterList<CsToken>();

                // Add the name if one was provided.
                if (name != null)
                {
                    genericArgumentListTokens.Add(name);
                }

                Node<CsToken> openingGenericBracketNode = null;

                // Add everything up to the opening bracket into the token list.
                for (int i = startIndex; i <= index; ++i)
                {
                    symbol = this.symbols.Peek(i);
                    Debug.Assert(symbol != null, "The next symbol should not be null");

                    if (symbol.SymbolType == SymbolType.LessThan)
                    {
                        if (openingGenericBracketNode != null)
                        {
                            // This is not a generic statement.
                            return null;
                        }

                        Bracket openingGenericBracket = new Bracket(
                            symbol.Text, CsTokenType.OpenGenericBracket, symbol.Location, genericTypeReference, this.symbols.Generated);
                        openingGenericBracketNode = genericArgumentListTokens.InsertLast(openingGenericBracket);
                    }
                    else
                    {
                        genericArgumentListTokens.Add(this.ConvertSymbol(symbol, TokenTypeFromSymbolType(symbol.SymbolType), genericTypeReference));
                    }
                }

                // Loop through the rest of the symbols.
                while (true)
                {
                    symbol = this.symbols.Peek(++index);
                    if (symbol == null)
                    {
                        // The code ran out before we found the end of the generic.
                        throw new SyntaxException(this.document.SourceCode, name.LineNumber);
                    }
                    else if (symbol.SymbolType == SymbolType.GreaterThan)
                    {
                        if (openingGenericBracketNode == null)
                        {
                            // This is not a generic statement.
                            return null;
                        }

                        // This is the end of the generic statement. Add the closing bracket to the token list.
                        Bracket closingGenericBracket = new Bracket(
                            symbol.Text, CsTokenType.CloseGenericBracket, symbol.Location, genericTypeReference, this.symbols.Generated);
                        Node<CsToken> closingGenericBracketNode = genericArgumentListTokens.InsertLast(closingGenericBracket);

                        ((Bracket)openingGenericBracketNode.Value).MatchingBracketNode = closingGenericBracketNode;
                        closingGenericBracket.MatchingBracketNode = openingGenericBracketNode;

                        endIndex = index;
                        break;
                    }
                    else if (symbol.SymbolType == SymbolType.Out || symbol.SymbolType == SymbolType.In)
                    {
                        // Get the in or out keyword.
                        genericArgumentListTokens.Add(
                            this.ConvertSymbol(symbol, symbol.SymbolType == SymbolType.In ? CsTokenType.In : CsTokenType.Out, genericTypeReference));
                    }
                    else if (symbol.SymbolType == SymbolType.Other)
                    {
                        int lastIndex = 0;
                        Reference<ICodePart> wordReference = new Reference<ICodePart>();
                        CsToken word = this.GetTypeTokenAux(wordReference, genericTypeReference, unsafeCode, true, false, index, out lastIndex);
                        if (word == null)
                        {
                            throw new SyntaxException(this.document.SourceCode, symbol.LineNumber);
                        }

                        // Advance the index to the end of the token.
                        index = lastIndex;

                        // Add the token.
                        genericArgumentListTokens.Add(word);
                    }
                    else if (symbol.SymbolType == SymbolType.WhiteSpace || symbol.SymbolType == SymbolType.EndOfLine || symbol.SymbolType == SymbolType.SingleLineComment
                             || symbol.SymbolType == SymbolType.MultiLineComment || symbol.SymbolType == SymbolType.PreprocessorDirective)
                    {
                        // Add these to the token list.
                        genericArgumentListTokens.Add(this.ConvertSymbol(symbol, TokenTypeFromSymbolType(symbol.SymbolType), genericTypeReference));
                    }
                    else if (symbol.SymbolType == SymbolType.Comma)
                    {
                        genericArgumentListTokens.Add(this.ConvertSymbol(symbol, CsTokenType.Comma, genericTypeReference));
                    }
                    else if (symbol.SymbolType == SymbolType.OpenSquareBracket)
                    {
                        // An attribute on the generic type.
                        genericArgumentListTokens.Add(this.GetAttribute(genericTypeReference, unsafeCode));
                    }
                    else
                    {
                        // Any other symbol signifies that this is not a generic statement.
                        genericArgumentListTokens = null;
                        break;
                    }
                }
            }

            return genericArgumentListTokens;
        }
Beispiel #25
0
 public static void AddToGame(Card card, int ownerIndex)
 {
     CardsOnDeck[ownerIndex].Add(card);
     MasterList.Add(card);
 }