/// <summary>
        /// <see cref="PropertyDrawer.OnGUI"/>
        /// </summary>
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            if (property.propertyType != SerializedPropertyType.String)
            {
                EditorGUI.PropertyField(position, property, label);
                return;
            }
            if (_resourceAttribute == null)
            {
                _resourceAttribute = attribute as ResourceAttribute;
            }

            string propertyPath = property.propertyPath;
            Data   data;
            bool   changed = !_data.ContainsKey(propertyPath);

            if (changed)
            {
                data = new Data(property, label);
            }
            else
            {
                data = _data[propertyPath];
            }

            EditorGUI.BeginProperty(position, data.Content, property);
            data.UpdateContent(label);
            data.Draw(position, property, _resourceAttribute.TypeRestriction);
            _data[propertyPath] = data;
            EditorGUI.EndProperty();
        }
Пример #2
0
        private object LoadTileset(string resourceName, ResourceAttribute attribute)
        {
            var   textures = new List <Texture2D>();
            Point tileSize;

            if (attribute is TilesetAttribute tilesetAttribute)
            {
                if (tilesetAttribute.IsMultipart)
                {
                    for (var i = 0; i < tilesetAttribute.FilesCount; i++)
                    {
                        var texturePart = contentManager.Load <Texture2D>($"{resourceName}.{i}");
                        textures.Add(texturePart);
                    }
                }
                else
                {
                    var texture = contentManager.Load <Texture2D>(resourceName);
                    textures.Add(texture);
                }

                tileSize = tilesetAttribute.TileSize;
            }
            else
            {
                var texture = contentManager.Load <Texture2D>(resourceName);
                textures.Add(texture);
                tileSize = texture.Bounds.Size;
            }

            return(new Tileset(textures, tileSize));
        }
Пример #3
0
        /// <summary>
        /// 根据类型创建面板
        /// </summary>
        private UIPanel CreatePanel(Type UIType)
        {
            ResourceAttribute attr    = Attribute.GetCustomAttribute(UIType, typeof(ResourceAttribute), false) as ResourceAttribute;
            string            resPath = attr == null ? $"Prefabs/UI/Panels/{UIType.Name}" : attr.ResPath;

            GameObject obj = ResourceManager.Instance.Load <GameObject>(resPath);

            if (obj)
            {
                if (obj.GetComponent <UIPanel>() == null)
                {
                    Debug.LogError($"需要实例化的对象中找不到UIPanel组件");
                    return(null);
                }

                GameObject gameObj = Instantiate <GameObject>(obj, UIRoot);
                UIPanel    panel   = gameObj.GetComponent <UIPanel>();
                Canvas     canvas  = panel.transform.GetOrAddComponent <Canvas>();
                canvas.overrideSorting = true;
                panel.transform.GetOrAddComponent <GraphicRaycaster>();
                m_panelDict.Add(UIType, panel);

                return(panel);
            }
            else
            {
                Debug.LogError($"无法找到需要实例化的面板,路径:{resPath}");
                return(null);
            }
        }
Пример #4
0
        protected override IGameObject CreateInstance(Ninject.Activation.IContext context)
        {
            ResourceAttribute attrib = (ResourceAttribute)context.Request.Target.GetCustomAttributes(typeof(ResourceAttribute), false).FirstOrDefault();

            if (attrib == null)
            {
                return(new UnityGameObject(new GameObject()));
            }
            return(loader.instantiate(attrib.Path));
        }
