コード例 #1
0
 public void IList_NonGeneric_Remove_NullContainedInCollection(int count)
 {
     if (!IsReadOnly && !ExpectedFixedSize && NullAllowed && !Enumerable.Contains(InvalidValues, null))
     {
         int    seed       = count * 21;
         IList  collection = NonGenericIListFactory(count);
         object value      = null;
         if (!collection.Contains(value))
         {
             collection.Add(value);
             count++;
         }
         collection.Remove(value);
         Assert.Equal(count - 1, collection.Count);
     }
 }
コード例 #2
0
 public void ICollection_NonGeneric_Remove_NullNotContainedInCollection(int count)
 {
     if (!IsReadOnly && NullAllowed && !Enumerable.Contains(InvalidValues, null))
     {
         int    seed       = count * 21;
         IList  collection = NonGenericIListFactory(count);
         object value      = null;
         while (collection.Contains(value))
         {
             collection.Remove(value);
             count--;
         }
         collection.Remove(value);
         Assert.Equal(count, collection.Count);
     }
 }
コード例 #3
0
 public void ICollection_Generic_Remove_DefaultValueContainedInCollection(int count)
 {
     if (!IsReadOnly && DefaultValueAllowed && !Enumerable.Contains(InvalidValues, default(T)))
     {
         int             seed       = count * 21;
         ICollection <T> collection = GenericICollectionFactory(count);
         T value = default(T);
         if (!collection.Contains(value))
         {
             collection.Add(value);
             count++;
         }
         Assert.True(collection.Remove(value));
         Assert.Equal(count - 1, collection.Count);
     }
 }
コード例 #4
0
        public static bool IsInNdock(int areaid, List <Mem_ship> ships)
        {
            if (ships == null || ships.get_Count() == 0)
            {
                return(false);
            }
            IEnumerable <Mem_ndock> enumerable = Enumerable.Where <Mem_ndock>(Comm_UserDatas.Instance.User_ndock.get_Values(), (Mem_ndock x) => x.Area_id == areaid && x.State == NdockStates.RESTORE);

            if (enumerable == null || Enumerable.Count <Mem_ndock>(enumerable) == 0)
            {
                return(false);
            }
            IEnumerable <int> rids = Enumerable.Select <Mem_ship, int>(ships, (Mem_ship ship) => ship.Rid);

            return(Enumerable.Any <Mem_ndock>(enumerable, (Mem_ndock ndock) => Enumerable.Contains <int>(rids, ndock.Ship_id)));
        }
コード例 #5
0
ファイル: TypeSystem.cs プロジェクト: dox0/DotNet471RS3
        internal static bool IsImplementationOf(this PropertyInfo propertyInfo, Type interfaceType)
        {
            Debug.Assert(interfaceType.IsInterface, "Ensure interfaceType is an interface before calling IsImplementationOf");

            // Find the property with the corresponding name on the interface, if present
            PropertyInfo interfaceProp = interfaceType.GetProperty(propertyInfo.Name, BindingFlags.Public | BindingFlags.Instance);

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

            // If the declaring type is an interface, compare directly.
            if (propertyInfo.DeclaringType.IsInterface)
            {
                return(interfaceProp.Equals(propertyInfo));
            }

            Debug.Assert(Enumerable.Contains(propertyInfo.DeclaringType.GetInterfaces(), interfaceType), "Ensure propertyInfo.DeclaringType implements interfaceType before calling IsImplementationOf");

            bool result = false;

            // Get the get_<Property> method from the interface property.
            MethodInfo getInterfaceProp = interfaceProp.GetGetMethod();

            // Retrieve the interface mapping for the interface on the candidate property's declaring type.
            InterfaceMapping interfaceMap = propertyInfo.DeclaringType.GetInterfaceMap(interfaceType);

            // Find the index of the interface's get_<Property> method in the interface methods of the interface map
            int propIndex = Array.IndexOf(interfaceMap.InterfaceMethods, getInterfaceProp);

            // Find the method on the property's declaring type that is the target of the interface's get_<Property> method.
            // This method will be at the same index in the interface mapping's target methods as the get_<Property> interface method index.
            MethodInfo[] targetMethods = interfaceMap.TargetMethods;
            if (propIndex > -1 && propIndex < targetMethods.Length)
            {
                // If the get method of the referenced property is the target of the get_<Property> method in this interface mapping,
                // then the property is the implementation of the interface's corresponding property.
                MethodInfo getPropertyMethod = propertyInfo.GetGetMethod();
                if (getPropertyMethod != null)
                {
                    result = getPropertyMethod.Equals(targetMethods[propIndex]);
                }
            }

            return(result);
        }
