コード例 #1
0
        public void OnRegistration(ICollection <IAuthorizationHandler> handlers)
        {
            var methId = GetScriptMethod("ПриРегистрацииОбработчиков", "OnHandlersRegistration");

            if (methId == -1)
            {
                return;
            }

            ArrayImpl newClasses = new ArrayImpl();
            var       args       = new IValue[] { newClasses };

            CallScriptMethod(methId, args);

            foreach (var classPath in newClasses.Select(x => x.AsString()))
            {
                var fInfo = _filesystem.GetFileInfo(classPath);
                if (!fInfo.Exists || fInfo.IsDirectory)
                {
                    throw new InvalidOperationException($"Module {classPath} is not found");
                }

                var codeSource = new FileInfoCodeSource(fInfo);
                var instance   = ScriptedAuthorizationHandler.CreateInstance(codeSource, _runtime);

                handlers.Add(instance);
            }
        }
コード例 #2
0
        public IWebProxy GetProxy(string protocol)
        {
            var       settings = GetSettings(protocol);
            IWebProxy returnProxy;

            if (settings.proxy == null)
            {
                if (String.IsNullOrEmpty(settings.server))
                {
                    throw new RuntimeException("Не заданы настройки прокси-сервера для протокола, используемого в запросе");
                }

                var wp = new WebProxy(settings.server, settings.port);
                wp.Credentials        = settings.creds;
                wp.BypassList         = _bypassProxyOnAddresses.Select(x => x.AsString()).ToArray();
                wp.BypassProxyOnLocal = _bypassLocal;
                settings.proxy        = wp;
                returnProxy           = wp;
            }
            else
            {
                returnProxy = _proxies[protocol].proxy;
            }

            return(returnProxy);
        }
コード例 #3
0
        public void Set(string protocol, string server, int port = 0, string username = "", string password = "", bool useOSAuthentication = true)
        {
            protocol = protocol.ToLower();
            if (!ProtocolNameIsValid(protocol))
            {
                throw RuntimeException.InvalidArgumentValue();
            }

            var builderServer = new UriBuilder(server);

            if (builderServer.Scheme.Equals(string.Empty))
            {
                builderServer.Scheme = protocol;
            }

            if (port != 0)
            {
                builderServer.Port = port;
            }

            var proxyCredentials = useOSAuthentication ? CredentialCache.DefaultNetworkCredentials :
                                   GetBasicCredential(builderServer.Uri, username, password);

            _proxies[protocol] = new WebProxy(builderServer.Uri, _bypassLocal,
                                              _bypassProxyOnAddresses?.Select(x => x.AsString()).ToArray() ?? new string[] {}, proxyCredentials);
        }
コード例 #4
0
ファイル: ValueListImpl.cs プロジェクト: shtorin/OneScript
 public void LoadValues(ArrayImpl source)
 {
     Clear();
     _items.AddRange(source.Select(x => new ValueListItem()
     {
         Value = x
     }));
 }
コード例 #5
0
        public IWebProxy GetProxy()
        {
            if (!_isDefault)
            {
                var wp = (WebProxy)_proxy;
                wp.Credentials        = _creds;
                wp.BypassList         = _bypassProxyOnAddresses.Select(x => x.AsString()).ToArray();
                wp.BypassProxyOnLocal = _bypassLocal;
            }

            return(_proxy);
        }
コード例 #6
0
 public DirectorySearcherImpl(DirectoryEntryImpl directoryEntry, string filter, ArrayImpl propsToLoad, SearchScopeImpl searchScope)
 {
     _directorySearcher = new DirectorySearcher(directoryEntry._directoryEntry, filter, propsToLoad.Select(p => p.AsString()).ToArray(), SearchScopeConverter.ToSearchScope(searchScope));
     SearchRoot         = directoryEntry;
     PropertiesToLoad   = propsToLoad;
     SearchScope        = searchScope;
 }