public virtual void TestToStringAndMultiAttributeImplementations()
        {
            AttributeSource src     = new AttributeSource();
            ITermAttribute  termAtt = src.AddAttribute <ITermAttribute>();
            ITypeAttribute  typeAtt = src.AddAttribute <ITypeAttribute>();

            termAtt.SetTermBuffer("TestTerm");
            typeAtt.Type = "TestType";
            Assert.AreEqual("(" + typeAtt.ToString() + "," + termAtt.ToString() + ")", src.ToString(), "Attributes should appear in original order");
            System.Collections.Generic.IEnumerator <Attribute> it = src.GetAttributeImplsIterator().GetEnumerator();
            Assert.IsTrue(it.MoveNext(), "Iterator should have 2 attributes left");
            Assert.AreSame(typeAtt, it.Current, "First AttributeImpl from iterator should be typeAtt");
            Assert.IsTrue(it.MoveNext(), "Iterator should have 1 attributes left");
            Assert.AreSame(termAtt, it.Current, "Second AttributeImpl from iterator should be termAtt");
            Assert.IsFalse(it.MoveNext(), "Iterator should have 0 attributes left");

            src = new AttributeSource();
            src.AddAttributeImpl(new Token());
            // this should not add a new attribute as Token implements TermAttribute, too
            termAtt = src.AddAttribute <ITermAttribute>();
            Assert.IsTrue(termAtt is Token, "TermAttribute should be implemented by Token");
            // get the Token attribute and check, that it is the only one
            it = src.GetAttributeImplsIterator().GetEnumerator();
            Assert.IsTrue(it.MoveNext());
            Token tok = (Token)it.Current;

            Assert.IsFalse(it.MoveNext(), "There should be only one attribute implementation instance");

            termAtt.SetTermBuffer("TestTerm");
            Assert.AreEqual("(" + tok.ToString() + ")", src.ToString(), "Token should only printed once");
        }
Exemple #2
0
 private static System.Collections.Generic.Dictionary <int, BankValueEntry> GetBankValue(System.Collections.Generic.Dictionary <string, string> result)
 {
     System.Collections.Generic.Dictionary <int, BankValueEntry> dictionary = new System.Collections.Generic.Dictionary <int, BankValueEntry>();
     System.Collections.Generic.IEnumerator <string>             enumerator = result.Keys.GetEnumerator();
     while (enumerator.MoveNext())
     {
         string current = enumerator.Current;
         string value   = result[current];
         if ("\0".Equals(value))
         {
             value = System.Convert.ToString(-1000);
         }
         else
         {
             if (string.IsNullOrEmpty(value))
             {
                 value = System.Convert.ToString(-500);
             }
         }
         int num = System.Convert.ToInt32(current.Substring(current.LastIndexOf(".") + 1));
         if (!dictionary.ContainsKey(num))
         {
             BankValueEntry value2 = new BankValueEntry(num);
             dictionary.Add(num, value2);
         }
         BankValueEntry   bankValueEntry   = dictionary[num];
         ApcBankStatusMib apcBankStatusMib = new ApcBankStatusMib(num);
         if (current.StartsWith(apcBankStatusMib.CurrentStatus))
         {
             bankValueEntry.Current = System.Convert.ToString((float)System.Convert.ToInt32(value) / 10f);
         }
     }
     return(dictionary);
 }
