/// <summary>
 /// Instantiates a <see cref="FimsAwsWorkerService"/>
 /// </summary>
 /// <param name="scope"></param>
 /// <param name="logger"></param>
 /// <param name="worker"></param>
 /// <param name="resourceSerializer"></param>
 public FimsAwsWorkerService(IDisposable scope, ILogger logger, IWorker worker, IResourceSerializer resourceSerializer)
 {
     Scope = scope;
     Logger = logger;
     Worker = worker;
     ResourceSerializer = resourceSerializer;
 }
Пример #2
0
 /// <summary>
 /// Instantiates a <see cref="DefaultRequestHandler"/>
 /// </summary>
 /// <param name="logger"></param>
 /// <param name="resourceDescriptorHelper"></param>
 /// <param name="resourceHandlerRegistry"></param>
 /// <param name="resourceSerializer"></param>
 public DefaultRequestHandler(ILogger logger,
                              IResourceDescriptorHelper resourceDescriptorHelper,
                              IResourceHandlerRegistry resourceHandlerRegistry,
                              IResourceSerializer resourceSerializer)
 {
     Logger = logger;
     ResourceDescriptorHelper = resourceDescriptorHelper;
     ResourceHandlerRegistry  = resourceHandlerRegistry;
     ResourceSerializer       = resourceSerializer;
 }
        /// <summary>
        /// Instantiates a <see cref="LambdaWorkerFunctionInvoker"/>
        /// </summary>
        /// <param name="logger"></param>
        /// <param name="resourceSerializer"></param>
        /// <param name="options"></param>
        public LambdaWorkerFunctionInvoker(ILogger logger, IResourceSerializer resourceSerializer, IOptions <LambdaOptions> options)
        {
            Logger             = logger;
            ResourceSerializer = resourceSerializer;

            // create client using credentials, if provided
            var region = options.Value?.RegionEndpoint;
            var creds  = options.Value?.Credentials;

            Lambda = creds != null ? new AmazonLambdaClient(creds, region) : new AmazonLambdaClient();
        }
Пример #4
0
        private int AddLinkedResources(TreeNode treeNode, IResource selectedResource, int linkID, LinkNode linkNode)
        {
            bool          directed  = _resourceStore.PropTypes [linkID].HasFlag(PropTypeFlags.DirectedLink);
            IResourceList resources = null;

            if (directed)
            {
                if (linkID < 0)
                {
                    resources = selectedResource.GetLinksTo(null, -linkID);
                }
                else
                {
                    resources = selectedResource.GetLinksFrom(null, linkID);
                }
            }
            else
            {
                resources = selectedResource.GetLinksOfType(null, linkID);
            }

            int count = 0;

            foreach (IResource resource in resources)
            {
                if (IsSerializerExists(resource))
                {
                    int iconIndex = GetIcon(resource);
                    Tracer._Trace(resource.DisplayName);
                    TreeNode            treeSubNode  = new TreeNode(GetTypeDisplayName(resource.Type) + ": " + resource.DisplayName, iconIndex, iconIndex);
                    ResourceNode        resourceNode = linkNode.AddResource(resource);
                    IPropertyCollection properties   = resourceNode.Resource.Properties;
                    foreach (IResourceProperty property in properties)
                    {
                        if (property.DataType != PropDataType.Link)
                        {
                            IResourceSerializer serializer = Core.PluginLoader.GetResourceSerializer(resourceNode.Resource.Type);
                            SerializationMode   serMode    = GetSerializationMode(serializer, resourceNode.Resource, property);
                            if (serMode == SerializationMode.NoSerialize)
                            {
                                continue;
                            }
                            resourceNode.AddProperty(property);
                        }
                    }

                    treeSubNode.Tag = new SerializableTag(resourceNode, SerializableTag.Type.LinkedResource);
                    treeNode.Nodes.Add(treeSubNode);
                    _resourceTreeView.SetNodeCheckState(treeSubNode, NodeCheckState.Checked);
                    count++;
                }
            }
            return(count);
        }
Пример #5
0
 /// <summary>
 /// Instantiates a <see cref="MediaInfoWorker"/>
 /// </summary>
 /// <param name="logger"></param>
 /// <param name="dataHandler"></param>
 /// <param name="accessibleLocationProvider"></param>
 /// <param name="processRunner"></param>
 /// <param name="mediaInfoOutputConverter"></param>
 /// <param name="fileStorage"></param>
 /// <param name="resourceSerializer"></param>
 /// <param name="processLocator"></param>
 public MediaInfoWorker(ILogger logger,
                        IResourceDataHandler dataHandler,
                        IMediaInfoAccessibleLocationProvider accessibleLocationProvider,
                        IProcessRunner processRunner,
                        IMediaInfoOutputConverter mediaInfoOutputConverter,
                        IFileStorage fileStorage,
                        IResourceSerializer resourceSerializer,
                        IMediaInfoProcessLocator processLocator)
     : base(dataHandler)
 {
     Logger = logger;
     AccessibleLocationProvider = accessibleLocationProvider;
     ProcessRunner            = processRunner;
     MediaInfoOutputConverter = mediaInfoOutputConverter;
     FileStorage        = fileStorage;
     ResourceSerializer = resourceSerializer;
     ProcessLocator     = processLocator;
 }
