public ClassMetadata GetMetadata(Type type, string alias){
     logger.get("comdiv.sys").debug(() => "was called on " + type);
     if (type.IsInterface){
         var xt = storage.Resolve(type);
         if (null != xt){
             type = xt;
         }
     }
     var result = new ClassMetadata();
     IList<PropertyMetadata> properties = new List<PropertyMetadata>();
     internalGetProperties(type, properties, alias);
     IList<CommandDesc> commands = new List<CommandDesc>();
     internalGetCommands(type, alias, commands);
     result.Properties = properties.ToArray();
     result.Commands = commands.ToArray();
     logger.get("comdiv.sys").debug(() => "finished " + type + " " + result.Properties.Count() + " properties");
     return result;
 }
Esempio n. 2
0
        private void MergeWithClsDefinition(ClassMetadata def, Type type, string alias){
            var cls = storage.First<ICls>(Restrictions.Eq("Comment", alias));
            if (null == cls){
                return;
            }
            if (def.Title.noContent()){
                def.Title = cls.Title;
            }
            foreach (var property in cls.Properties){
                switch (property.ClsPropertyType.Code){
                    case "allow.new":
                        def.AllowNew = bool.Parse(property.Name);
                        break;
                    case "allow.edit":
                        def.AllowEdit = bool.Parse(property.Name);
                        break;
                    case "allow.delete":
                        def.AllowDelete = bool.Parse(property.Name);
                        break;
                    case "visible":
                        def.Visible = bool.Parse(property.Name);
                        break;
                    case "sort":
                        def.Sort = def.Sort.hasContent() ? def.Sort : property.Name;
                        break;
                    case "group":
                        def.GroupBy = def.GroupBy.hasContent() ? def.GroupBy : property.Name;
                        break;
                    case "path":
                        def.Path = def.Path.hasContent() ? def.Path : property.Name;
                        break;
                    case "commands":
                        var ser = XmlSerializer.FromTypes(new[]{typeof (CommandDesc[])})[0];
                        var commands =
                            (CommandDesc[]) ser.Deserialize(XmlReader.Create(new StringReader(property.Name)));
                        def.Commands = (def.Commands ?? new CommandDesc[]{}).Union(commands).ToArray();
                        break;
                    case "properties":
                        var ser2 = XmlSerializer.FromTypes(new[]{typeof (PropertyMetadata[])})[0];
                        var props =
                            (PropertyMetadata[]) ser2.Deserialize(XmlReader.Create(new StringReader(property.Name)));
                        def.Properties = def.Properties.Union(props).ToArray();

                        break;


                    default:
                        if (!def.Parameters.ContainsKey(property.Code)){
                            def.Parameters[property.Code] = property.Name;
                        }
                        break;
                }
            }
        }