Ejemplo n.º 1
0
        private static void AddToResourceFinder(IResource toAdd, IDictionary <string, IResource> finder)
        {
            string[] makeResourceParts(IResource resource)
            {
                switch (resource)
                {
                case var _ when resource.IsInternal: return(new[] { resource.Name });

                case var _ when resource.IsInnerResource:
                    var dots = resource.Name.Count('.');
                    return(resource.Name.Split(new[] { '.' }, dots));

                default: return(resource.Name.Split('.'));
                }
            }

            var parts = makeResourceParts(toAdd);

            parts.ForEach((item, index) =>
            {
                var key = string.Join(".", parts.Skip(index));
                if (finder.ContainsKey(key))
                {
                    finder[key] = null;
                }
                else
                {
                    finder[key] = toAdd;
                }
            });
        }
Ejemplo n.º 2
0
 internal static void RemoveResource(IResource toRemove)
 {
     ResourceByName.Remove(toRemove.Name);
     ResourceByType.Remove(toRemove.Type);
     ReloadResourceFinder();
     UpdateConfiguration();
 }
Ejemplo n.º 3
0
 internal static void AddResource(IResource toAdd)
 {
     ResourceByName[toAdd.Name] = toAdd;
     ResourceByType[toAdd.Type] = toAdd;
     AddToResourceFinder(toAdd, ResourceFinder);
     UpdateConfiguration();
     toAdd.Type.GetDeclaredProperties();
 }
Ejemplo n.º 4
0
 private bool RemoveResource(IResource resource)
 {
     if (resource is IEntityResource er && er.Provider == Id)
     {
         RESTarConfig.RemoveResource(resource);
         return(true);
     }
     return(false);
 }
 /// <summary>
 /// Used when creating generic requests
 /// </summary>
 internal RequestParameters(Context context, Method method, IResource resource, string protocolIdentifier = null, string viewName = null)
 {
     TraceId            = context.InitialTraceId;
     Context            = context;
     Method             = method;
     Headers            = new Headers();
     iresource          = resource;
     IsWebSocketUpgrade = Context.WebSocket?.Status == WebSocketStatus.Waiting;
     Uri = new URI
     {
         ResourceSpecifier = resource.Name,
         ViewName          = viewName
     };
     CachedProtocolProvider = ProtocolController.ResolveProtocolProvider(protocolIdentifier);
 }