ModelApplicationBase GetMasterModel(bool recreate) { var modelApplicationBase = GetMasterModelCore(recreate); _modelApplicationBases.Add(modelApplicationBase, XafTypesInfo.Instance); _typeInfo.AssignAsInstance(); return modelApplicationBase; }
public void Register <TArtifactStateRule>(ISupportArtifactState supportArtifactState) { if (!providers.Keys.Contains(supportArtifactState)) { providers.Add(supportArtifactState, typeof(TArtifactStateRule)); } }
/// <summary> /// Adds buttons /// </summary> /// <param name="keys">Keys</param> /// <param name="buttons">Buttons</param> /// <param name="tab">Tab control</param> /// <param name="tools">Tools</param> /// <param name="size">Size</param> /// <param name="resources">Resources</param> /// <param name="translate">Translate sign</param> public static void Add(string[] keys, ButtonWrapper[][] buttons, TabControl tab, ToolsDiagram tools, Size size, Dictionary <string, object>[] resources, bool translate) { LightDictionary <string, ButtonWrapper[]> d = new LightDictionary <string, ButtonWrapper[]>(); d.Add(keys, buttons); Add(d, tab, tools, size, resources, translate); }
public void IDictionary_NonGeneric_Add_KeyOfWrongType(int count) { if (!IsReadOnly) { IDictionary dictionary = new LightDictionary <string, string>(); object missingKey = 23; Assert.Throws <ArgumentException>("key", () => dictionary.Add(missingKey, CreateTValue(12345))); Assert.Empty(dictionary); } }
public void IDictionary_NonGeneric_Add_ValueOfWrongType(int count) { if (!IsReadOnly) { IDictionary dictionary = new LightDictionary <string, string>(); object missingKey = GetNewKey(dictionary); Assert.Throws <ArgumentException>("value", () => dictionary.Add(missingKey, 324)); Assert.Empty(dictionary); } }
public void LightDictionary_Generic_RemoveKey_ValidKeyContainedInDictionary(int count) { LightDictionary <TKey, TValue> dictionary = (LightDictionary <TKey, TValue>)GenericIDictionaryFactory(count); TKey missingKey = GetNewKey(dictionary); TValue inValue = CreateTValue(count); dictionary.Add(missingKey, inValue); Assert.True(dictionary.Remove(missingKey)); Assert.Equal(count, dictionary.Count); }
public void IDictionary_NonGeneric_Add_NullValueWhenDefaultTValueIsNonNull(int count) { if (!IsReadOnly) { IDictionary dictionary = new LightDictionary <string, int>(); object missingKey = GetNewKey(dictionary); Assert.Throws <ArgumentNullException>(() => dictionary.Add(missingKey, null)); Assert.Empty(dictionary); } }
static CommonService.LightDictionary <string, ButtonWrapper[]> GetButtons(Motion6D.Interfaces.IPositionObjectFactory factory) { Motion6D.Interfaces.IPositionObjectFactory f = factory; if (f == null) { f = Motion6D.PositionObjectFactory.BaseFactory; } string[] tabs = new string[] { "General", "Statistics", "Database", "6D Motion", "Image", "Events", "Arrows" }; ButtonWrapper[][] but = new ButtonWrapper[tabs.Length][]; int i = 0; List <ButtonWrapper> gen = new List <ButtonWrapper>(); gen.AddRange(DataPerformer.UI.Factory.StaticFactory.GeneralObjectsButtons); gen.AddRange(ControlSystems.Data.UI.Factory.ControlSystemsFactory.ObjectButtons); gen.AddRange(Simulink.Proxy.UI.Factory.SimulinkProxyFactory.ObjectButtons); gen.AddRange(SoundService.UI.Factory.SoundUIFactrory.ObjectButtons); but[i] = gen.ToArray(); ++i; but[i] = EngineeringUIFactory.StatisticalObjectsButtons; ++i; but[i] = Database.UI.Factory.DatabaseFactory.ObjectButtons; ++i; List <ButtonWrapper> geom = new List <ButtonWrapper>(); geom.AddRange(Motion6D.UI.Factory.MotionFactory.ObjectButtons); geom.AddRange(Motion6D.UI.Factory.VisibleFactory.GetVisualObjectButtons(f)); but[i] = geom.ToArray(); ++i; List <ButtonWrapper> image = new List <ButtonWrapper>(); image.AddRange(ImageTransformations.Factory.ImageTransformationFactory.ObjectButtons); image.AddRange(ImageNavigation.Factory.ImageNavigationFactory.ObjectButtons); but[i] = image.ToArray(); ++i; List <ButtonWrapper> events = new List <ButtonWrapper>(); events.AddRange(Event.UI.Factory.UIFactory.ObjectButtons); but[i] = events.ToArray(); ++i; List <ButtonWrapper> arr = new List <ButtonWrapper>(); arr.AddRange(EngineeringUIFactory.ArrowButtons); arr.Add(EngineeringUIFactory.DataExchangeArrowButtons[0]); arr.AddRange(Database.UI.Factory.DatabaseFactory.ArrowButtons); arr.AddRange(Motion6D.UI.Factory.MotionFactory.ArrowButtons); arr.AddRange(Motion6D.UI.Factory.VisibleFactory.VisualArrowButtons); arr.AddRange(ImageTransformations.Factory.ImageTransformationFactory.ArrowButtons); arr.AddRange(ImageNavigation.Factory.ImageNavigationFactory.ArrowButtons); arr.AddRange(Event.UI.Factory.UIFactory.ArrowButtons); but[i] = arr.ToArray(); LightDictionary <string, ButtonWrapper[]> buttons = new LightDictionary <string, ButtonWrapper[]>(); buttons.Add(tabs, but); return(buttons); }
protected override ICollection NonGenericICollectionFactory(int count) { LightDictionary <string, string> list = new LightDictionary <string, string>(); int seed = 13453; for (int i = 0; i < count; i++) { list.Add(CreateT(seed++), CreateT(seed++)); } return(list.Values); }
public void LightDictionary_Generic_ValueCollection_GetEnumerator(int count) { LightDictionary <string, string> dictionary = new LightDictionary <string, string>(); int seed = 13453; while (dictionary.Count < count) { dictionary.Add(CreateT(seed++), CreateT(seed++)); } dictionary.Values.GetEnumerator(); }
public void LightDictionary_Generic_ContainsValue_DefaultValuePresent(int count) { LightDictionary <TKey, TValue> dictionary = (LightDictionary <TKey, TValue>)GenericIDictionaryFactory(count); int seed = 4315; TKey notPresent = CreateTKey(seed++); while (dictionary.ContainsKey(notPresent)) { notPresent = CreateTKey(seed++); } dictionary.Add(notPresent, default(TValue)); Assert.True(dictionary.ContainsValue(default(TValue))); }
public void LightDictionary_Generic_ContainsValue_Present(int count) { LightDictionary <TKey, TValue> dictionary = (LightDictionary <TKey, TValue>)GenericIDictionaryFactory(count); int seed = 4315; KeyValuePair <TKey, TValue> notPresent = CreateT(seed++); while (dictionary.Contains(notPresent)) { notPresent = CreateT(seed++); } dictionary.Add(notPresent.Key, notPresent.Value); Assert.True(dictionary.ContainsValue(notPresent.Value)); }
public void Remove_NonExistentEntries_DoesNotPreventEnumeration() { const string SubKey = "-sub-key"; var dictionary = new LightDictionary <string, string>(); dictionary.Add("a", "b"); dictionary.Add("c", "d"); foreach (string key in dictionary.Keys) { if (dictionary.Remove(key + SubKey)) { break; } } dictionary.Add("c" + SubKey, "d"); foreach (string key in dictionary.Keys) { if (dictionary.Remove(key + SubKey)) { break; } } }
public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, IServiceProvider provider, object value) { string[] tabs = new string[] { "General", "6D Motion", "Arrows" }; ButtonWrapper[][] but = new ButtonWrapper[tabs.Length][]; int i = 0; List <ButtonWrapper> gen = new List <ButtonWrapper>(); gen.AddRange(DataPerformer.UI.Factory.StaticFactory.GeneralObjectsButtons); // gen.AddRange(ControlSystems.Data.UI.Factory.ControlSystemsFactory.ObjectButtons); but[i] = gen.ToArray(); ++i; List <ButtonWrapper> geom = new List <ButtonWrapper>(); //geom.AddRange(Motion6D.UI.Factory.MotionFactory.ObjectButtons); // geom.AddRange(Motion6D.UI.Factory.VisibleFactory.GetVisualObjectButtons(factory)); but[i] = geom.ToArray(); ++i; List <ButtonWrapper> arr = new List <ButtonWrapper>(); arr.AddRange(EngineeringUIFactory.ArrowButtons); arr.AddRange(Motion6D.UI.Factory.MotionFactory.ArrowButtons); arr.AddRange(Motion6D.UI.Factory.VisibleFactory.VisualArrowButtons); but[i] = arr.ToArray(); LightDictionary <string, ButtonWrapper[]> buttons = new LightDictionary <string, ButtonWrapper[]>(); buttons.Add(tabs, but); IUIFactory[] factories = new IUIFactory[] { // ControlSystems.Data.UI.Factory.ControlSystemsFactory.Object, }; IApplicationInitializer[] init = new IApplicationInitializer[] { }; Dictionary <string, object>[] d = Motion6D.UI.Utils.ControlUtilites.Resources; ByteHolder holder = value as ByteHolder; FormMain m = MotionApplicationCreator.CreateForm(null, holder, OrdinaryDifferentialEquations.Runge4Solver.Singleton, DataPerformer.Portable.DifferentialEquationProcessors.RungeProcessor.Processor, init, factories, true, buttons, Properties.Resources.Aviation, null, null, Motion6D.UI.Utils.ControlUtilites.Resources, "Astronomy + OpenGL", ".cfa", "Astronomy configuration files |*.cfa", null, null); m.ShowDialog(); return(m.Creator.Holder); }
public async Task LightDictionaryConcurrentAccessDetection_ValueTypeKey(Type comparerType) { IEqualityComparer <int> customComparer = null; LightDictionary <int, int> dic = comparerType == null ? new LightDictionary <int, int>() : new LightDictionary <int, int>((customComparer = (IEqualityComparer <int>)Activator.CreateInstance(comparerType))); dic.Add(1, 1); await LightDictionaryConcurrentAccessDetection(dic, typeof(int).IsValueType, customComparer, d => d.Add(1, 1), d => { var v = d[1]; }, d => d.Remove(1)); }
public async Task LightDictionaryConcurrentAccessDetection_ReferenceTypeKey(Type comparerType) { IEqualityComparer <DummyRefType> customComparer = null; LightDictionary <DummyRefType, DummyRefType> dic = comparerType == null ? new LightDictionary <DummyRefType, DummyRefType>() : new LightDictionary <DummyRefType, DummyRefType>((customComparer = (IEqualityComparer <DummyRefType>)Activator.CreateInstance(comparerType))); var keyValueSample = new DummyRefType() { Value = 1 }; dic.Add(keyValueSample, keyValueSample); await LightDictionaryConcurrentAccessDetection(dic, typeof(DummyRefType).IsValueType, customComparer, d => d.Add(keyValueSample, keyValueSample), d => { var v = d[keyValueSample]; }, d => d.Remove(keyValueSample)); }
public virtual List <object> GetAnalysisDataList(Type targetObjectType) { List <object> cachedReports; if (analysisCache.TryGetValue(targetObjectType, out cachedReports)) { return(cachedReports); } _typeInfoContainer = (ITypeInfoContainer)Application.Modules.Single(@base => @base is ITypeInfoContainer); using (var objectSpace = Application.CreateObjectSpace(_typeInfoContainer.TypesInfo.AnalysisType)) { List <string> targetObjectTypeNames = GetTargetObjectTypeNames(targetObjectType); var result = new List <object>(); if (targetObjectTypeNames.Count > 0) { IList reports = objectSpace.CreateCollection(_typeInfoContainer.TypesInfo.AnalysisType, new InOperator("ObjectTypeName", targetObjectTypeNames)); result.AddRange(reports.Cast <object>().Select(objectSpace.GetKeyValue)); } analysisCache.Add(targetObjectType, result); return(result); } }
/// <summary> /// Initialization of containers tools /// </summary> /// <param name="baseDirectory">Base directory</param> /// <param name="tools">Tools</param> /// <param name="tabControl">Tab control</param> /// <param name="resources">Resources</param> static public void InitContainers(string baseDirectory, ToolsDiagram tools, TabControl tabControl, Dictionary <string, object>[] resources) { string cont = baseDirectory; if (cont[cont.Length - 1] != Path.DirectorySeparatorChar) { cont = cont + Path.DirectorySeparatorChar; } cont = cont + "Containers" + Path.DirectorySeparatorChar + "Containers.xml"; if (!File.Exists(cont)) { return; } XmlDocument doc = new XmlDocument(); doc.Load(cont); XmlNodeList nl = doc.GetElementsByTagName("Assemblies"); if (nl.Count > 0) { XmlElement ass = nl[0] as XmlElement; string dir = AppDomain.CurrentDomain.BaseDirectory; foreach (XmlNode ndll in ass.ChildNodes) { if (!(ndll is XmlElement)) { continue; } XmlElement dll = ndll as XmlElement; string fn = dir + dll.GetAttribute("file"); if (!File.Exists(fn)) { throw new Exception("File + \"" + fn + "\" does not exist"); } byte[] b = fn.GetFileBytes(); AppDomain.CurrentDomain.Load(b); } } XmlNodeList contPages = doc.GetElementsByTagName("Page"); // int k = 0; LightDictionary <string, ButtonWrapper[]> dict = new LightDictionary <string, ButtonWrapper[]>(); foreach (XmlElement page in contPages) { XmlNodeList list = page.ChildNodes; List <ButtonWrapper> buttons = new List <ButtonWrapper>(); foreach (XmlNode eln in list) { if (!(eln is XmlElement)) { continue; } XmlElement el = eln as XmlElement; string tag = el.Name; string ico = AppDomain.CurrentDomain.BaseDirectory + el.Attributes["icon"].Value; Image image = Image.FromFile(ico); string name = el.GetAttribute("name"); string hint = el.Attributes["hint"].Value; bool isArrow = el.Attributes["arrow"].Value.Equals("true"); ButtonWrapper button = null; if (isArrow) { button = new ButtonWrapper(typeof(LibraryArrowWrapper), name, hint, image, null, true, true); } else { if (tag.Equals("Aggregate")) { bool b = true; if (el.Attributes["wrapper"] != null) { if (el.GetAttribute("wrapper").Equals("true")) { button = new ButtonWrapper(typeof(LibraryObjectWrapper), name, hint, image, null, true, false); b = false; } } if (b) { button = new ButtonWrapper(typeof(ObjectContainer), name, hint, image, null, true, false); } } if (tag.Equals("Object")) { string tp = el.GetAttribute("type"); Type t = Type.GetType(tp); if (t == null) { throw new Exception("Type \"" + tp + "\" does not exist"); } button = new ButtonWrapper(t, el.GetAttribute("param"), hint, image, null, true, false); } } buttons.Add(button); } XmlAttribute an = page.Attributes["pageName"]; string vis = page.GetAttribute("visible"); if (vis == "false") { vis = "@"; } else { vis = ""; } dict.Add(new string[] { an.Value + vis }, new ButtonWrapper[][] { buttons.ToArray() }); } ButtonWrapper.Add(dict, tabControl, tools, new Size(25, 25), resources, false); }
private void FillMenuContents(DevExpress.Web.MenuItemCollection holderMenuItems, ChoiceActionItemCollection actionItems) { foreach (ChoiceActionItem groupValue in actionItems) { if (!groupValue.Active) { continue; } if (groupValue.Items.Count == 0) { ASPxMenuItemChoiceActionItem itemWrapper = new ASPxMenuItemChoiceActionItem(SingleChoiceAction, groupValue); MenuItemToWrapperMap.Add(itemWrapper.CurrentMenuItem, itemWrapper); holderMenuItems.Add(itemWrapper.CurrentMenuItem); ActionItemToMenuItemMap.Add(groupValue, itemWrapper.CurrentMenuItem); } else { ASPxMenuGroupChoiceActionItem groupItem = new ASPxMenuGroupChoiceActionItem(SingleChoiceAction, groupValue); GroupWrappers.Add(groupItem); DevExpress.Web.MenuItem group = groupItem.MenuGroup; ActionItemToMenuGroupMap.Add(groupValue, group); holderMenuItems.Add(group); ItemsDisplayStyle itemsDisplayStyle = ItemsDisplayStyle.LargeIcons; if (groupValue.Model != null) { itemsDisplayStyle = ItemsDisplayStyle.List; if (groupValue.Model is IModelChoiceActionItemChildItemsDisplayStyle) { itemsDisplayStyle = ((IModelChoiceActionItemChildItemsDisplayStyle)groupValue.Model).ChildItemsDisplayStyle; } } CreateCustomGroupControlEventArgs args = new CreateCustomGroupControlEventArgs(groupValue); OnCreateCustomGroupControl(args); if (args.Control != null) { var customControlItem = new ASPxMenuCustomControlItem(args.Control); customControlItem.InitTemplate(); group.Items.Add(customControlItem); } else { switch (itemsDisplayStyle) { case ItemsDisplayStyle.LargeIcons: case ItemsDisplayStyle.List: if (groupValue.IsHierarchical()) { FillMenuContents(group.Items, groupValue.Items); } else { FillMenuGroup(group, groupValue); } break; } } } } }