private void SetupReorder(ListAttribute listAttribute, ListField field, SerializedProperty property, Type declaringType) { if (field.AllowReorder) { if (!string.IsNullOrEmpty(listAttribute.ReorderCallback)) { var reorderCallback = ReflectionHelper.CreateActionCallback(listAttribute.ReorderCallback, declaringType, property); if (reorderCallback != null) { field.RegisterCallback <ListField.ItemReorderedEvent>(evt => reorderCallback.Invoke()); } else { var reorderCallbackFromTo = ReflectionHelper.CreateActionCallback <int, int>(listAttribute.ReorderCallback, declaringType, property); if (reorderCallbackFromTo != null) { field.RegisterCallback <ListField.ItemReorderedEvent>(evt => reorderCallbackFromTo.Invoke(evt.FromIndex, evt.ToIndex)); } else { Debug.LogWarningFormat(_invalidReorderCallbackWarning, property.propertyPath); } } } } }
internal FieldProvisionHandler(FieldAttribute field, ContentTypeAttribute contentType, ListAttribute list, SpProvisionModel <TContext, TEntity> model, Type valueType) : base(model) { Field = field; ContentType = contentType; List = list; _valueType = valueType; }
private void SetupAdd(ListAttribute listAttribute, PropertyListProxy proxy, ListField field, SerializedProperty property, Type declaringType, bool isReference) { if (field.AllowAdd) { if (!string.IsNullOrEmpty(listAttribute.AllowAdd)) { proxy.CanAddCallback = ReflectionHelper.CreateValueSourceFunction(listAttribute.AllowAdd, property, field, declaringType, true); } if (!string.IsNullOrEmpty(listAttribute.AddCallback)) { if (!isReference) { var addCallback = ReflectionHelper.CreateActionCallback(listAttribute.AddCallback, declaringType, property); if (addCallback != null) { field.RegisterCallback <ListField.ItemAddedEvent>(evt => addCallback.Invoke()); } else { var addCallbackIndex = ReflectionHelper.CreateActionCallback <int>(listAttribute.AddCallback, declaringType, property); if (addCallbackIndex != null) { field.RegisterCallback <ListField.ItemAddedEvent>(evt => addCallbackIndex.Invoke(evt.Index)); } else { Debug.LogWarningFormat(_invalidAddCallbackWarning, property.propertyPath); } } } else { var addCallback = ReflectionHelper.CreateActionCallback(listAttribute.AddCallback, declaringType, property); if (addCallback != null) { field.RegisterCallback <ListField.ItemAddedEvent>(evt => addCallback.Invoke()); } else { var addCallbackIndex = ReflectionHelper.CreateActionCallback <int>(listAttribute.AddCallback, declaringType, property); if (addCallbackIndex != null) { field.RegisterCallback <ListField.ItemAddedEvent>(evt => addCallbackIndex.Invoke(evt.Index)); } else { Debug.LogWarningFormat(_invalidAddReferenceCallbackWarning, property.propertyPath); } } } } } }
private void SetupChange(ListAttribute listAttribute, ListField field, SerializedProperty property, Type declaringType) { if (!string.IsNullOrEmpty(listAttribute.ChangeCallback)) { var changeCallback = ReflectionHelper.CreateActionCallback(listAttribute.ChangeCallback, declaringType, property); if (changeCallback != null) { field.RegisterCallback <ListField.ItemsChangedEvent>(evt => changeCallback.Invoke()); } else { Debug.LogWarningFormat(_invalidChangeCallbackWarning, property.propertyPath); } } }
public static void SetAveragingConventionsList <AveragingConventionField>(PXCache sender, object row, params KeyValuePair <object, Dictionary <object, string[]> >[] pars) where AveragingConventionField : IBqlField { Dictionary <string, string> fullDict = new ListAttribute().ValueLabelDic; foreach (KeyValuePair <object, Dictionary <object, string[]> > pair in pars) { object parValue = pair.Key; Dictionary <object, string[]> matrix = pair.Value; string[] matrixArray; if (parValue != null && matrix.TryGetValue(parValue, out matrixArray)) { foreach (string val in matrixArray) { fullDict.Remove(val); } } } PXStringListAttribute.SetList <AveragingConventionField>(sender, row, fullDict.Keys.ToArray(), fullDict.Values.ToArray()); }
public Panel CreateSingleSelectList(ListAttribute lattr, PropertyInfo prop, object configuration_instance) { var evalue = GetConfigValue(prop, configuration_instance); var panel = base.CreateControl(lattr, prop, configuration_instance); var combo_list = new ComboBox() { Width = 150 }; combo_list.ItemsSource = lattr.ValueList; combo_list.SelectedIndex = Array.IndexOf(lattr.ValueList, evalue.ToString()); panel.Children.Add(combo_list); combo_list.SelectionChanged += (s, e) => { SetConfigValue(prop, configuration_instance, $"{combo_list.SelectedValue}"); }; return(panel); }
public Panel CreateMultiSelectList(ListAttribute lattr, PropertyInfo prop, object configuration_instance) { var evalue = GetConfigValue(prop, configuration_instance); var panel = base.CreateControl(lattr, prop, configuration_instance); string[] values = lattr.ValueList; IEnumerable <string> default_values = evalue.ToString().Split(lattr.SplitSeparator).Select(s => s.Trim()); var multi_list = new MultiSelectComboBox() { Width = 250 }; var dict = new Dictionary <string, object>(); var default_dict = new Dictionary <string, object>(); if (values != null) { foreach (var val in values) { dict.Add(val, val); } foreach (var val in default_values) { default_dict.Add(val, val); } } multi_list.ItemsSource = dict; multi_list.SelectedItems = default_dict; multi_list.Click += (s, e) => { SetConfigValue(prop, configuration_instance, string.Join(lattr.SplitSeparator.ToString(), multi_list.SelectedItems.Keys)); ConfigWindow.RequireRestart = lattr.RequireRestart; }; panel.Children.Add(multi_list); return(panel); }
public static SPList CreateList <T>(SPWeb web) where T : SharePointListEntityTest { ListAttribute la = GetListAttribute(typeof(T)); SPList lst; try { lst = web.Lists[la.List]; if (lst != null) { lst.Delete(); } } catch { } web.Lists.Add(la.List, "", SPListTemplateType.GenericList); lst = web.Lists[la.List]; lst.OnQuickLaunch = true; lst.Update(); return(lst); }
private void SetupRemove(ListAttribute listAttribute, PropertyListProxy proxy, ListField field, SerializedProperty property, Type declaringType) { if (field.AllowRemove) { if (!string.IsNullOrEmpty(listAttribute.AllowRemove)) { proxy.CanRemoveCallback = ReflectionHelper.CreateFunctionCallback <int, bool>(listAttribute.AllowRemove, declaringType, property); if (proxy.CanRemoveCallback == null) { var canRemove = ReflectionHelper.CreateValueSourceFunction(listAttribute.AllowRemove, property, field, declaringType, true); proxy.CanRemoveCallback = index => canRemove(); } } if (!string.IsNullOrEmpty(listAttribute.RemoveCallback)) { var removeCallback = ReflectionHelper.CreateActionCallback(listAttribute.RemoveCallback, declaringType, property); if (removeCallback != null) { field.RegisterCallback <ListField.ItemRemovedEvent>(evt => removeCallback.Invoke()); } else { var removeCallbackIndex = ReflectionHelper.CreateActionCallback <int>(listAttribute.RemoveCallback, declaringType, property); if (removeCallbackIndex != null) { field.RegisterCallback <ListField.ItemRemovedEvent>(evt => removeCallbackIndex.Invoke(evt.Index)); } else { Debug.LogWarningFormat(_invalidRemoveCallbackWarning, property.propertyPath); } } } } }
public ListProvisionHandler(ListAttribute list, SpProvisionModel <TContext, TEntity> model) : base(model) { _list = list; }
public override Panel CreateControl(BaseConfigurationAttribute attr, PropertyInfo prop, object configuration_instance) { ListAttribute lattr = attr as ListAttribute; return(lattr.AllowMultiSelect ? CreateMultiSelectList(lattr, prop, configuration_instance) : CreateSingleSelectList(lattr, prop, configuration_instance)); }
public ContentTypeProvisionHandler(ContentTypeAttribute contentType, ListAttribute list, SpProvisionModel <TContext, TEntity> model) : base(model) { _contentType = contentType; _list = list; }
protected override void Seed(WebSiteDBContext context) { Random rand = new Random(); string[] noms = { "Martin", "Bernard", "Thomas", "Petit", "Robert", "Richard", "Durand" }; string[] adresses = { "chemin de la justice", "rue bernard lepecq", "rue des vallés", "chemin de la pavillon", "route de la malnoue", "route des champs", "rue des jules vernes" }; string[] prenoms = { "Abel", "Pascale", "Paul", "Adelaide", "Adele", "Adeline", "Noemie" }; string[] Villes = { "Paris", "Laval", "Lemans", "Rennes", "Besançon", "Nantes", "Nice" }; string[] Pays = { "France", "Tunisie", "Belgique", "USA", "Inde", "Canada", "Argentine" }; Key key_1 = new Key() { Name = "Nom", }; Key key_2 = new Key() { Name = "Adresse" }; Key key_3 = new Key() { Name = "Prénom" }; Key key_4 = new Key() { Name = "Facture" }; Key key_5 = new Key() { Name = "Code client" }; Key key_6 = new Key() { Name = "Ville" }; Key key_7 = new Key() { Name = "Code postal" }; Key key_8 = new Key() { Name = "Nbre Vote" }; Key key_9 = new Key() { Name = "Réference" }; Key key_10 = new Key() { Name = "Pays" }; ListAttribute ls1 = new ListAttribute { Visiblity = true, Name = "liste 1" }; ls1.Keys.Add(key_1); ls1.Keys.Add(key_2); ls1.Keys.Add(key_3); ls1.Keys.Add(key_4); ls1.Keys.Add(key_5); ListAttribute ls2 = new ListAttribute { Visiblity = true, Name = "liste 2" }; ls2.Keys.Add(key_5); ls2.Keys.Add(key_7); ls2.Keys.Add(key_8); ls2.Keys.Add(key_9); ls2.Keys.Add(key_10); ListAttribute ls3 = new ListAttribute { Visiblity = true, Name = "liste 3" }; ls3.Keys.Add(key_1); ls3.Keys.Add(key_3); ls3.Keys.Add(key_2); ls3.Keys.Add(key_9); ls3.Keys.Add(key_10); OperationType OpType_1 = new OperationType { name = OpType.Ag, ListAttribute = ls1 }; OperationType OpType_2 = new OperationType { name = OpType.Vote, ListAttribute = ls2 }; OperationType OpType_3 = new OperationType { name = OpType.Pda, ListAttribute = ls3 }; /************ Operation 1 *****************/ Operation op1 = new Operation { Begin = DateTime.Now, End = DateTime.Now.AddDays(30), Name = "Operation 1", Type = OpType_1 }; // 5000 docuements pour la 1er operation for (int i = 0; i < 300; i++) { Document d = new Document { creationDate = DateTime.Now, operation = op1 }; Dal.Models.Attribute at1 = new Dal.Models.Attribute { Key = key_1, Value = noms[rand.Next(0, 7)] }; Dal.Models.Attribute at2 = new Dal.Models.Attribute { Key = key_2, Value = rand.Next(0, 100) + " " + adresses[rand.Next(0, 7)] }; Dal.Models.Attribute at3 = new Dal.Models.Attribute { Key = key_3, Value = prenoms[rand.Next(0, 7)] }; Dal.Models.Attribute at4 = new Dal.Models.Attribute { Key = key_4, Value = rand.Next(1000, 10000).ToString() }; Dal.Models.Attribute at5 = new Dal.Models.Attribute { Key = key_5, Value = "00-" + rand.Next(2000, 3000) }; d.Attributes.Add(at1); d.Attributes.Add(at2); d.Attributes.Add(at3); d.Attributes.Add(at4); d.Attributes.Add(at5); d.scanFile = new ScanFile() { Name = "StandardFile-" + i + ".pdf", }; context.Documents.Add(d); context.SaveChanges(); } /************ Operation 2 *****************/ Operation op2 = new Operation { Begin = DateTime.Now, End = DateTime.Now.AddDays(60), Name = "Operation 2", Type = OpType_2 }; // 100 docuements pour la 2eme operation for (int i = 300; i < 600; i++) { Document d = new Document { creationDate = DateTime.Now, operation = op2 }; Dal.Models.Attribute at5 = new Dal.Models.Attribute { Key = key_5, Value = "00-" + rand.Next(3000, 4000) }; Dal.Models.Attribute at7 = new Dal.Models.Attribute { Key = key_7, Value = rand.Next(75000, 100000).ToString() }; Dal.Models.Attribute at8 = new Dal.Models.Attribute { Key = key_8, Value = rand.Next(7, 100).ToString() }; Dal.Models.Attribute at9 = new Dal.Models.Attribute { Key = key_9, Value = rand.Next(10000, 100000).ToString() //ref }; Dal.Models.Attribute at10 = new Dal.Models.Attribute { Key = key_10, Value = Pays[rand.Next(0, 7)] // pays }; d.Attributes.Add(at5); d.Attributes.Add(at7); d.Attributes.Add(at8); d.Attributes.Add(at9); d.Attributes.Add(at10); d.scanFile = new ScanFile() { Name = "StandardFile-" + i + ".pdf", }; context.Documents.Add(d); context.SaveChanges(); } /************ Operation 3 *****************/ Operation op3 = new Operation { Begin = DateTime.Now, End = DateTime.Now.AddDays(45), Name = "Operation 3", Type = OpType_3 }; // 100 docuements pour la 3eme operation for (int i = 600; i < 900; i++) { Document d = new Document { creationDate = DateTime.Now, operation = op3 }; Dal.Models.Attribute at1 = new Dal.Models.Attribute { Key = key_1, Value = noms[rand.Next(0, 7)] }; Dal.Models.Attribute at3 = new Dal.Models.Attribute { Key = key_3, Value = prenoms[rand.Next(0, 7)] }; Dal.Models.Attribute at2 = new Dal.Models.Attribute { Key = key_2, Value = rand.Next(0, 100) + " " + adresses[rand.Next(0, 7)] }; Dal.Models.Attribute at9 = new Dal.Models.Attribute { Key = key_9, Value = rand.Next(10000, 100000).ToString() }; Dal.Models.Attribute at10 = new Dal.Models.Attribute { Key = key_10, Value = Pays[rand.Next(0, 7)] }; d.Attributes.Add(at1); d.Attributes.Add(at3); d.Attributes.Add(at2); d.Attributes.Add(at9); d.Attributes.Add(at10); d.scanFile = new ScanFile() { Name = "StandardFile-" + i + ".pdf", }; context.Documents.Add(d); context.SaveChanges(); } //******************************** Application app = new Application() { Name = "Application A" }; app.Operations.Add(op1); app.Operations.Add(op2); app.Operations.Add(op3); //******************************** }
internal FieldProvisionHandler(FieldAttribute field, ListAttribute list, SpProvisionModel <TContext, TEntity> model, Type valueType) : this(field, null, list, model, valueType) { }
/// <summary> Write a List XML Element from attributes in a member. </summary> public virtual void WriteList(System.Xml.XmlWriter writer, System.Reflection.MemberInfo member, ListAttribute attribute, BaseAttribute parentAttribute, System.Type mappedClass) { writer.WriteStartElement( "list" ); // Attribute: <name> writer.WriteAttributeString("name", attribute.Name==null ? DefaultHelper.Get_List_Name_DefaultValue(member) : GetAttributeValue(attribute.Name, mappedClass)); // Attribute: <access> if(attribute.Access != null) writer.WriteAttributeString("access", GetAttributeValue(attribute.Access, mappedClass)); // Attribute: <table> if(attribute.Table != null) writer.WriteAttributeString("table", GetAttributeValue(attribute.Table, mappedClass)); // Attribute: <schema> if(attribute.Schema != null) writer.WriteAttributeString("schema", GetAttributeValue(attribute.Schema, mappedClass)); // Attribute: <catalog> if(attribute.Catalog != null) writer.WriteAttributeString("catalog", GetAttributeValue(attribute.Catalog, mappedClass)); // Attribute: <subselect> if(attribute.Subselect != null) writer.WriteAttributeString("subselect", GetAttributeValue(attribute.Subselect, mappedClass)); // Attribute: <lazy> if(attribute.Lazy != CollectionLazy.Unspecified) writer.WriteAttributeString("lazy", GetXmlEnumValue(typeof(CollectionLazy), attribute.Lazy)); // Attribute: <inverse> if( attribute.InverseSpecified ) writer.WriteAttributeString("inverse", attribute.Inverse ? "true" : "false"); // Attribute: <mutable> if( attribute.MutableSpecified ) writer.WriteAttributeString("mutable", attribute.Mutable ? "true" : "false"); // Attribute: <cascade> if(attribute.Cascade != null) writer.WriteAttributeString("cascade", GetAttributeValue(attribute.Cascade, mappedClass)); // Attribute: <order-by> if(attribute.OrderBy != null) writer.WriteAttributeString("order-by", GetAttributeValue(attribute.OrderBy, mappedClass)); // Attribute: <where> if(attribute.Where != null) writer.WriteAttributeString("where", GetAttributeValue(attribute.Where, mappedClass)); // Attribute: <batch-size> if(attribute.BatchSize != -9223372036854775808) writer.WriteAttributeString("batch-size", attribute.BatchSize.ToString()); // Attribute: <outer-join> if(attribute.OuterJoin != OuterJoinStrategy.Unspecified) writer.WriteAttributeString("outer-join", GetXmlEnumValue(typeof(OuterJoinStrategy), attribute.OuterJoin)); // Attribute: <fetch> if(attribute.Fetch != CollectionFetchMode.Unspecified) writer.WriteAttributeString("fetch", GetXmlEnumValue(typeof(CollectionFetchMode), attribute.Fetch)); // Attribute: <persister> if(attribute.Persister != null) writer.WriteAttributeString("persister", GetAttributeValue(attribute.Persister, mappedClass)); // Attribute: <collection-type> if(attribute.CollectionType != null) writer.WriteAttributeString("collection-type", GetAttributeValue(attribute.CollectionType, mappedClass)); // Attribute: <check> if(attribute.Check != null) writer.WriteAttributeString("check", GetAttributeValue(attribute.Check, mappedClass)); // Attribute: <optimistic-lock> if( attribute.OptimisticLockSpecified ) writer.WriteAttributeString("optimistic-lock", attribute.OptimisticLock ? "true" : "false"); // Attribute: <node> if(attribute.Node != null) writer.WriteAttributeString("node", GetAttributeValue(attribute.Node, mappedClass)); // Attribute: <embed-xml> if( attribute.EmbedXmlSpecified ) writer.WriteAttributeString("embed-xml", attribute.EmbedXml ? "true" : "false"); // Attribute: <generic> if( attribute.GenericSpecified ) writer.WriteAttributeString("generic", attribute.Generic ? "true" : "false"); WriteUserDefinedContent(writer, member, null, attribute); System.Collections.ArrayList memberAttribs = GetSortedAttributes(member); int attribPos; // Find the position of the ListAttribute (its <sub-element>s must be after it) for(attribPos=0; attribPos<memberAttribs.Count; attribPos++) if( memberAttribs[attribPos] is ListAttribute && ((BaseAttribute)memberAttribs[attribPos]).Position == attribute.Position ) break; // found int i = attribPos + 1; // Element: <meta> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(MetaAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is ListAttribute ) break; // Following attributes are for this List if( memberAttrib is MetaAttribute ) WriteMeta(writer, member, memberAttrib as MetaAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(MetaAttribute), attribute); // Element: <subselect> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(SubselectAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is ListAttribute ) break; // Following attributes are for this List if( memberAttrib is SubselectAttribute ) WriteSubselect(writer, member, memberAttrib as SubselectAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(SubselectAttribute), attribute); // Element: <cache> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(CacheAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is ListAttribute ) break; // Following attributes are for this List if( memberAttrib is CacheAttribute ) WriteCache(writer, member, memberAttrib as CacheAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(CacheAttribute), attribute); // Element: <synchronize> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(SynchronizeAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is ListAttribute ) break; // Following attributes are for this List if( memberAttrib is SynchronizeAttribute ) WriteSynchronize(writer, member, memberAttrib as SynchronizeAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(SynchronizeAttribute), attribute); // Element: <comment> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(CommentAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is ListAttribute ) break; // Following attributes are for this List if( memberAttrib is CommentAttribute ) WriteComment(writer, member, memberAttrib as CommentAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(CommentAttribute), attribute); // Element: <key> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(KeyAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is ListAttribute ) break; // Following attributes are for this List if( memberAttrib is KeyAttribute ) WriteKey(writer, member, memberAttrib as KeyAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(KeyAttribute), attribute); // Element: <index> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(IndexAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is ListAttribute ) break; // Following attributes are for this List if( memberAttrib is IndexAttribute ) WriteIndex(writer, member, memberAttrib as IndexAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(IndexAttribute), attribute); // Element: <list-index> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(ListIndexAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is ListAttribute ) break; // Following attributes are for this List if( memberAttrib is ListIndexAttribute ) WriteListIndex(writer, member, memberAttrib as ListIndexAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(ListIndexAttribute), attribute); // Element: <element> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(ElementAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is ListAttribute ) break; // Following attributes are for this List if( memberAttrib is ElementAttribute ) WriteElement(writer, member, memberAttrib as ElementAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(ElementAttribute), attribute); // Element: <one-to-many> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(OneToManyAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is ListAttribute ) break; // Following attributes are for this List if( memberAttrib is OneToManyAttribute ) WriteOneToMany(writer, member, memberAttrib as OneToManyAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(OneToManyAttribute), attribute); // Element: <many-to-many> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(ManyToManyAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is ListAttribute ) break; // Following attributes are for this List if( memberAttrib is ManyToManyAttribute ) WriteManyToMany(writer, member, memberAttrib as ManyToManyAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(ManyToManyAttribute), attribute); // Element: <composite-element> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(CompositeElementAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is ListAttribute ) break; // Following attributes are for this List if( memberAttrib is CompositeElementAttribute ) WriteCompositeElement(writer, member, memberAttrib as CompositeElementAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(CompositeElementAttribute), attribute); // Element: <many-to-any> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(ManyToAnyAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is ListAttribute ) break; // Following attributes are for this List if( memberAttrib is ManyToAnyAttribute ) WriteManyToAny(writer, member, memberAttrib as ManyToAnyAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(ManyToAnyAttribute), attribute); // Element: <loader> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(LoaderAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is ListAttribute ) break; // Following attributes are for this List if( memberAttrib is LoaderAttribute ) WriteLoader(writer, member, memberAttrib as LoaderAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(LoaderAttribute), attribute); // Element: <sql-insert> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(SqlInsertAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is ListAttribute ) break; // Following attributes are for this List if( memberAttrib is SqlInsertAttribute ) WriteSqlInsert(writer, member, memberAttrib as SqlInsertAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(SqlInsertAttribute), attribute); // Element: <sql-update> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(SqlUpdateAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is ListAttribute ) break; // Following attributes are for this List if( memberAttrib is SqlUpdateAttribute ) WriteSqlUpdate(writer, member, memberAttrib as SqlUpdateAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(SqlUpdateAttribute), attribute); // Element: <sql-delete> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(SqlDeleteAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is ListAttribute ) break; // Following attributes are for this List if( memberAttrib is SqlDeleteAttribute ) WriteSqlDelete(writer, member, memberAttrib as SqlDeleteAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(SqlDeleteAttribute), attribute); // Element: <sql-delete-all> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(SqlDeleteAllAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is ListAttribute ) break; // Following attributes are for this List if( memberAttrib is SqlDeleteAllAttribute ) WriteSqlDeleteAll(writer, member, memberAttrib as SqlDeleteAllAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(SqlDeleteAllAttribute), attribute); // Element: <filter> for(; i<memberAttribs.Count; i++) { BaseAttribute memberAttrib = memberAttribs[i] as BaseAttribute; if( IsNextElement(memberAttrib, parentAttribute, attribute.GetType()) || IsNextElement(memberAttrib, attribute, typeof(FilterAttribute)) ) break; // next attributes are 'elements' of the same level OR for 'sub-elements' else { if( memberAttrib is ListAttribute ) break; // Following attributes are for this List if( memberAttrib is FilterAttribute ) WriteFilter(writer, member, memberAttrib as FilterAttribute, attribute, mappedClass); } } WriteUserDefinedContent(writer, member, typeof(FilterAttribute), attribute); writer.WriteEndElement(); }
private string CreateClientType(Type type, DotNet2TS dotNet2TS) { DictionaryAttribute dictAttr = type.GetCustomAttributes(typeof(DictionaryAttribute), false) .OfType <DictionaryAttribute>() .FirstOrDefault(); ListAttribute listAttr = type.GetCustomAttributes(typeof(ListAttribute), false).OfType <ListAttribute>().FirstOrDefault(); if (dictAttr != null && dictAttr.KeyName == null) { throw new ArgumentException("DictionaryAttribute KeyName property must not be null"); } StringBuilder sb = new StringBuilder(512); string dictName = null; string listName = null; if (dictAttr != null) { dictName = dictAttr.DictionaryName == null ? $"{type.Name}Dict" : dictAttr.DictionaryName; } if (listAttr != null) { listName = listAttr.ListName == null ? $"{type.Name}List" : listAttr.ListName; } bool isListItem = dictAttr != null || listAttr != null; string valsName = dotNet2TS.RegisterType(type); //can return here if no need to create Dictionary or List if (!type.IsClass || !isListItem) { return(sb.ToString()); } string itemName = $"{type.Name}ListItem"; string aspectName = $"T{type.Name}ItemAspect"; List <PropertyInfo> propInfos = type.GetProperties().ToList(); string list_properties = string.Empty; #region Define fn_Properties Func <List <PropertyInfo>, string> fn_Properties = props => { StringBuilder sbProps = new StringBuilder(256); sbProps.Append("["); bool isFirst = true; props.ForEach(propInfo => { if (!isFirst) { sbProps.Append(","); } DataType dataType = DataType.None; try { dataType = propInfo.PropertyType.IsArrayType() ? DataType.None : dotNet2TS.DataTypeFromDotNetType(propInfo.PropertyType); } catch (UnsupportedTypeException) { dataType = DataType.None; } sbProps.Append("{"); sbProps.Append(string.Format("name:'{0}',dtype:{1}", propInfo.Name, (int)dataType)); sbProps.Append("}"); isFirst = false; }); sbProps.Append("]"); return(sbProps.ToString()); }; #endregion if (dictAttr != null || listAttr != null) { sb.AppendLine(CreateListItem(itemName, aspectName, valsName, propInfos, dotNet2TS)); sb.AppendLine(); list_properties = fn_Properties(propInfos); } if (dictAttr != null) { sb.AppendLine(CreateDictionary(dictName, dictAttr.KeyName, itemName, aspectName, valsName, list_properties, propInfos, dotNet2TS)); sb.AppendLine(); } if (listAttr != null) { sb.AppendLine(CreateList(listName, itemName, aspectName, valsName, list_properties)); sb.AppendLine(); } return(sb.ToString()); }
private PropertyListProxy CreateProxy(string label, SerializedProperty property, ListAttribute listAttribute) { var drawer = this.GetNextDrawer(); var tooltip = this.GetTooltip(); var proxy = new PropertyListProxy(property, drawer) { Label = label, Tooltip = tooltip, AllowAdd = listAttribute.AllowAdd != null, AllowRemove = listAttribute.AllowRemove != null, AllowReorder = listAttribute.AllowReorder != null }; if (listAttribute.EmptyLabel != null) { proxy.EmptyLabel = listAttribute.EmptyLabel; } return(proxy); }