Exemple #3
0
        public static TSource First <TSource> (IEnumerable <TSource> source)
        {
            Check.Source(source);

            IList <TSource> list = source as IList <TSource>;

            if (list != null)
            {
                if (list.Count != 0)
                {
                    return(list [0]);
                }
            }
            else
            {
                using (System.Collections.Generic.IEnumerator <TSource> enumerator = source.GetEnumerator())
                {
                    if (enumerator.MoveNext())
                    {
                        return(enumerator.Current);
                    }
                }
            }

            throw EmptySequence();
        }
        /// <summary>
        /// Takes any character, or a whitespace, and calls the respective appropriate append method.
        /// </summary>
        /// <param name="input"></param>
        public void Append(System.Collections.Generic.IEnumerator <char> input)
        {
            string word = "";

            while (input.MoveNext())
            {
                char current = input.Current;
                if (current == ' ')
                {
                    AppendWord(word.GetEnumerator());
                    this.AppendWhitespace();
                    word = "";
                }
                else if (current == '_')
                {
                    AppendWord(word.GetEnumerator());
                    this.AppendNewLine();
                    word = "";
                }

                else
                {
                    word += current;
                }
            }
            if (word.Length > 0)
            {
                AppendWord(word.GetEnumerator());
            }
        }
        public void AppendWord(System.Collections.Generic.IEnumerator <char> input)
        {
            string         character = "";
            LetterCategory inputCategory;
            LetterCategory previousCategory;
            char           previous;
            char           current            = '\0';
            var            charactersToAppend = new List <string>();

            while (input.MoveNext())
            {
                previous         = current;
                current          = input.Current;
                previousCategory = categorizer.Categorize(previous);
                inputCategory    = categorizer.Categorize(current);
                if (previousCategory != LetterCategory.Vowel && inputCategory == LetterCategory.Vowel)
                {
                    character += current;
                }
                else if (character == "")
                {
                    character += current;
                }
                else if (character.Length == 1)
                {
                    charactersToAppend.Add(character);
                    //Append(character);
                    character  = "";
                    character += current;
                }
                else
                {
                    charactersToAppend.Add(character);
                    //Append(character);
                    character = "";
                }
                if (character.Length >= 2)
                {
                    charactersToAppend.Add(character);
                    //Append(character);
                    character = "";
                }
            }
            if (character.Length > 0)
            {
                charactersToAppend.Add(character);
                //Append(character);
            }
            //Add a newline if this word does not fit on this line
            var currentPosition = this.position * this.Feed + this.Offset;

            if (currentPosition.X + this.Feed.Width * charactersToAppend.Count > PageSize.Width)
            {
                AppendNewLine();
            }
            foreach (var c in charactersToAppend)
            {
                Append(c);
            }
        }
        public static System.Collections.Generic.IEnumerator <byte> Run(System.Collections.Generic.IEnumerator <byte> coroutine, Object tag = null)
        {
            if (coroutine.MoveNext() == true)
            {
                var key = (tag == null ? 0 : tag.GetInstanceID());
                List <IEnumerator> list = null;
                for (int i = 0; i < Coroutines.instance.list.Count; ++i)
                {
                    var item = Coroutines.instance.list[i];
                    if (item.tag == key)
                    {
                        list = item.list;
                    }
                }

                if (list != null)
                {
                    list.Add(coroutine);
                }
                else
                {
                    Coroutines.instance.list.Add(new Item()
                    {
                        tag = key, list = new List <IEnumerator>()
                        {
                            coroutine
                        }
                    });
                }
            }

            return(coroutine);
        }
Exemple #7
0
        public static void printActivityTreeA(Activity activity)
        {
            if (tag == null)
            {
                tag = new activityStruct();
                tag.parent = null;
                tag.currentActivity = activity;
                tag.displayName = activity.DisplayName;

            }


            System.Collections.Generic.IEnumerator<Activity> list = WorkflowInspectionServices.GetActivities(activity).GetEnumerator();

            while (list.MoveNext())
            {
                activityStruct temp = new activityStruct();

                temp.parent = tag;
                temp.currentActivity = list.Current;
                temp.displayName = list.Current.DisplayName;
                printActivityTreeA(list.Current);

            }

        }
Exemple #8
0
        public static Polyline[] InterpolatePolylines(Polyline from, Polyline to, int Steps, bool includeEnds = true)
        {
            if (from.Count == to.Count)
            {
                Polyline[] interpolatedPolylines = new Polyline[Steps + (Convert.ToInt32(includeEnds) * 2)];

                for (int i = 0; i < Steps + (Convert.ToInt32(includeEnds) * 2); i++)
                {
                    interpolatedPolylines[i] = new Polyline();
                }


                System.Collections.Generic.IEnumerator <Point3d> enum0 = from.GetEnumerator();
                System.Collections.Generic.IEnumerator <Point3d> enum1 = to.GetEnumerator();



                while (enum0.MoveNext())
                {
                    Point3d[] pt = NGonsCore.PointUtil.InterpolatePoints(enum0.Current, enum1.Current, Steps, includeEnds);

                    for (int i = 0; i < Steps + (Convert.ToInt32(includeEnds) * 2); i++)
                    {
                        interpolatedPolylines[i].Add(pt[i]);
                    }

                    enum1.MoveNext();
                }

                return(interpolatedPolylines);
            }

            return(null);
        }
Exemple #9
0
        public void Save()
        {
            lock (this.m_lock)
            {
                Guild guild2;
                using (System.Collections.Generic.IEnumerator <Guild> enumerator = (
                           from guild in this.m_guilds.Values
                           where guild.IsDirty
                           select guild).GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        guild2 = enumerator.Current;
                        guild2.Save(base.Database);
                    }
                    goto IL_8F;
                }
IL_71:
                guild2 = this.m_guildsToDelete.Pop();
                base.Database.Delete(guild2.Record);
IL_8F:
                if (this.m_guildsToDelete.Count > 0)
                {
                    goto IL_71;
                }
            }
        }