コード例 #6
0
        public PullRequestDTO(PullRequestNode fromNode)
        {
            number       = fromNode.number;
            title        = fromNode.title;
            additions    = fromNode.additions;
            deletions    = fromNode.deletions;
            changes      = additions + deletions;
            changedFiles = fromNode.changedFiles;
            author       = GetUserName(fromNode.author);
            createdAtUtc = fromNode.createdAt.ToUnixTimeMilliseconds();
            updatedAtUtc = fromNode.updatedAt.ToUnixTimeMilliseconds();
            closedAtUtc  = fromNode.updatedAt.ToUnixTimeMilliseconds();
            isDraft      = fromNode.isDraft;
            mergeable    = fromNode.mergeable;
            reactions    = fromNode.reactionGroups.Select(rg => new ReactionGroupDTO
            {
                content = rg.content,
                users   = rg.users.nodes.Select(n => GetUserName(n)).ToList()
            }).ToList();

            totalPositiveReactions = reactions
                                     .Where(rg => Enumerable.Contains(new string[] { "THUMBS_UP", "HOORAY", "HEART", "ROCKET" }, rg.content))
                                     .SelectMany(rg => rg.users) // Get a list of all users who voted for any of these
                                     .Distinct()                 // Remove duplicates, so each users vote only counts once, even if they reacted multiple times
                                     .Count();                   // Get the number of users who voted for positive reactions

            totalNegativeReations = reactions
                                    .Where(rg => Enumerable.Contains(new string[] { "CONFUSED", "THUMBS_DOWN" }, rg.content))
                                    .SelectMany(rg => rg.users)
                                    .Distinct()
                                    .Count();

            url     = fromNode.url;
            reviews = fromNode.reviews.nodes.Select(n => new ReviewDTO
            {
                user           = GetUserName(n.author),
                state          = n.state,
                submittedAtUtc = n.submittedAt.ToUnixTimeMilliseconds()
            }).ToList();
            reviewDecision = fromNode.reviewDecision;

            labels = fromNode.labels.nodes.Select(n => new LabelDTO
            {
                name  = n.name,
                color = n.color
            }).ToList();
        }
コード例 #7
0
        protected void FillReports()
        {
            var reports = (from n in DataContext.LP_Reports
                           where Enumerable.Contains(SelectedReports, n.ID)
                           select n).ToList();

            var converter = new ReportEntityUnitModelConverter(DataContext);

            var reportModels = reports.Select(n => converter.Convert(n));

            var reportUnits = new ReportUnitsModel
            {
                List = reportModels.ToList()
            };

            reportUnitsControl.Model = reportUnits;
        }
コード例 #8
0
    public static void Foreach <T>(object enumerable, Action <T> action)
    {
        if (enumerable == null)
        {
            return;
        }
        Type typeFromHandle = typeof(IEnumerable);

        if (!Enumerable.Contains <Type>(enumerable.GetType().GetInterfaces(), typeFromHandle))
        {
            Debug.LogError("Object does not implement IEnumerable interface");
            return;
        }
        MethodInfo method = typeFromHandle.GetMethod("GetEnumerator");

        if (method == null)
        {
            Debug.LogError("Failed to get 'GetEnumberator()' method info from IEnumerable type");
            return;
        }
        IEnumerator enumerator = null;

        try
        {
            enumerator = (IEnumerator)method.Invoke(enumerable, null);
            if (enumerator is IEnumerator)
            {
                while (enumerator.MoveNext())
                {
                    action.Invoke((T)((object)enumerator.Current));
                }
            }
            else
            {
                Debug.LogError(string.Format("{0}.GetEnumerator() returned '{1}' instead of IEnumerator.", enumerable.ToString(), enumerator.GetType().Name));
            }
        }
        finally
        {
            IDisposable disposable = enumerator as IDisposable;
            if (disposable != null)
            {
                disposable.Dispose();
            }
        }
    }
