public override void Send(Action <string> success, Action <string> fail)
        {
            JulietLogger.Info(TAG, "Send");

            Dictionary <string, string> content = new Dictionary <string, string>
            {
                { this.usernameKey, this.usernameValue },
                { this.passwordKey, this.passwordValue }
            };

            foreach (var attribute in attributes)
            {
                string key   = attribute.Key;
                string value = (string)attribute.Value;

                content.Add(key, value);
            }

            MethodForm form = new MethodForm()
            {
                Method    = this.methodType,
                URL       = this.url,
                POSTLOGIN = content
            };

            JulietAPI.Instance.Request(form, success, fail);
        }
        public override void Send(Action <Texture> success, Action <string> fail)
        {
            JulietLogger.Info(TAG, "Send");

            MethodForm form = new MethodForm()
            {
                URL = this.url
            };

            JulietAPI.Instance.Request(form, success, fail);
        }
Beispiel #3
0
 public MethodMember(string name, string fullName, IType declaringType, Visibility visibility,
                     List <IType> parameters, IType returnType, bool isVirtual, MethodForm methodForm,
                     List <GenericParameter> genericParameters)
 {
     Name              = name;
     FullName          = fullName;
     DeclaringType     = declaringType;
     Visibility        = visibility;
     Parameters        = parameters;
     ReturnType        = returnType;
     IsVirtual         = isVirtual;
     MethodForm        = methodForm;
     GenericParameters = genericParameters;
 }
 public MethodMember(string name, string fullName, IType declaringType, Visibility visibility,
                     ITypeInstance <IType> returnType, bool isVirtual, MethodForm methodForm, bool isGeneric, bool isStub,
                     bool isCompilerGenerated)
 {
     Name                = name;
     FullName            = fullName;
     DeclaringType       = declaringType;
     Visibility          = visibility;
     _returnTypeInstance = returnType;
     IsVirtual           = isVirtual;
     MethodForm          = methodForm;
     IsGeneric           = isGeneric;
     IsStub              = isStub;
     IsCompilerGenerated = isCompilerGenerated;
 }
Beispiel #5
0
        private void AssignDependenciesToAccessedProperty(MethodMember methodMember,
                                                          MethodBody methodBody, MethodForm methodForm)
        {
            var matchFunction = GetMatchFunction(methodForm);

            matchFunction.RequiredNotNull();

            var accessedProperty =
                MatchToPropertyMember(methodMember.Name, methodMember.FullName, matchFunction);

            if (accessedProperty == null)
            {
                return;
            }

            var memberDependenciesToAdd = CreateMethodCallDependenciesForProperty(accessedProperty, methodBody)
                                          .ToList();

            methodBody.Instructions
            .Select(instruction => instruction.Operand)
            .OfType <FieldDefinition>()
            .ForEach(fieldDefinition =>
            {
                var backingField = FindMatchingField(fieldDefinition);
                accessedProperty.BackingField = backingField;
            });
            if (accessedProperty.BackingField != null && accessedProperty.BackingField.MemberDependencies.Count != 0)
            {
                memberDependenciesToAdd.AddRange(accessedProperty.BackingField.MemberDependencies);
            }

            if (methodForm == MethodForm.Getter)
            {
                accessedProperty.Getter?.MemberDependencies.AddRange(memberDependenciesToAdd);
            }
            else if (methodForm == MethodForm.Setter)
            {
                accessedProperty.Setter?.MemberDependencies.AddRange(memberDependenciesToAdd);
            }

            accessedProperty.MemberDependencies.AddRange(memberDependenciesToAdd);
        }
Beispiel #6
0
        private static MatchFunction GetMatchFunction(MethodForm methodForm)
        {
            MatchFunction matchFunction;

            switch (methodForm)
            {
            case MethodForm.Getter:
                matchFunction = new MatchFunction(RegexUtils.MatchGetPropertyName);
                break;

            case MethodForm.Setter:
                matchFunction = new MatchFunction(RegexUtils.MatchSetPropertyName);
                break;

            default:
                matchFunction = null;
                break;
            }

            return(matchFunction.RequiredNotNull());
        }
