Example #1
0
        protected override void InternalCompute()
        {
            Contract.Ensures(this.ComponentCount >= 0);
            Contract.Ensures(this.VisitedGraph.VertexCount == 0 || this.ComponentCount > 0);
            Contract.Ensures(Enumerable.All(this.VisitedGraph.Vertices, v => this.Components.ContainsKey(v)));
            Contract.Ensures(this.VisitedGraph.VertexCount == this.Components.Count);
            Contract.Ensures(Enumerable.All(this.Components.Values, c => c <= this.ComponentCount));

            this.Components.Clear();
            this.Roots.Clear();
            this.DiscoverTimes.Clear();
            this.stack.Clear();
            this.componentCount = 0;
            this.dfsTime        = 0;

            DepthFirstSearchAlgorithm <TVertex, TEdge> dfs = null;

            try
            {
                dfs = new DepthFirstSearchAlgorithm <TVertex, TEdge>(
                    this,
                    VisitedGraph,
                    new Dictionary <TVertex, GraphColor>(this.VisitedGraph.VertexCount)
                    );
                dfs.DiscoverVertex += new VertexAction <TVertex>(this.DiscoverVertex);
                dfs.FinishVertex   += new VertexAction <TVertex>(this.FinishVertex);

                dfs.Compute();
            }
            finally
            {
                if (dfs != null)
                {
                    dfs.DiscoverVertex -= new VertexAction <TVertex>(this.DiscoverVertex);
                    dfs.FinishVertex   -= new VertexAction <TVertex>(this.FinishVertex);
                }
            }
        }
Example #2
0
 private bool Matches(List <string> searchStrings)
 {
     // ISSUE: method pointer
     if (searchStrings.Count == 0 || Enumerable.All <string>(searchStrings, (Func <string, bool>) new Func <string, bool>(string.IsNullOrWhiteSpace)))
     {
         return(false);
     }
     List <string> .Enumerator enumerator = searchStrings.GetEnumerator();
     try
     {
         while (enumerator.MoveNext())
         {
             string current = enumerator.Current;
             bool   flag    = false;
             string title   = this.Title;
             char[] chArray = new char[1] {
                 ' '
             };
             foreach (string str in ((string)title).Split((char[])chArray))
             {
                 flag = str.StartsWith(current, (StringComparison)3);
                 if (flag)
                 {
                     break;
                 }
             }
             if (!flag)
             {
                 return(false);
             }
         }
     }
     finally
     {
         enumerator.Dispose();
     }
     return(true);
 }
        /// <summary>
        /// Retrieves the authorizations matching the specified parameters.
        /// </summary>
        /// <param name="subject">The subject associated with the authorization.</param>
        /// <param name="client">The client associated with the authorization.</param>
        /// <param name="status">The authorization status.</param>
        /// <param name="type">The authorization type.</param>
        /// <param name="scopes">The minimal scopes associated with the authorization.</param>
        /// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
        /// <returns>
        /// A <see cref="Task"/> that can be used to monitor the asynchronous operation,
        /// whose result returns the authorizations corresponding to the criteria.
        /// </returns>
        public virtual async Task <ImmutableArray <TAuthorization> > FindAsync(
            [NotNull] string subject, [NotNull] string client,
            [NotNull] string status, [NotNull] string type,
            ImmutableArray <string> scopes, CancellationToken cancellationToken)
        {
            if (string.IsNullOrEmpty(subject))
            {
                throw new ArgumentException("The subject cannot be null or empty.", nameof(subject));
            }

            if (string.IsNullOrEmpty(client))
            {
                throw new ArgumentException("The client identifier cannot be null or empty.", nameof(client));
            }

            if (string.IsNullOrEmpty(status))
            {
                throw new ArgumentException("The status cannot be null or empty.", nameof(status));
            }

            if (string.IsNullOrEmpty(type))
            {
                throw new ArgumentException("The type cannot be null or empty.", nameof(type));
            }

            var database = await Context.GetDatabaseAsync(cancellationToken);

            var collection = database.GetCollection <TAuthorization>(Options.CurrentValue.AuthorizationsCollectionName);

            // Note: Enumerable.All() is deliberately used without the extension method syntax to ensure
            // ImmutableArrayExtensions.All() (which is not supported by MongoDB) is not used instead.
            return(ImmutableArray.CreateRange(await collection.Find(authorization =>
                                                                    authorization.Subject == subject &&
                                                                    authorization.ApplicationId == ObjectId.Parse(client) &&
                                                                    authorization.Status == status &&
                                                                    authorization.Type == type &&
                                                                    Enumerable.All(scopes, scope => authorization.Scopes.Contains(scope))).ToListAsync(cancellationToken)));
        }
Example #4
0
        /// <summary>
        /// Checks that <paramref name="root"/> is a predecessor of <paramref name="vertex"/>
        /// </summary>
        /// <typeparam name="TVertex">type of the vertices</typeparam>
        /// <typeparam name="TEdge">type of the edges</typeparam>
        /// <param name="predecessors"></param>
        /// <param name="root"></param>
        /// <param name="vertex"></param>
        /// <returns></returns>
        public static bool IsPredecessor <TVertex, TEdge>
            (this IDictionary <TVertex, TEdge> predecessors,
            TVertex root,
            TVertex vertex)
            where TEdge : IEdge <TVertex>
        {
            Contract.Requires(predecessors != null);
            Contract.Requires(root != null);
            Contract.Requires(vertex != null);
            Contract.Requires(
                typeof(TEdge).IsValueType ||
                Enumerable.All(predecessors.Values, e => e != null));

            var current = vertex;

            if (root.Equals(current))
            {
                return(true);
            }

            TEdge predecessor;

            while (predecessors.TryGetValue(current, out predecessor))
            {
                var source = GetOtherVertex(predecessor, current);
                if (current.Equals(source))
                {
                    return(false);
                }
                if (source.Equals(root))
                {
                    return(true);
                }
                current = source;
            }

            return(false);
        }
        /// <summary>
        /// Computes the offline least common ancestor between pairs of vertices in a rooted tree
        /// using Tarjan algorithm.
        /// </summary>
        /// <remarks>
        /// Reference:
        /// Gabow, H. N. and Tarjan, R. E. 1983. A linear-time algorithm for a special case of disjoint set union. In Proceedings of the Fifteenth Annual ACM Symposium on theory of Computing STOC '83. ACM, New York, NY, 246-251. DOI= http://doi.acm.org/10.1145/800061.808753
        /// </remarks>
        /// <typeparam name="TVertex">type of the vertices</typeparam>
        /// <typeparam name="TEdge">type of the edges</typeparam>
        /// <param name="visitedGraph"></param>
        /// <param name="root"></param>
        /// <param name="pairs"></param>
        /// <returns></returns>
        public static TryFunc <SEquatableEdge <TVertex>, TVertex> OfflineLeastCommonAncestorTarjan <TVertex, TEdge>
            (this IVertexListGraph <TVertex, TEdge> visitedGraph,
            TVertex root,
            IEnumerable <SEquatableEdge <TVertex> > pairs)
            where TEdge : IEdge <TVertex>
        {
            Contract.Requires(visitedGraph != null);
            Contract.Requires(root != null);
            Contract.Requires(pairs != null);
            Contract.Requires(visitedGraph.ContainsVertex(root));
            Contract.Requires(Enumerable.All(pairs, p => visitedGraph.ContainsVertex(p.Source)));
            Contract.Requires(Enumerable.All(pairs, p => visitedGraph.ContainsVertex(p.Target)));

            var algo = new TarjanOfflineLeastCommonAncestorAlgorithm <TVertex, TEdge>(visitedGraph);

            algo.Compute(root, pairs);
            var ancestors = algo.Ancestors;

            return(delegate(SEquatableEdge <TVertex> pair, out TVertex value)
            {
                return ancestors.TryGetValue(pair, out value);
            });
        }