Пример #5
0
        /// <summary>
        /// 标记了Component特性的,或标记了继承Component特性的特性的类,为此类中的标记了Resource特性的成员注入值。
        /// </summary>
        /// <param name="dlls">指定的要被扫描的dll。</param>
        private void ScanResource(string[] dlls)
        {
            foreach (string dll in dlls)
            {
                Assembly assembly = Assembly.LoadFile(dll);
                Type[]   types    = assembly.GetTypes();
                foreach (Type clazz in types)
                {
                    if (clazz.IsClass)
                    {
                        Attribute attributeComponetAttribute = clazz.GetCustomAttribute(typeof(ComponentAttribute));
                        if (attributeComponetAttribute == null)
                        {
                            continue;
                        }

                        ComponentAttribute componentAttribute = (ComponentAttribute)attributeComponetAttribute;
                        string             clazzName          = clazz.Name.Substring(0, 1).ToLower() + (clazz.Name.Length > 1 ? clazz.Name.Substring(1) : string.Empty);
                        if (!string.IsNullOrWhiteSpace(componentAttribute.Name))
                        {
                            clazzName = componentAttribute.Name;
                        }

                        FieldInfo[] fieldInfos = clazz.GetFields(BindingFlags.Instance | BindingFlags.NonPublic);
                        foreach (FieldInfo fieldInfo in fieldInfos)
                        {
                            Attribute attributeResourceAttribute = fieldInfo.GetCustomAttribute(typeof(ResourceAttribute));
                            if (attributeResourceAttribute == null)
                            {
                                continue;
                            }

                            ResourceAttribute resourceAttribute = (ResourceAttribute)attributeResourceAttribute;
                            string            resourceName      = fieldInfo.Name;
                            if (!string.IsNullOrWhiteSpace(resourceAttribute.Name))
                            {
                                resourceName = resourceAttribute.Name;
                            }
                            if (!BeanContainer.ContainsKey(resourceName))
                            {
                                throw new BeanNotFoundException(string.Format("找不到指定的实例‘{0}’。", resourceName));
                            }

                            if (BeanContainer.ContainsKey(clazzName))
                            {
                                fieldInfo.SetValue(BeanContainer[clazzName].Bean, BeanContainer[resourceName].Bean);
                            }
                        }
                    }
                }
            }
        }
Пример #6
0
    /// <summary>
    /// Fetch records once from C01RM0190 for tooltip purpose.
    /// </summary>
    public static void SetTooltips()
    {
        Tooltips = new List <Tuple <int, string> >();

        EssResourceAttribute = ResourceAttribute.LoadList();
        var records = from c in EssResourceAttribute
                      select new
        {
            ResId   = c.ResourceAttributeID,
            ResName = c.ResourceAttributeName
        };

        foreach (var record in records)
        {
            Tooltips.Add(new Tuple <int, string>((int)record.ResId, record.ResName));
        }
    }