コード例 #9
0
        private static IEnumerable <IPlugin> LoadPluginsFromFile(string file, string exeName, Logging.IPALogger logger)
        {
            List <IPlugin> plugins = new List <IPlugin>();

            if (!File.Exists(file) || !file.EndsWith(".dll", true, null))
            {
                return(plugins);
            }

            try
            {
                Assembly assembly = Assembly.LoadFrom(file);

                foreach (Type t in assembly.GetTypes())
                {
                    if (t.GetInterface("IPlugin") != null)
                    {
                        try
                        {
                            IPlugin  pluginInstance = Activator.CreateInstance(t) as IPlugin;
                            string[] filter         = null;

                            if (pluginInstance is IEnhancedPlugin)
                            {
                                filter = ((IEnhancedPlugin)pluginInstance).Filter;
                            }

                            if (filter == null || Enumerable.Contains(filter, exeName, StringComparer.OrdinalIgnoreCase))
                            {
                                plugins.Add(pluginInstance);
                            }
                        }
                        catch (Exception e)
                        {
                            logger.Warning($"Could not load plugin {t.FullName} in {Path.GetFileName(file)}. {e}", "IPA");
                        }
                    }
                }
            }
            catch (Exception e)
            {
                logger.Error($"Could not load {Path.GetFileName(file)}. {e}", "IPA");
            }

            return(plugins);
        }
コード例 #10
0
        protected virtual bool AuthorizeCore(HttpContextBase httpContext)
        {
            if (httpContext == null)
            {
                throw new ArgumentNullException("httpContext");
            }
            IPrincipal user = httpContext.User;

            if (!user.Identity.IsAuthenticated || this._usersSplit.Length > 0 && !Enumerable.Contains <string>((IEnumerable <string>) this._usersSplit, user.Identity.Name, (IEqualityComparer <string>)StringComparer.OrdinalIgnoreCase) || this._rolesSplit.Length > 0 && !Enumerable.Any <string>((IEnumerable <string>) this._rolesSplit, new Func <string, bool>(user.IsInRole)))
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
コード例 #11
0
ファイル: CultureManager.cs プロジェクト: radtek/Shopdrawing
        public static void InitializeWithCurrentUserContext(string applicationVersionedRegistryPath)
        {
            CultureManager.ReadUserLanguagePreferencePropertyFromRegistry(applicationVersionedRegistryPath);
            Collection <CultureInfo>  collection        = CultureManager.ReadLastKnownInstalledLanguagesFromRegistry(applicationVersionedRegistryPath);
            ICollection <CultureInfo> installedCultures = CultureManager.FindInstalledCultures(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));

            CultureManager.AvailableLanguagesChangedSinceLastSession = !Enumerable.SequenceEqual <CultureInfo>((IEnumerable <CultureInfo>)collection, (IEnumerable <CultureInfo>)installedCultures, (IEqualityComparer <CultureInfo>) new CultureInfoLcidComparer());
            if (CultureManager.UserLanguagePreference != null)
            {
                CultureManager.UserLanguagePreferenceAvailableAtStartup = Enumerable.Contains <CultureInfo>((IEnumerable <CultureInfo>)installedCultures, CultureManager.UserLanguagePreference, (IEqualityComparer <CultureInfo>) new CultureInfoLcidComparer());
            }
            if (installedCultures.Count > 1 && (CultureManager.AvailableLanguagesChangedSinceLastSession || !CultureManager.UserLanguagePreferenceAvailableAtStartup))
            {
                CultureManager.CurrentUserNeedsToSetLanguagePreference = true;
            }
            CultureManager.WriteLastKnownInstalledLanguagesToRegistry(applicationVersionedRegistryPath);
        }