Example #6
0
        protected override SitecoreIndexableItem GetIndexableAndCheckDeletes(IIndexableUniqueId indexableUniqueId)
        {
            var itemUri = (ItemUri)(indexableUniqueId as SitecoreItemUniqueId);

            using (new SecurityDisabler())
            {
                Item item;
                using (new WriteCachesDisabler())
                    item = Sitecore.Data.Database.GetItem(itemUri);
                if (item != null)
                {
                    var item2 = Sitecore.Data.Database.GetItem(new ItemUri(itemUri.ItemID, itemUri.Language, Sitecore.Data.Version.Latest, itemUri.DatabaseName));
                    Sitecore.Data.Version[] versionArray;
                    using (new WriteCachesDisabler())
                        versionArray = item2.Versions.GetVersionNumbers() ?? new Sitecore.Data.Version[0];
                    if (Enumerable.All(versionArray, v => v.Number != itemUri.Version.Number))
                    {
                        item2 = null;
                    }
                }
                return(item);
            }
        }
Example #7
0
        private bool Matches(List <string> searchStrings)
        {
            // ISSUE: method pointer
            if (searchStrings.Count == 0 || Enumerable.All <string>(searchStrings, (Func <string, bool>) new Func <string, bool>(string.IsNullOrWhiteSpace)))
            {
                return(false);
            }
            bool flag1 = true;

            List <string> .Enumerator enumerator = searchStrings.GetEnumerator();
            try
            {
                while (enumerator.MoveNext())
                {
                    string current = enumerator.Current;
                    bool   flag2   = false;
                    foreach (string str in this._groupNameSplit)
                    {
                        flag2 = str.StartsWith(current, (StringComparison)3);
                        if (flag2)
                        {
                            break;
                        }
                    }
                    flag1 &= flag2;
                    if (!flag1)
                    {
                        break;
                    }
                }
            }
            finally
            {
                enumerator.Dispose();
            }
            return(flag1);
        }
Example #8
0
        public static bool HasCycles <TVertex, TEdge>(
#if !NET20
            this
#endif
            IEnumerable <TEdge> path)
            where TEdge : IEdge <TVertex>
        {
            Contract.Requires(path != null);
            Contract.Requires(typeof(TEdge).GetTypeInfo().IsValueType || Enumerable.All(path, e => e != null));

            var  vertices = new Dictionary <TVertex, int>();
            bool first    = true;

            foreach (var edge in path)
            {
                if (first)
                {
                    if (edge.Source.Equals(edge.Target)) // self-edge
                    {
                        return(true);
                    }
                    vertices.Add(edge.Source, 0);
                    vertices.Add(edge.Target, 0);
                    first = false;
                }
                else
                {
                    if (vertices.ContainsKey(edge.Target))
                    {
                        return(true);
                    }
                    vertices.Add(edge.Target, 0);
                }
            }

            return(false);
        }
Example #9
0
        private string Localize(object input)
        {
            string str = input.ToString();

            if (Enumerable.All <char>((IEnumerable <char>)str.ToCharArray(), new Func <char, bool>(char.IsUpper)))
            {
                return(str);
            }
            if (str.StartsWith("D") && str.Length == 2 && char.IsNumber(str[1]))
            {
                return(str[1].ToString());
            }
            string input1 = str.Replace("Oem", string.Empty);
            string text;

            if (StaticText.TryGetString("Keyboard" + input1, out text))
            {
                return(text);
            }
            else
            {
                return(Regex.Replace(input1, "([A-Z])", " $1", RegexOptions.Compiled).Trim());
            }
        }
 private static bool All([NotNull, ItemCanBeNull] this IEnumerable items, [NotNull] Func <object, bool> condition)
 {
     return(Enumerable.All(items.Cast <object>(), condition));
 }
Example #11
0
 public bool Linq_List_Reference()
 => Enumerable.All(listReference, _ => true);
