Пример #1
0
        private void ExpenseManagement(IEquatable <string> operationRequest)
        {
            using (var frmExpense = new FrmExpense())
            {
                if (operationRequest.Equals(Resources.OperationRequestUpdate))
                {
                    frmExpense.Expense = _ExpenseList[dgvExpense.CurrentRow.Index];
                }

                if (frmExpense.ShowDialog(this) == DialogResult.OK)
                {
                    try
                    {
                        if (operationRequest.Equals(Resources.OperationRequestInsert))
                        {
                            _ExpenseList.Add(frmExpense.Expense);
                        }

                        dgvExpense.Refresh();
                        UpdateResultInfo();
                        EnableActionButton();
                    }
                    catch (Exception exception)
                    {
                        FrmExtendedMessageBox.UnknownErrorMessage(
                            Resources.MsgCaptionUnknownError,
                            exception.Message);
                    }
                }
            }
        }
Пример #2
0
        public void PopReceipt_ValidateInterfaces()
        {
            // Create a PopReceipt instances.
            PopReceipt pr      = new PopReceipt();
            PopReceipt pr1     = new PopReceipt(sTestPopReceipt1);
            PopReceipt emptyPR = new PopReceipt(sEmptyPopReceipt);

            // Check that is the empty PopReceipt.
            Assert.AreEqual <PopReceipt>(PopReceipt.Empty, pr);

            // Validate that the instance can be case to each of the interfaces.
            IFormattable iFormattable = pr as IFormattable;

            Assert.IsNotNull(iFormattable);

            IComparable <PopReceipt> iComparablePR = pr as IComparable <PopReceipt>;

            Assert.IsNotNull(iComparablePR);

            IEquatable <PopReceipt> iEquatablePR
                = pr as IEquatable <PopReceipt>;

            Assert.IsNotNull(iEquatablePR);

            // Use each interface's methods.
            string sPR = iFormattable.ToString();

            Assert.AreEqual <string>(sEmptyPopReceipt, sPR);

            Assert.AreEqual <int>(-1, iComparablePR.CompareTo(pr1));
            Assert.IsFalse(iEquatablePR.Equals(pr1));
            Assert.IsTrue(iEquatablePR.Equals(emptyPR));
        }
Пример #3
0
    public void HandlesImplementsIEquatable()
    {
        var handle5 = new HANDLE((IntPtr)5);
        IEquatable <HANDLE> handle5Equatable = handle5;
        var handle8 = new HANDLE((IntPtr)8);

        Assert.True(handle5Equatable.Equals(handle5));
        Assert.False(handle5Equatable.Equals(handle8));
    }
