public ToxiproxyClient(HttpClient httpClient, Uri toxiproxyServerUri, IProxyHelper proxyHelper = null, IToxicHelper toxicHelper = null)
 {
     _httpClient         = httpClient ?? throw new ArgumentNullException(nameof(httpClient));
     _toxiproxyServerUri = toxiproxyServerUri ?? throw new ArgumentNullException(nameof(toxiproxyServerUri));
     _proxyHelper        = proxyHelper ?? new ProxyHelper(httpClient, toxiproxyServerUri);
     _toxicHelper        = toxicHelper ?? new ToxicHelper(httpClient, toxiproxyServerUri);
 }
Exemplo n.º 2
0
        public static void VA_Invoke1(dynamic vaProxy)
        {
            IProxyHelper proxy = ProxyHelperFactory.GetProxy(vaProxy);

            proxy.WriteToLog("Some magic is happening", "blue");
            proxy.WriteToLog(proxy.PluginPath(), "blue");
        }
Exemplo n.º 3
0
        public SmushSite()
        {
            InitializeComponent();

            _utils = new Utils();
            _commonUtils = new CommonUtils();
            _smushLogic = new SmushLogic();
            _proxyHelper = new ProxyHelper();

            // Set the default output directory
            txtOutputUrl.Text = @"C:\Temp";

            lblComplete.ToggleLabel(false);
            imgTick.ToggleImage(false);
            btnInfo.ToggleButton(false);
        }
Exemplo n.º 4
0
        public static IProxyHelper GetProxy(dynamic vaProxy)
        {
            ApiInfo apiInfo      = new ApiInfo(vaProxy);
            string  proxyVersion = apiInfo.ProxyVersion.ToString();

            // TODO: Replace with an abstraction to decouple factory from concrete implementations
            IProxyHelper proxy = null;

            switch (proxyVersion)
            {
            case "1.0.0.0":
                proxy = new ProxyHelperV4(apiInfo.Proxy);
                break;

            default:
                throw new NotSupportedException("Unknown API version detected. Plugin initialization unsuccessful.");
            }

            return(proxy);
        }
Exemplo n.º 5
0
        public async Task Invoke(HttpContext context)
        {
            IProxyHelper _proxyHelper = context.GetInstanceFromContext <IProxyHelper>();

            if (!_proxyHelper.isProxyRequest())
            {
                await _next(context);
            }
            else
            {
                try
                {
                    await _proxyHelper.processProxyRequestStreamAsync();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    await HandleExceptionAsync(context, ex);
                }
            }
        }
Exemplo n.º 6
0
 public Main()
 {
     InitializeComponent();
     _proxyHelper = new ProxyHelper();
 }
Exemplo n.º 7
0
 public GroupProxy(IHttpClient client, IAuthenticationService authenticationService, IJson json, IProxyHelper proxyHelper) : base(json)
 {
     _client = client;
     _authenticationService = authenticationService;
     _proxyHelper           = proxyHelper;
 }
Exemplo n.º 8
0
 public AuthenticationProxy(IHttpClient httpClient, IJson json, IProxyHelper proxyHelper) : base(json)
 {
     _httpClient  = httpClient;
     _proxyHelper = proxyHelper;
 }
Exemplo n.º 9
0
        protected void HandleValueHolderContainer(IValueHolderContainer vhc, RelationMember[] relationMembers, IObjRef[][] relations)
        {
            ICacheHelper cacheHelper = this.CacheHelper;
            ICacheIntern parent      = this.Parent;
            IProxyHelper proxyHelper = this.ProxyHelper;

            for (int relationIndex = relationMembers.Length; relationIndex-- > 0;)
            {
                RelationMember relationMember    = relationMembers[relationIndex];
                IObjRef[]      relationsOfMember = relations[relationIndex];

                if (!CascadeLoadMode.EAGER.Equals(relationMember.CascadeLoadMode))
                {
                    if (ValueHolderState.INIT != vhc.Get__State(relationIndex))
                    {
                        // Update ObjRef information within the entity and do nothing else
                        vhc.Set__ObjRefs(relationIndex, relationsOfMember);
                        continue;
                    }
                }
                // We can safely access to relation if we want to
                if (relationsOfMember == null)
                {
                    // Reset value holder state because we do not know the content currently
                    vhc.Set__Uninitialized(relationIndex, null);
                    continue;
                }
                Object relationValue = relationMember.GetValue(vhc);
                if (relationsOfMember.Length == 0)
                {
                    if (!relationMember.IsToMany)
                    {
                        if (relationValue != null)
                        {
                            // Relation has to be flushed
                            relationMember.SetValue(vhc, null);
                        }
                    }
                    else
                    {
                        if (relationValue != null)
                        {
                            // Reuse existing collection
                            ListUtil.ClearList(relationValue);
                        }
                        else
                        {
                            // We have to create a new empty collection
                            relationValue = cacheHelper.CreateInstanceOfTargetExpectedType(relationMember.RealType, relationMember.ElementType);
                            relationMember.SetValue(vhc, relationValue);
                        }
                    }
                    continue;
                }
                // So we know the new content (which is not empty) and we know that the current content is already initialized
                // Now we have to refresh the current content eagerly

                // load entities as if we were an "eager valueholder" here
                IList <Object> potentialNewItems = parent.GetObjects(new List <IObjRef>(relationsOfMember), this, CacheDirective.None);
                if (OverwriteToManyRelations)
                {
                    Object newRelationValue = cacheHelper.ConvertResultListToExpectedType(potentialNewItems, relationMember.RealType,
                                                                                          relationMember.ElementType);
                    // Set new to-many-relation, even if there has not changed anything in its item content
                    relationMember.SetValue(vhc, newRelationValue);
                    continue;
                }
                IList <Object> relationItems = ListUtil.AnyToList(relationValue);

                bool diff = (relationItems.Count != potentialNewItems.Count);
                if (!diff)
                {
                    for (int b = potentialNewItems.Count; b-- > 0;)
                    {
                        if (!Object.ReferenceEquals(potentialNewItems[b], relationItems[b]))
                        {
                            diff = true;
                            break;
                        }
                    }
                }
                if (!diff)
                {
                    // Nothing to do
                    continue;
                }
                if (relationValue != null && relationMember.IsToMany)
                {
                    // Reuse existing collection
                    ListUtil.ClearAndFillList(relationValue, relationItems);
                }
                else
                {
                    // We have to create a new empty collection or replace the to-one value
                    Object newRelationValue = cacheHelper.ConvertResultListToExpectedType(potentialNewItems, relationMember.RealType,
                                                                                          relationMember.ElementType);
                    relationMember.SetValue(vhc, newRelationValue);
                }
            }
        }