Пример #6
0
        public void GenerateXML(XmlDocument document, XmlNode parent)
        {
            if (!AcceptSending)
            {
                return;
            }
            XmlNode resNode = document.CreateElement("Resource");

            LoadProperies(document, resNode);
            LoadLinks(document, resNode);

            IResourceSerializer serializer = ICore.Instance.PluginLoader.GetResourceSerializer(_resource.Type);

            if (serializer != null)
            {
                serializer.AfterSerialize(_parentResource, _resource, resNode);
            }

            parent.AppendChild(resNode);
        }
Пример #7
0
        private void AddProperties(TreeNode treeNode, ResourceNode resourceNode)
        {
            IResourceSerializer serializer = Core.PluginLoader.GetResourceSerializer(resourceNode.Resource.Type);

            if (serializer == null)
            {
                return;
            }

            IPropertyCollection properties = resourceNode.Resource.Properties;

            foreach (IResourceProperty property in properties)
            {
                SerializationMode serMode = GetSerializationMode(serializer, resourceNode.Resource, property);
                if (serMode == SerializationMode.NoSerialize)
                {
                    continue;
                }

                if (property.DataType == PropDataType.Link)
                {
                    if (serMode == SerializationMode.Serialize || serMode == SerializationMode.AskSerialize)
                    {
                        AddLink(resourceNode, property, treeNode);
                    }
                }
                else
                {
                    if (serMode == SerializationMode.AskSerialize)
                    {
                        AddProperty(resourceNode, property, treeNode);
                    }
                    else
                    {
                        resourceNode.AddProperty(property);
                    }
                }
            }
        }
Пример #8
0
        public void AcceptReceiving()
        {
            if (!_valid)
            {
                return;
            }
            IResourceSerializer serializer      = Core.PluginLoader.GetResourceSerializer(_resource.Type);
            IResource           matchedResource = null;

            if (serializer != null)
            {
                IResource parentResource = _resource;
                if (_linkUnpack != null)
                {
                    parentResource = _linkUnpack.ParentResource;
                }
                matchedResource = serializer.AfterDeserialize(parentResource, _resource, _xmlNode);
            }

            if (matchedResource == null || matchedResource.Id == _resource.Id)
            {
                _resource.EndUpdate();
            }
            if (matchedResource != null)
            {
                _resource = matchedResource;
            }
            if (_linkUnpack != null)
            {
                //  In the case of directed link, this is the proper linkage,
                //  in the case of indirected one the actual order is insignificant
                _resource.AddLink(_linkUnpack.InternalName, _linkUnpack.ParentResource);
            }
            Core.WorkspaceManager.AddToActiveWorkspace(_resource);
            if (Core.TextIndexManager != null && Core.ResourceStore.ResourceTypes[_resource.Type].Flags != ResourceTypeFlags.NoIndex)
            {
                Core.TextIndexManager.QueryIndexing(_resource.Id);
            }
        }
Пример #9
0
        private SerializationMode GetSerializationMode(IResourceSerializer serializer, IResource resource, IResourceProperty property)
        {
            SerializationMode serMode = serializer.GetSerializationMode(resource, property.Name);

            if (serMode == SerializationMode.Default)
            {
                IPropType propType = Core.ResourceStore.PropTypes [property.Name];
                if (propType.HasFlag(PropTypeFlags.AskSerialize))
                {
                    return(SerializationMode.AskSerialize);
                }
                if (propType.HasFlag(PropTypeFlags.NoSerialize))
                {
                    return(SerializationMode.NoSerialize);
                }
                if (property.DataType == PropDataType.Link && propType.HasFlag(PropTypeFlags.Internal))
                {
                    return(SerializationMode.NoSerialize);
                }
                return(SerializationMode.Serialize);
            }
            return(serMode);
        }
Пример #10
0
 /// <summary>
 /// Instantiates an <see cref="AzureFunctionWorkerInvoker"/>
 /// </summary>
 /// <param name="resourceSerializer"></param>
 public AzureFunctionWorkerInvoker(IResourceSerializer resourceSerializer)
 {
     ResourceSerializer = resourceSerializer;
 }
 public void SetUp()
 {
     serializer = new AtomPlusXmlSerializer();
 }
Пример #12
0
 /// <summary>
 /// Instantiates a <see cref="HttpResourceDataHandler"/>
 /// </summary>
 /// <param name="environment"></param>
 /// <param name="resourceSerializer"></param>
 public HttpResourceDataHandler(IEnvironment environment, IResourceSerializer resourceSerializer)
 {
     Environment        = environment;
     ResourceSerializer = resourceSerializer;
 }