Пример #7
0
        public ResourceInfo(
            AutumnDataSettings dataSettings,
            EntityInfo entityInfo,
            string defaultApiVersion,
            IReadOnlyDictionary <HttpMethod, Type> proxyRequestTypes,
            ResourceAttribute resourceAttribute)
        {
            EntityInfo        = entityInfo;
            ProxyRequestTypes = proxyRequestTypes ?? throw new ArgumentNullException(nameof(proxyRequestTypes));
            ApiVersion        =
                Regex.Match(resourceAttribute.Version ?? string.Empty, "v[0-9]+", RegexOptions.IgnoreCase).Success
                    ? resourceAttribute.Version
                    : defaultApiVersion;
            Name = resourceAttribute.Name ?? entityInfo.EntityType.Name;
            if (dataSettings.Parent.NamingStrategy != null)
            {
                ControllerName = dataSettings.Parent.NamingStrategy.GetPropertyName(Name, false);
            }
            if (dataSettings.PluralizeController && !ControllerName.EndsWith("s"))
            {
                ControllerName = string.Concat(ControllerName, "s");
            }
            var ignoreOperations = new List <HttpMethod>();

            if (!resourceAttribute.Insertable)
            {
                ignoreOperations.Add(HttpMethod.Post);
            }
            if (!resourceAttribute.Updatable)
            {
                ignoreOperations.Add(HttpMethod.Put);
            }
            if (!resourceAttribute.Deletable)
            {
                ignoreOperations.Add(HttpMethod.Delete);
            }
            IgnoreOperations = new ReadOnlyCollection <HttpMethod>(ignoreOperations);
        }
        public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
        {
            // using (JS_MethodLogger.Log("JsonAPIFormatSerializer DocumentRootConverter WriteJson :" + value.GetType().Name, JS_LogOptions.All))
            {
                //Add root reference
                serializer.ReferenceResolver.AddReference(null, IncludedReferenceResolver.RootReference, value);

                var contract = (JsonObjectContract)serializer.ContractResolver.ResolveContract(value.GetType());
                writer.WriteStartObject();



                var propertiesOutput = new HashSet <string>();
                foreach (var prop in contract.Properties)
                {
                    //we will do includes last, so we we can ensure all the references have been added
                    if (prop.PropertyName == PropertyNames.Included)
                    {
                        continue;
                    }

                    //respect the serializers null handling value
                    var propValue = prop.ValueProvider.GetValue(value);
                    if (propValue == null && (prop.NullValueHandling ?? serializer.NullValueHandling) == NullValueHandling.Ignore)
                    {
                        continue;
                    }

                    //main object links
                    if (_href != null && prop.PropertyName == PropertyNames.Data)
                    {
                        ResourceAttribute resA = new ResourceAttribute(_href);
                        WriterUtil.GenerateResourceLinks(serializer, writer, propValue, resA, propValue.GetType().Name.ToLower());//todo
                    }

                    //A document MAY contain any of these top-level members: jsonapi, links, included
                    //We are also allowing everything else they happen to have on the root document
                    writer.WritePropertyName(prop.PropertyName);
                    serializer.Serialize(writer, propValue);
                    propertiesOutput.Add(prop.PropertyName);
                }


                //A document MUST contain one of the following (data, errors, meta)
                //so if we do not have one of them we will output a null data
                if (!propertiesOutput.Contains(PropertyNames.Data) &&
                    !propertiesOutput.Contains(PropertyNames.Errors) &&
                    !propertiesOutput.Contains(PropertyNames.Meta))
                {
                    propertiesOutput.Add(PropertyNames.Data);
                    writer.WritePropertyName(PropertyNames.Data);
                    writer.WriteNull();
                }
                //Handle Include
                //If a document does not contain a top-level data key, the included member MUST NOT be present
                if (propertiesOutput.Contains(PropertyNames.Data))
                {
                    //output the included. If we have a specified included field we will out everything in there
                    //and we will also output all the references defined in our reference resolver
                    var resolver           = (serializer.ReferenceResolver as IncludedReferenceResolver);
                    var renderedReferences = resolver?.RenderedReferences ?? new HashSet <string>();
                    var includedReferences = serializer.ReferenceResolver as IDictionary <string, object> ?? Enumerable.Empty <KeyValuePair <string, object> >();


                    var referencesToInclude = includedReferences
                                              .Where(x => x.Key != IncludedReferenceResolver.RootReference)
                                              .Where(x => !renderedReferences.Contains(x.Key))
                                              .Where(x => resolver.ResourceToInclude.Contains(x.Key))
                                              .ToList(); //dont output values we have already output
                    var includedProperty = contract.Properties.GetClosestMatchProperty(PropertyNames.Included);
                    var includedValues   = includedProperty?.ValueProvider?.GetValue(value) as IEnumerable <object> ?? Enumerable.Empty <object>();

                    //if we have some references we will output them
                    if (referencesToInclude.Any() || includedValues.Any())
                    {
                        writer.WritePropertyName(PropertyNames.Included);
                        writer.WriteStartArray();

                        foreach (var includedValue in includedValues)
                        {
                            serializer.Serialize(writer, includedValue);
                        }

                        //I know we can alter the OrderedDictionary while enumerating it, otherwise this would error
                        //foreach (var includedReference in includedReferences)
                        //for (int i = 0; i < includedReferences.Count(); i++)
                        //{
                        //    var includedReference = includedReferences.ElementAt(i);
                        //    serializer.Serialize(writer, includedReference.Value);
                        //}

                        while (referencesToInclude.Count > 0)
                        {
                            for (int i = 0; i < referencesToInclude.Count(); i++)
                            {
                                var includedReference = referencesToInclude.ElementAt(i);
                                serializer.Serialize(writer, includedReference.Value);
                            }
                            referencesToInclude = includedReferences
                                                  .Where(x => x.Key != IncludedReferenceResolver.RootReference)
                                                  .Where(x => !renderedReferences.Contains(x.Key))
                                                  .Where(x => resolver.ResourceToInclude.Contains(x.Key))
                                                  .ToList(); //dont output values we have already output
                        }


                        writer.WriteEndArray();
                    }
                }

                writer.WriteEndObject();
            }
        }
        private void WriteResourceJson(JsonWriter writer, object value, JsonSerializer serializer)
        {
            var resolver     = (serializer.ReferenceResolver as IncludedReferenceResolver);
            var currentIndex = resolver.RefList.Count;
            var valueType    = value.GetType();

            //Serialize object
            var contract = (JsonObjectContract)serializer.ContractResolver.ResolveContract(valueType);

            writer.WriteStartObject();

            //will capture id and type as we go through
            object id   = null;
            object type = null;

            //Handle link
            var linkProps = valueType.GetProperties().Where(p => p.GetCustomAttributes(typeof(ResourceAttribute), false).Count() != 0).ToList();

            //A resource object MUST contain at least the following top-level members: type
            var typeProp = contract.Properties.GetClosestMatchProperty("type");

            type = GenerateDefaultTypeName(valueType);
            if (typeProp == null)
            {
                writer.WritePropertyName("type");
                serializer.Serialize(writer, type);
            }

            List <JsonWriterCapture> attributes    = new List <JsonWriterCapture>();
            List <JsonWriterCapture> relationships = new List <JsonWriterCapture>();

            foreach (var prop in contract.Properties.Where(x => !x.Ignored))
            {
                var propValue = prop.ValueProvider.GetValue(value);
                if (propValue == null && (prop.NullValueHandling ?? serializer.NullValueHandling) == NullValueHandling.Ignore)
                {
                    continue;
                }

                switch (prop.PropertyName)
                {
                //In addition, a resource object MAY contain any of these top - level members: links, meta, attributes, relationships
                case PropertyNames.Id:     //Id is optional on base objects
                case PropertyNames.Tid:    //
                    id = propValue;
                    writer.WritePropertyName(prop.PropertyName);
                    serializer.Serialize(writer, id);
                    break;

                case PropertyNames.Meta:
                    writer.WritePropertyName(prop.PropertyName);
                    serializer.Serialize(writer, propValue);
                    break;

                case PropertyNames.Type:
                    writer.WritePropertyName(PropertyNames.Type);
                    type = typeProp?.ValueProvider?.GetValue(value) ?? GenerateDefaultTypeName(valueType);
                    serializer.Serialize(writer, type);
                    break;

                default:
                    var resAttr = linkProps?.Where(l => l.Name.ToLower() == prop.PropertyName.ToLower()).SingleOrDefault();

                    //we do not know if it is an Attribute or a Relationship
                    //so we will send out a probe to determine which one it is
                    var probe = new AttributeOrRelationshipProbe();
                    probe.WritePropertyName(prop.PropertyName);
                    serializer.Serialize(probe, propValue);

                    //handle relationship links start
                    if (probe.PropertyType == AttributeOrRelationshipProbe.Type.Relationship)
                    {
                        ResourceAttribute link = null;
                        if (resAttr != null)
                        {
                            link = resAttr.GetCustomAttributes(typeof(ResourceAttribute), false)[0] as ResourceAttribute;
                            if (link.Links != null && link.Links.Count > 0)
                            {
                                //probe.WriteStartObject();
                                var act = probe.GetActions();
                                //001:remove last entry and add links
                                act.RemoveAt(act.Count - 1);

                                WriterUtil.GenerateResourceLinks(serializer, probe, value, link, type.ToString(), prop.PropertyName, propValue);
                                //additional end object since it is removed to add links in 001 section
                                probe.AddEndObject();
                            }
                            if (!link.IsResource)
                            {
                                probe.PropertyType = AttributeOrRelationshipProbe.Type.Attribute;
                            }
                        }

                        //Handle Includes
                        if (resolver.Includes != null && resolver.Includes.Count() > 0)
                        {
                            if (ListUtil.IsList(propValue.GetType()))
                            {
                                var enumerable   = propValue as IEnumerable <object> ?? Enumerable.Empty <object>();
                                var include_name = ((link != null && !string.IsNullOrEmpty(link.IncludeName)) ? link.IncludeName : prop.PropertyName);
                                if (enumerable.Count() > 0 && resolver.Includes.Contains(include_name.ToLower()))
                                {
                                    foreach (var valueElement in enumerable)
                                    {
                                        var include_id   = valueElement.GetType().GetProperties().Where(p => p.Name.ToLower() == PropertyNames.Id).FirstOrDefault()?.GetValue(valueElement);
                                        var include_type = valueElement.GetType().GetProperties().Where(p => p.Name.ToLower() == PropertyNames.Type).FirstOrDefault()?.GetValue(valueElement);
                                        if (include_type == null)
                                        {
                                            include_type = valueElement.GetType().Name.ToLower();
                                        }
                                        if (include_id != null && include_type != null)
                                        {
                                            var refer = IncludedReferenceResolver.GetReferenceValue(include_id.ToString(), include_type.ToString());
                                            resolver.ResourceToInclude.Add(refer);
                                            serializer.ReferenceResolver.AddReference(null, refer, valueElement);
                                        }
                                    }
                                }
                            }
                            else
                            {
                                var include_id   = propValue.GetType().GetProperties().Where(p => p.Name.ToLower() == PropertyNames.Id).FirstOrDefault()?.GetValue(propValue);
                                var include_type = propValue.GetType().GetProperties().Where(p => p.Name.ToLower() == PropertyNames.Type).FirstOrDefault()?.GetValue(propValue);
                                if (include_type == null)
                                {
                                    include_type = propValue.GetType().Name.ToLower();
                                }
                                if (include_id != null && include_type != null)
                                {
                                    var include_name = ((link != null && !string.IsNullOrEmpty(link.IncludeName)) ? link.IncludeName : prop.PropertyName);
                                    if (resolver.Includes != null && resolver.Includes.Contains(include_name.ToLower()))
                                    {
                                        var refer = IncludedReferenceResolver.GetReferenceValue(include_id.ToString(), include_type.ToString());
                                        resolver.ResourceToInclude.Add(refer);
                                        serializer.ReferenceResolver.AddReference(null, refer, propValue);
                                    }
                                }
                            }
                        }
                    }
                    //handle relationship links end

                    (probe.PropertyType == AttributeOrRelationshipProbe.Type.Attribute
                                   ? attributes
                                   : relationships).Add(probe);

                    break;
                }
            }

            //add reference to this type, so others can reference it
            var referenceValue = IncludedReferenceResolver.GetReferenceValue(id?.ToString(), type?.ToString());

            serializer.ReferenceResolver.AddReference(null, referenceValue, value);
            resolver?.RenderedReferences?.Add(referenceValue);

            //set parent reference for generating link parameters
            for (int i = currentIndex; i < resolver.RefList.Count; i++)
            {
                if (resolver.RefList[i].Reference != referenceValue)
                {
                    resolver.RefList[i].ParentReference = referenceValue;
                }
            }
            //output our attibutes in an attribute tag
            if (attributes.Count > 0)
            {
                writer.WritePropertyName(PropertyNames.Attributes);
                writer.WriteStartObject();
                foreach (var attribute in attributes)
                {
                    attribute.ApplyCaptured(writer);
                }
                writer.WriteEndObject();
            }

            //output our relationships in a relationship tag
            if (relationships.Count > 0)
            {
                writer.WritePropertyName(PropertyNames.Relationships);
                writer.WriteStartObject();

                foreach (var relationship in relationships)
                {
                    relationship.ApplyCaptured(writer);
                }
                writer.WriteEndObject();
            }
            //Links
            var res = ((value.GetType().GetCustomAttributes(typeof(ResourceAttribute))).SingleOrDefault() as ResourceAttribute);

            WriterUtil.GenerateResourceLinks(serializer, writer, value, res, type.ToString());

            writer.WriteEndObject();
        }