Example #12
0
 public static bool IsCyrillic(string input)
 {
     return(Enumerable.All <char>(input, (Func <char, bool>)(c => Transliteration.mapCyrillic.ContainsKey(c))));
 }
        private void SerializeNode(JsonWriter writer, IXmlNode node, XmlNamespaceManager manager, bool writePropertyName)
        {
            switch (node.NodeType)
            {
            case 1:
                if (this.IsArray(node) && Enumerable.All <IXmlNode>(node.ChildNodes, (IXmlNode n) => n.LocalName == node.LocalName) && node.ChildNodes.get_Count() > 0)
                {
                    this.SerializeGroupedNodes(writer, node, manager, false);
                }
                else
                {
                    using (IEnumerator <IXmlNode> enumerator = node.Attributes.GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            IXmlNode current = enumerator.get_Current();
                            if (current.NamespaceURI == "http://www.w3.org/2000/xmlns/")
                            {
                                string text = (!(current.LocalName != "xmlns")) ? string.Empty : current.LocalName;
                                manager.AddNamespace(text, current.Value);
                            }
                        }
                    }
                    if (writePropertyName)
                    {
                        writer.WritePropertyName(this.GetPropertyName(node, manager));
                    }
                    if (Enumerable.Count <IXmlNode>(this.ValueAttributes(node.Attributes)) == 0 && node.ChildNodes.get_Count() == 1 && node.ChildNodes.get_Item(0).NodeType == 3)
                    {
                        writer.WriteValue(node.ChildNodes.get_Item(0).Value);
                    }
                    else if (node.ChildNodes.get_Count() == 0 && CollectionUtils.IsNullOrEmpty <IXmlNode>(node.Attributes))
                    {
                        writer.WriteNull();
                    }
                    else
                    {
                        writer.WriteStartObject();
                        for (int i = 0; i < node.Attributes.get_Count(); i++)
                        {
                            this.SerializeNode(writer, node.Attributes.get_Item(i), manager, true);
                        }
                        this.SerializeGroupedNodes(writer, node, manager, true);
                        writer.WriteEndObject();
                    }
                }
                return;

            case 2:
            case 3:
            case 4:
            case 7:
            case 13:
            case 14:
                if (node.NamespaceURI == "http://www.w3.org/2000/xmlns/" && node.Value == "http://james.newtonking.com/projects/json")
                {
                    return;
                }
                if (node.NamespaceURI == "http://james.newtonking.com/projects/json" && node.LocalName == "Array")
                {
                    return;
                }
                if (writePropertyName)
                {
                    writer.WritePropertyName(this.GetPropertyName(node, manager));
                }
                writer.WriteValue(node.Value);
                return;

            case 8:
                if (writePropertyName)
                {
                    writer.WriteComment(node.Value);
                }
                return;

            case 9:
            case 11:
                this.SerializeGroupedNodes(writer, node, manager, writePropertyName);
                return;

            case 17:
            {
                IXmlDeclaration xmlDeclaration = (IXmlDeclaration)node;
                writer.WritePropertyName(this.GetPropertyName(node, manager));
                writer.WriteStartObject();
                if (!string.IsNullOrEmpty(xmlDeclaration.Version))
                {
                    writer.WritePropertyName("@version");
                    writer.WriteValue(xmlDeclaration.Version);
                }
                if (!string.IsNullOrEmpty(xmlDeclaration.Encoding))
                {
                    writer.WritePropertyName("@encoding");
                    writer.WriteValue(xmlDeclaration.Encoding);
                }
                if (!string.IsNullOrEmpty(xmlDeclaration.Standalone))
                {
                    writer.WritePropertyName("@standalone");
                    writer.WriteValue(xmlDeclaration.Standalone);
                }
                writer.WriteEndObject();
                return;
            }
            }
            throw new JsonSerializationException("Unexpected XmlNodeType when serializing nodes: " + node.NodeType);
        }
        public object GetShopBranchs(long shopId, bool getParent, string skuIds, string counts, int page, int rows, long shippingAddressId, long regionId)
        {
            string[]            strArray            = skuIds.Split(',');
            int[]               _counts             = Enumerable.ToArray <int>(Enumerable.Select <string, int>((IEnumerable <string>)counts.Split(','), (Func <string, int>)(p => TypeHelper.ObjectToInt((object)p))));
            ShippingAddressInfo userShippingAddress = ShippingAddressApplication.GetUserShippingAddress(shippingAddressId);
            int             streetId        = 0;
            int             districtId      = 0;
            ShopBranchQuery shopBranchQuery = new ShopBranchQuery();

            shopBranchQuery.ShopId   = shopId;
            shopBranchQuery.PageNo   = page;
            shopBranchQuery.PageSize = rows;
            shopBranchQuery.Status   = new ShopBranchStatus?(ShopBranchStatus.Normal);
            ShopBranchQuery query = shopBranchQuery;

            if (userShippingAddress != null)
            {
                query.FromLatLng = string.Format("{0},{1}", (object)userShippingAddress.Latitude, (object)userShippingAddress.Longitude);
                streetId         = userShippingAddress.RegionId;
                Region region = RegionApplication.GetRegion((long)userShippingAddress.RegionId, Region.RegionLevel.Town);
                if (region != null && region.ParentId > 0)
                {
                    districtId = region.ParentId;
                }
                else
                {
                    districtId = streetId;
                    streetId   = 0;
                }
            }
            bool hasLatLng = false;

            if (!string.IsNullOrWhiteSpace(query.FromLatLng))
            {
                hasLatLng = (query.FromLatLng.Split(',').Length == 2 ? 1 : 0) != 0;
            }
            Region region1 = RegionApplication.GetRegion(regionId, getParent ? Region.RegionLevel.City : Region.RegionLevel.County);

            if (region1 != null)
            {
                query.AddressPath = region1.GetIdPath(",");
            }
            List <SKU> skuInfos = ProductManagerApplication.GetSKUs((IEnumerable <string>)strArray);

            query.ProductIds = Enumerable.ToArray <long>(Enumerable.Select <SKU, long>((IEnumerable <SKU>)skuInfos, (Func <SKU, long>)(p => p.ProductId)));
            QueryPageModel <ShopBranch> shopBranchsAll = ShopBranchApplication.GetShopBranchsAll(query);
            List <ShopBranchSkusInfo>   shopBranchSkus = ShopBranchApplication.GetSkus(shopId, Enumerable.Select <ShopBranch, long>((IEnumerable <ShopBranch>)shopBranchsAll.Models, (Func <ShopBranch, long>)(p => p.Id)));

            shopBranchsAll.Models.ForEach((Action <ShopBranch>)(p => p.Enabled = Enumerable.All <SKU>((IEnumerable <SKU>)skuInfos, (Func <SKU, bool>)(skuInfo => Enumerable.Any <ShopBranchSkusInfo>((IEnumerable <ShopBranchSkusInfo>)shopBranchSkus, (Func <ShopBranchSkusInfo, bool>)(sbSku => sbSku.ShopBranchId == p.Id && sbSku.Stock >= _counts[skuInfos.IndexOf(skuInfo)] && sbSku.SkuId == skuInfo.Id))))));
            List <ShopBranch> list1      = new List <ShopBranch>();
            List <long>       fillterIds = new List <long>();
            List <ShopBranch> list2      = Enumerable.ToList <ShopBranch>((IEnumerable <ShopBranch>)Enumerable.OrderBy <ShopBranch, double>(Enumerable.Where <ShopBranch>((IEnumerable <ShopBranch>)shopBranchsAll.Models, (Func <ShopBranch, bool>)(p => hasLatLng && p.Enabled && ((double)p.Latitude > 0.0 && (double)p.Longitude > 0.0))), (Func <ShopBranch, double>)(p => p.Distance)));

            if (list2 != null && Enumerable.Count <ShopBranch>((IEnumerable <ShopBranch>)list2) > 0)
            {
                fillterIds.AddRange(Enumerable.Select <ShopBranch, long>((IEnumerable <ShopBranch>)list2, (Func <ShopBranch, long>)(p => p.Id)));
                list1.AddRange((IEnumerable <ShopBranch>)list2);
            }
            List <ShopBranch> list3 = Enumerable.ToList <ShopBranch>(Enumerable.Where <ShopBranch>((IEnumerable <ShopBranch>)shopBranchsAll.Models, (Func <ShopBranch, bool>)(p => !fillterIds.Contains(p.Id) && p.Enabled && p.AddressPath.Contains("," + (object)streetId + ","))));

            if (list3 != null && Enumerable.Count <ShopBranch>((IEnumerable <ShopBranch>)list3) > 0)
            {
                fillterIds.AddRange(Enumerable.Select <ShopBranch, long>((IEnumerable <ShopBranch>)list3, (Func <ShopBranch, long>)(p => p.Id)));
                list1.AddRange((IEnumerable <ShopBranch>)list3);
            }
            List <ShopBranch> list4 = Enumerable.ToList <ShopBranch>(Enumerable.Where <ShopBranch>((IEnumerable <ShopBranch>)shopBranchsAll.Models, (Func <ShopBranch, bool>)(p => !fillterIds.Contains(p.Id) && p.Enabled && p.AddressPath.Contains("," + (object)districtId + ","))));

            if (list4 != null && Enumerable.Count <ShopBranch>((IEnumerable <ShopBranch>)list4) > 0)
            {
                fillterIds.AddRange(Enumerable.Select <ShopBranch, long>((IEnumerable <ShopBranch>)list4, (Func <ShopBranch, long>)(p => p.Id)));
                list1.AddRange((IEnumerable <ShopBranch>)list4);
            }
            List <ShopBranch> list5 = Enumerable.ToList <ShopBranch>(Enumerable.Where <ShopBranch>((IEnumerable <ShopBranch>)shopBranchsAll.Models, (Func <ShopBranch, bool>)(p => !fillterIds.Contains(p.Id) && p.Enabled)));

            if (list5 != null && Enumerable.Count <ShopBranch>((IEnumerable <ShopBranch>)list5) > 0)
            {
                fillterIds.AddRange(Enumerable.Select <ShopBranch, long>((IEnumerable <ShopBranch>)list5, (Func <ShopBranch, long>)(p => p.Id)));
                list1.AddRange((IEnumerable <ShopBranch>)list5);
            }
            List <ShopBranch> list6 = Enumerable.ToList <ShopBranch>(Enumerable.Where <ShopBranch>((IEnumerable <ShopBranch>)shopBranchsAll.Models, (Func <ShopBranch, bool>)(p => !fillterIds.Contains(p.Id))));

            if (list6 != null && Enumerable.Count <ShopBranch>((IEnumerable <ShopBranch>)list6) > 0)
            {
                list1.AddRange((IEnumerable <ShopBranch>)list6);
            }
            if (Enumerable.Count <ShopBranch>((IEnumerable <ShopBranch>)list1) != Enumerable.Count <ShopBranch>((IEnumerable <ShopBranch>)shopBranchsAll.Models))
            {
                return((object)this.Json(new
                {
                    Success = false
                }));
            }
            var content = new
            {
                Success   = true,
                StoreList = Enumerable.Select((IEnumerable <ShopBranch>)list1, sb =>
                {
                    var fAnonymousType37 = new
                    {
                        ContactUser    = sb.ContactUser,
                        ContactPhone   = sb.ContactPhone,
                        AddressDetail  = sb.AddressDetail,
                        ShopBranchName = sb.ShopBranchName,
                        Id             = sb.Id,
                        Enabled        = sb.Enabled
                    };
                    return(fAnonymousType37);
                })
            };

            return((object)this.Json(content));
        }
Example #15
0
 public bool Linq_List_Value()
 => Enumerable.All(listValue, _ => true);
