private static IEnumerable <Lazy <T, IOrderMetadata> > Order(IEnumerable <Lazy <T, IOrderMetadata> > collection) { IndexDictionary index = new IndexDictionary(collection); SortItem root = new SortItem(); foreach (Lazy <T, IOrderMetadata> item in collection) { SortItem sourceItem = null; if (!String.IsNullOrEmpty(item.Metadata.ID) && index.ContainsKey(item.Metadata.ID)) { sourceItem = index[item.Metadata.ID]; } else { sourceItem = new SortItem(); sourceItem.Item = item; } if (!string.IsNullOrEmpty(item.Metadata.Before) && index.ContainsKey(item.Metadata.Before)) { SortItem targetItem = index[item.Metadata.Before]; if (!targetItem.Used) { sourceItem.Children.Add(targetItem); targetItem.Used = true; } } else if (!string.IsNullOrEmpty(item.Metadata.After) && index.ContainsKey(item.Metadata.After)) { if (!sourceItem.Used) { SortItem targetItem = index[item.Metadata.After]; targetItem.Children.Add(sourceItem); sourceItem.Used = true; } } if (!sourceItem.Used) { root.Children.Add(sourceItem); sourceItem.Used = true; } } return(root.ToCollection()); }
public void NoAuthentication(string configurationName, AuthenticationConfig authenticationConfig) { var indexedDictionary = new IndexDictionary <string, WebhookConfig> { { configurationName, new WebhookConfig { Name = configurationName, AuthenticationConfig = authenticationConfig } } }; var factory = new AuthenticationHandlerFactory(indexedDictionary, new Mock <IBigBrother>().Object); var handler = factory.Get(configurationName); Assert.Null(handler); }
public void GetTokenProvider(string configurationName, AuthenticationConfig authenticationConfig, IAcquireTokenHandler expectedHandler) { var indexedDictionary = new IndexDictionary <string, WebhookConfig> { { configurationName, new WebhookConfig { Name = configurationName, AuthenticationConfig = authenticationConfig } } }; var factory = new AuthenticationHandlerFactory(indexedDictionary, new Mock <IBigBrother>().Object); var handler = factory.Get(configurationName); Assert.Equal(expectedHandler.GetType(), handler.GetType()); }
static LocalizationBase() { DefaultCulture = new CultureInfoFixed(0x409) { CustomName = "English" }; CultureInfoFixed[] array = { DefaultCulture, new CultureInfoFixed(0x419) { CustomName = "Русский" }, new CultureInfoFixed(0x407) { CustomName = "Deutsch" }, new CultureInfoFixed(0x40c) { CustomName = "Française" } }; CultureLCIDDictionary = new IndexDictionary <Int32, CultureInfoFixed>(array.Select(culture => new KeyValuePair <Int32, CultureInfoFixed>(culture.LCID, culture))); CodeByLCIDMap = new Map <Int32, String>(CultureLCIDDictionary.ToDictionary(pair => pair.Value.LCID, pair => pair.Value.Code.ToLower())); DefaultComparer = new CultureComparer(CultureLCIDDictionary.Select(pair => pair.Value)); SystemCulture = CultureLCIDDictionary.TryGetValue(CultureInfo.CurrentUICulture.LCID, DefaultCulture); CurrentCulture = SystemCulture; }
public NestedCommandRule(T id, ReaderHandler <T> handler = null, IEqualityComparer <T> comparer = null) : base(id) { _rules = new IndexDictionary <T, ICommandRule <T> >(comparer); DefaultHandler = handler; }
private void Reset() { ResetAllChildAttachments(); IndexDictionary.Clear(); SetupIndices(_observableCollection); }
public ShellImageList(SHIL iconSize) { _imageList = new NativeImageList(Native.SHGetImageList(iconSize)); _imageSourceCache = new IndexDictionary <ImageSource>(); }