Exemplo n.º 1
0
        private ExtensionDescriptorEntry GetExtensionDescriptor(string locationPath, string extensionId, string extensionType, string manifestPath, bool manifestIsOptional)
        {
            return(_cacheManager.Get(manifestPath, context =>
            {
                if (!DisableMonitoring)
                {
                    Logger.Debug("监控虚拟路径 \"{0}\"", manifestPath);
                    context.Monitor(_applicationFolder.WhenPathChanges(manifestPath));
                }

                var manifestText = _applicationFolder.ReadFile(manifestPath);
                if (manifestText == null)
                {
                    if (manifestIsOptional)
                    {
                        manifestText = string.Format("Id: {0}", extensionId);
                    }
                    else
                    {
                        return null;
                    }
                }

                var entry = new ExtensionDescriptorEntry(new ExtensionDescriptor(), extensionId, extensionType, locationPath);
                ExtensionDescriptorSerializer.Parse(manifestText, entry, Logger, T);
                return entry;
            }));
        }
Exemplo n.º 2
0
        public PlacementFile Parse(string virtualPath)
        {
            return(_cacheManager.Get(virtualPath, context =>
            {
                if (!DisableMonitoring)
                {
                    Logger.Debug("监控虚拟路径 \"{0}\"", virtualPath);
                    context.Monitor(_webSiteFolder.WhenPathChanges(virtualPath));
                }

                var placementText = _webSiteFolder.ReadFile(virtualPath);
                return ParseImplementation(placementText);
            }));
        }
Exemplo n.º 3
0
        private IEnumerable <T> Init()
        {
            if (!_applicationFolder.FileExists(_filePath))
            {
                return(null);
            }

            var serializer = new XmlSerializer(typeof(T[]));
            var content    = _applicationFolder.ReadFile(_filePath);

            using (var reader = new StringReader(content))
            {
                var array = serializer.Deserialize(reader) as T[];
                return(array);
            }
        }