Example #16
0
        private void SerializeNode(JsonWriter writer, IXmlNode node, XmlNamespaceManager manager, bool writePropertyName)
        {
            switch (node.NodeType)
            {
            case XmlNodeType.Element:
                if (this.IsArray(node) && (Enumerable.All <IXmlNode>((IEnumerable <IXmlNode>)node.ChildNodes, (Func <IXmlNode, bool>)(n => n.LocalName == node.LocalName)) && node.ChildNodes.Count > 0))
                {
                    this.SerializeGroupedNodes(writer, node, manager, false);
                    break;
                }
                else
                {
                    foreach (IXmlNode xmlNode in (IEnumerable <IXmlNode>)node.Attributes)
                    {
                        if (xmlNode.NamespaceUri == "http://www.w3.org/2000/xmlns/")
                        {
                            string prefix = xmlNode.LocalName != "xmlns" ? xmlNode.LocalName : string.Empty;
                            manager.AddNamespace(prefix, xmlNode.Value);
                        }
                    }
                    if (writePropertyName)
                    {
                        writer.WritePropertyName(this.GetPropertyName(node, manager));
                    }
                    if (!Enumerable.Any <IXmlNode>(this.ValueAttributes((IEnumerable <IXmlNode>)node.Attributes)) && node.ChildNodes.Count == 1 && node.ChildNodes[0].NodeType == XmlNodeType.Text)
                    {
                        writer.WriteValue(node.ChildNodes[0].Value);
                        break;
                    }
                    else if (node.ChildNodes.Count == 0 && CollectionUtils.IsNullOrEmpty <IXmlNode>((ICollection <IXmlNode>)node.Attributes))
                    {
                        writer.WriteNull();
                        break;
                    }
                    else
                    {
                        writer.WriteStartObject();
                        for (int index = 0; index < node.Attributes.Count; ++index)
                        {
                            this.SerializeNode(writer, node.Attributes[index], manager, true);
                        }
                        this.SerializeGroupedNodes(writer, node, manager, true);
                        writer.WriteEndObject();
                        break;
                    }
                }

            case XmlNodeType.Attribute:
            case XmlNodeType.Text:
            case XmlNodeType.CDATA:
            case XmlNodeType.ProcessingInstruction:
            case XmlNodeType.Whitespace:
            case XmlNodeType.SignificantWhitespace:
                if (node.NamespaceUri == "http://www.w3.org/2000/xmlns/" && node.Value == "http://james.newtonking.com/projects/json" || node.NamespaceUri == "http://james.newtonking.com/projects/json" && node.LocalName == "Array")
                {
                    break;
                }
                if (writePropertyName)
                {
                    writer.WritePropertyName(this.GetPropertyName(node, manager));
                }
                writer.WriteValue(node.Value);
                break;

            case XmlNodeType.Comment:
                if (!writePropertyName)
                {
                    break;
                }
                writer.WriteComment(node.Value);
                break;

            case XmlNodeType.Document:
            case XmlNodeType.DocumentFragment:
                this.SerializeGroupedNodes(writer, node, manager, writePropertyName);
                break;

            case XmlNodeType.XmlDeclaration:
                IXmlDeclaration xmlDeclaration = (IXmlDeclaration)node;
                writer.WritePropertyName(this.GetPropertyName(node, manager));
                writer.WriteStartObject();
                if (!string.IsNullOrEmpty(xmlDeclaration.Version))
                {
                    writer.WritePropertyName("@version");
                    writer.WriteValue(xmlDeclaration.Version);
                }
                if (!string.IsNullOrEmpty(xmlDeclaration.Encoding))
                {
                    writer.WritePropertyName("@encoding");
                    writer.WriteValue(xmlDeclaration.Encoding);
                }
                if (!string.IsNullOrEmpty(xmlDeclaration.Standalone))
                {
                    writer.WritePropertyName("@standalone");
                    writer.WriteValue(xmlDeclaration.Standalone);
                }
                writer.WriteEndObject();
                break;

            default:
                throw new JsonSerializationException("Unexpected XmlNodeType when serializing nodes: " + (object)node.NodeType);
            }
        }
Example #17
0
 public static void LoadServer(Guid serverId)
 {
     IdentificationServer.ServerId   = serverId;
     IdentificationServer.MainServer = BcIdentificationServer.LoadById(IdentificationServer.ServerId);
     try
     {
         List <BcDevices> actualDevices = BcDevicesStorageExtensions.LoadByIsid(IdentificationServer.ServerId);
         foreach (BcDevices bcDevices in Enumerable.ToArray <BcDevices>(Enumerable.Where <BcDevices>((IEnumerable <BcDevices>)IdentificationServer.AllDevices, (Func <BcDevices, bool>)(devices => Enumerable.All <BcDevices>((IEnumerable <BcDevices>)actualDevices, (Func <BcDevices, bool>)(bcDevices => bcDevices.Id != devices.Id))))))
         {
             if (bcDevices.CurrentThread != null)
             {
                 IdentificationServer.DestroyIfNeeded(bcDevices.CurrentThread);
             }
             IdentificationServer.AllDevices.Remove(bcDevices);
         }
         foreach (BcDevices bcDevices1 in actualDevices)
         {
             BcDevices d1         = bcDevices1;
             BcDevices bcDevices2 = Enumerable.FirstOrDefault <BcDevices>((IEnumerable <BcDevices>)IdentificationServer.AllDevices, (Func <BcDevices, bool>)(dev => dev.Id == d1.Id));
             if (bcDevices2 != null)
             {
                 bcDevices2.SetData(d1.GetData());
             }
             else
             {
                 IdentificationServer.AllDevices.Add(d1);
                 d1.CurrentThread = new Thread(new ParameterizedThreadStart(IdentificationServer.VideoThread))
                 {
                     IsBackground = true
                 };
                 d1.CurrentThread.Start((object)d1);
             }
         }
     }
     catch (Exception ex)
     {
         IdentificationServer.Logger.Error((object)ex);
     }
     IdentificationServer.IsLoaded = true;
     IdentificationServer.SetGetServerSettings(true);
     Task.Factory.StartNew(new Action(IdentificationServer.RefreshFaces));
     Task.Factory.StartNew(new Action(IdentificationServer.RefreshDevices));
 }
Example #18
0
        public static bool Prefix(PlayerInteract __instance, GameObject doorId)
        {
            try
            {
                var  allowTheAccess = true;
                Door door           = null;

                if (!__instance._playerInteractRateLimit.CanExecute() || (__instance._hc.CufferId > 0 && !PlayerInteract.CanDisarmedInteract))
                {
                    return(false);
                }

                if (doorId == null)
                {
                    return(false);
                }

                if (__instance._ccm.CurClass == RoleType.None || __instance._ccm.CurClass == RoleType.Spectator)
                {
                    return(false);
                }

                if (!doorId.TryGetComponent(out door))
                {
                    return(false);
                }


                if ((door.Buttons.Count == 0) ? (!__instance.ChckDis(doorId.transform.position)) : Enumerable.All(door.Buttons, item => !__instance.ChckDis(item.button.transform.position)))
                {
                    return(false);
                }

                __instance.OnInteract();

                if (!__instance._sr.BypassMode && !(door.PermissionLevels.HasPermission(Door.AccessRequirements.Checkpoints) &&
                                                    __instance._ccm.CurRole.team == Team.SCP))
                {
                    try
                    {
                        if (door.PermissionLevels == 0)
                        {
                            allowTheAccess = !door.locked;
                        }
                        else if (!door.RequireAllPermissions)
                        {
                            var itemPerms = __instance._inv.GetItemByID(__instance._inv.curItem).permissions;
                            allowTheAccess = itemPerms.Any(p =>
                                                           Door.backwardsCompatPermissions.TryGetValue(p, out var flag) &&
                                                           door.PermissionLevels.HasPermission(flag));
                        }
                        else
                        {
                            allowTheAccess = false;
                        }
                    }
                    catch
                    {
                        allowTheAccess = false;
                    }
                }

                Events.InvokeDoorInteraction(__instance.gameObject.GetPlayer(), door, ref allowTheAccess);

                if (allowTheAccess)
                {
                    door.ChangeState(__instance._sr.BypassMode);
                }
                else
                {
                    __instance.RpcDenied(doorId);
                }

                return(false);
            }
            catch (Exception e)
            {
                Log.Error($"DoorInteraction Error: {e}");

                return(true);
            }
        }
Example #19
0
 public bool Linq_Enumerable_Reference()
 => Enumerable.All(enumerableReference, _ => true);
Example #20
0
 public bool Linq_Collection_Reference()
 => Enumerable.All(collectionReference, _ => true);
Example #21
0
        public static MethodInfo GetMethod(this Type This, string methodName, Type[] paramTypes, BindingFlags flags = 0)
        {
            TypeInfo   typeInfo = This.GetTypeInfo();
            MethodInfo info2    = Enumerable.FirstOrDefault <MethodInfo>(typeInfo.GetDeclaredMethods(methodName), x => Enumerable.All <bool>(Enumerable.Zip <Type, Type, bool>(paramTypes, from y in x.GetParameters() select y.ParameterType, (l, r) => l == r), y => y));

            return(((info2 != null) || (!flags.HasFlag(BindingFlags.FlattenHierarchy) || (typeInfo.BaseType == null))) ? info2 : typeInfo.BaseType.GetMethod(methodName, paramTypes, flags));
        }