Exemple #10
0
 public override void DataBind()
 {
     this.Items.Clear();
     this.Items.Add(new System.Web.UI.WebControls.ListItem(this.NullToDisplay, string.Empty));
     if (this.IsUnclassified)
     {
         this.Items.Add(new System.Web.UI.WebControls.ListItem("未分类商品", "0"));
     }
     System.Collections.Generic.IList <CategoryInfo> list;
     if (this.IsTopCategory)
     {
         list = SubsiteCatalogHelper.GetMainCategories();
         using (System.Collections.Generic.IEnumerator <CategoryInfo> enumerator = list.GetEnumerator())
         {
             while (enumerator.MoveNext())
             {
                 CategoryInfo current = enumerator.Current;
                 this.Items.Add(new System.Web.UI.WebControls.ListItem(Globals.HtmlDecode(current.Name), current.CategoryId.ToString()));
             }
             return;
         }
     }
     list = SubsiteCatalogHelper.GetSequenceCategories();
     for (int i = 0; i < list.Count; i++)
     {
         this.Items.Add(new System.Web.UI.WebControls.ListItem(this.FormatDepth(list[i].Depth, Globals.HtmlDecode(list[i].Name)), list[i].CategoryId.ToString(System.Globalization.CultureInfo.InvariantCulture)));
     }
 }
            private bool __MoveNext()
            {
                bool moveNext()
                {
                    if (_subEnumerator.MoveNext())
                    {
#if !WinCopies3
Current 
#else
                        _current
#endif
                        = _subEnumerator.Current;

                        return true;
                    }

                    return false;
                }

                do
                {
                    if (moveNext())

                        return true;

                } while (_MoveNext());

                return false;
            }
Exemple #12
0
        /// <summary>
        /// Counts the items within the given list.
        /// <locDE><para />Zählt die Elemente in der angegebenen Liste.</locDE>
        /// </summary>
        /// <typeparam name="T">The element type of the given list.<locDE><para />Elementtyp der angegebenen Liste.</locDE></typeparam>
        /// <param name="source">The list to count the contained items.<locDE><para />Liste, deren Elemente gezählt werden soll.</locDE></param>
        /// <param name="stopCountAt">Stop counting at this value (i.e. just want to know if there are at least n items).
        /// <locDE><para />Zählung beim Erreichen dieses Wertes abbrechen (wenn man nur wissen will, ob mind. soviele Elemente enthalten sind).</locDE></param>
        /// <returns>Item count (maybe limited by stopCountAt value).<locDE><para />Anzahl der Elemente (ggf. limitiert durch stopCountAt Wert).</locDE></returns>
        public static int Count <T>(this System.Collections.Generic.IEnumerable <T> source, int stopCountAt)
        {
            if (null == source)
            {
                return(0);
            }

            System.Collections.Generic.ICollection <T> genCollection = source as System.Collections.Generic.ICollection <T>;
            if (null != genCollection)
            {
                return(Math.Min(genCollection.Count, stopCountAt));
            }

            System.Collections.ICollection stdcollection = source as System.Collections.ICollection;
            if (null != stdcollection)
            {
                return(Math.Min(stdcollection.Count, stopCountAt));
            }

            int num = 0;

            using (System.Collections.Generic.IEnumerator <T> enumerator = source.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    num++;
                    if (num > stopCountAt)
                    {
                        break;
                    }
                }
            }
            return(num);
        }
Exemple #13
0
    public static string ToEngFormat <T, T2>(this System.Collections.Generic.IEnumerable <T> collection, string word, System.Func <T, T2> select, System.Func <T2, bool> where, System.Func <T2, string> select2)
    {
        System.Collections.Generic.List <string> list = new System.Collections.Generic.List <string>();
        if (typeof(T).IsValueType)
        {
            using (System.Collections.Generic.IEnumerator <T> enumerator = collection.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    T      current = enumerator.Current;
                    T2     arg     = select(current);
                    string item;
                    if (where (arg) && !string.IsNullOrEmpty(item = select2(arg)))
                    {
                        list.Add(item);
                    }
                }
                goto IL_CE;
            }
        }
        foreach (T current2 in collection)
        {
            T2     arg;
            string item;
            if (current2 != null && (arg = select(current2)) != null && where (arg) && !string.IsNullOrEmpty(item = select2(arg)))
            {
                list.Add(item);
            }
        }
