private XmlElement CreateClassNode(XmlDocument document, SecurableClassInfo classInfo)
        {
            XmlElement classElement = document.CreateElement("class", _metadataSchema.SchemaUri);

            XmlAttribute classIdAttribute = document.CreateAttribute("id");

            classIdAttribute.Value = classInfo.ID;

            XmlAttribute classNameAttribute = document.CreateAttribute("name");

            classNameAttribute.Value = classInfo.Name;

            classElement.Attributes.Append(classIdAttribute);
            classElement.Attributes.Append(classNameAttribute);

            if (classInfo.BaseClass != null)
            {
                XmlAttribute baseClassAttribute = document.CreateAttribute("base");
                baseClassAttribute.Value = classInfo.BaseClass.ID;

                classElement.Attributes.Append(baseClassAttribute);
            }

            AppendCollection(document, classElement, "stateProperties", classInfo.Properties, CreateStatePropertyRefElement);
            AppendCollection(document, classElement, "accessTypes", classInfo.AccessTypes, CreateAccessTypeRefElement);

            return(classElement);
        }
Ejemplo n.º 2
0
        public void AddSecurableClassInfo(Type key, SecurableClassInfo value)
        {
            ArgumentUtility.CheckNotNull("key", key);
            ArgumentUtility.CheckNotNull("value", value);

            _classes.Add(key, value);
        }
Ejemplo n.º 3
0
        public SecurableClassInfo GetMetadata(Type type, MetadataCache cache)
        {
            ArgumentUtility.CheckNotNullAndTypeIsAssignableFrom("type", type, typeof(ISecurableObject));
            if (type.IsValueType)
            {
                throw new ArgumentException("Value types are not supported.", "type");
            }
            ArgumentUtility.CheckNotNull("cache", cache);

            SecurableClassInfo info = cache.GetSecurableClassInfo(type);

            if (info == null)
            {
                info      = new SecurableClassInfo();
                info.Name = TypeUtility.GetPartialAssemblyQualifiedName(type);
                PermanentGuidAttribute guidAttribute = (PermanentGuidAttribute)Attribute.GetCustomAttribute(type, typeof(PermanentGuidAttribute), true);
                if (guidAttribute != null)
                {
                    info.ID = guidAttribute.Value.ToString();
                }
                info.Properties.AddRange(GetProperties(type, cache));
                info.AccessTypes.AddRange(_accessTypeReflector.GetAccessTypesFromType(type, cache));

                cache.AddSecurableClassInfo(type, info);

                if (typeof(ISecurableObject).IsAssignableFrom(type.BaseType))
                {
                    info.BaseClass = GetMetadata(type.BaseType, cache);
                    info.BaseClass.DerivedClasses.Add(info);
                }
            }

            return(info);
        }
 private LocalizedName CreateLocalizedNameFromClassInfo(SecurableClassInfo classInfo, string text)
 {
     return(new LocalizedName(classInfo.ID, classInfo.Name, classInfo.Description));
 }