public void MergeNotAllowedWhenMergeNotEnabled() { ManagedDictionary child = new ManagedDictionary(); Assert.Throws <InvalidOperationException>(() => child.Merge(null), "Not allowed to merge when the 'MergeEnabled' property is set to 'false'"); }
/// <summary> /// /// </summary> /// <param name="xml"></param> /// <param name="obj"></param> private void writeNode(XmlTextWriter xml, ManagedDictionary<string,LoadCase> obj) { xml.WriteStartElement("Load_Case_Definitions"); foreach(LoadCase lCase in obj.Values) if(lCase!= null) writeLoadCase(xml, lCase); xml.WriteEndElement(); }
private AbstractObjectDefinition ParseAttributeSource(XmlElement element, ParserContext parserContext) { XmlNodeList methods = element.SelectNodes("*[local-name()='method' and namespace-uri()='" + element.NamespaceURI + "']"); ManagedDictionary transactionAttributeMap = new ManagedDictionary(); foreach (XmlElement methodElement in methods) { string name = GetAttributeValue(methodElement, "name"); TypedStringValue nameHolder = new TypedStringValue(name); RuleBasedTransactionAttribute attribute = new RuleBasedTransactionAttribute(); string propagation = GetAttributeValue(methodElement, PROPAGATION); string isolation = GetAttributeValue(methodElement, ISOLATION); string timeout = GetAttributeValue(methodElement, TIMEOUT); string readOnly = GetAttributeValue(methodElement, READ_ONLY); if (StringUtils.HasText(propagation)) { attribute.PropagationBehavior = (TransactionPropagation)Enum.Parse(typeof(TransactionPropagation), propagation, true); } if (StringUtils.HasText(isolation)) { attribute.TransactionIsolationLevel = (IsolationLevel)Enum.Parse(typeof(IsolationLevel), isolation, true); } if (StringUtils.HasText(timeout)) { try { attribute.TransactionTimeout = Int32.Parse(timeout); } catch (FormatException ex) { parserContext.ReaderContext.ReportException(methodElement, "tx advice", "timeout must be an integer value: [" + timeout + "]", ex); } } if (StringUtils.HasText(readOnly)) { attribute.ReadOnly = Boolean.Parse(GetAttributeValue(methodElement, READ_ONLY)); } var rollbackRules = new List <RollbackRuleAttribute>(); if (methodElement.HasAttribute(ROLLBACK_FOR)) { string rollbackForValue = GetAttributeValue(methodElement, ROLLBACK_FOR); AddRollbackRuleAttributesTo(rollbackRules, rollbackForValue); } if (methodElement.HasAttribute(NO_ROLLBACK_FOR)) { string noRollbackForValue = GetAttributeValue(methodElement, NO_ROLLBACK_FOR); AddNoRollbackRuleAttributesTo(rollbackRules, noRollbackForValue); } attribute.RollbackRules = rollbackRules; transactionAttributeMap[nameHolder] = attribute; } ObjectDefinitionBuilder builder = parserContext .ParserHelper .CreateRootObjectDefinitionBuilder(typeof(NameMatchTransactionAttributeSource)); builder.AddPropertyValue(NAME_MAP, transactionAttributeMap); return(builder.ObjectDefinition); }
public void MergeNotAllowedWhenMergeNotEnabled() { ManagedDictionary child = new ManagedDictionary(); child.Merge(null); }
/// <summary> /// Destruye todo el modelo y lo deja limpio /// </summary> /// <TODO>Modified, Save, Load</TODO> public void Reset() { try { this.undoManager = new UndoManager(this); undoManager.Enabled = false; this.abstractCases = new ManagedList<Canguro.Model.Load.AbstractCase>(); abstractCases.ElementRemoved += new ManagedList<AbstractCase>.ListChangedEventHandler(abstractCases_ElementRemoved); this.activeLoadCase = null; this.areaList = new ItemList<AreaElement>(); this.constraintList = new ManagedList<Constraint>(); this.isLocked = false; this.jointList = new ItemList<Joint>(); this.layers = new ItemList<Layer>(); layers.ElementRemoved += new ManagedList<Layer>.ListChangedEventHandler(layers_ElementRemoved); this.lineList = new ItemList<LineElement>(); this.loadCases = new ManagedDictionary<string, LoadCase>(); loadCases.ElementRemoved += new ManagedDictionary<string, LoadCase>.ListChangedEventHandler(loadCases_ElementRemoved); this.summary = new ModelSummary(this); this.designOptions = new List<DesignOptions>(); designOptions.Add(NoDesign.Instance); designOptions.Add(new LRFD99()); designOptions.Add(new ACI318_02()); designOptions.Add(new ASD01()); designOptions.Add(new RCDF2001()); designOptions.Add(new UBC97_ASD()); designOptions.Add(new UBC97_LRFD()); designOptions.Add(new UBC97_Conc()); steelDesignOptions = NoDesign.Instance; concreteDesignOptions = NoDesign.Instance; coldFormedDesignOptions = NoDesign.Instance; aluminumDesignOptions = NoDesign.Instance; this.results = new Canguro.Model.Results.Results(0); // Layer es un Item y todos los Items asignan su propiedad layer // de acuerdo a ActiveLayer, por lo que hay que asignarla en null // antes de crear el primer Layer, root de todos los demás activeLayer = null; Layer rootLayer = new Layer(Culture.Get("defaultLayerName")); ActiveLayer = rootLayer; activeLoadCase = new LoadCase(Culture.Get("defaultLoadCase"), LoadCase.LoadCaseType.Dead); activeLoadCase.SelfWeight = 1.0f; loadCases.Add(activeLoadCase.Name, activeLoadCase); AnalysisCase anc = new Canguro.Model.Load.AnalysisCase(Culture.Get("defaultLoadCase")); AbstractCases.Add(anc); if (anc != null) { StaticCaseProps props = anc.Properties as StaticCaseProps; if (props != null) { List<StaticCaseFactor> list = props.Loads; list.Add(new StaticCaseFactor(ActiveLoadCase)); props.Loads = list; } } MaterialManager.Instance.Initialize(); SectionManager.Instance.Initialize(ref sections); sections.ElementRemoved += new Catalog<Canguro.Model.Section.Section>.ListChangedEventHandler(sections_ElementRemoved); this.currentPath = ""; foreach (Canguro.Model.UnitSystem.UnitSystem us in UnitSystemsManager.Instance.UnitSystems) if (Properties.Settings.Default.UnitSystem.Equals(us.GetType().Name)) UnitSystemsManager.Instance.CurrentSystem = us; viewManager = Canguro.View.GraphicViewManager.Instance; modified = false; } catch (Exception e) { Console.WriteLine(e.StackTrace); throw e; } finally { if (ModelReset != null) ModelReset(this, EventArgs.Empty); undoManager.Enabled = true; } }
/** * Subclasses may implement this method to provide additional headers. */ protected virtual void PostProcessHeaders(XmlElement element, ManagedDictionary headers, ParserContext parserContext) { }
/// <summary>The parse map element.</summary> /// <param name="mapEle">The map ele.</param> /// <param name="bd">The bd.</param> /// <returns>The System.Collections.IDictionary.</returns> public IDictionary ParseMapElement(XmlElement mapEle, IObjectDefinition bd) { string defaultKeyType = mapEle.GetAttribute(KEY_TYPE_ATTRIBUTE); string defaultValueType = mapEle.GetAttribute(VALUE_TYPE_ATTRIBUTE); XmlNodeList entryEles = mapEle.GetElementsByTagName(ENTRY_ELEMENT, OBJECTS_NAMESPACE_URI); var map = new ManagedDictionary(entryEles.Count); map.KeyTypeName = defaultKeyType; map.ValueTypeName = defaultValueType; map.MergeEnabled = this.ParseMergeAttribute(mapEle); foreach (XmlNode entryEle in entryEles) { // Should only have one value child element: ref, value, list, etc. // Optionally, there might be a key child element. XmlNodeList entrySubNodes = entryEle.ChildNodes; XmlElement keyEle = null; XmlElement valueEle = null; for (int j = 0; j < entrySubNodes.Count; j++) { XmlNode node = entrySubNodes.Item(j); if (node is XmlElement) { var candidateEle = (XmlElement)node; if (this.NodeNameEquals(candidateEle, KEY_ELEMENT)) { if (keyEle != null) { this.Error("<entry> element is only allowed to contain one <key> sub-element", entryEle); } else { keyEle = candidateEle; } } else { // Child element is what we're looking for. if (valueEle != null) { this.Error("<entry> element must not contain more than one value sub-element", entryEle); } else { valueEle = candidateEle; } } } } // Extract key from attribute or sub-element. object key = null; bool hasKeyAttribute = this.HasAttribute(entryEle, KEY_ATTRIBUTE); bool hasKeyRefAttribute = this.HasAttribute(entryEle, KEY_REF_ATTRIBUTE); if ((hasKeyAttribute && hasKeyRefAttribute) || (hasKeyAttribute || hasKeyRefAttribute) && keyEle != null) { this.Error( "<entry> element is only allowed to contain either " + "a 'key' attribute OR a 'key-ref' attribute OR a <key> sub-element", entryEle); } if (hasKeyAttribute) { key = this.buildTypedStringValueForMap(entryEle.Attributes[KEY_ATTRIBUTE].Value, defaultKeyType); } else if (hasKeyRefAttribute) { string refName = entryEle.Attributes[KEY_REF_ATTRIBUTE].Value; if (!StringUtils.HasText(refName)) { this.Error("<entry> element contains empty 'key-ref' attribute", entryEle); } var reference = new RuntimeObjectReference(refName); key = reference; } else if (keyEle != null) { key = this.parseKeyElement(keyEle, bd, defaultKeyType); } else { this.Error("<entry> element must specify a key", entryEle); } // Extract value from attribute or sub-element. object value = null; bool hasValueAttribute = this.HasAttribute(entryEle, VALUE_ATTRIBUTE); bool hasValueRefAttribute = this.HasAttribute(entryEle, VALUE_REF_ATTRIBUTE); if ((hasValueAttribute && hasValueRefAttribute) || (hasValueAttribute || hasValueRefAttribute) && valueEle != null) { this.Error( "<entry> element is only allowed to contain either " + "'value' attribute OR 'value-ref' attribute OR <value> sub-element", entryEle); } if (hasValueAttribute) { value = this.buildTypedStringValueForMap(entryEle.Attributes[VALUE_ATTRIBUTE].Value, defaultValueType); } else if (hasValueRefAttribute) { string refName = entryEle.Attributes[VALUE_REF_ATTRIBUTE].Value; if (!StringUtils.HasText(refName)) { this.Error("<entry> element contains empty 'value-ref' attribute", entryEle); } var reference = new RuntimeObjectReference(refName); value = reference; } else if (valueEle != null) { value = this.parsePropertySubElement(valueEle, bd, defaultValueType); } else { this.Error("<entry> element must specify a value", entryEle); } // Add final key and value to the Map. map.Add(key, value); } return(map); }