Пример #10
0
        // propertyName and relationshipObj need to be passed when relationships links generated, relationship resource id might be needed to generate the link
        internal static void GenerateResourceLinks(JsonSerializer serializer, JsonWriter writer, object obj, ResourceAttribute resAttr, string reftype, string propertyName = "", object relationshipObj = null)
        {
            var probe = writer as AttributeOrRelationshipProbe;

            if (resAttr != null && resAttr.Links.Count > 0)
            {
                var resolver = (serializer.ReferenceResolver as IncludedReferenceResolver);
                if (probe != null)
                {
                    probe.AddPropertyName(PropertyNames.Links);
                    probe.AddStartObject();
                }
                else
                {
                    writer.WritePropertyName(PropertyNames.Links);
                    writer.WriteStartObject();
                }


                //var typeProp = obj.GetType().GetProperties().Where(p => p.Name.ToLower() == PropertyNames.Type).FirstOrDefault();
                // var reftype = defaultTypeName; //typeProp == null ? defaultTypeName : typeProp.GetValue(obj).ToString();
                var relationshipRefType = string.IsNullOrEmpty(resAttr.IncludeName) ? propertyName: resAttr.IncludeName;
                var id            = obj.GetType().GetProperties().Where(p => p.Name.ToLower() == PropertyNames.Id).FirstOrDefault()?.GetValue(obj);
                var reference     = ("#{" + (reftype.ToString().ToLower()) + ".id}#");
                var relatedObjRef = "#{" + (relationshipRefType) + ".id}#";
                var relatedObjId  = "";
                if (!string.IsNullOrEmpty(relationshipRefType) && relationshipObj != null)
                {
                    var childProp = relationshipObj.GetType().GetProperties().Where(p => p.Name.ToLower() == PropertyNames.Id).FirstOrDefault();
                    if (childProp != null)
                    {
                        relatedObjId = childProp.GetValue(relationshipObj).ToString();
                    }
                }
                foreach (var entry in resAttr.Links)
                {
                    //var lk = entry.Value.Replace(("#{id}#"), id.ToString());
                    var lk = entry.Value.Replace(reference, id?.ToString()).Replace(relatedObjRef, relatedObjId.ToString());
                    if (!ListUtil.IsList(obj.GetType()))
                    {
                        lk = lk.Replace("#{" + obj.GetType().Name.ToLower() + ".id}#", id?.ToString());
                    }

                    lk = lk.Replace("#{BASE_URL}#", resolver.BaseUrl);

                    Regex rg  = new Regex("(?>(#{)[^},(BASE_URL)]*(}#))");
                    var   arr = rg.Matches(lk);
                    if (arr.Count > 0)
                    {
                        foreach (Match m in arr)
                        {
                            var tag = m.Value.Replace("#{", "").Replace("}#", "");
                            var s   = tag.Split('.');
                            var key = string.Join(".", s.Take(s.Length - 1));

                            //loop through link object list to map parent ids
                            var linkedObj = resolver.RefList.Where(r => r.Reference == reftype + ":" + id).SingleOrDefault();
                            if (linkedObj != null)
                            {
                                var  parentObj = resolver.RefList.Where(r => r.Reference == linkedObj.ParentReference).SingleOrDefault();
                                bool found     = false;
                                while (!found && parentObj != null)
                                {
                                    if (parentObj.Reference.ToLower().StartsWith(key + ":"))
                                    {
                                        var val = parentObj.Reference.Replace(key + ":", "");
                                        lk        = lk.Replace(("#{" + tag.ToString() + "}#"), val.ToString());
                                        found     = true;
                                        parentObj = null;
                                    }
                                    else
                                    {
                                        parentObj = resolver.RefList.Where(r => r.Reference == parentObj.ParentReference).SingleOrDefault();
                                    }
                                }
                            }
                        }
                    }
                    if (probe != null)
                    {
                        probe.AddPropertyName(entry.Key);
                        probe.AddValue(lk);
                    }
                    else
                    {
                        writer.WritePropertyName(entry.Key);
                        writer.WriteValue(lk);
                    }
                }
                if (probe != null)
                {
                    probe.AddEndObject();
                }
                else
                {
                    writer.WriteEndObject();
                }
            }
        }