Пример #4
0
        public static void IsCanonical <T>(this IEquatableAssert assert, IEquatable <T> equatable)
        {
            Assert.IsFalse(equatable.Equals(default(T)), CreateMessage("x.Equals(null) == False"));
            Assert.IsFalse(equatable.Equals(default(object)), CreateMessage("x.Equals(null) == False"));

            string CreateMessage(string requirement)
            {
                return($"{typeof(IEquatable<T>).ToPrettyString()} violates the {requirement.QuoteWith("'")} requirement.");
            }
        }
Пример #5
0
 static bool pnlMatchesSelection(IEquatable <string> selected, double value)
 {
     if (selected.Equals("ALL"))
     {
         return(true);
     }
     if (selected.Equals("losing"))
     {
         return(value < 0);
     }
     return(value > 0);
 }
Пример #6
0
        private static string PosInFocus(IEquatable <string> metricName)
        {
            var posOut = String.Empty;

            if (metricName.Equals("Tdp"))
            {
                posOut = "QB";
            }
            if (metricName.Equals("Tdr"))
            {
                posOut = "RB";
            }
            return(posOut);
        }
Пример #7
0
    public void EqualityChecks()
    {
        HResult hr3 = 3;
        HResult hr5 = 5;
        IEquatable <HResult> hr3Equatable = hr3;

        Assert.Equal(hr3, hr3);
        Assert.True(hr3.Equals(hr3));
        Assert.True(hr3Equatable.Equals(hr3));

        Assert.NotEqual(hr3, hr5);
        Assert.False(hr3.Equals(hr5));
        Assert.False(hr3Equatable.Equals(hr5));
    }
Пример #8
0
    public void EqualityChecks()
    {
        NTSTATUS hr3 = 3;
        NTSTATUS hr5 = 5;
        IEquatable <NTSTATUS> hr3Equatable = hr3;

        Assert.Equal(hr3, hr3);
        Assert.True(hr3.Equals(hr3));
        Assert.True(hr3Equatable.Equals(hr3));

        Assert.NotEqual(hr3, hr5);
        Assert.False(hr3.Equals(hr5));
        Assert.False(hr3Equatable.Equals(hr5));
    }
 public static bool ElementaryEqualsThenEquatableEquals <T>(IEquatable <T> obj, object other)
 {
     return(ElementaryEquals(obj, other)
            ?? (obj.GetType() != other.GetType()
             ? false
             : obj.Equals((T)other)));
 }
Пример #10
0
        public static void AreEqual <T>(IEquatable <T> expected, IEquatable <T> actual, string varName = "", params object[] args)
        {
            var errorMsg = "Assert.AreEqual() FAILED: expected " +
                           varName + "= " + expected + " NOT equal to actual " + varName + "= " + actual;

            Assert(expected.Equals(actual), errorMsg, args);
        }
Пример #11
0
        public static void TestArrayTypeAlias()
        {
            IFoo <IBar[]> foo = new G1 <IBar[]>();

            Assert.AreEqual(1, foo.Foo(null));

            IFoo <string> foo1 = new G2();

            Assert.AreEqual(2, foo1.Foo(null));

            var g3 = new G3();
            IEquatable <IBar[]>   ibar = g3;
            IEquatable <string[]> istr = g3;

            g3.tracker = 0;
            g3.Equals(new IBar[0]);
            Assert.AreEqual(1, g3.tracker);

            g3.tracker = 0;
            ibar.Equals(new IBar[0]);
            Assert.AreEqual(1, g3.tracker);

            g3.tracker = 0;
            istr.Equals(new string[0]);
            Assert.AreEqual(2, g3.tracker);
        }
Пример #12
0
        public static void IfNotEquals <T>(T item, T wrongValue)
            where T : IConvertible, IEquatable <T>
        {
            bool notEquals = !IEquatable <T> .Equals(item, wrongValue);

            ThrowImpl(notEquals, new ArgumentException("Should not be equal"));
        }
Пример #13
0
        public static void IfEquals <T>(T item, T wrongValue)
            where T : IConvertible, IEquatable <T>
        {
            bool equals = IEquatable <T> .Equals(item, wrongValue);

            IfTrue(equals, nameof(item));
        }
 private static IRejectedExecutionHandler CreateRejectedExecutionHandler(IEquatable <string> policyName)
 {
     if (policyName.Equals("ABORT"))
     {
         return(new ThreadPoolExecutor.AbortPolicy());
     }
     if (policyName.Equals("DISCARD"))
     {
         return(new ThreadPoolExecutor.DiscardPolicy());
     }
     if (policyName.Equals("DISCARD_OLDEST"))
     {
         return(new ThreadPoolExecutor.DiscardOldestPolicy());
     }
     return(new ThreadPoolExecutor.CallerRunsPolicy());
 }
 /// <summary>
 ///     Instructs that a better ranking would have the same value between the two given value.
 /// </summary>
 /// <param name="a">The first entity's value.</param>
 /// <param name="b">The second entity's value.</param>
 /// <param name="weight">The weighting to give this comparison.</param>
 public void NotEqual <T>(IEquatable <T> a, IEquatable <T> b, float weight)
 {
     if (!a.Equals(b))
     {
         ranking += weight;
     }
 }
Пример #16
0
        public static bool InSet <T>(this T value, params T[] set)
        {
            IEquatable <T> eqvalue = value as IEquatable <T>;

            if (eqvalue != null)
            {
                for (int i = 0; i < set.Length; i++)
                {
                    if (eqvalue.Equals(set[i]))
                    {
                        return(true);
                    }
                }
            }
            else if (value != null)
            {
                for (int i = 0; i < set.Length; i++)
                {
                    if (value.Equals(set[i]))
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
Пример #17
0
        public void HashBasedEquatibleRealValueNodesEqualsTest()
        {
            var c = new HashBasedEquatibleRealValueNodesConverter();

            IEquatable <RealValueNodes> n1 = c.Covert(new RealValueNodes(new double[] { 1.0, 1.0 }, new double[] { 1.0, 2.0 }, new double[] { 1.0, 5.0 }));
            IEquatable <RealValueNodes> n2 = c.Covert(new RealValueNodes(new double[] { 1.0, 1.0 }, new double[] { 1.0, 2.0 }, new double[] { 1.0, 5.0 }));
            IEquatable <RealValueNodes> n3 = c.Covert(new RealValueNodes(new double[] { 1.0, 1.0 }, new double[] { 1.0, 2.0 }, new double[] { 1.0, 4.0 }));
            IEquatable <RealValueNodes> n4 = c.Covert(new RealValueNodes(new double[] { 1.0, 3.0 }, new double[] { 1.0, 2.0 }, new double[] { 1.0, 5.0 }));

            Assert.IsTrue(n1.Equals(n2));
            Assert.IsTrue(n1.Equals(new RealValueNodes(new double[] { 1.0, 1.0 }, new double[] { 1.0, 2.0 }, new double[] { 1.0, 5.0 })));
            Assert.IsFalse(n1.Equals(n3));
            Assert.IsFalse(n1.Equals(n4));
            Assert.IsFalse(n4.Equals(n3));
            Assert.IsFalse(n2.Equals(n4));
        }
Пример #18
0
        protected virtual bool PerformEqualToOperation(T currentValue, T referenceValue)
        {
            IEquatable <T> original = currentValue as IEquatable <T>;

            // ReSharper disable once PossibleNullReferenceException
            return(original.Equals(referenceValue));
        }
Пример #19
0
 /// <summary>
 /// Throws an ArgumentException if a and b are not equal.
 /// </summary>
 /// <typeparam name="T">The type of objects.</typeparam>
 /// <param name="a">The object to compare.</param>
 /// <param name="b">The object to compare to.</param>
 public static void Equals <T>(IEquatable <T> a, IEquatable <T> b)
 {
     if (!a.Equals(b))
     {
         throw new ArgumentException("The objects are not equal");
     }
 }
Пример #20
0
 private GeneticCode(string name, string aas, string start, IEquatable <string> base1, IEquatable <string> base2,
                     IEquatable <string> base3)
 {
     if (!base1.Equals(b1))
     {
         throw new Exception("Wrong codons.");
     }
     if (!base2.Equals(b2))
     {
         throw new Exception("Wrong codons.");
     }
     if (!base3.Equals(b3))
     {
         throw new Exception("Wrong codons.");
     }
     this.name  = name;
     this.start = start;
     for (int i = 0; i < b1.Length; i++)
     {
         string codon = "" + b1[i] + b2[i] + b3[i];
         codon2Aa.Add(codon, aas[i]);
         if (codon.Contains("T"))
         {
             string c2 = codon.Replace('T', 'U');
             codon2Aa.Add(c2, aas[i]);
         }
     }
 }
Пример #21
0
        protected bool SetAndRaisePropertyChanged <T>(ref T propertyDataField, T value, [CallerMemberName] string propertyName = null)
        {
            bool           equal;
            IEquatable <T> equatableValue = value as IEquatable <T>;

            if (equatableValue != null)
            {
                equal = equatableValue.Equals(propertyDataField);
            }
            else if (typeof(T).IsSubclassOf(typeof(Enum)))
            {
                equal = Equals(value, propertyDataField);
            }
            else
            {
                equal = Equals(value, propertyDataField);
            }

            if (!equal)
            {
                propertyDataField = value;
                this.RaisePropertyChanged(propertyName);
            }

            return(!equal);
        }
Пример #22
0
        /// <summary>
        /// yeilds an enumeration of enumerations.
        /// takes the sequence of items of <typeparamref name="T"/> and groups them together between the seperator;
        /// eg: where (X) is the seperator:
        /// {1,2,3,4,X,5,6,7,8}
        /// returns:
        ///     {1,2,3,4}
        ///     {5,6,7,8}
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="items">an enumeration of items of type <typeparamref name="T"/></param>
        /// <param name="seperator">the item to seperate on, must be equatable to <typeparamref name="T"/></param>
        /// <returns></returns>
        public static IEnumerable <IEnumerable <T> > Seperate <T>(this IEnumerable <T> items, IEquatable <T> seperator)
        {
            var list = new List <T>();

            // enumerate the items
            foreach (T item in items)
            {
                // whenever we encounter a seperator, yeild the current list and reset it
                if (seperator.Equals(item))
                {
                    // ignore empty lists;
                    if (list.Count > 0)
                    {
                        yield return(list);

                        list = new List <T>();
                    }
                }
                else
                {
                    list.Add(item);
                }
            }

            // don't assume there is a seperator at the end: yield the remaining items (if any)
            if (list.Count > 0)
            {
                yield return(list);
            }
        }
 /// <summary>
 /// IEquatable<T> Equals Check
 /// </summary>
 private void CheckVariableChanged(IEquatable <T> previous, IEquatable <T> next)
 {
     if (!previous.Equals(next))
     {
         ValueChanged();
     }
 }
Пример #24
0
 /// <summary>
 /// Throws an ArgumentException if a and b are not equal.
 /// </summary>
 /// <typeparam name="T">The type of objects.</typeparam>
 /// <param name="a">The object to compare.</param>
 /// <param name="b">The object to compare to.</param>
 public static void Equals <T>(IEquatable <T> a, IEquatable <T> b)
 {
     if (!a.Equals(b))
     {
         throw new ArgumentException();
     }
 }
Пример #25
0
        private bool IsStable(BookmarkScope scope, bool nonScopedBookmarksExist)
        {
            Fx.Assert(_bookmarkManagers.ContainsKey(scope), "The caller should have made sure this scope exists in the bookmark managers dictionary.");

            if (nonScopedBookmarksExist)
            {
                return(false);
            }

            if (_bookmarkManagers != null)
            {
                foreach (KeyValuePair <BookmarkScope, BookmarkManager> scopeBookmarks in _bookmarkManagers)
                {
                    IEquatable <BookmarkScope> comparison = scopeBookmarks.Key;
                    if (!comparison.Equals(scope))
                    {
                        if (scopeBookmarks.Value.HasBookmarks)
                        {
                            return(false);
                        }
                    }
                }
            }

            return(true);
        }
Пример #26
0
        public void TestEquatable()
        {
            var vertex = new Vertex(12.34f, -98.7f, 54);

            IEquatable <Vertex> ieqVertex = vertex;

            Assert.False(ieqVertex.Equals((Vertex)null));

            var vertex2 = new Vertex();

            Assert.False(ieqVertex.Equals(vertex2));

            vertex2 = new Vertex(12.34f, -98.7f, 54);
            Assert.True(ieqVertex.Equals(vertex2));

            Assert.True(ieqVertex.Equals(vertex));
        }
Пример #27
0
        public static void EqualityThroughInterface_Reflexivity()
        {
            int[]        array = { 42, 43, 44, 45, 46 };
            Memory <int> left  = new Memory <int>(array, 2, 3);
            IEquatable <Memory <int> > leftAsEquatable = left;

            Assert.True(leftAsEquatable.Equals(left));
        }
Пример #28
0
 public static int FindIndexOf <T>(this IList <T> modificadoresSeleccionados, IEquatable <T> p)
 {
     if (p is null)
     {
         return(modificadoresSeleccionados.FindIndexOf(x => x is null));
     }
     return(modificadoresSeleccionados.FindIndexOf(x => p.Equals(x)));
 }
Пример #29
0
        public static void CheckEquality <T>(IEquatable <T> obj, Type mappedType)
        {
            if (!obj.Equals((T)obj))
            {
                throw new Exception("Object is not self equal");
            }
            var openGammaFudgeContext = new OpenGammaFudgeContext();
            var fudgeSerializer       = openGammaFudgeContext.GetSerializer();
            //TODO type hint
            FudgeMsg msg        = fudgeSerializer.SerializeToMsg(obj);
            object   rehydrated = fudgeSerializer.Deserialize(msg, mappedType);

            if (!obj.Equals((T)rehydrated))
            {
                throw new Exception("roundtripped object not equals");
            }
        }
            private static string Process(object conditionValue, IEquatable <string> type)
            {
                if (type.Equals("DateTime"))
                {
                    var value = conditionValue.GetType().Equals(typeof(DateTime))
                                    ? (DateTime)conditionValue
                                    : DateTime.Parse(conditionValue.ToString());
                    return(SPUtility.CreateISO8601DateTimeFromSystemDateTime(value));
                }

                if (type.Equals("Boolean"))
                {
                    return((bool)conditionValue ? "TRUE" : "FALSE");
                }

                return(conditionValue.ToString());
            }
Пример #31
0
        private GeneticCode(string name, string aas, string start, IEquatable<string> base1, IEquatable<string> base2,
			IEquatable<string> base3)
        {
            if (!base1.Equals(b1)){
                throw new Exception("Wrong codons.");
            }
            if (!base2.Equals(b2)){
                throw new Exception("Wrong codons.");
            }
            if (!base3.Equals(b3)){
                throw new Exception("Wrong codons.");
            }
            this.name = name;
            this.start = start;
            for (int i = 0; i < b1.Length; i++){
                string codon = "" + b1[i] + b2[i] + b3[i];
                codon2Aa.Add(codon, aas[i]);
                if (codon.Contains("T")){
                    string c2 = codon.Replace('T', 'U');
                    codon2Aa.Add(c2, aas[i]);
                }
            }
        }
Пример #32
0
        private void ProductManagement(IEquatable<string> operationRequest)
        {
            try
            {
                if ((dgvProduct.CurrentRow == null) && (!operationRequest.Equals(Resources.OperationRequestInsert)))
                    return;

                using (var frmCatalog = new FrmCatalog())
                {
                    float preQtyInStock = 0;
                    if (_productList.Count != 0)
                        preQtyInStock = (_productList[dgvProduct.CurrentRow.Index]).QtyInStock;
                    if (operationRequest.Equals(Resources.OperationRequestUpdate))
                        frmCatalog.Product = _productList[dgvProduct.CurrentRow.Index];

                    if (frmCatalog.ShowDialog(this) == DialogResult.OK)
                    {
                        try
                        {
                            if (frmCatalog.Product == null)
                            {
                                IListToBindingList(
                                    _productService.GetCatalogs(chbInstockOnly.Checked));
                            }
                            else
                            {
                                if (operationRequest.Equals(Resources.OperationRequestUpdate))
                                {
                                    UpdateSelectedProduct(
                                        frmCatalog.Product,
                                        preQtyInStock);

                                    if (frmCatalog.Product.QtyInStock == 0)
                                    {
                                        for (var counter = 0; counter < _productList.Count; counter++)
                                        {
                                            if (_productList[counter].ProductId == frmCatalog.Product.ProductId)
                                                _productList.RemoveAt(counter);
                                        }
                                    }
                                }
                                else
                                {
                                    if (frmCatalog.Product.QtyInStock == 0)
                                        _productList.Add(frmCatalog.Product);
                                }
                            }
                            dgvProduct.Refresh();
                            SetProductInfo();

                            UpdateResultInfo();
                            EnableActionButton();
                        }
                        catch (Exception exception)
                        {
                            FrmExtendedMessageBox.UnknownErrorMessage(
                                Resources.MsgCaptionUnknownError,
                                exception.Message);
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                FrmExtendedMessageBox.UnknownErrorMessage(
                    Resources.MsgCaptionUnknownError,
                    exception.Message);
            }
        }
Пример #33
0
 private static DayOfWeek? GetDayOfWeek(IEquatable<string> dateString, IList<string> dayNames)
 {
     for (int i = 0; i < dayNames.Count; i++)
     {
         if (dateString.Equals(dayNames[i].ToLowerInvariant()))
         {
             return (DayOfWeek) (i % 7);
         }
     }
     return null;
 }
 private static IRejectedExecutionHandler CreateRejectedExecutionHandler(IEquatable<string> policyName)
 {
     if(policyName.Equals("ABORT")) {
         return new AbortPolicy();
     }
     if(policyName.Equals("DISCARD")) {
         return new DiscardPolicy();
     }
     if(policyName.Equals("DISCARD_OLDEST")) {
         return new DiscardOldestPolicy();
     }
     return new CallerRunsPolicy();
 }
Пример #35
0
 private void Remove(IEquatable<QuickColorizer> colorizer)
 {
     foreach (ListViewItem item in listViewQuickColorizers.Items)
     {
         if (colorizer.Equals(item.Tag as QuickColorizer))
         {
             item.Remove();
             return;
         }
     }
 }
Пример #36
0
 private void Remove(IEquatable<EtwProvider> provider)
 {
     foreach (ListViewItem item in listView.Items)
     {
         if (provider.Equals(item.Tag as EtwProvider))
         {
             item.Remove();
             return;
         }
     }
 }
Пример #37
0
        /// <summary>
        /// Maintains a list of already processed assemblies.
        /// </summary>
        /// <param name="assemblyName"></param>
        /// <returns></returns>
        private bool AlreadyProcessed(IEquatable<string> assemblyName)
        {
            foreach (string processedAssembly in processedAssemblies)
            {
                if (assemblyName.Equals(processedAssembly))
                {
                    return true;
                }
            }

            return false;
        }
Пример #38
0
 private void EndElement(IEquatable<string> qName, HandleUniprotEntry handle, bool isTrembl)
 {
     if (qName.Equals("sequence")){
         entry.Sequence = StringUtils.RemoveWhitespace(sequence.ToString());
         sequence = null;
     } else if (qName.Equals("keyword")) {
         entry.AddKeyword(StringUtils.RemoveWhitespace(keyword.ToString()));
         keyword = null;
     } else if (qName.Equals("entry")) {
         entry.Accessions = accessions.ToArray();
         entry.ProteinFullNames = proteinFullNames.ToArray();
         entry.ProteinShortNames = proteinShortNames.ToArray();
         entry.ProteinEcNumbers = proteinEcNumbers.ToArray();
         entry.GeneNamesAndTypes = gnames.ToArray();
         entry.OrganismNames = onames.ToArray();
         entry.UniprotNames = unames.ToArray();
         entry.IsTrembl = isTrembl;
         handle(entry);
         entryCount++;
     } else if (qName.Equals("dbReference")){
         inDbRef = false;
     } else if (qName.Equals("accession")){
         accessions.Add(StringUtils.RemoveWhitespace(accession.ToString()));
         accession = null;
     } else if (qName.Equals("location")){
         if (inFeature){
             inFeatureLocation = false;
             entry.AddFeatureLocation(featureBegin, featureEnd);
         }
     } else if (qName.Equals("variation")){
         if (inFeature){
             entry.AddFeatureVariation(StringUtils.RemoveWhitespace(variation.ToString()));
             variation = null;
         }
     } else if (qName.Equals("original")){
         if (inFeature){
             entry.AddFeatureOriginal(StringUtils.RemoveWhitespace(original.ToString()));
             original = null;
         }
     } else if (qName.Equals("feature")){
         inFeature = false;
         foreach (FeatureType type in entry.GetAllFeatureTypes()){
             int c = entry.GetFeatureCount(type);
             if (!featureCounts.ContainsKey(type)){
                 featureCounts.Add(type, 0);
             }
             featureCounts[type] += c;
         }
     } else if (qName.Equals("fullName") && inProteinRecommendedName){
         proteinFullNames.Add(proteinFullName.ToString().Trim());
         proteinFullName = null;
     } else if (qName.Equals("shortName") && inProteinRecommendedName){
         proteinShortNames.Add(proteinShortName.ToString().Trim());
         proteinShortName = null;
     } else if (qName.Equals("ecNumber") && inProteinRecommendedName){
         proteinEcNumbers.Add(proteinEcNumber.ToString().Trim());
         proteinEcNumber = null;
     } else if (qName.Equals("name") && inGene){
         gnames.Add(new Tuple<string, string>(gname.ToString().Trim(), gnameType.Trim()));
         gname = null;
         gnameType = null;
     } else if (qName.Equals("name") && inOrganism){
         if (oname != null){
             string on = oname.ToString().Trim();
             if (on.Length > 0){
                 onames.Add(on);
                 oname = null;
             }
         }
     } else if (qName.Equals("name") && level == 1){
         unames.Add(uname.ToString().Trim());
         uname = null;
     } else if (qName.Equals("protein")){
         inProtein = false;
     } else if (qName.Equals("recommendedName") && inProtein){
         inProteinRecommendedName = false;
     } else if (qName.Equals("gene")){
         inGene = false;
     } else if (qName.Equals("organism")) {
         inOrganism = false;
     } else if (qName.Equals("organismHost")) {
         inOrganismHost = false;
     }
 }
Пример #39
0
        /// <summary>
        /// Add's an option to the x264 query string.
        /// Handles 2 cases.  1 Where rtf_x264Query.Text is empty, and one where there is an option with no value,
        /// e.g no-fast-pskip
        /// </summary>
        /// <param name="optNameToChange">The Option Name to Change</param>
        private void HasNoOptions(IEquatable<string> optNameToChange)
        {
            string colon = string.Empty;
            if (rtf_x264Query.Text != string.Empty)
                colon = ":";

            string query = rtf_x264Query.Text;
            if (optNameToChange.Equals("me"))
            {
                switch (drop_MotionEstimationMethod.SelectedIndex)
                {
                    case 1:
                        query = query + colon + "me=dia";
                        break;

                    case 2:
                        query = query + colon + "me=hex";
                        break;

                    case 3:
                        query = query + colon + "me=umh";
                        break;

                    case 4:
                        query = query + colon + "me=esa";
                        break;

                    case 5:
                        query = query + colon + "me=tesa";
                        break;

                    default:
                        break;
                }
            }
            else if (optNameToChange.Equals("direct"))
            {
                switch (drop_directPrediction.SelectedIndex)
                {
                    case 1:
                        query = query + colon + "direct=none";
                        break;

                    case 2:
                        query = query + colon + "direct=spatial";
                        break;

                    case 3:
                        query = query + colon + "direct=temporal";
                        break;

                    case 4:
                        query = query + colon + "direct=auto";
                        break;

                    default:
                        break;
                }
            }
            else if (optNameToChange.Equals("analyse"))
            {
                switch (drop_analysis.SelectedIndex)
                {
                    case 1:
                        query = query + colon + "analyse=none";
                        break;

                    case 2:
                        query = query + colon + "analyse=some";
                        break;

                    case 3:
                        query = query + colon + "analyse=all";
                        break;

                    default:
                        break;
                }
            }
            else if (optNameToChange.Equals("merange"))
            {
                int value = drop_MotionEstimationRange.SelectedIndex + 3;
                query = query + colon + "merange=" + value;
            }
            else if (optNameToChange.Equals("b-adapt"))
            {
                int value = drop_adaptBFrames.SelectedIndex - 1;
                query = query + colon + "b-adapt=" + value;
            }
            else if (optNameToChange.Equals("deblock"))
            {
                string da = drop_deblockAlpha.SelectedItem.ToString();
                string db = drop_deblockBeta.Text;

                if (((da.Contains("Default")) && (db.Contains("Default"))) || ((da.Contains("0")) && (db.Contains("0"))))
                {
                    drop_deblockBeta.SelectedItem = "Default (0)";
                    drop_deblockAlpha.SelectedItem = "Default (0)";
                }
                else
                {
                    if (db.Contains("Default"))
                        db = "0";

                    if (da.Contains("Default"))
                        da = "0";

                    query = query + colon + "deblock=" + da + "," + db;
                }
            }
            else if (optNameToChange.Equals("aq-strength"))
            {
                if (slider_adaptiveQuantStrength.Value == 10)
                    query = string.Empty;
                else
                {
                    double value = slider_adaptiveQuantStrength.Value * 0.1;
                    string aqs = value.ToString("f1", culture);
                    query += colon + "aq-strength=" + aqs;
                }
            }
            else if (optNameToChange.Equals("psy-rd"))
            {
                if (slider_psyrd.Value == 10 && slider_psytrellis.Value == 0)
                    query += string.Empty;
                else
                {
                    double psyrd = slider_psyrd.Value * 0.1;
                    double psytre = slider_psytrellis.Value * 0.05;

                    string rd = psyrd.ToString("f1", culture);
                    string rt = psytre.ToString("f2", culture);

                    query += colon + "psy-rd=" + rd + "," + rt;
                }
            }
            else if (optNameToChange.Equals("b-pyramid"))
            {
                switch (combo_pyrmidalBFrames.SelectedIndex)
                {
                    case 0:
                        break;
                    case 1:
                        query = query + colon + "b-pyramid=none";
                        break;
                    case 2:
                        query = query + colon + "b-pyramid=strict";
                        break;
                }
            }
            else if (optNameToChange.Equals("no-dct-decimate"))
            {
                if (check_noDCTDecimate.CheckState == CheckState.Checked)
                    query = query + colon + "no-dct-decimate=1";
            }
            else if (optNameToChange.Equals("8x8dct"))
            {
                if (check_8x8DCT.CheckState == CheckState.Unchecked)
                    query = query + colon + "8x8dct=0";
            }
            else if (optNameToChange.Equals("cabac"))
            {
                if (check_Cabac.CheckState != CheckState.Checked)
                    query = query + colon + "cabac=0";
            }
            else if (optNameToChange.Equals("weightp"))
            {
                if (check_weightp.CheckState == CheckState.Unchecked)
                    query = query + colon + "weightp=0";
            }
            else if (optNameToChange.Equals("ref"))
            {
                if (!drop_refFrames.SelectedItem.ToString().Contains("Default"))
                    query = query + colon + "ref=" + drop_refFrames.SelectedItem;
            }
            else if (optNameToChange.Equals("bframes"))
            {
                string value = drop_bFrames.SelectedItem.ToString();
                if (!drop_bFrames.SelectedItem.ToString().Contains("Default"))
                    query = query + colon + "bframes=" + value;
            }
            else if (optNameToChange.Equals("subq"))
            {
                string value = drop_subpixelMotionEstimation.SelectedItem.ToString();
                if (!drop_subpixelMotionEstimation.SelectedItem.ToString().Contains("Default"))
                {
                    string[] val = value.Split(':');
                    query = query + colon + "subq=" + val[0];
                }
            }
            else if (optNameToChange.Equals("trellis"))
            {
                switch (drop_trellis.SelectedIndex)
                {
                    case 1: // Off
                        query = query + colon + "trellis=0";
                        break;
                    case 2: // Encode Only
                        query = query + colon + "trellis=1";
                        break;
                    case 3: // Always
                        query = query + colon + "trellis=2";
                        break;
                    default:
                        break;
                }
            }

            rtf_x264Query.Text = query;
        }
Пример #40
0
 private static string PosInFocus(IEquatable<string> metricName)
 {
     var posOut = String.Empty;
     if (metricName.Equals("Tdp"))
         posOut = "QB";
     if (metricName.Equals("Tdr"))
         posOut = "RB";
     return posOut;
 }
Пример #41
0
 private void Remove(IEquatable<Filter> filter)
 {
     foreach (ListViewItem item in listView.Items)
     {
         if (filter.Equals(item.Tag as Filter))
         {
             item.Remove();
             return;
         }
     }
 }
Пример #42
0
 private void StartElement(IEquatable<string> qName, IDictionary<string, string> attrs)
 {
     if (inFeature){
         if (qName.Equals("location")){
             //inFeatureLocation = true;
         } else if (qName.Equals("position")){
             string position = attrs["position"];
             featureBegin = position;
             featureEnd = position;
         } else if (qName.Equals("begin")){
             string position = attrs.ContainsKey("position") ? attrs["position"] : attrs["status"];
             featureBegin = position;
         } else if (qName.Equals("end")){
             string position = attrs.ContainsKey("position") ? attrs["position"] : attrs["status"];
             featureEnd = position;
         } else if (qName.Equals("original")){
             original = new StringBuilder();
         } else if (qName.Equals("variation")){
             variation = new StringBuilder();
         }else{
             throw new Exception("Unknown qname: " + qName);
         }
     }
     if (inOrganism) {
         if (qName.Equals("name")) {
             string type = attrs["type"];
             if (type.Equals("scientific")) {
                 oname = new StringBuilder();
             }
         } else if (qName.Equals("dbReference")) {
             string type = attrs["type"];
             if (type.Equals("NCBI Taxonomy")) {
                 string id = attrs["id"];
                 entry.AddTaxonomyId(id);
             }
         }
     }
     if (inOrganismHost) {
         if (qName.Equals("dbReference")) {
             string type = attrs["type"];
             if (type.Equals("NCBI Taxonomy")) {
                 string id = attrs["id"];
                 entry.AddHostTaxonomyId(id);
             }
         }
     }
     if (qName.Equals("entry")) {
         entry = new UniprotEntry();
         accessions = new List<string>();
         proteinFullNames = new List<string>();
         proteinShortNames = new List<string>();
         proteinEcNumbers = new List<string>();
         gnames = new List<Tuple<string, string>>();
         onames = new List<string>();
         unames = new List<string>();
         level = 0;
         numIsoforms = 0;
         isoformToEnst = new Dictionary<string, List<string>>();
     } else if (qName.Equals("dbReference")){
         inDbRef = true;
         dbReferenceType = attrs["type"];
         dbReferenceId = attrs["id"];
         entry.AddDbEntry(dbReferenceType, dbReferenceId);
     } else if (qName.Equals("molecule") && dbReferenceType.Equals("Ensembl")){
         molecule = new StringBuilder();
     } else if (qName.Equals("property")){
         if (inDbRef){
             entry.AddDbEntryProperty(dbReferenceType, dbReferenceId, attrs["type"], attrs["value"]);
         }
     } else if (qName.Equals("feature")){
         inFeature = true;
         featureType = attrs.ContainsKey("type") ? attrs["type"] : "";
         featureDescription = attrs.ContainsKey("description") ? attrs["description"] : "";
         featureStatus = attrs.ContainsKey("status") ? attrs["status"] : "";
         featureId = attrs.ContainsKey("id") ? attrs["id"] : "";
         entry.AddFeature(featureType, featureDescription, featureStatus, featureId);
     } else if (qName.Equals("sequence")) {
         sequence = new StringBuilder();
     } else if (qName.Equals("keyword")) {
         keyword = new StringBuilder();
     } else if (qName.Equals("accession")) {
         accession = new StringBuilder();
     } else if (qName.Equals("protein")){
         inProtein = true;
     } else if (qName.Equals("recommendedName") && inProtein){
         inProteinRecommendedName = true;
     } else if (qName.Equals("organism")) {
         inOrganism = true;
     } else if (qName.Equals("organismHost")) {
         inOrganismHost = true;
     } else if (qName.Equals("gene")) {
         inGene = true;
     } else if (qName.Equals("fullName") && inProteinRecommendedName){
         proteinFullName = new StringBuilder();
     } else if (qName.Equals("shortName") && inProteinRecommendedName){
         proteinShortName = new StringBuilder();
     } else if (qName.Equals("ecNumber") && inProteinRecommendedName){
         proteinEcNumber = new StringBuilder();
     } else if (qName.Equals("name") && inGene){
         gname = new StringBuilder();
         gnameType = attrs["type"];
     } else if (qName.Equals("name") && level == 1){
         uname = new StringBuilder();
     } else if (qName.Equals("isoform")){
         if (inDbRef)
             ++numIsoforms;
     }
 }
Пример #43
0
        private void CustomerManagement(IEquatable<string> operationRequest)
        {
            using (var frmCustomer = new FrmCustomer())
            {
                frmCustomer.CommonService = _commonService;
                frmCustomer.CustomerService = _customerService;

                if (operationRequest.Equals(Resources.OperationRequestUpdate))
                    if (dgvCustomer.CurrentRow != null)
                        frmCustomer.Customer = _customerList[dgvCustomer.CurrentRow.Index];

                if (frmCustomer.ShowDialog(this) == DialogResult.OK)
                {
                    try
                    {
                        ThreadStart threadStart = UpdateControlContent;
                        var thread = new Thread(threadStart);
                        thread.Start();

                        if (operationRequest.Equals(Resources.OperationRequestInsert))
                            _customerList.Add(frmCustomer.Customer);

                        dgvCustomer.Refresh();
                        SetCustomerInfo();
                        UpdateResultInfo();
                        EnableActionButton();
                    }
                    catch (Exception exception)
                    {
                        FrmExtendedMessageBox.UnknownErrorMessage(
                            Resources.MsgCaptionUnknownError,
                            exception.Message);
                    }
                }
            }

            SetFocusToCustomerList();
        }
Пример #44
0
		private static void AssertNodeName(XmlNode node, IEquatable<string> expectedName)
		{
			if (expectedName.Equals(node.Name))
				return;
			
			String message = String.Format("Unexpected node under '{0}': Expected '{1}' but found '{2}'",
										   expectedName, expectedName, node.Name);

			throw new Exception(message);
		}
Пример #45
0
        private void UserManagement(IEquatable<string> operationRequest)
        {
            using (var frmUser = new FrmUser())
            {
                if (operationRequest.Equals(Resources.OperationRequestUpdate))
                    if (dgvUser.CurrentRow != null) frmUser.User = _UserList[dgvUser.CurrentRow.Index];

                if (frmUser.ShowDialog(this) == DialogResult.OK)
                {
                    try
                    {
                        if ((operationRequest.Equals(Resources.OperationRequestInsert)))
                            _UserList.Add(frmUser.User);
                        dgvUser.Refresh();
                        UpdateResultInfo();
                        EnableActionButton();
                    }
                    catch (Exception exception)
                    {
                        FrmExtendedMessageBox.UnknownErrorMessage(
                            Resources.MsgCaptionUnknownError,
                            exception.Message);
                    }
                }
            }
        }
Пример #46
0
 private void EndElement(IEquatable<string> qName, HandleUniprotEntry handle, bool isTrembl)
 {
     if (qName.Equals("sequence")){
         entry.Sequence = StringUtils.RemoveWhitespace(sequence.ToString());
         sequence = null;
     } else if (qName.Equals("keyword")) {
         entry.AddKeyword(StringUtils.RemoveWhitespace(keyword.ToString()));
         keyword = null;
     } else if (qName.Equals("molecule") && dbReferenceType.Equals("Ensembl")){
         string mol = molecule.ToString().Trim();
         entry.AddDbEntryProperty(dbReferenceType, dbReferenceId, "isoform ID", mol);
         if (!isoformToEnst.ContainsKey(mol))
             isoformToEnst.Add(mol, new List<string>());
         isoformToEnst[mol].Add(dbReferenceId);
         molecule = null;
     } else if (qName.Equals("entry")){
         entry.Accessions = accessions.ToArray();
         entry.ProteinFullNames = proteinFullNames.ToArray();
         entry.ProteinShortNames = proteinShortNames.ToArray();
         entry.ProteinEcNumbers = proteinEcNumbers.ToArray();
         entry.GeneNamesAndTypes = gnames.ToArray();
         entry.OrganismNames = onames.ToArray();
         entry.UniprotNames = unames.ToArray();
         entry.IsTrembl = isTrembl;
         if (resolveIsoforms){
             if (numIsoforms > 1 && isoformToEnst.Count > 1){
                 List<UniprotEntry> isoEntries = entry.ResolveIsoforms(isoformToEnst);
                 foreach (UniprotEntry e in isoEntries){
                     handle(e);
                 }
             } else
                 handle(entry);
         } else
             handle(entry);
     } else if (qName.Equals("dbReference")){
         inDbRef = false;
     } else if (qName.Equals("accession")){
         accessions.Add(StringUtils.RemoveWhitespace(accession.ToString()));
         accession = null;
     } else if (qName.Equals("location")){
         if (inFeature){
             //inFeatureLocation = false;
             entry.AddFeatureLocation(featureBegin, featureEnd);
         }
     } else if (qName.Equals("variation")){
         if (inFeature){
             entry.AddFeatureVariation(StringUtils.RemoveWhitespace(variation.ToString()));
             variation = null;
         }
     } else if (qName.Equals("original")){
         if (inFeature){
             entry.AddFeatureOriginal(StringUtils.RemoveWhitespace(original.ToString()));
             original = null;
         }
     } else if (qName.Equals("feature")){
         inFeature = false;
         foreach (FeatureType type in entry.GetAllFeatureTypes()){
             int c = entry.GetFeatureCount(type);
             if (!featureCounts.ContainsKey(type)){
                 featureCounts.Add(type, 0);
             }
             featureCounts[type] += c;
         }
     } else if (qName.Equals("fullName") && inProteinRecommendedName){
         proteinFullNames.Add(proteinFullName.ToString().Trim());
         proteinFullName = null;
     } else if (qName.Equals("shortName") && inProteinRecommendedName){
         proteinShortNames.Add(proteinShortName.ToString().Trim());
         proteinShortName = null;
     } else if (qName.Equals("ecNumber") && inProteinRecommendedName){
         proteinEcNumbers.Add(proteinEcNumber.ToString().Trim());
         proteinEcNumber = null;
     } else if (qName.Equals("name") && inGene){
         gnames.Add(new Tuple<string, string>(gname.ToString().Trim(), gnameType.Trim()));
         gname = null;
         gnameType = null;
     } else if (qName.Equals("name") && inOrganism){
         string on = oname?.ToString().Trim();
         if (@on?.Length > 0){
             onames.Add(@on);
             oname = null;
         }
     } else if (qName.Equals("name") && level == 1){
         unames.Add(uname.ToString().Trim());
         uname = null;
     } else if (qName.Equals("protein")){
         inProtein = false;
     } else if (qName.Equals("recommendedName") && inProtein){
         inProteinRecommendedName = false;
     } else if (qName.Equals("gene")){
         inGene = false;
     } else if (qName.Equals("organism")) {
         inOrganism = false;
     } else if (qName.Equals("organismHost")) {
         inOrganismHost = false;
     }
 }
Пример #47
0
        private void Set(Config rc, string key, int currentValue, IEquatable<int> defaultValue)
		{
			if (defaultValue.Equals(currentValue))
			{
				Unset(rc, key);
			}
			else
			{
				rc.setInt(Section, Name, key, currentValue);
			}
		}
Пример #48
0
 private void Remove(IEquatable<ColorSet> set)
 {
     foreach (ListViewItem item in listViewColorSets.Items)
     {
         if (set.Equals(item.Tag as ColorSet))
         {
             item.Remove();
             return;
         }
     }
 }