Exemplo n.º 1
0
        internal static Boolean AddAttribute(ICollection <LinkAttribute> attributes, LinkAttribute attrToAdd)
        {
            if (IsSingle(attrToAdd.Name))
            {
                foreach (LinkAttribute attr in attributes)
                {
                    if (attr.Name.Equals(attrToAdd.Name))
                    {
                        if (log.IsDebugEnabled)
                        {
                            log.Debug("Found existing singleton attribute: " + attr.Name);
                        }
                        return(false);
                    }
                }
            }

            // special rules
            if (attrToAdd.Name.Equals(ContentType) && attrToAdd.IntValue < 0)
            {
                return(false);
            }
            if (attrToAdd.Name.Equals(MaxSizeEstimate) && attrToAdd.IntValue < 0)
            {
                return(false);
            }

            attributes.Add(attrToAdd);
            return(true);
        }
Exemplo n.º 2
0
        public static RemoteResource Deserialize(String linkFormat)
        {
            RemoteResource root    = new RemoteResource(String.Empty);
            Scanner        scanner = new Scanner(linkFormat);

            String path = null;

            while ((path = scanner.Find(ResourceNameRegex)) != null)
            {
                path = path.Substring(1, path.Length - 2);

                // Retrieve specified resource, create if necessary
                RemoteResource resource = new RemoteResource(path);

                LinkAttribute attr = null;
                while (scanner.Find(DelimiterRegex, 1) == null && (attr = ParseAttribute(scanner)) != null)
                {
                    AddAttribute(resource.Attributes, attr);
                }

                root.AddSubResource(resource);
            }

            return(root);
        }