Пример #11
0
 /// <summary>
 /// The Fn::GetAtt intrinsic function returns the value of an attribute from a resource in the template.
 /// https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-getatt.html
 /// </summary>
 /// <param name="logicalId">The logical name (also called logical ID) of the resource that contains the attribute that you want.</param>
 /// <param name="attributeName">The name of the resource-specific attribute whose value you want. See the resource's reference page for details about the attributes available for that resource type.</param>
 public static GetAtt GetAtt(string logicalId, ResourceAttribute attributeName) => new GetAtt(logicalId, attributeName);
Пример #12
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="logicalId">The logical name (also called logical ID) of the resource that contains the attribute that you want.</param>
 /// <param name="attribute">The name of the resource-specific attribute whose value you want. See the resource's reference page for details about the attributes available for that resource type.</param>
 public GetAtt(string logicalId, ResourceAttribute attribute)
 {
     Token = new JObject(
         new JProperty(Name,
                       new JArray(logicalId, attribute.Name)));
 }
        private Authorization GetFromAuthorizationResource(RoleDefinitionDataProvider roleDP, ResourceAttribute resAttr)
        {
            Authorization auth = new Authorization()
            {
                ResourceName        = resAttr.Name,
                ResourceDescription = resAttr.Description,
            };

            auth.AllowedRoles.Add(new Role()
            {
                RoleId = RoleDefinitionDataProvider.SuperUserId
            });
            if (resAttr.Anonymous)
            {
                auth.AllowedRoles.Add(new Role()
                {
                    RoleId = roleDP.GetAnonymousRoleId()
                });
            }
            if (resAttr.User)
            {
                auth.AllowedRoles.Add(new Role()
                {
                    RoleId = roleDP.GetUserRoleId()
                });
            }
            if (resAttr.Editor)
            {
                auth.AllowedRoles.Add(new Role()
                {
                    RoleId = roleDP.GetEditorRoleId()
                });
            }
            if (resAttr.Administrator)
            {
                auth.AllowedRoles.Add(new Role()
                {
                    RoleId = roleDP.GetAdministratorRoleId()
                });
            }
            return(auth);
        }