protected StringPropertyEditorBase(Type objectType, DictionaryNode info) : base(objectType, info) { if (string.IsNullOrEmpty(info.GetAttributeValue(DetailViewItemInfoNodeWrapper.ImmediatePostDataAttribute))){ ImmediatePostData = true; } }
public ListDictionary () { count = 0; version = 0; comparer = null; head = null; }
private DictionaryNode GetNewVariantNode(DictionaryNode variantsNode, PopupWindowShowActionExecuteEventArgs e, out ViewCloner viewCloner) { DictionaryNode newVariantNode = variantsNode.AddChildNode("Variant"); viewCloner = ((ViewCloner) e.PopupWindow.View.CurrentObject); newVariantNode.SetAttribute("ViewID", viewCloner.Caption); setAttributes(newVariantNode, viewCloner); return newVariantNode; }
public void Add(object key, object value) { if (key == null) { throw new ArgumentNullException("key", SR.GetString("ArgumentNull_Key")); } this.version++; DictionaryNode node = null; for (DictionaryNode node2 = this.head; node2 != null; node2 = node2.next) { object x = node2.key; if ((this.comparer == null) ? x.Equals(key) : (this.comparer.Compare(x, key) == 0)) { throw new ArgumentException(SR.GetString("Argument_AddingDuplicate")); } node = node2; } DictionaryNode node3 = new DictionaryNode { key = key, value = value }; if (node != null) { node.next = node3; } else { this.head = node3; } this.count++; }
public string GetCurrentAspectXml(DictionaryNode node) { if (node.Dictionary == null){ return GetAspectXml(DictionaryAttribute.DefaultLanguage, node); } return GetAspectXml(node.Dictionary.CurrentAspect, node); }
public static void AddFields(DictionaryNode rootNode, XPDictionary dictionary) { foreach (PropertyInfoNodeWrapper customFieldInfo in GetCustomFields(rootNode)) try { Type classType = ReflectionHelper.GetType(customFieldInfo.Class.Name); var typeInfo = dictionary.GetClassInfo(classType); lock (typeInfo) { if (typeInfo.FindMember(customFieldInfo.Name) == null) { Type memberType = ReflectionHelper.GetType(customFieldInfo.Type); XPCustomMemberInfo memberInfo = typeInfo.CreateMember(customFieldInfo.Name, memberType); if (customFieldInfo.Size != 0) memberInfo.AddAttribute(new DevExpress.Xpo.SizeAttribute(customFieldInfo.Size)); XafTypesInfo.Instance.RefreshInfo(classType); } } } catch (Exception exception) { throw new Exception( ExceptionLocalizerTemplate<SystemExceptionResourceLocalizer, ExceptionId>.GetExceptionMessage( ExceptionId.ErrorOccursWhileAddingTheCustomProperty, customFieldInfo.Type, customFieldInfo.Class.Name, customFieldInfo.Name, exception.Message)); } }
protected override ReadOnlyDictionaryNodeCollection GetNodesCollectionInternal(DictionaryNode node, string attributeName) { var collectionInternal = new DictionaryNodeCollection(); collectionInternal.AddRange(new ApplicationNodeWrapper(node.Dictionary.RootNode).Node.GetChildNode(ModuleController.Modules).ChildNodes); return collectionInternal; }
public string GetAspectXml(string aspect, DictionaryNode node, bool includeChildNodes) { string result = GetAspectXml(aspect, node, 0, includeChildNodes); if (string.IsNullOrEmpty(result) && IsDefaultAspect(aspect, node)){ result = string.Format("<{0} />\r\n", node.Name); } return result; }
public Object this[Object key] { get { if (key == null) { throw new ArgumentNullException("key", Environment.GetResourceString("ArgumentNull_Key")); } Contract.EndContractBlock(); DictionaryNode node = head; while (node != null) { if ( node.key.Equals(key) ) { return node.value; } node = node.next; } return null; } set { if (key == null) { throw new ArgumentNullException("key", Environment.GetResourceString("ArgumentNull_Key")); } Contract.EndContractBlock(); #if FEATURE_SERIALIZATION if (!key.GetType().IsSerializable) throw new ArgumentException(Environment.GetResourceString("Argument_NotSerializable"), "key"); if( (value != null) && (!value.GetType().IsSerializable ) ) throw new ArgumentException(Environment.GetResourceString("Argument_NotSerializable"), "value"); #endif version++; DictionaryNode last = null; DictionaryNode node; for (node = head; node != null; node = node.next) { if( node.key.Equals(key) ) { break; } last = node; } if (node != null) { // Found it node.value = value; return; } // Not found, so add a new one DictionaryNode newNode = new DictionaryNode(); newNode.key = key; newNode.value = value; if (last != null) { last.next = newNode; } else { head = newNode; } count++; } }
private static ICollection<PropertyInfoNodeWrapper> GetCustomFields(DictionaryNode applicationNode) { var result = new List<PropertyInfoNodeWrapper>(); foreach (DictionaryNode node in applicationNode.GetChildNode(BOModelNodeWrapper.NodeName).GetChildNodes(PropertyInfoNodeWrapper.NodeName, IsRuntimeMember, bool.TrueString, true)) { result.Add(new PropertyInfoNodeWrapper(node)); } return result; }
public void Create_Application() { var helper = new SchemaHelper(); DictionaryNode node=helper.CreateElement(ModelElement.Application); var dictionaryNode = new DictionaryNode("Element"); dictionaryNode.SetAttribute("Name", ModelElement.Application.ToString()); Assert.AreEqual(dictionaryNode.ToXml(), node.ToXml()); }
protected override ReadOnlyDictionaryNodeCollection GetNodesCollectionInternal(DictionaryNode node, string attributeName) { var allNodes = base.GetNodesCollectionInternal(node, attributeName); var result = new DictionaryNodeCollection(); var nonStringProperties = allNodes.Where(n => n.GetAttributeValue("Type").Equals(typeof(string).FullName)); foreach (var stringProperty in nonStringProperties) { result.Add(stringProperty); } return result; }
public void Create_Class() { var helper = new SchemaHelper(); DictionaryNode node=helper.CreateElement(ModelElement.Class); var dictionaryNode = new DictionaryNode("Element"); dictionaryNode.SetAttribute("Name", ModelElement.Application.ToString()); var childNode = dictionaryNode.AddChildNode("Element"); childNode.SetAttribute("Name", ModelElement.BOModel.ToString()); childNode.AddChildNode("Element").SetAttribute("Name", ModelElement.Class.ToString()); Assert.AreEqual(dictionaryNode.ToXml(), node.ToXml()); }
public override bool IsInvisible(DictionaryNode node, string attributeName) { var attributeValueByPath = helper.GetAttributeValueByPath(node, helper.GetParamValue("ID", "@ID")); if (!string.IsNullOrEmpty(attributeValueByPath)) { var wrapper = new ApplicationNodeWrapper(node.Dictionary).Views.FindViewById(attributeValueByPath); if ((helper.GetParamValue("ViewType") == ViewType.DetailView.ToString() && wrapper is DetailViewInfoNodeWrapper) || (helper.GetParamValue("ViewType") == ViewType.ListView.ToString() && wrapper is ListViewInfoNodeWrapper)) return true; if (helper.GetParamValue("ViewType") == ViewType.Any.ToString() && wrapper != null) return true; } return false; }
public void Add(object key, object value) { if (key == null) { throw new ArgumentNullException("key", Environment.GetResourceString("ArgumentNull_Key")); } if (!key.GetType().IsSerializable) { throw new ArgumentException(Environment.GetResourceString("Argument_NotSerializable"), "key"); } if ((value != null) && !value.GetType().IsSerializable) { throw new ArgumentException(Environment.GetResourceString("Argument_NotSerializable"), "value"); } this.version++; DictionaryNode node = null; DictionaryNode head = this.head; while (head != null) { if (head.key.Equals(key)) { throw new ArgumentException(Environment.GetResourceString("Argument_AddingDuplicate__", new object[] { head.key, key })); } node = head; head = head.next; } if (head != null) { head.value = value; } else { DictionaryNode node3 = new DictionaryNode { key = key, value = value }; if (node != null) { node.next = node3; } else { this.head = node3; } this.count++; } }
protected override ReadOnlyDictionaryNodeCollection GetNodesCollectionInternal(DictionaryNode node, string attributeName) { var result = new DictionaryNodeCollection(); DictionaryNode classesNode = node.Dictionary.RootNode.FindChildNode(BOModelNodeWrapper.NodeName); if (classesNode != null) { string typeName = parser.GetAttributeValueByPath(node, classNameAttrPath); DictionaryNode classNode = classesNode.FindChildNode(ClassInfoNodeWrapper.NameAttribute, typeName); Type type = ReflectionHelper.GetType(typeName); result.Add(classNode); foreach (DictionaryNode checkNode in classesNode.ChildNodes) { Type checkType = ReflectionHelper.GetType(checkNode.GetAttributeValue("Name")); if (checkType.IsSubclassOf(type) || type.IsSubclassOf(checkType)) { result.Add(checkNode); } } } return result; }
private string GetAspectXml(string aspect, DictionaryNode node, int indent, bool includeChildNodes) { string result = string.Empty; var indentString = new string('\t', indent); var childrenTextBuilder = new StringBuilder(); var attributesTextBuilder = new StringBuilder(); if (includeChildNodes){ IEnumerable<DictionaryNode> nodes = orderNodes ? node.ChildNodes.GetOrderedByName() : (IEnumerable<DictionaryNode>) node.ChildNodes; foreach (DictionaryNode childNode in nodes){ childrenTextBuilder.Append(GetAspectXml(aspect, childNode, indent + 1, true)); } } foreach (DictionaryAttribute attribute in node.Attributes){ BuildAttribute(aspect, attribute, attributesTextBuilder); } if ((IsDefaultAspect(aspect, node) && node.IsNew) || attributesTextBuilder.Length > 0 || childrenTextBuilder.Length > 0){ DictionaryAttribute key = node.KeyAttribute; if (key != null){ attributesTextBuilder.Insert(0, "\""); attributesTextBuilder.Insert(0, HttpUtility.HtmlEncode(key.Value)); attributesTextBuilder.Insert(0, "=\""); attributesTextBuilder.Insert(0, key.Name); attributesTextBuilder.Insert(0, " "); } } if (attributesTextBuilder.Length > 0 || childrenTextBuilder.Length > 0){ if (childrenTextBuilder.Length > 0){ result = string.Format(indentString + "<{0}{1}>\r\n{2}" + indentString + "</{0}>\r\n", node.Name, attributesTextBuilder, childrenTextBuilder); } else{ result = string.Format(indentString + "<{0}{1} />\r\n", node.Name, attributesTextBuilder); } } else if (IsDefaultAspect(aspect, node) && node.IsNew){ result = string.Format(indentString + "<{0} />\r\n", node.Name); } return result; }
public void Load_From_Directory() { Isolate.Fake.StaticMethods(typeof(Validator)); var store = new XpoModelDictionaryDifferenceStoreFactory<XpoWinModelDictionaryDifferenceStore>().Create( Isolate.Fake.Instance<XafApplication>(), true); #region isolate store Isolate.WhenCalled(() => store.GetModelPaths()).WillReturn(new List<string> { "model.xafml", "model_el.xafml", "LogonParameters.xafml" }); Isolate.WhenCalled(() => store.UseModelFromPath()).WillReturn(true); Isolate.WhenCalled(() => store.SaveDifference(null)).IgnoreCall(); #endregion var dictionaryNode = new DictionaryNode("Application"); #region isolate dictionaryXmlReader var dictionaryXmlReader = Isolate.Fake.Instance<DictionaryXmlReader>(); Isolate.Swap.AllInstances<DictionaryXmlReader>().With(dictionaryXmlReader); Isolate.WhenCalled(() => dictionaryXmlReader.ReadFromFile(null)).WillReturn(dictionaryNode); #endregion Dictionary dictionary = store.LoadDifference(Schema.GetCommonSchema()); Assert.AreEqual(dictionaryNode.ToXml(), dictionary.RootNode.ToXml()); }
private DictionaryNode FindEntry (object key, out DictionaryNode prev) { if (key == null) throw new ArgumentNullException ("key", "Attempted lookup for a null key."); DictionaryNode entry = head; prev = null; if (comparer == null) { while (entry != null) { if (key.Equals (entry.key)) break; prev = entry; entry = entry.next; } } else { while (entry != null) { if (comparer.Compare (key, entry.key) == 0) break; prev = entry; entry = entry.next; } } return entry; }
public void Clear() { head = null; count = 0; version++; }
public DictionaryNode(object key, object value, DictionaryNode next) { this.key = key; this.value = value; this.next = next; }
public DictionaryEnumerator(DictionaryNode <TKey, TValue> Head) { this.Head = Head; this.ptr = null; }
public NodeKeyValueEnumerator(ListDictionaryInternal list, bool isKeys) { this.list = list; this.isKeys = isKeys; this.version = list.version; this.start = true; this.current = null; }
public NodeEnumerator(ListDictionaryInternal list) { this.list = list; version = list.version; start = true; current = null; }
public object this[object key] { get { if (key == null) { throw new ArgumentNullException(nameof(key)); } DictionaryNode node = _head; if (_comparer == null) { while (node != null) { object oldKey = node.key; if (oldKey.Equals(key)) { return(node.value); } node = node.next; } } else { while (node != null) { object oldKey = node.key; if (_comparer.Compare(oldKey, key) == 0) { return(node.value); } node = node.next; } } return(null); } set { if (key == null) { throw new ArgumentNullException(nameof(key)); } _version++; DictionaryNode last = null; DictionaryNode node; for (node = _head; node != null; node = node.next) { object oldKey = node.key; if ((_comparer == null) ? oldKey.Equals(key) : _comparer.Compare(oldKey, key) == 0) { break; } last = node; } if (node != null) { // Found it node.value = value; return; } // Not found, so add a new one DictionaryNode newNode = new DictionaryNode(); newNode.key = key; newNode.value = value; if (last != null) { last.next = newNode; } else { _head = newNode; } _count++; } }
public Dictionary() { this.Head = this.Tail = null; //set head and tail to null this._Count = 0; }
public ButtonDetailViewItem(Type objectType, DictionaryNode info) : base(objectType, info) { }
/// <summary> /// Sets property into the container. /// </summary> /// <param name="key">Key.</param> /// <param name="value">Value.</param> public void SetProperty(object key, object value) { CheckKey(key); // object p = _type; // empty list if (p == null) { _type = key; _obj = value; } // one item list, with the same key else if (p == key) { _obj = value; } // linked list else if (object.ReferenceEquals(p, TypeList)) { Debug.Assert(_obj is DictionaryNode); // replaces value if key already in collection, // counts items int count = 0; for (var node = (DictionaryNode)_obj; node != null; node = node.next) { if (node.key == key) { node.value = value; return; } count++; } // add new item if (count < MaxListSize) { _obj = new DictionaryNode() { key = key, value = value, next = (DictionaryNode)_obj }; } else { // upgrade to hashtable var hashtable = ToHashtable((DictionaryNode)_obj); hashtable.Add(key, value); _obj = hashtable; _type = TypeHashtable; } } // hashtable else if (object.ReferenceEquals(p, TypeHashtable)) { Debug.Assert(_obj is Hashtable); ((Hashtable)_obj)[key] = value; } // one item list, // upgrade to linked list else { _obj = new DictionaryNode() { key = _type, value = _obj, next = new DictionaryNode() { key = key, value = value, next = null, } }; _type = TypeList; } }
private static Hashtable/*!*/ToHashtable(DictionaryNode/*!*/node) { var hashtable = new Hashtable(13); for (var p = node; p != null; p = p.next) hashtable.Add(p.key, p.value); return hashtable; }
public void Reset() { if (version != list.version) { throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_EnumFailedVersion")); } start = true; current = null; }
public void Clear() { this.count = 0; this.head = null; this.version++; }
public void Clear() { _count = 0; _head = null; _version++; }
public void SetSettings(DictionaryNode settingsNode) { }
public object this[object key] { get { if (key == null) { throw new ArgumentNullException("key", SR.GetString("ArgumentNull_Key")); } DictionaryNode head = this.head; if (this.comparer != null) { while (head != null) { object x = head.key; if ((x != null) && (this.comparer.Compare(x, key) == 0)) { return(head.value); } head = head.next; } } else { while (head != null) { object obj2 = head.key; if ((obj2 != null) && obj2.Equals(key)) { return(head.value); } head = head.next; } } return(null); } set { if (key == null) { throw new ArgumentNullException("key", SR.GetString("ArgumentNull_Key")); } this.version++; DictionaryNode node = null; DictionaryNode head = this.head; while (head != null) { object x = head.key; if ((this.comparer == null) ? x.Equals(key) : (this.comparer.Compare(x, key) == 0)) { break; } node = head; head = head.next; } if (head != null) { head.value = value; } else { DictionaryNode node3 = new DictionaryNode() { key = key, value = value }; if (node != null) { node.next = node3; } else { this.head = node3; } this.count++; } } }
public void Reset() { FailFast(); isAtStart = true; current = null; }
public bool MoveNext() { if (version != list.version) { throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_EnumFailedVersion")); } if (start) { current = list.head; start = false; } else { if( current != null) { current = current.next; } } return (current != null); }
public Object this[Object key] { get { if (key == null) { throw new ArgumentNullException(nameof(key), SR.ArgumentNull_Key); } Contract.EndContractBlock(); DictionaryNode node = head; while (node != null) { if (node.key.Equals(key)) { return(node.value); } node = node.next; } return(null); } set { if (key == null) { throw new ArgumentNullException(nameof(key), SR.ArgumentNull_Key); } Contract.EndContractBlock(); version++; DictionaryNode last = null; DictionaryNode node; for (node = head; node != null; node = node.next) { if (node.key.Equals(key)) { break; } last = node; } if (node != null) { // Found it node.value = value; return; } // Not found, so add a new one DictionaryNode newNode = new DictionaryNode(); newNode.key = key; newNode.value = value; if (last != null) { last.next = newNode; } else { head = newNode; } count++; } }
/// <summary> /// Counts items in the linked list. /// </summary> private static int CountItems(DictionaryNode head) { int count = 0; for (var p = head; p != null; p = p.next) count++; return count; }
public Object this[Object key] { get { if (key == null) { throw new ArgumentNullException("key", Environment.GetResourceString("ArgumentNull_Key")); } Contract.EndContractBlock(); DictionaryNode node = head; while (node != null) { if (node.key.Equals(key)) { return(node.value); } node = node.next; } return(null); } set { if (key == null) { throw new ArgumentNullException("key", Environment.GetResourceString("ArgumentNull_Key")); } Contract.EndContractBlock(); #if FEATURE_SERIALIZATION if (!key.GetType().IsSerializable) { throw new ArgumentException(Environment.GetResourceString("Argument_NotSerializable"), "key"); } if ((value != null) && (!value.GetType().IsSerializable)) { throw new ArgumentException(Environment.GetResourceString("Argument_NotSerializable"), "value"); } #endif version++; DictionaryNode last = null; DictionaryNode node; for (node = head; node != null; node = node.next) { if (node.key.Equals(key)) { break; } last = node; } if (node != null) { node.value = value; return; } DictionaryNode newNode = new DictionaryNode(); newNode.key = key; newNode.value = value; if (last != null) { last.next = newNode; } else { head = newNode; } count++; } }
private static DictionaryNode ToList(Hashtable/*!*/hashtable) { DictionaryNode list = null; foreach (DictionaryEntry p in hashtable) { list = new DictionaryNode() { key = p.Key, value = p.Value, next = list }; } return list; }
/// <summary> /// Removes property from the container. /// </summary> /// <param name="key">Key.</param> /// <returns><c>True</c> if property was found and removed. otherwise <c>false</c>.</returns> public bool RemoveProperty(object key) { CheckKey(key); var p = _type; var o = _obj; if (p != null) { if (object.Equals(p, key)) { _type = null; _obj = null; return(true); } else if (object.ReferenceEquals(p, TypeList)) { Debug.Assert(o is DictionaryNode); DictionaryNode prev = null; for (var node = (DictionaryNode)o; node != null; node = node.next) { if (object.Equals(node.key, key)) { if (prev == null) { if ((_obj = node.next) == null) { _type = null; // empty list } } else { prev.next = node.next; } return(true); } // prev = node; } } else if (object.ReferenceEquals(p, TypeHashtable)) { Debug.Assert(o is Hashtable); var hashtable = (Hashtable)o; int count = hashtable.Count; hashtable.Remove(key); if (hashtable.Count != count) { if (hashtable.Count <= MaxListSize) { _obj = ToList(hashtable); _type = TypeList; } return(true); } } } return(false); }
public IntegerPropertyEditor(Type objectType, DictionaryNode info) : base(objectType, info) { }
/// <devdoc> /// <para>[To be supplied.]</para> /// </devdoc> public void Clear() { Count = 0; head = null; version++; }
private DictionaryNode FindEntry(object key, out DictionaryNode entry) { entry = new DictionaryNode(); return(entry); }