コード例 #12
0
        protected override void AddToCollection(ICollection <KeyValuePair <TKey, TValue> > collection, int numberOfItemsToAdd)
        {
            Assert.False(IsReadOnly);
            int seed = 12353;
            IDictionary <TKey, TValue> casted = (IDictionary <TKey, TValue>)collection;
            int initialCount = casted.Count;

            while ((casted.Count - initialCount) < numberOfItemsToAdd)
            {
                KeyValuePair <TKey, TValue> toAdd = CreateT(seed++);
                while (casted.ContainsKey(toAdd.Key) || Enumerable.Contains(InvalidValues, toAdd))
                {
                    toAdd = CreateT(seed++);
                }
                collection.Add(toAdd);
            }
        }
コード例 #13
0
        private static bool ContainsDuplicant(this IList <TextureMeta> textures, TextureMeta other)
        {
            if (other == null)
            {
                return(true);
            }

            for (var i = 0; i < textures.Count; i++)
            {
                if (textures[i] == null)
                {
                    textures.RemoveAt(i); i--;
                }
            }

            return(Enumerable.Contains(textures, other));
        }
コード例 #14
0
        // Token: 0x06000010 RID: 16 RVA: 0x0000258C File Offset: 0x0000078C
        internal static void Postfix(int tile, ref IEnumerable <ThingDef> __result, ref World __instance)
        {
            Traverse  traverse = Traverse.Create(__instance);
            WorldGrid value    = traverse.Field("grid").GetValue <WorldGrid>();
            bool      flag     = value[tile].biome.defName.Equals("RockMoonBiome");
            bool      flag2    = flag;

            if (flag2)
            {
                __result = new List <ThingDef>
                {
                    DefDatabase <ThingDef> .GetNamed("BiomesNEO_HighlandRock", true)
                };
            }
            else
            {
                bool flag3 = Enumerable.Contains <ThingDef>(__result, DefDatabase <ThingDef> .GetNamed("BiomesNEO_HighlandRock", true));
                bool flag4 = Enumerable.Contains <ThingDef>(__result, DefDatabase <ThingDef> .GetNamed("BiomesNEO_MariaRock", true));
                bool flag5 = flag3 || flag4;
                if (flag5)
                {
                    Rand.PushState();
                    Rand.Seed = tile;
                    List <ThingDef> rocks = Enumerable.ToList <ThingDef>(__result);
                    bool            flag6 = flag3;
                    if (flag6)
                    {
                        rocks.Remove(DefDatabase <ThingDef> .GetNamed("BiomesNEO_HighlandRock", true));
                    }
                    bool flag7 = flag4;
                    if (flag7)
                    {
                        rocks.Remove(DefDatabase <ThingDef> .GetNamed("BiomesNEO_MariaRock", true));
                    }
                    List <ThingDef> list  = Enumerable.ToList <ThingDef>(Enumerable.Where <ThingDef>(DefDatabase <ThingDef> .AllDefs, (ThingDef d) => d.category.Equals(ThingCategory.Building) && d.building.isNaturalRock && !d.building.isResourceRock && !d.IsSmoothed && !rocks.Contains(d) && d.defName != "BiomesNEO_HighlandRock" && d.defName != "BiomesNEO_MariaRock"));
                    bool            flag8 = !list.NullOrEmpty <ThingDef>();
                    bool            flag9 = flag8;
                    if (flag9)
                    {
                        rocks.Add(list.RandomElement <ThingDef>());
                    }
                    __result = rocks;
                    Rand.PopState();
                }
            }
        }