Пример #13
0
 public void SetUp()
 {
     serializer = new JsonSerializer();
 }
 public RestfulieMarshaller(IRelationsFactory relationsFactory, IResourceSerializer serializer, IHypermediaInjector hypermedia)
 {
     this.relationsFactory = relationsFactory;
     this.serializer = serializer;
     this.hypermedia = hypermedia;
 }
Пример #15
0
 public void SetUp()
 {
     serializer = new XmlSerializer();
 }
Пример #16
0
 /// <summary>
 /// Deserializes a response body to a single resource
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="serializer"></param>
 /// <param name="response"></param>
 /// <returns></returns>
 public static async Task <T> DeserializeResponseBodyToResource <T>(this IResourceSerializer serializer, HttpResponseMessage response)
     where T : Resource, new()
 {
     return(await serializer.Deserialize <T>(await response.Content.ReadAsStringAsync()));
 }
Пример #17
0
 public RestfulieMarshaller(IRelationsFactory relationsFactory, IResourceSerializer serializer, IHypermediaInjector hypermedia)
 {
     this.relationsFactory = relationsFactory;
     this.serializer       = serializer;
     this.hypermedia       = hypermedia;
 }
 public JsonApiOutputFormatter(IResourceSerializer serializer = null)
 {
     _serializer = serializer ?? new ResourceSerializer();
 }
Пример #19
0
 /// <summary>
 /// Instantiates an <see cref="AzureFunctionWorkerInvoker"/>
 /// </summary>
 /// <param name="resourceSerializer"></param>
 /// <param name="environment"></param>
 public AzureFunctionWorkerInvoker(IResourceSerializer resourceSerializer, IEnvironment environment)
 {
     ResourceSerializer = resourceSerializer;
     Environment        = environment;
 }
 public void SetUp()
 {
     serializer = new JsonSerializer();   
 }
 public void SetUp()
 {
     serializer = new AtomPlusXmlSerializer();
 }
Пример #22
0
 public Driver(IResourceSerializer serializer, IHypermediaInjector injector, IResourceDeserializer deserializer)
 {
     Serializer = serializer;
     HypermediaInjector = injector;
     Deserializer = deserializer;
 }
Пример #23
0
 /// <summary>
 /// Instantiates a <see cref="FimsAzureWorker"/>
 /// </summary>
 /// <param name="worker"></param>
 /// <param name="resourceSerializer"></param>
 public FimsAzureWorker(IWorker worker, IResourceSerializer resourceSerializer)
 {
     Worker             = worker;
     ResourceSerializer = resourceSerializer;
 }
Пример #24
0
 /// <summary>
 /// Deserializes a response body to a single resource
 /// </summary>
 /// <param name="serializer"></param>
 /// <param name="type"></param>
 /// <param name="response"></param>
 /// <returns></returns>
 public static async Task <Resource> DeserializeResponseBodyToResource(this IResourceSerializer serializer, Type type, HttpResponseMessage response)
 {
     return(await serializer.Deserialize(await response.Content.ReadAsStringAsync()));
 }
Пример #25
0
 public Driver(IResourceSerializer serializer, IHypermediaInjector injector, IResourceDeserializer deserializer)
 {
     Serializer         = serializer;
     HypermediaInjector = injector;
     Deserializer       = deserializer;
 }
Пример #26
0
 /// <summary>
 /// Deserializes a response body to a collection of resources
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="serializer"></param>
 /// <param name="response"></param>
 /// <returns></returns>
 public static async Task <IEnumerable <T> > DeserializeResponseBodyToResourceCollection <T>(this IResourceSerializer serializer, HttpResponseMessage response)
     where T : Resource, new()
 {
     return(await Task.WhenAll(JArray.Parse(await response.Content.ReadAsStringAsync()).Select(t => serializer.Deserialize <T>(t.ToString()))));
 }
Пример #27
0
 public void RegisterResourceSerializer(string resType, IResourceSerializer serializer)
 {
     _resourceSerializers[resType] = serializer;
 }
 public JsonApiOutputFormatter(IResourceSerializer serializer = null)
 {
     _serializer = serializer ?? new ResourceSerializer();
 }
Пример #29
0
 /// <summary>
 /// Instantiates a <see cref="McmaAzureWorker"/>
 /// </summary>
 /// <param name="worker"></param>
 /// <param name="resourceSerializer"></param>
 /// <param name="environment"></param>
 public McmaAzureWorker(IWorker worker, IResourceSerializer resourceSerializer, IEnvironment environment)
 {
     Worker             = worker;
     ResourceSerializer = resourceSerializer;
     Environment        = environment;
 }
Пример #30
0
 public void SetUp()
 {
     serializer = new XmlSerializer();   
 }
Пример #31
0
 public void AddSerializer(string fileExtension, IResourceSerializer serializer)
 {
     serializers[fileExtension] = serializer;
 }