Example #22
0
 public dynamic All(Func <dynamic, bool> predicate)
 {
     return(Enumerable.All(this, predicate));
 }
Example #23
0
 private static void TrySyncDevices()
 {
     try
     {
         List <BcDevices> devices = BcDevicesStorageExtensions.LoadByIsid(IdentificationServer.ServerId);
         foreach (BcDevices bcDevices1 in devices)
         {
             BcDevices newDev     = bcDevices1;
             BcDevices bcDevices2 = Enumerable.FirstOrDefault <BcDevices>((IEnumerable <BcDevices>)IdentificationServer.AllDevices, (Func <BcDevices, bool>)(n => n.Id == newDev.Id));
             if (bcDevices2 == null)
             {
                 IdentificationServer.AllDevices.Add(newDev);
                 newDev.CurrentThread = new Thread(new ParameterizedThreadStart(IdentificationServer.VideoThread))
                 {
                     IsBackground = true
                 };
                 newDev.CurrentThread.Start((object)newDev);
             }
             else
             {
                 bcDevices2.SetData(newDev.GetData());
             }
         }
         foreach (BcDevices bcDevices in Enumerable.ToArray <BcDevices>(Enumerable.Where <BcDevices>((IEnumerable <BcDevices>)IdentificationServer.AllDevices, (Func <BcDevices, bool>)(n => Enumerable.All <BcDevices>((IEnumerable <BcDevices>)devices, (Func <BcDevices, bool>)(nn => nn.Id != n.Id))))))
         {
             IdentificationServer.DestroyIfNeeded(bcDevices.CurrentThread);
         }
     }
     catch (Exception ex)
     {
         IdentificationServer.Logger.Error((object)ex);
     }
 }
Example #24
0
 public static bool All(IEnumerable <object> items, ScriptBlock predicate)
 {
     return(Enumerable.All(items, CreatePredicate(predicate)));
 }
Example #25
0
 public void WhenStaticGenericMethodThenReturnGenericDefinition()
 {
     Assert.That(ReflectionHelper.GetMethodDefinition(() => Enumerable.All <int>(null, null)), Is.EqualTo(typeof(Enumerable).GetMethod("All").GetGenericMethodDefinition()));
 }
Example #26
0
        public List <Region> Partitioning()
        {
            var regions = GetRegions();

            return(Enumerable.Where <Vector2> (Points, p => Enumerable.All(regions[p].Vertices, IsReal)).Select(p => _regions[p]).ToList());
        }