IL_CE:
        return(RCextensions.HandleEngFormat(word, list));
    }
    public bool PosTest1()
    {
        bool   retVal = true;
        String str    = TestLibrary.Generator.GetString(-55, true, minLength, maxLength);

        TestLibrary.TestFramework.BeginScenario("Check IENumerator.get_Current show the correct element when index is valid...");
        char[] strCopy = new char[str.Length];
        str.CopyTo(0, strCopy, 0, str.Length);

        try
        {
            System.Collections.Generic.IEnumerator <Char> charIEnum = (System.Collections.Generic.IEnumerator <Char>)((System.Collections.Generic.IEnumerable <Char>)str).GetEnumerator();
            charIEnum.Reset();

            for (int i = 0; i < str.Length; i++)
            {
                charIEnum.MoveNext();
                if (!charIEnum.Current.Equals(strCopy[i]))
                {
                    TestLibrary.TestFramework.LogError("001", "IENumerator.get_Current show the wrong element when index is valid!");
                    retVal = false;
                }
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("002", "Unecpected exception occurs :" + e);
            retVal = false;
        }

        return(retVal);
    }
Exemple #15
0
        public override void InitializeList()
        {
            FilteredElementCollector elements = base.GetElements();

            System.Collections.Generic.IEnumerator <Element> enumerator = elements.GetEnumerator();
            while (enumerator.MoveNext())
            {
                Element element = null;
                try
                {
                    element = enumerator.Current;
                    Parameter parameter = element.get_Parameter((BuiltInParameter)(-1002500));
                    if (parameter != null && !string.IsNullOrEmpty(parameter.AsString()))
                    {
                        base.Add(element);
                    }
                }
                catch (System.Exception)
                {
                    if (element != null)
                    {
                        Log.WriteLine("Get BuiltInParameter.UNIFORMAT_CODE failed: " + element.Id);
                    }
                }
            }
        }
Exemple #16
0
        private static System.Collections.Generic.Dictionary <int, SensorValueEntry> GetSensorValue(System.Collections.Generic.Dictionary <string, string> result)
        {
            System.Collections.Generic.Dictionary <int, SensorValueEntry> dictionary = new System.Collections.Generic.Dictionary <int, SensorValueEntry>();
            System.Collections.Generic.IEnumerator <string> enumerator = result.Keys.GetEnumerator();
            ApcSensorStatusMib apcSensorStatusMib = null;
            int num = 0;

            while (enumerator.MoveNext())
            {
                string text  = enumerator.Current;
                string text2 = result[text];
                if ("\0".Equals(text2) || "n/a".Equals(text2) || "N/A".Equals(text2) || "-1".Equals(text2))
                {
                    text2 = System.Convert.ToString(-1000);
                }
                else
                {
                    if (string.IsNullOrEmpty(text2) || text2.Equals("Null"))
                    {
                        text2 = System.Convert.ToString(-500);
                    }
                }
                if (text.LastIndexOf(".0") > 0)
                {
                    text = text.Substring(0, text.LastIndexOf(".0"));
                }
                int num2 = System.Convert.ToInt32(text.Substring(text.LastIndexOf(".") + 1));
                if (!dictionary.ContainsKey(num2))
                {
                    SensorValueEntry value = new SensorValueEntry(num2);
                    dictionary.Add(num2, value);
                }
                if (num != num2)
                {
                    apcSensorStatusMib = new ApcSensorStatusMib(num2);
                    num = num2;
                }
                SensorValueEntry sensorValueEntry = dictionary[num2];
                if (text.StartsWith(apcSensorStatusMib.Humidity))
                {
                    sensorValueEntry.Humidity = text2;
                }
                else
                {
                    if (text.StartsWith(apcSensorStatusMib.Temperature))
                    {
                        if (text2.Equals(System.Convert.ToString(-1000)) || text2.Equals(System.Convert.ToString(-500)))
                        {
                            sensorValueEntry.Temperature = text2;
                        }
                        else
                        {
                            sensorValueEntry.Temperature = ((float)System.Convert.ToInt32(text2) / 10f).ToString();
                        }
                    }
                }
            }
            return(dictionary);
        }
Exemple #17
0
        public static void InitFromProcessParameters<T>(T obj, System.Collections.Generic.IEnumerator<string> enumerator) where T : ArchiveProcessParameters
        {
            ThrowIfNull(obj, nameof(obj));
            ThrowIfNull(enumerator, nameof(enumerator));

            System.Reflection.PropertyInfo[] enumerable = obj.GetType().GetProperties();

            try
            {
                ActionIn<System.Reflection.PropertyInfo> action = _action;

                void _action(in System.Reflection.PropertyInfo _p)
                {
                    void __action(in System.Reflection.PropertyInfo __p)
                    {
                        if (enumerator.MoveNext())

                            __p.SetValue(obj, typeof(Enum).IsAssignableFrom(__p.PropertyType) ? Enum.Parse(__p.PropertyType, enumerator.Current) : Convert.ChangeType(enumerator.Current, __p.PropertyType));

                        else

                            throw new InvalidOperationException(ProcessParametersCouldNotBeParsedCorrectly);
                    }

                    if (_p.Name == nameof(Guid))
                    {
                        action = __action;

                        _ = enumerator.MoveNext();

                        return;
                    }

                    __action(_p);
                }

                foreach (System.Reflection.PropertyInfo p in enumerable)

                    action(p);
            }

            catch (Exception ex) when (ex.Is(false, typeof(InvalidCastException), typeof(FormatException), typeof(OverflowException), typeof(ArgumentNullException)))
            {
                throw new InvalidOperationException(ProcessParametersCouldNotBeParsedCorrectly, ex);
            }
        }
Exemple #18
0
        ///////////////////////////////////////////////////////////////
        public E this[int i]
        {
            get
            {
                Debug.Assert(i >= 0);
                Debug.Assert(i < expressions.Count);

                System.Collections.Generic.IEnumerator <E> ie = expressions.GetEnumerator();
                ie.MoveNext();
                for (int j = 0; j < i; j++)
                {
                    ie.MoveNext();
                }

                return(ie.Current);
            }
        }
Exemple #19
0
        private static System.Collections.Generic.Dictionary <int, BankValueEntry> GetBankValue(System.Collections.Generic.Dictionary <string, string> result)
        {
            System.Collections.Generic.Dictionary <int, BankValueEntry> dictionary = new System.Collections.Generic.Dictionary <int, BankValueEntry>();
            System.Collections.Generic.IEnumerator <string>             enumerator = result.Keys.GetEnumerator();
            int num = 0;

            while (enumerator.MoveNext())
            {
                string current = enumerator.Current;
                string text    = result[current];
                if ("\0".Equals(text))
                {
                    text = System.Convert.ToString(-1000);
                }
                else
                {
                    if (string.IsNullOrEmpty(text))
                    {
                        text = System.Convert.ToString(-500);
                    }
                }
                int num2 = System.Convert.ToInt32(current.Substring(current.LastIndexOf(".") + 1));
                if (!dictionary.ContainsKey(num2))
                {
                    BankValueEntry value = new BankValueEntry(num2);
                    dictionary.Add(num2, value);
                }
                if (num != num2)
                {
                    new BankValueMib(num2);
                    num = num2;
                }
                BankValueEntry          bankValueEntry         = dictionary[num2];
                EatonGroupCurrentMib_M2 eatonGroupCurrentMib_M = new EatonGroupCurrentMib_M2(num2);
                EatonGroupVoltageMib_M2 eatonGroupVoltageMib_M = new EatonGroupVoltageMib_M2(num2);
                EatonGroupPowerMib_M2   eatonGroupPowerMib_M   = new EatonGroupPowerMib_M2(num2);
                if (current.StartsWith(eatonGroupCurrentMib_M.CurrentValue))
                {
                    bankValueEntry.Current = System.Convert.ToString((float)System.Convert.ToInt32(text) / 1000f);
                }
                else
                {
                    if (current.StartsWith(eatonGroupVoltageMib_M.VoltageValue))
                    {
                        bankValueEntry.Voltage = System.Convert.ToString((float)System.Convert.ToInt32(text) / 1000f);
                    }
                    else
                    {
                        if (current.StartsWith(eatonGroupPowerMib_M.PowerValue))
                        {
                            bankValueEntry.Power = text;
                        }
                    }
                }
            }
            return(dictionary);
        }
Exemple #20
0
        private void btnUpdateOrderAmount_Click(object sender, System.EventArgs e)
        {
            if (!this.order.CheckAction(OrderActions.SELLER_MODIFY_TRADE))
            {
                this.ShowMsg("你当前订单的状态不能进行修改订单费用操作", false);
                return;
            }
            decimal adjustedFreight;
            decimal payCharge;
            decimal adjustedDiscount;

            if (!this.ValidateValues(out adjustedFreight, out payCharge, out adjustedDiscount))
            {
                return;
            }
            string text = string.Empty;

            this.order.AdjustedFreight  = adjustedFreight;
            this.order.PayCharge        = payCharge;
            this.order.AdjustedDiscount = adjustedDiscount;
            decimal total = this.order.GetTotal();

            this.order.Points = this.GetPoint(this.order);
            ValidationResults validationResults = Validation.Validate <OrderInfo>(this.order, new string[]
            {
                "ValOrder"
            });

            if (!validationResults.IsValid)
            {
                using (System.Collections.Generic.IEnumerator <ValidationResult> enumerator = ((System.Collections.Generic.IEnumerable <ValidationResult>)validationResults).GetEnumerator())
                {
                    if (enumerator.MoveNext())
                    {
                        ValidationResult current = enumerator.Current;
                        text += Formatter.FormatErrorMessage(current.Message);
                        this.ShowMsg(text, false);
                        return;
                    }
                }
            }
            if (total > 0m)
            {
                if (OrderHelper.UpdateOrderAmount(this.order))
                {
                    this.BindTatolAmount(this.order);
                    this.ShowMsg("成功的修改了订单金额", true);
                    return;
                }
                this.ShowMsg("修改订单金额失败", false);
                return;
            }
            else
            {
                this.ShowMsg("订单的应付总金额不应该是负数,请重新输入订单折扣", false);
            }
        }
Exemple #21
0
        public static ValueMessage GetValueMessageApcPDU(DevModelConfig modelCfg, System.Collections.Generic.Dictionary <string, string> result)
        {
            ValueMessage valueMessage = new ValueMessage();

            System.Collections.Generic.Dictionary <string, string> dictionary  = new System.Collections.Generic.Dictionary <string, string>();
            System.Collections.Generic.Dictionary <string, string> dictionary2 = new System.Collections.Generic.Dictionary <string, string>();
            System.Collections.Generic.Dictionary <string, string> dictionary3 = new System.Collections.Generic.Dictionary <string, string>();
            System.Collections.Generic.IEnumerator <string>        enumerator  = result.Keys.GetEnumerator();
            while (enumerator.MoveNext())
            {
                string current = enumerator.Current;
                string text    = result[current];
                if (current.StartsWith(ApcDeviceStatusMib.Entry) || current.StartsWith(ApcPhaseStatusMib.Entry))
                {
                    dictionary.Add(current, text);
                }
                else
                {
                    if (current.StartsWith(ApcBankStatusMib.Entry))
                    {
                        dictionary2.Add(current, text);
                    }
                    else
                    {
                        if (current.StartsWith(ApcPDUBaseMib.Mac))
                        {
                            valueMessage.DeviceReplyMac = text.Replace(" ", ":").Replace("-", ":");
                        }
                        else
                        {
                            if (current.StartsWith(ApcSensorStatusMib.Entry))
                            {
                                dictionary3.Add(current, text);
                            }
                        }
                    }
                }
            }
            if (dictionary != null && dictionary.Count > 0)
            {
                valueMessage.DeviceValue = ApcMibParser.GetDeviceValue(dictionary);
            }
            if (dictionary2 != null && dictionary2.Count > 0)
            {
                valueMessage.BankValue = ApcMibParser.GetBankValue(dictionary2);
            }
            if (dictionary3 != null && dictionary3.Count > 0)
            {
                valueMessage.SensorValue = ApcMibParser.GetSensorValue(dictionary3);
            }
            else
            {
                valueMessage.SensorValue = ApcMibParser.GetSensorValue_Empty(dictionary3);
            }
            return(valueMessage);
        }
Exemple #22
0
        public static SortedSet <T> ToSet <T> (this System.Collections.Generic.IEnumerator <T> obj)
        {
            SortedSet <T> s = new SortedSet <T> ();

            while (obj.MoveNext())
            {
                s.Add(obj.Current);
            }
            return(s);
        }
Exemple #23
0
        private static System.Collections.Generic.Dictionary <int, SensorThreshold> GetSensorThreshold(System.Collections.Generic.Dictionary <string, string> result)
        {
            System.Collections.Generic.Dictionary <int, SensorThreshold> dictionary = new System.Collections.Generic.Dictionary <int, SensorThreshold>();
            System.Collections.Generic.IEnumerator <string> enumerator = result.Keys.GetEnumerator();
            ApcSensorConfigMib apcSensorConfigMib = null;
            int num = 0;

            while (enumerator.MoveNext())
            {
                string current = enumerator.Current;
                string text    = result[current];
                if ("\0".Equals(text))
                {
                    text = System.Convert.ToString(-1000);
                }
                else
                {
                    if (text == null || string.IsNullOrEmpty(text) || text.Equals("Null"))
                    {
                        text = System.Convert.ToString(-500);
                    }
                    else
                    {
                        if (text.Equals("-1"))
                        {
                            text = System.Convert.ToString(-600);
                        }
                    }
                }
                int num2 = System.Convert.ToInt32(current.Substring(current.LastIndexOf(".") + 1));
                if (!dictionary.ContainsKey(num2))
                {
                    SensorThreshold value = new SensorThreshold(num2);
                    dictionary.Add(num2, value);
                }
                if (num != num2)
                {
                    apcSensorConfigMib = new ApcSensorConfigMib(num2);
                    num = num2;
                }
                SensorThreshold sensorThreshold = dictionary[num2];
                if (current.StartsWith(apcSensorConfigMib.MaxTemperature))
                {
                    sensorThreshold.MaxTemperatureMT = (float)System.Convert.ToInt32(text);
                }
                else
                {
                    if (current.StartsWith(apcSensorConfigMib.MinHumidity))
                    {
                        sensorThreshold.MinHumidityMT = (float)System.Convert.ToInt32(text);
                    }
                }
            }
            return(dictionary);
        }
Exemple #24
0
        private static DeviceValueEntry GetDeviceValue(System.Collections.Generic.Dictionary <string, string> result)
        {
            DeviceValueEntry deviceValueEntry = new DeviceValueEntry();

            System.Collections.Generic.IEnumerator <string> enumerator = result.Keys.GetEnumerator();
            while (enumerator.MoveNext())
            {
                string current = enumerator.Current;
                string text    = result[current];
                if ("\0".Equals(text))
                {
                    text = System.Convert.ToString(-1000);
                }
                else
                {
                    if (string.IsNullOrEmpty(text))
                    {
                        text = System.Convert.ToString(-500);
                    }
                }
                int num = System.Convert.ToInt32(current.Substring(current.LastIndexOf(".") + 1));
                if (num == 1)
                {
                    ApcDeviceStatusMib apcDeviceStatusMib = new ApcDeviceStatusMib(num);
                    ApcPhaseStatusMib  apcPhaseStatusMib  = new ApcPhaseStatusMib(num);
                    System.Convert.ToInt32(text);
                    if (current.StartsWith(apcDeviceStatusMib.PowerStatus))
                    {
                        deviceValueEntry.Power = System.Convert.ToString((float)System.Convert.ToInt32(text) / 100f * 1000f);
                    }
                    else
                    {
                        if (current.StartsWith(apcDeviceStatusMib.PowerDsptStatus))
                        {
                            deviceValueEntry.PowerDissipation = System.Convert.ToString((float)System.Convert.ToInt32(text) / 10f);
                        }
                        else
                        {
                            if (current.StartsWith(apcPhaseStatusMib.CurrentStatus))
                            {
                                deviceValueEntry.Current = System.Convert.ToString((float)System.Convert.ToInt32(text) / 10f);
                            }
                            else
                            {
                                if (current.StartsWith(apcPhaseStatusMib.VoltageStatus))
                                {
                                    deviceValueEntry.Voltage = text;
                                }
                            }
                        }
                    }
                }
            }
            return(deviceValueEntry);
        }
Exemple #25
0
        public static PropertiesMessage GetApcPDUPropertiesMessage(System.Collections.Generic.Dictionary <string, string> variables)
        {
            if (variables == null || variables.Count < 1)
            {
                return(null);
            }
            PropertiesMessage propertiesMessage = new PropertiesMessage();

            System.Collections.Generic.IEnumerator <string> enumerator = variables.Keys.GetEnumerator();
            while (enumerator.MoveNext())
            {
                string current = enumerator.Current;
                string text    = variables[current];
                if (current.StartsWith(ApcPDUBaseMib.DeviceName))
                {
                    if ("\0".Equals(text) || string.IsNullOrEmpty(text))
                    {
                        text = string.Empty;
                    }
                    propertiesMessage.DeviceName = text;
                }
                else
                {
                    if (current.StartsWith(ApcPDUBaseMib.FWversion))
                    {
                        text = text.Replace("v", "");
                        text = text.Replace("V", "");
                        propertiesMessage.FirwWareVersion = text;
                    }
                    else
                    {
                        if (current.StartsWith(ApcPDUBaseMib.Mac))
                        {
                            propertiesMessage.MacAddress = text.Replace(" ", ":").Replace("-", ":");
                        }
                        else
                        {
                            if (!current.StartsWith(ApcPDUBaseMib.ModelName))
                            {
                                return(null);
                            }
                            if ("\0".Equals(text) || string.IsNullOrEmpty(text))
                            {
                                return(null);
                            }
                            propertiesMessage.ModelName = text;
                        }
                    }
                }
            }
            propertiesMessage.DashboardRackname = "";
            propertiesMessage.CreateTime        = System.DateTime.Now;
            return(propertiesMessage);
        }
        static void printActivityTree(Activity activity, string tag)
        {
            Console.WriteLine("{0} DisplayName:{1},type:{2}", tag, activity.DisplayName, activity.GetType());

            System.Collections.Generic.IEnumerator <Activity> list = WorkflowInspectionServices.GetActivities(activity).GetEnumerator();

            while (list.MoveNext())
            {
                printActivityTree(list.Current, "  " + tag);
            }
        }
Exemple #27
0
 public static void ClearAll()
 {
     System.Collections.Generic.IEnumerator <string> names = instances.Keys.GetEnumerator
                                                                 ();
     while (names.MoveNext())
     {
         string name = names.Current;
         NeoDatis.Odb.Core.Transaction.ICrossSessionCache cache = instances[name];
         cache.Clear();
     }
     instances.Clear();
 }
    public bool NegTest2()
    {
        bool   retVal = true;
        String str    = TestLibrary.Generator.GetString(-55, true, minLength, maxLength);

        TestLibrary.TestFramework.BeginScenario("Check the last index...");
        char[] strCopy = new char[str.Length];
        str.CopyTo(0, strCopy, 0, str.Length);

        try
        {
            System.Collections.Generic.IEnumerator <Char> charIEnum = (System.Collections.Generic.IEnumerator <Char>)((System.Collections.Generic.IEnumerable <Char>)str).GetEnumerator();
            charIEnum.Reset();
            for (int i = 0; i < str.Length; i++)
            {
                charIEnum.MoveNext();
                if (!charIEnum.Current.Equals(strCopy[i]))
                {
                    TestLibrary.TestFramework.LogError("005", "IEnumerator.get_Current show the wrong element!");
                    retVal = false;
                }
            }
            charIEnum.MoveNext();
            char charTest = (char)charIEnum.Current;

            TestLibrary.TestFramework.LogError("006", "No exception occurs when fetch IEnumerator.Current out of range!");
            retVal = false;
        }
        catch (InvalidOperationException)
        {
            TestLibrary.TestFramework.LogInformation("InvalidOperationException is thrown after fetch IEnumerator.Current out of range");
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("007", "Unexpected exception occurs: " + e);
            return(retVal);
        }

        return(retVal);
    }
Exemple #29
0
        public static bool Any <TSource>(IEnumerable <TSource> source)
        {
            Check.Source(source);

            ICollection <TSource> collection = source as ICollection <TSource>;

            if (collection != null)
            {
                return(collection.Count > 0);
            }

            using (System.Collections.Generic.IEnumerator <TSource> enumerator = source.GetEnumerator())
                return(enumerator.MoveNext());
        }
Exemple #30
0
        private static System.Collections.Generic.Dictionary <int, SensorValueEntry> GetSensorValue(System.Collections.Generic.Dictionary <string, string> result)
        {
            System.Collections.Generic.Dictionary <int, SensorValueEntry> dictionary = new System.Collections.Generic.Dictionary <int, SensorValueEntry>();
            System.Collections.Generic.IEnumerator <string> enumerator = result.Keys.GetEnumerator();
            int num = 0;

            while (enumerator.MoveNext())
            {
                string current = enumerator.Current;
                string value   = result[current];
                if ("\0".Equals(value) || "n/a".Equals(value) || "N/A".Equals(value))
                {
                    value = System.Convert.ToString(-10000);
                }
                else
                {
                    if (string.IsNullOrEmpty(value))
                    {
                        value = System.Convert.ToString(-5000);
                    }
                }
                string text = ((float)System.Convert.ToInt32(value) / 10f).ToString();
                int    num2 = System.Convert.ToInt32(current.Substring(current.LastIndexOf(".") + 1));
                if (!dictionary.ContainsKey(num2))
                {
                    SensorValueEntry value2 = new SensorValueEntry(num2);
                    dictionary.Add(num2, value2);
                }
                if (num != num2)
                {
                    new SensorValueMib(num2);
                    num = num2;
                }
                SensorValueEntry             sensorValueEntry            = dictionary[num2];
                EatonSensorTemperatureMib_M2 eatonSensorTemperatureMib_M = new EatonSensorTemperatureMib_M2(num2);
                EatonSensorHumidityMib_M2    eatonSensorHumidityMib_M    = new EatonSensorHumidityMib_M2(num2);
                if (current.StartsWith(eatonSensorTemperatureMib_M.TemperatureValue))
                {
                    sensorValueEntry.Temperature = text;
                }
                else
                {
                    if (current.StartsWith(eatonSensorHumidityMib_M.HumidityValue))
                    {
                        sensorValueEntry.Humidity = text;
                    }
                }
            }
            return(dictionary);
        }