Beispiel #7
0
        static void Main(string[] args)
        {
            CmdLineArgs wmiArgs = null;

            try
            {
                wmiArgs = CmdLineArgs.ParseFromCmdLine(args);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, GetProgramTitle(), MessageBoxButtons.OK, MessageBoxIcon.Stop, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly);
            }
            using (var presenter = new WmiPresenter(wmiArgs))
                if (wmiArgs != null && presenter.ConnectToComputer())
                {
                    Application.EnableVisualStyles();
                    Application.SetCompatibleTextRenderingDefault(false);
                    switch (wmiArgs.StartCmd)
                    {
                    case CmdLineCommand.EditProperty:
                        using (var propForm = new EditPropertyForm(presenter))
                            propForm.ShowDialog();
                        break;

                    case CmdLineCommand.ExecuteMethod:
                        using (var methodForm = new MethodForm(presenter))
                        {
                            methodForm.PrepareForm();
                            methodForm.ShowDialog();
                        }
                        break;

                    default:
                        WmiClassList.Instance.EnumLocalMachineClasses();
                        Application.Run(new MainForm(presenter));
                        break;
                    }
                }
        }
Beispiel #8
0
        public void MethodOnClick(object sender, EventArgs e)
        {
            var menuItem = sender as ToolStripMenuItem;

            if (menuItem == null)
            {
                return;
            }
            var md = menuItem.Tag as MethodData;

            if (md == null)
            {
                return;
            }
            using (var form = new MethodForm(this))
            {
                form.WmiClass  = m_Class;
                form.WmiObject = WmiObject;
                form.WmiMethod = md;
                form.PrepareForm();
                form.ShowDialog();
            }
        }
        public override void SendWithImage(Action <string> success, Action <string> fail)
        {
            JulietLogger.Info(TAG, "Send ");

            MethodForm form = new MethodForm()
            {
                Method = MethodType.POST,
                URL    = this.url
            };

            WWWForm contentPost = new WWWForm();

            foreach (var attribute in attributes)
            {
                string key   = attribute.Key;
                string value = attribute.Value.ToString();

                JulietLogger.Info(TAG, "SendWithImage Key " + key + ", Value " + value);

                contentPost.AddField(key, value);
            }

            foreach (var attribute in attributeImages)
            {
                string    key   = attribute.Key;
                ImageType value = attribute.Value;

                JulietLogger.Info(TAG, "SendWithImage Key " + key + ", Filename " + value.filename + ", MineType " + value.mineType + ", Size " + value.imgBytes.Length);

                contentPost.AddBinaryData(key, value.imgBytes, value.filename, value.mineType);
            }

            form.POST_IMAGES = contentPost;

            JulietAPI.Instance.Request(form, success, fail);
        }
Beispiel #10
0
        private static object[] BuildAccessMethodTestData(Type classType, string propertyName, MethodForm methodForm)
        {
            if (classType == null)
            {
                throw new ArgumentNullException(nameof(classType));
            }

            if (propertyName == null)
            {
                throw new ArgumentNullException(nameof(propertyName));
            }

            if (methodForm != MethodForm.Getter && methodForm != MethodForm.Setter)
            {
                throw new InvalidInputException(
                          $"Given MethodForm {nameof(methodForm)} is not valid for this test. Please give the form of Getter or Setter.");
            }

            var baseClass        = Architecture.GetClassOfType(classType);
            var accessedProperty = baseClass.GetPropertyMembersWithName(propertyName).First();
            var accessorMethod   = methodForm == MethodForm.Getter ? accessedProperty.Getter : accessedProperty.Setter;

            return(new object[] { accessedProperty, accessorMethod });
        }
        public override void Send(Action <string> success, Action <string> fail)
        {
            JulietLogger.Info(TAG, "Send ");

            MethodForm form = new MethodForm()
            {
                Method = this.methodType,
                URL    = this.url
            };

            switch (this.methodType)
            {
            case MethodType.POST:

                Dictionary <string, string> contentPost = new Dictionary <string, string>();

                foreach (var attribute in attributes)
                {
                    string key   = attribute.Key;
                    string value = (string)attribute.Value;

                    contentPost.Add(key, value);
                }

                form.POST = contentPost;

                break;

            case MethodType.GET:

                form.GET = this.url;

                break;

            case MethodType.PUT:

                Dictionary <string, string> contentPut = new Dictionary <string, string>();

                foreach (var attribute in attributes)
                {
                    string key   = attribute.Key;
                    string value = (string)attribute.Value;

                    contentPut.Add(key, value);
                }

                string jsonPut = JsonUtility.ToJson(contentPut);

                form.PUT = System.Text.Encoding.UTF8.GetBytes(jsonPut);

                break;

            case MethodType.DELETE:

                form.DELETE = this.url;

                break;
            }

            JulietAPI.Instance.Request(form, success, fail);
        }