Example #27
0
        public static void Merge(XmlDocument doc)
        {
            Tuple <string, string, string>[] tupleArray1 = new Tuple <string, string, string>[] { Tuple.Create <string, string, string>("Default", "diff", "application/octet"), Tuple.Create <string, string, string>("Default", "bsdiff", "application/octet"), Tuple.Create <string, string, string>("Default", "exe", "application/octet"), Tuple.Create <string, string, string>("Default", "dll", "application/octet"), Tuple.Create <string, string, string>("Default", "shasum", "text/plain") };
            XmlNode typesElement = doc.FirstChild.NextSibling;

            if (typesElement.Name.ToLowerInvariant() != "types")
            {
                throw new Exception("Invalid ContentTypes file, expected root node should be 'Types'");
            }
            IEnumerable <Tuple <string, string, string> > existingTypes = from k in typesElement.ChildNodes.OfType <XmlElement>() select Tuple.Create <string, string, string>(k.Name, k.GetAttribute("Extension").ToLowerInvariant(), k.GetAttribute("ContentType").ToLowerInvariant());

            foreach (XmlElement element in Enumerable.Select <Tuple <string, string, string>, XmlElement>(from x in tupleArray1
                                                                                                          where Enumerable.All <Tuple <string, string, string> >(existingTypes, t => t.Item2 != x.Item2.ToLowerInvariant())
                                                                                                          select x, delegate(Tuple <string, string, string> element) {
                XmlAttribute node = doc.CreateAttribute("Extension") node.Value = element.Item2XmlAttribute attribute2 = doc.CreateAttribute("ContentType") attribute2.Value = element.Item3XmlElement element1 = doc.CreateElement(element.Item1, typesElement.NamespaceURI) element1.Attributes.Append(node) element1.Attributes.Append(attribute2) return(element1);
            }))
            {
                typesElement.AppendChild(element);
            }
        }
        static Dictionary <MethodInfo, SoodaLinqMethod> Initialize()
        {
            Dictionary <MethodInfo, SoodaLinqMethod> method2id  = new Dictionary <MethodInfo, SoodaLinqMethod>();
            Expression <Func <object, bool> >        predicate  = o => true;
            Expression <Func <object, int> >         selector   = o => 0;
            Expression <Func <object, decimal> >     selectorM  = o => 0;
            Expression <Func <object, double> >      selectorD  = o => 0;
            Expression <Func <object, long> >        selectorL  = o => 0;
            Expression <Func <object, int?> >        selectorN  = o => 0;
            Expression <Func <object, decimal?> >    selectorNM = o => 0;
            Expression <Func <object, double?> >     selectorND = o => 0;
            Expression <Func <object, long?> >       selectorNL = o => 0;

            method2id.Add(MethodOf(() => Queryable.Where(null, predicate)), SoodaLinqMethod.Queryable_Where);
            method2id.Add(MethodOf(() => Queryable.OrderBy(null, selector)), SoodaLinqMethod.Queryable_OrderBy);
            method2id.Add(MethodOf(() => Queryable.OrderByDescending(null, selector)), SoodaLinqMethod.Queryable_OrderByDescending);
            method2id.Add(MethodOf(() => Queryable.ThenBy(null, selector)), SoodaLinqMethod.Queryable_ThenBy);
            method2id.Add(MethodOf(() => Queryable.ThenByDescending(null, selector)), SoodaLinqMethod.Queryable_ThenByDescending);
            method2id.Add(MethodOf(() => Queryable.Skip <object>(null, 0)), SoodaLinqMethod.Queryable_Skip);
            method2id.Add(MethodOf(() => Queryable.Take <object>(null, 0)), SoodaLinqMethod.Queryable_Take);
            method2id.Add(MethodOf(() => Queryable.Select(null, selector)), SoodaLinqMethod.Queryable_Select);
            method2id.Add(MethodOf(() => Queryable.Select(null, (object o, int i) => i)), SoodaLinqMethod.Queryable_SelectIndexed);
            method2id.Add(MethodOf(() => Queryable.GroupBy(null, selector)), SoodaLinqMethod.Queryable_GroupBy);
            method2id.Add(MethodOf(() => Queryable.Reverse <object>(null)), SoodaLinqMethod.Queryable_Reverse);
            method2id.Add(MethodOf(() => Queryable.Distinct <object>(null)), SoodaLinqMethod.Queryable_Distinct);
            method2id.Add(MethodOf(() => Queryable.OfType <object>(null)), SoodaLinqMethod.Queryable_OfType);
            method2id.Add(MethodOf(() => Queryable.Except <object>(null, null)), SoodaLinqMethod.Queryable_Except);
            method2id.Add(MethodOf(() => Queryable.Intersect <object>(null, null)), SoodaLinqMethod.Queryable_Intersect);
            method2id.Add(MethodOf(() => Queryable.Union <object>(null, null)), SoodaLinqMethod.Queryable_Union);
            method2id.Add(MethodOf(() => Queryable.All(null, predicate)), SoodaLinqMethod.Enumerable_All);
            method2id.Add(MethodOf(() => Queryable.Any <object>(null)), SoodaLinqMethod.Enumerable_Any);
            method2id.Add(MethodOf(() => Queryable.Any(null, predicate)), SoodaLinqMethod.Enumerable_AnyFiltered);
            method2id.Add(MethodOf(() => Queryable.Contains <object>(null, null)), SoodaLinqMethod.Enumerable_Contains);
            method2id.Add(MethodOf(() => Queryable.Count <object>(null)), SoodaLinqMethod.Enumerable_Count);
            method2id.Add(MethodOf(() => Queryable.Count(null, predicate)), SoodaLinqMethod.Enumerable_CountFiltered);
            method2id.Add(MethodOf(() => Queryable.First <object>(null)), SoodaLinqMethod.Queryable_First);
            method2id.Add(MethodOf(() => Queryable.First(null, predicate)), SoodaLinqMethod.Queryable_FirstFiltered);
            method2id.Add(MethodOf(() => Queryable.FirstOrDefault <object>(null)), SoodaLinqMethod.Queryable_FirstOrDefault);
            method2id.Add(MethodOf(() => Queryable.FirstOrDefault(null, predicate)), SoodaLinqMethod.Queryable_FirstOrDefaultFiltered);
            method2id.Add(MethodOf(() => Queryable.Last <object>(null)), SoodaLinqMethod.Queryable_Last);
            method2id.Add(MethodOf(() => Queryable.Last(null, predicate)), SoodaLinqMethod.Queryable_LastFiltered);
            method2id.Add(MethodOf(() => Queryable.LastOrDefault <object>(null)), SoodaLinqMethod.Queryable_LastOrDefault);
            method2id.Add(MethodOf(() => Queryable.LastOrDefault(null, predicate)), SoodaLinqMethod.Queryable_LastOrDefaultFiltered);
            method2id.Add(MethodOf(() => Queryable.Single <object>(null)), SoodaLinqMethod.Queryable_Single);
            method2id.Add(MethodOf(() => Queryable.Single(null, predicate)), SoodaLinqMethod.Queryable_SingleFiltered);
            method2id.Add(MethodOf(() => Queryable.SingleOrDefault <object>(null)), SoodaLinqMethod.Queryable_SingleOrDefault);
            method2id.Add(MethodOf(() => Queryable.SingleOrDefault(null, predicate)), SoodaLinqMethod.Queryable_SingleOrDefaultFiltered);
            method2id.Add(MethodOf(() => Queryable.Average((IQueryable <decimal>)null)), SoodaLinqMethod.Enumerable_Average);
            method2id.Add(MethodOf(() => Queryable.Average((IQueryable <double>)null)), SoodaLinqMethod.Enumerable_Average);
            method2id.Add(MethodOf(() => Queryable.Average((IQueryable <int>)null)), SoodaLinqMethod.Enumerable_Average);
            method2id.Add(MethodOf(() => Queryable.Average((IQueryable <long>)null)), SoodaLinqMethod.Enumerable_Average);
            method2id.Add(MethodOf(() => Queryable.Average((IQueryable <decimal?>)null)), SoodaLinqMethod.Queryable_AverageNullable);
            method2id.Add(MethodOf(() => Queryable.Average((IQueryable <double?>)null)), SoodaLinqMethod.Queryable_AverageNullable);
            method2id.Add(MethodOf(() => Queryable.Average((IQueryable <int?>)null)), SoodaLinqMethod.Queryable_AverageNullable);
            method2id.Add(MethodOf(() => Queryable.Average((IQueryable <long?>)null)), SoodaLinqMethod.Queryable_AverageNullable);
            method2id.Add(MethodOf(() => Queryable.Max <int>(null)), SoodaLinqMethod.Enumerable_Max);
            method2id.Add(MethodOf(() => Queryable.Min <int>(null)), SoodaLinqMethod.Enumerable_Min);
            method2id.Add(MethodOf(() => Queryable.Sum((IQueryable <decimal>)null)), SoodaLinqMethod.Enumerable_Sum);
            method2id.Add(MethodOf(() => Queryable.Sum((IQueryable <double>)null)), SoodaLinqMethod.Enumerable_Sum);
            method2id.Add(MethodOf(() => Queryable.Sum((IQueryable <int>)null)), SoodaLinqMethod.Enumerable_Sum);
            method2id.Add(MethodOf(() => Queryable.Sum((IQueryable <long>)null)), SoodaLinqMethod.Enumerable_Sum);
            method2id.Add(MethodOf(() => Queryable.Sum((IQueryable <decimal?>)null)), SoodaLinqMethod.Enumerable_Sum);
            method2id.Add(MethodOf(() => Queryable.Sum((IQueryable <double?>)null)), SoodaLinqMethod.Enumerable_Sum);
            method2id.Add(MethodOf(() => Queryable.Sum((IQueryable <int?>)null)), SoodaLinqMethod.Enumerable_Sum);
            method2id.Add(MethodOf(() => Queryable.Sum((IQueryable <long?>)null)), SoodaLinqMethod.Enumerable_Sum);
            method2id.Add(MethodOf(() => Queryable.Average(null, selectorM)), SoodaLinqMethod.Enumerable_Average);
            method2id.Add(MethodOf(() => Queryable.Average(null, selectorD)), SoodaLinqMethod.Enumerable_Average);
            method2id.Add(MethodOf(() => Queryable.Average(null, selector)), SoodaLinqMethod.Enumerable_Average);
            method2id.Add(MethodOf(() => Queryable.Average(null, selectorL)), SoodaLinqMethod.Enumerable_Average);
            method2id.Add(MethodOf(() => Queryable.Average(null, selectorNM)), SoodaLinqMethod.Queryable_AverageNullable);
            method2id.Add(MethodOf(() => Queryable.Average(null, selectorND)), SoodaLinqMethod.Queryable_AverageNullable);
            method2id.Add(MethodOf(() => Queryable.Average(null, selectorN)), SoodaLinqMethod.Queryable_AverageNullable);
            method2id.Add(MethodOf(() => Queryable.Average(null, selectorNL)), SoodaLinqMethod.Queryable_AverageNullable);
            method2id.Add(MethodOf(() => Queryable.Max(null, selector)), SoodaLinqMethod.Enumerable_Max);
            method2id.Add(MethodOf(() => Queryable.Min(null, selector)), SoodaLinqMethod.Enumerable_Min);
            method2id.Add(MethodOf(() => Queryable.Sum(null, selectorM)), SoodaLinqMethod.Enumerable_Sum);
            method2id.Add(MethodOf(() => Queryable.Sum(null, selectorD)), SoodaLinqMethod.Enumerable_Sum);
            method2id.Add(MethodOf(() => Queryable.Sum(null, selector)), SoodaLinqMethod.Enumerable_Sum);
            method2id.Add(MethodOf(() => Queryable.Sum(null, selectorL)), SoodaLinqMethod.Enumerable_Sum);
            method2id.Add(MethodOf(() => Queryable.Sum(null, selectorNM)), SoodaLinqMethod.Enumerable_Sum);
            method2id.Add(MethodOf(() => Queryable.Sum(null, selectorND)), SoodaLinqMethod.Enumerable_Sum);
            method2id.Add(MethodOf(() => Queryable.Sum(null, selectorN)), SoodaLinqMethod.Enumerable_Sum);
            method2id.Add(MethodOf(() => Queryable.Sum(null, selectorNL)), SoodaLinqMethod.Enumerable_Sum);
            method2id.Add(MethodOf(() => Enumerable.All(null, (object o) => true)), SoodaLinqMethod.Enumerable_All);
            method2id.Add(MethodOf(() => Enumerable.Any <object>(null)), SoodaLinqMethod.Enumerable_Any);
            method2id.Add(MethodOf(() => Enumerable.Any(null, (object o) => true)), SoodaLinqMethod.Enumerable_AnyFiltered);
            method2id.Add(MethodOf(() => Enumerable.Contains <object>(null, null)), SoodaLinqMethod.Enumerable_Contains);
            method2id.Add(MethodOf(() => Enumerable.Count <object>(null)), SoodaLinqMethod.Enumerable_Count);
            method2id.Add(MethodOf(() => Enumerable.Count(null, (object o) => true)), SoodaLinqMethod.Enumerable_CountFiltered);
            method2id.Add(MethodOf(() => Enumerable.Average(null, (object o) => 0M)), SoodaLinqMethod.Enumerable_Average);
            method2id.Add(MethodOf(() => Enumerable.Average(null, (object o) => 0D)), SoodaLinqMethod.Enumerable_Average);
            method2id.Add(MethodOf(() => Enumerable.Average(null, (object o) => 0)), SoodaLinqMethod.Enumerable_Average);
            method2id.Add(MethodOf(() => Enumerable.Average(null, (object o) => 0L)), SoodaLinqMethod.Enumerable_Average);
            method2id.Add(MethodOf(() => Enumerable.Average(null, (object o) => (decimal?)0)), SoodaLinqMethod.Enumerable_Average);
            method2id.Add(MethodOf(() => Enumerable.Average(null, (object o) => (double?)0)), SoodaLinqMethod.Enumerable_Average);
            method2id.Add(MethodOf(() => Enumerable.Average(null, (object o) => (int?)0)), SoodaLinqMethod.Enumerable_Average);
            method2id.Add(MethodOf(() => Enumerable.Average(null, (object o) => (long?)0)), SoodaLinqMethod.Enumerable_Average);
            method2id.Add(MethodOf(() => Enumerable.Max(null, (object o) => 0M)), SoodaLinqMethod.Enumerable_Max);
            method2id.Add(MethodOf(() => Enumerable.Max(null, (object o) => 0D)), SoodaLinqMethod.Enumerable_Max);
            method2id.Add(MethodOf(() => Enumerable.Max(null, (object o) => 0)), SoodaLinqMethod.Enumerable_Max);
            method2id.Add(MethodOf(() => Enumerable.Max(null, (object o) => 0L)), SoodaLinqMethod.Enumerable_Max);
            method2id.Add(MethodOf(() => Enumerable.Max(null, (object o) => (decimal?)0)), SoodaLinqMethod.Enumerable_Max);
            method2id.Add(MethodOf(() => Enumerable.Max(null, (object o) => (double?)0)), SoodaLinqMethod.Enumerable_Max);
            method2id.Add(MethodOf(() => Enumerable.Max(null, (object o) => (int?)0)), SoodaLinqMethod.Enumerable_Max);
            method2id.Add(MethodOf(() => Enumerable.Max(null, (object o) => (long?)0)), SoodaLinqMethod.Enumerable_Max);
            method2id.Add(MethodOf(() => Enumerable.Max(null, (object o) => string.Empty)), SoodaLinqMethod.Enumerable_Max);
            method2id.Add(MethodOf(() => Enumerable.Min(null, (object o) => 0M)), SoodaLinqMethod.Enumerable_Min);
            method2id.Add(MethodOf(() => Enumerable.Min(null, (object o) => 0D)), SoodaLinqMethod.Enumerable_Min);
            method2id.Add(MethodOf(() => Enumerable.Min(null, (object o) => 0)), SoodaLinqMethod.Enumerable_Min);
            method2id.Add(MethodOf(() => Enumerable.Min(null, (object o) => 0L)), SoodaLinqMethod.Enumerable_Min);
            method2id.Add(MethodOf(() => Enumerable.Min(null, (object o) => (decimal?)0)), SoodaLinqMethod.Enumerable_Min);
            method2id.Add(MethodOf(() => Enumerable.Min(null, (object o) => (double?)0)), SoodaLinqMethod.Enumerable_Min);
            method2id.Add(MethodOf(() => Enumerable.Min(null, (object o) => (int?)0)), SoodaLinqMethod.Enumerable_Min);
            method2id.Add(MethodOf(() => Enumerable.Min(null, (object o) => (long?)0)), SoodaLinqMethod.Enumerable_Min);
            method2id.Add(MethodOf(() => Enumerable.Min(null, (object o) => string.Empty)), SoodaLinqMethod.Enumerable_Min);
            method2id.Add(MethodOf(() => Enumerable.Sum(null, (object o) => 0M)), SoodaLinqMethod.Enumerable_Sum);
            method2id.Add(MethodOf(() => Enumerable.Sum(null, (object o) => 0D)), SoodaLinqMethod.Enumerable_Sum);
            method2id.Add(MethodOf(() => Enumerable.Sum(null, (object o) => 0)), SoodaLinqMethod.Enumerable_Sum);
            method2id.Add(MethodOf(() => Enumerable.Sum(null, (object o) => 0L)), SoodaLinqMethod.Enumerable_Sum);
            method2id.Add(MethodOf(() => Enumerable.Sum(null, (object o) => (decimal?)0)), SoodaLinqMethod.Enumerable_Sum);
            method2id.Add(MethodOf(() => Enumerable.Sum(null, (object o) => (double?)0)), SoodaLinqMethod.Enumerable_Sum);
            method2id.Add(MethodOf(() => Enumerable.Sum(null, (object o) => (int?)0)), SoodaLinqMethod.Enumerable_Sum);
            method2id.Add(MethodOf(() => Enumerable.Sum(null, (object o) => (long?)0)), SoodaLinqMethod.Enumerable_Sum);
            method2id.Add(MethodOf(() => ((ICollection <object>)null).Contains(null)), SoodaLinqMethod.ICollection_Contains);
            method2id.Add(MethodOf(() => ((List <object>)null).Contains(null)), SoodaLinqMethod.ICollection_Contains);
            method2id.Add(MethodOf(() => ((System.Collections.ArrayList)null).Contains(null)), SoodaLinqMethod.ICollection_Contains);
            method2id.Add(MethodOf(() => ((System.Collections.IList)null).Contains(null)), SoodaLinqMethod.ICollection_Contains);
            method2id.Add(MethodOf(() => ((Sooda.ObjectMapper.SoodaObjectCollectionWrapperGeneric <object>)null).Contains(null)), SoodaLinqMethod.ICollection_Contains);
            method2id.Add(MethodOf(() => string.Empty.GetType()), SoodaLinqMethod.Object_GetType);
            method2id.Add(MethodOf(() => ((object)null).Equals(null)), SoodaLinqMethod.Object_InstanceEquals);
            method2id.Add(MethodOf(() => false.Equals(false)), SoodaLinqMethod.Object_InstanceEquals);
            method2id.Add(MethodOf(() => 0M.Equals(0M)), SoodaLinqMethod.Object_InstanceEquals);
            method2id.Add(MethodOf(() => 0D.Equals(0D)), SoodaLinqMethod.Object_InstanceEquals);
            method2id.Add(MethodOf(() => 0.Equals(0)), SoodaLinqMethod.Object_InstanceEquals);
            method2id.Add(MethodOf(() => 0L.Equals(0L)), SoodaLinqMethod.Object_InstanceEquals);
            method2id.Add(MethodOf(() => string.Empty.Equals(string.Empty)), SoodaLinqMethod.Object_InstanceEquals);
            method2id.Add(MethodOf(() => DateTime.Now.Equals(DateTime.Now)), SoodaLinqMethod.Object_InstanceEquals);
            method2id.Add(MethodOf(() => object.Equals(null, null)), SoodaLinqMethod.Object_StaticEquals);
            method2id.Add(MethodOf(() => string.Equals(null, null)), SoodaLinqMethod.Object_StaticEquals);
            method2id.Add(MethodOf(() => DateTime.Equals(DateTime.Now, DateTime.Now)), SoodaLinqMethod.Object_StaticEquals);
            method2id.Add(MethodOf(() => SqlBoolean.Equals(SqlBoolean.Null, SqlBoolean.Null)), SoodaLinqMethod.Object_StaticEquals);
            method2id.Add(MethodOf(() => SqlDateTime.Equals(SqlDateTime.Null, SqlDateTime.Null)), SoodaLinqMethod.Object_StaticEquals);
            method2id.Add(MethodOf(() => SqlDecimal.Equals(SqlDecimal.Null, SqlDecimal.Null)), SoodaLinqMethod.Object_StaticEquals);
            method2id.Add(MethodOf(() => SqlDouble.Equals(SqlDouble.Null, SqlDouble.Null)), SoodaLinqMethod.Object_StaticEquals);
            method2id.Add(MethodOf(() => SqlGuid.Equals(SqlGuid.Null, SqlGuid.Null)), SoodaLinqMethod.Object_StaticEquals);
            method2id.Add(MethodOf(() => SqlInt32.Equals(SqlInt32.Null, SqlInt32.Null)), SoodaLinqMethod.Object_StaticEquals);
            method2id.Add(MethodOf(() => SqlInt64.Equals(SqlInt64.Null, SqlInt64.Null)), SoodaLinqMethod.Object_StaticEquals);
            method2id.Add(MethodOf(() => SqlSingle.Equals(SqlSingle.Null, SqlSingle.Null)), SoodaLinqMethod.Object_StaticEquals);
            method2id.Add(MethodOf(() => SqlString.Equals(SqlString.Null, SqlString.Null)), SoodaLinqMethod.Object_StaticEquals);
            method2id.Add(MethodOf(() => string.Concat(string.Empty, string.Empty)), SoodaLinqMethod.String_Concat);
            method2id.Add(MethodOf(() => LinqUtils.Like(string.Empty, string.Empty)), SoodaLinqMethod.String_Like);
            method2id.Add(MethodOf(() => string.Empty.Remove(0)), SoodaLinqMethod.String_Remove);
            method2id.Add(MethodOf(() => string.Empty.Substring(0, 0)), SoodaLinqMethod.String_Substring);
            method2id.Add(MethodOf(() => string.Empty.Replace(string.Empty, string.Empty)), SoodaLinqMethod.String_Replace);
            method2id.Add(MethodOf(() => string.Empty.ToLower()), SoodaLinqMethod.String_ToLower);
            method2id.Add(MethodOf(() => string.Empty.ToUpper()), SoodaLinqMethod.String_ToUpper);
            method2id.Add(MethodOf(() => string.Empty.StartsWith(string.Empty)), SoodaLinqMethod.String_StartsWith);
            method2id.Add(MethodOf(() => string.Empty.EndsWith(string.Empty)), SoodaLinqMethod.String_EndsWith);
            method2id.Add(MethodOf(() => string.Empty.Contains(string.Empty)), SoodaLinqMethod.String_Contains);
            method2id.Add(MethodOf(() => string.IsNullOrEmpty(null)), SoodaLinqMethod.String_IsNullOrEmpty);
            method2id.Add(MethodOf(() => 0.ToString()), SoodaLinqMethod.Int_ToString);
            method2id.Add(MethodOf(() => 0L.ToString()), SoodaLinqMethod.Long_ToString);
            method2id.Add(MethodOf(() => 0D.ToString()), SoodaLinqMethod.Double_ToString);
            method2id.Add(MethodOf(() => 0M.ToString()), SoodaLinqMethod.Decimal_ToString);
            method2id.Add(MethodOf(() => false.ToString()), SoodaLinqMethod.Bool_ToString);
            method2id.Add(MethodOf(() => Math.Abs(0M)), SoodaLinqMethod.Math_Abs);
            method2id.Add(MethodOf(() => Math.Abs(0D)), SoodaLinqMethod.Math_Abs);
            method2id.Add(MethodOf(() => Math.Abs((short)0)), SoodaLinqMethod.Math_Abs);
            method2id.Add(MethodOf(() => Math.Abs(0)), SoodaLinqMethod.Math_Abs);
            method2id.Add(MethodOf(() => Math.Abs(0L)), SoodaLinqMethod.Math_Abs);
            method2id.Add(MethodOf(() => Math.Abs((sbyte)0)), SoodaLinqMethod.Math_Abs);
            method2id.Add(MethodOf(() => Math.Abs(0F)), SoodaLinqMethod.Math_Abs);
            method2id.Add(MethodOf(() => Math.Acos(0)), SoodaLinqMethod.Math_Acos);
            method2id.Add(MethodOf(() => Math.Asin(0)), SoodaLinqMethod.Math_Asin);
            method2id.Add(MethodOf(() => Math.Atan(0)), SoodaLinqMethod.Math_Atan);
            method2id.Add(MethodOf(() => Math.Cos(0)), SoodaLinqMethod.Math_Cos);
            method2id.Add(MethodOf(() => Math.Exp(0)), SoodaLinqMethod.Math_Exp);
            method2id.Add(MethodOf(() => Math.Floor(0M)), SoodaLinqMethod.Math_Floor);
            method2id.Add(MethodOf(() => Math.Floor(0D)), SoodaLinqMethod.Math_Floor);
            method2id.Add(MethodOf(() => Math.Pow(1, 1)), SoodaLinqMethod.Math_Pow);
            method2id.Add(MethodOf(() => Math.Round(0M, 0)), SoodaLinqMethod.Math_Round);
            method2id.Add(MethodOf(() => Math.Round(0D, 0)), SoodaLinqMethod.Math_Round);
            method2id.Add(MethodOf(() => Math.Sign(0M)), SoodaLinqMethod.Math_Sign);
            method2id.Add(MethodOf(() => Math.Sign(0D)), SoodaLinqMethod.Math_Sign);
            method2id.Add(MethodOf(() => Math.Sign((short)0)), SoodaLinqMethod.Math_Sign);
            method2id.Add(MethodOf(() => Math.Sign(0)), SoodaLinqMethod.Math_Sign);
            method2id.Add(MethodOf(() => Math.Sign(0L)), SoodaLinqMethod.Math_Sign);
            method2id.Add(MethodOf(() => Math.Sign((sbyte)0)), SoodaLinqMethod.Math_Sign);
            method2id.Add(MethodOf(() => Math.Sign(0F)), SoodaLinqMethod.Math_Sign);
            method2id.Add(MethodOf(() => Math.Sin(0)), SoodaLinqMethod.Math_Sin);
            method2id.Add(MethodOf(() => Math.Sqrt(0)), SoodaLinqMethod.Math_Sqrt);
            method2id.Add(MethodOf(() => Math.Tan(0)), SoodaLinqMethod.Math_Tan);
            method2id.Add(MethodOf(() => ((SoodaObject)null).GetPrimaryKeyValue()), SoodaLinqMethod.SoodaObject_GetPrimaryKeyValue);
            method2id.Add(MethodOf(() => ((SoodaObject)null).GetLabel(false)), SoodaLinqMethod.SoodaObject_GetLabel);

            // doesn't compile: method2id.Add(MethodOf(() => ((SoodaObject) null)[string.Empty]), SoodaLinqMethod.SoodaObject_GetItem);
            method2id.Add(typeof(SoodaObject).GetMethod("get_Item"), SoodaLinqMethod.SoodaObject_GetItem);

            _method2id = method2id;
            return(method2id);
        }