コード例 #15
0
        private static IEnumerable <IPlugin> LoadPluginsFromFile(string file, string exeName)
        {
            List <IPlugin> plugins = new List <IPlugin>();

            if (!File.Exists(file) || !file.EndsWith(".dll", true, null))
            {
                return(plugins);
            }

            try
            {
                Assembly assembly = Assembly.LoadFrom(file);

                foreach (Type t in assembly.GetTypes())
                {
                    if (t.GetInterface("IPlugin") != null)
                    {
                        try
                        {
                            IPlugin  pluginInstance = Activator.CreateInstance(t) as IPlugin;
                            string[] filter         = null;

                            if (pluginInstance is IEnhancedPlugin)
                            {
                                filter = ((IEnhancedPlugin)pluginInstance).Filter;
                            }

                            if (filter == null || Enumerable.Contains(filter, exeName, StringComparer.OrdinalIgnoreCase))
                            {
                                plugins.Add(pluginInstance);
                            }
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine("[WARN] Could not load plugin {0} in {1}! {2}", t.FullName, Path.GetFileName(file), e);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("[ERROR] Could not load {0}! {1}", Path.GetFileName(file), e);
            }

            return(plugins);
        }
コード例 #16
0
ファイル: Communicator.cs プロジェクト: NiekAukes/BtProject
        public static void DistributeData()
        {
            StreamReader sr = new StreamReader(dataStream);

            while (Active)
            {
                //dataStream.EndRead(readres);
                //dataStream.Read(buf, 0, 1023);
                string   s        = sr.ReadToEnd();
                ushort[] shortbuf = new ushort[512];
                for (int i = 0; i < 512; i++)
                {
                    shortbuf[i] = BitConverter.ToUInt16(buf, (i * 2) % 1023);
                }

                if (Enumerable.Contains <ushort>(shortbuf, 65535))
                {
                    //still shit to do
                    ushort[]   dat  = CommunicatorHelper.SubArray <ushort>(shortbuf, 0, 7);
                    DataPacket pack = ProcessData(dat);
                    charsread += 14;
                    if (pack != null)
                    {
                        Debug.WriteLine("detected a new message" + pack.val.ToString());
                        if (Startwindow.inst != null)
                        {
                            Random rand = new Random();
                            Startwindow.addNodeToGraph(pack.id, 2 + (pack.val * 2));
                        }
                    }
                }
                else
                {
                }

                for (int i = 0; i < 1024; i++)
                {
                }
                //readres = dataStream.BeginRead(buf, 0, 1024, null, null);

                //Thread.Sleep(10);

                //errorstream
            }
        }
コード例 #17
0
ファイル: CE02C.cs プロジェクト: careyads/maxwellbiostweaker
 public void SetP0AndP2MemoryClock(uint clock)
 {
     if (!this.AreP0AndP2MMemoryClocksSame())
     {
         return;
     }
     foreach (UCPerfTableEntryControl obj in Enumerable.ToList <UCPerfTableEntryControl>(Enumerable.Where <UCPerfTableEntryControl>(this._EntryControlList, e =>
     {
         if (e.PerfEntry != null)
         {
             return(Enumerable.Contains <byte>(new byte[1], e.PerfEntry.Caption));
         }
         return(false);
     })))
     {
         obj.SetMemoryClock(clock);
     }
 }
コード例 #18
0
        private bool IsTargetExtension(string extension)
        {
            if (string.IsNullOrEmpty(extension))
            {
                return(false);
            }
            switch (this.GetSearchFileTypesValue())
            {
            case FindInFilesDialog.SearchFileTypes.XAML:
                return(Enumerable.Contains <string>((IEnumerable <string>)FindInFilesDialog.xamlExtensions, extension.ToUpperInvariant()));

            case FindInFilesDialog.SearchFileTypes.Code:
                return(Enumerable.Contains <string>((IEnumerable <string>)FindInFilesDialog.codeExtensions, extension.ToUpperInvariant()));

            default:
                return(Enumerable.Contains <string>((IEnumerable <string>)FindInFilesDialog.allExtensions, extension.ToUpperInvariant()));
            }
        }
コード例 #19
0
        public bool ValidateKey(char key, KeyTypes keyType)
        {
            switch (keyType)
            {
            case KeyTypes.IsNumber:
                return(Enumerable.Contains(numbers, key));

            case KeyTypes.IsOperator:
                return(Enumerable.Contains(operators, key));

            case KeyTypes.IsResultSign:
                return(Enumerable.Contains(resultSign, key));

            case KeyTypes.IsSpecialKeys:
                return(Enumerable.Contains(specialKeys, key));
            }
            return(false);
        }
コード例 #20
0
        /// <summary>
        /// Retourne la langue utilisé par l'appareil
        /// </summary>
        /// <returns>la langue en code à deux caractères</returns>
        public static string GetLangueAppareil()
        {
            var langue = Windows.System.UserProfile.GlobalizationPreferences.Languages[0];

            if (Enumerable.Contains(langue, '-'))
            {
                langue = langue.Substring(0, 2);
            }

            if (langue.Length == 2)
            {
                return(langue);
            }
            else
            {
                return("en");
            }
        }
コード例 #21
0
        public void Should_query_categories_filterd_using_empty_local_list_inline_with_enumerable_method()
        {
            System.Linq.Expressions.Expression <Func <Category, bool> > lambdaNewArrayInit =
                c => Enumerable.Contains(new List <string>(), c.Name);

            var mc = (System.Linq.Expressions.MethodCallExpression)lambdaNewArrayInit.Body;

            var lambdaConst = System.Linq.Expressions.Expression.Lambda <Func <Category, bool> >(
                System.Linq.Expressions.Expression.Call(
                    mc.Method,
                    System.Linq.Expressions.Expression.Constant(new List <string>()),
                    mc.Arguments[1]),
                lambdaNewArrayInit.Parameters);

            _categoryQueryable.Where(c => Enumerable.Contains(new List <string>(), c.Name)).ToList().ShouldBeEmpty();
            _categoryQueryable.Where(lambdaNewArrayInit).ToList().ShouldBeEmpty();
            _categoryQueryable.Where(lambdaConst).ToList().ShouldBeEmpty();
        }
コード例 #22
0
        protected override void AddToCollection(ICollection collection, int numberOfItemsToAdd)
        {
            Assert.False(IsReadOnly);
            int         seed         = 12353;
            IDictionary casted       = (IDictionary)collection;
            int         initialCount = casted.Count;

            while ((casted.Count - initialCount) < numberOfItemsToAdd)
            {
                object key   = CreateTKey(seed++);
                object value = CreateTValue(seed++);
                while (casted.Contains(key) || Enumerable.Contains(InvalidValues, key))
                {
                    key = CreateTKey(seed++);
                }
                casted.Add(key, value);
            }
        }
コード例 #23
0
        protected bool IsAnonymity()
        {
            string str1 = this.GetRouteString("controller").ToLower();
            string str2 = this.GetRouteString("action").ToLower();

            string[] strArray1 = new string[1]
            {
                "cart"
            };
            string[] strArray2 = new string[4]
            {
                "editbranchproducttocart",
                "getbranchcartproducts",
                "clearbranchcartproducts",
                "clearbranchcartinvalidproducts"
            };
            return(Enumerable.Contains <string>((IEnumerable <string>)strArray1, str1) && Enumerable.Contains <string>((IEnumerable <string>)strArray2, str2));
        }
コード例 #24
0
        public List <SearchResult> SearchTextFiles(string path, List <string> searchStrings, List <string> searchFilters)
        {
            List <string>       searchResults = new List <string>();
            List <SearchResult> myResults     = new List <SearchResult>();

            string[] textArray1 = new string[] { "*.pdf", "*.jpg", "*.doc", "*.docx" };
            string[] strArray   = textArray1;
            foreach (string str in searchFilters)
            {
                if (!Enumerable.Contains <string>(strArray, str))
                {
                    foreach (string str2 in Directory.GetFiles(path, str))
                    {
                        searchResults.Add(str2);
                    }
                }
            }
            foreach (string searchString in searchStrings)
            {
                if (!string.IsNullOrEmpty(searchString))
                {
                    foreach (string str4 in searchResults)
                    {
                        int num2 = 0;
                        using (IEnumerator <string> enumerator3 = File.ReadLines(str4).GetEnumerator())
                        {
                            while (enumerator3.MoveNext())
                            {
                                num2++;
                                if (enumerator3.Current.Contains(searchString))
                                {
                                    SearchResult item = new SearchResult();
                                    item.FilePath  = str4;
                                    item.RowNumber = new int?(num2);
                                    item.Keyword   = searchString;
                                    myResults.Add(item);
                                }
                            }
                        }
                    }
                }
            }
            return(myResults);
        }
コード例 #25
0
        public override IEnumerable <object> ProcessSubmittedValue(Field field, IEnumerable <object> postedValues, HttpContextBase context)
        {
            bool                   flag1 = false;
            bool                   flag2 = false;
            List <object>          list  = new List <object>();
            string                 path1 = context.Request[field.Id.ToString() + "_file"] ?? "";
            HttpFileCollectionBase files = context.Request.Files;

            if (files.Count > 0 && Enumerable.Contains <string>((IEnumerable <string>)files.AllKeys, field.Id.ToString()))
            {
                flag1 = true;
            }
            if (!string.IsNullOrEmpty(path1))
            {
                flag2 = true;
            }
            if (flag1)
            {
                if (flag2)
                {
                    File.Delete(IOHelper.MapPath(path1));
                }
                int index = 0;
                foreach (string str in files.AllKeys)
                {
                    if (str == field.Id.ToString())
                    {
                        HttpPostedFileBase httpPostedFileBase = files[index];
                        if (httpPostedFileBase.ContentLength > 0)
                        {
                            string url   = Enumerable.Last <string>((IEnumerable <string>)httpPostedFileBase.FileName.Split('\\'));
                            string path2 = Configuration.UploadTempPath + "/" + Guid.NewGuid().ToString();
                            string path3 = path2 + "/" + FileHelper.SafeUrl(url);
                            Directory.CreateDirectory(IOHelper.MapPath(path2));
                            httpPostedFileBase.SaveAs(IOHelper.MapPath(path3));
                            list.Add((object)path3);
                        }
                    }
                    ++index;
                }
            }
            list.Add((object)path1);
            return((IEnumerable <object>)list);
        }
コード例 #26
0
        public override void Execute(Action <DaemonStageResult> committer)
        {
            var highlightingConsumer = new FilteringHighlightingConsumer(DaemonProcess.SourceFile, File,
                                                                         DaemonProcess.ContextBoundSettingsStore);

            File.ProcessThisAndDescendants(this, highlightingConsumer);

            foreach (var declaration in File.Descendants <ICSharpFunctionDeclaration>())
            {
                var declaredElement = declaration.DeclaredElement;

                if (declaredElement == null)
                {
                    continue;
                }

                if (myEventFunctions != null && Enumerable.Contains(myEventFunctions, declaredElement))
                {
                    var method        = (declaredElement as IMethod).NotNull("method != null");
                    var eventFunction = myAPI.GetUnityEventFunction(method);

                    if (eventFunction == null) // happens after event function refactoring
                    {
                        continue;
                    }

                    myCommonIconProvider.AddEventFunctionHighlighting(highlightingConsumer, method, eventFunction,
                                                                      "Event function", myContext);
                    myMarkedDeclarations.Add(method);
                }
                else
                {
                    if (myMarkedDeclarations.Contains(declaredElement))
                    {
                        continue;
                    }

                    myCommonIconProvider.AddFrequentlyCalledMethodHighlighting(highlightingConsumer, declaration,
                                                                               "Frequently called", "Frequently called code", myContext);
                }
            }

            committer(new DaemonStageResult(highlightingConsumer.Highlightings));
        }
コード例 #27
0
ファイル: NetworkWorker.cs プロジェクト: Yaguar666/ffxivapp
        private void UpdateConnectionList()
        {
            var serverIPList = GetXIVServerIPList();

            if (serverIPList != null)
            {
                if (ServerConnections.Any())
                {
                    foreach (var server in serverIPList)
                    {
                        var serverIP = server;
                        foreach (var connection in ServerConnections.Where(connection => !serverIP.Equals(connection)))
                        {
                            ServerConnections.Add(server);
                        }
                    }
                }
                else
                {
                    ServerConnections = serverIPList;
                }
            }
            var removeFromDropped = new List <ServerConnection>();

            foreach (var connection in DroppedConnections)
            {
                if (DateTime.Now.Subtract(connection.TimeStamp)
                    .TotalMilliseconds > 30000.0)
                {
                    removeFromDropped.Add(connection);
                    continue;
                }
                var found = Enumerable.Contains(ServerConnections, connection);
                if (found)
                {
                    removeFromDropped.Add(connection);
                }
            }
            foreach (var connection in removeFromDropped)
            {
                DroppedConnections.Remove(connection);
            }
        }
コード例 #28
0
        private void cboTransportType_SelectedIndexChanged(object sender, EventArgs e)
        {
            var connectionStringType = cboServiceBusNamespace.SelectedIndex > 1
                ? serviceBusHelper.ServiceBusNamespaces[cboServiceBusNamespace.Text].ConnectionStringType
                : ServiceBusNamespaceType.Custom;
            var containsStsEndpoint = !string.IsNullOrWhiteSpace(Key) &&
                                      !string.IsNullOrWhiteSpace(serviceBusHelper.ServiceBusNamespaces[Key].StsEndpoint);

            if (cboServiceBusNamespace.Text == EnterConnectionString ||
                connectionStringType == ServiceBusNamespaceType.OnPremises || containsStsEndpoint)
            {
                btnOk.Enabled = !string.IsNullOrWhiteSpace(txtUri.Text);
                if (string.IsNullOrEmpty(txtUri.Text))
                {
                    return;
                }
                var cn = txtUri.Text;
                if (cn[cn.Length - 1] == ';')
                {
                    cn = cn.Substring(0, cn.Length - 1);
                }
                var parameters =
                    Enumerable.Where <string>(cn.Split(';'), p => Enumerable.Contains(p, '='))
                    .ToDictionary(s => s.Substring(0, s.IndexOf('=')).ToLower(),
                                  s => s.Substring(s.IndexOf('=') + 1));
                var value = parameters.ContainsKey(ConnectionStringTransportType)
                    ? cn.Replace(parameters[ConnectionStringTransportType], cboTransportType.SelectedItem.ToString())
                    : cn + string.Format((string)ConnectionStringTransportTypeFormat, (object)cboTransportType.SelectedItem);
                if (parameters.ContainsKey(ConnectionStringRuntimePort))
                {
                    if (!(cboTransportType.SelectedItem is TransportType))
                    {
                        return;
                    }
                    var transportType = (TransportType)cboTransportType.SelectedItem;
                    value = value.Replace(parameters[ConnectionStringRuntimePort],
                                          transportType == TransportType.Amqp
                            ? DefaultAmqpRuntimePort
                            : DefaultNetMessagingRuntimePort);
                }
                txtUri.Text = value;
            }
        }
コード例 #29
0
        public void RemoveAll()
        {
            string[] myCookies = _request.Cookies.AllKeys;
            string[] except    = { Constants.CookieKeys.Currency, Constants.CookieKeys.Culture, Constants.CookieKeys.Marketplace };

            foreach (string cookie in myCookies)
            {
                if (!Enumerable.Contains(except, cookie))
                {
                    HttpCookie userAuthCookie = new HttpCookie(cookie, "");
                    if (_request.Url.Host.ToLower() != "localhost")
                    {
                        userAuthCookie.Domain = ".itestapp.com";
                    }
                    userAuthCookie.Expires = DateTime.UtcNow.AddDays(-2d);
                    _response.Cookies.Add(userAuthCookie);
                }
            }
        }
コード例 #30
0
        private static bool Prefix(PlayerInteract __instance)
        {
            try
            {
                if (!__instance._playerInteractRateLimit.CanExecute() ||
                    (__instance._hc.CufferId > 0 && !PlayerInteract.CanDisarmedInteract))
                {
                    return(false);
                }

                GameObject gameObject = GameObject.Find("OutsitePanelScript");

                if (!__instance.ChckDis(gameObject.transform.position))
                {
                    return(false);
                }

                Item itemById = __instance._inv.GetItemByID(__instance._inv.curItem);

                if (!__instance._sr.BypassMode &&
                    (itemById == null || !Enumerable.Contains(itemById.permissions, "CONT_LVL_3")))
                {
                    return(false);
                }

                var ev = new ActivatingWarheadPanelEventArgs(API.Features.Player.Get(__instance.gameObject), new List <string> {
                    "CONT_LVL_3"
                });

                Handlers.Player.OnActivatingWarheadPanel(ev);

                gameObject.GetComponentInParent <AlphaWarheadOutsitePanel>().NetworkkeycardEntered = true;
                __instance.OnInteract();

                return(false);
            }
            catch (Exception e)
            {
                Exiled.API.Features.Log.Error($"Exiled.Events.Patches.Events.Player.ActivatingWarheadPanel: {e}\n{e.StackTrace}");

                return(true);
            }
        }