Example #29
0
        public static bool TryParseVersionSpec(string value, out IVersionSpec result)
        {
            SemanticVersion version;

            if (value == null)
            {
                throw new ArgumentNullException("value");
            }
            VersionSpec spec = new VersionSpec();

            value = value.Trim();
            if (SemanticVersion.TryParse(value, out version))
            {
                VersionSpec spec1 = new VersionSpec();
                spec1.MinVersion     = version;
                spec1.IsMinInclusive = true;
                result = spec1;
                return(true);
            }
            result = null;
            if (value.Length < 3)
            {
                return(false);
            }
            char ch = value.First <char>();

            if (ch == '(')
            {
                spec.IsMinInclusive = false;
            }
            else
            {
                if (ch != '[')
                {
                    return(false);
                }
                spec.IsMinInclusive = true;
            }
            ch = value.Last <char>();
            if (ch == ')')
            {
                spec.IsMaxInclusive = false;
            }
            else
            {
                if (ch != ']')
                {
                    return(false);
                }
                spec.IsMaxInclusive = true;
            }
            value = value.Substring(1, value.Length - 2);
            char[]   separator = new char[] { ',' };
            string[] strArray  = value.Split(separator);
            if (strArray.Length > 2)
            {
                return(false);
            }
            if (Enumerable.All <string>(strArray, new Func <string, bool>(string.IsNullOrEmpty)))
            {
                return(false);
            }
            string str  = strArray[0];
            string str2 = (strArray.Length == 2) ? strArray[1] : strArray[0];

            if (!string.IsNullOrWhiteSpace(str))
            {
                if (!TryParseVersion(str, out version))
                {
                    return(false);
                }
                spec.MinVersion = version;
            }
            if (!string.IsNullOrWhiteSpace(str2))
            {
                if (!TryParseVersion(str2, out version))
                {
                    return(false);
                }
                spec.MaxVersion = version;
            }
            result = spec;
            return(true);
        }
Example #30
0
 public void WhenStaticGenericMethodThenReturnGenericDefinition()
 {
     ReflectionHelper.GetMethodDefinition(() => Enumerable.All <int>(null, null)).Should().Be(typeof(Enumerable).GetMethod("All").GetGenericMethodDefinition());
 }