/// <summary> /// Initializes a new instance of the <see cref="VisualStudio"/> class. /// </summary> /// <param name="value">The value.</param> public VisualStudio(UserMember <Variable> value) { this.value = value; first = UserMember.Create(() => Value.GetField("_Myfirst")); last = UserMember.Create(() => Value.GetField("_Mylast")); end = UserMember.Create(() => Value.GetField("_Myend")); }
public static void RemovePermission(Type classType, string identifier, string userName) { if (logger.IsDebugEnabled) { logger.DebugFormat("Finding entity permission: {0} {1}", classType.Name, identifier); } EntityPermission ep = ControllerManager.EntityPermission.Find(classType.Name, identifier); UserMember um = ControllerManager.UserMember.GetById(MembershipHelper.GetUser(userName).UserId); if (ep != null) { if (ep.Users.Contains(um)) { if (logger.IsDebugEnabled) { logger.DebugFormat("Removing entity permission: {0} {1}", classType.Name, identifier); } ep.Users.Remove(um); ControllerManager.EntityPermission.Save(ep); // Remove any cached information string cachedKey = string.Format("LISTIDENTIFIERS_{0}_{1}_{2}", classType.Name.ToString(), PermissionAction.Create.ToString(), MembershipHelper.GetUser(userName).UserId); object result = CacheManager.ExpireItem(cachedKey); } } }
/// <summary> /// Initializes a new instance of the <see cref="VisualStudio"/> class. /// </summary> /// <param name="variable">The variable.</param> /// <param name="savedData">Data returned from VerifyCodeType function.</param> public VisualStudio(Variable variable, object savedData) { ExtractedData data = (ExtractedData)savedData; ulong address = variable.GetPointerAddress(); list = UserMember.Create(() => new list <pair <TKey, TValue> >(Variable.Create(data.ListCodeType, address + (uint)data.ListOffset))); }
/// <summary> /// Executes the add user member to a directory role scenario. /// </summary> protected override void RunScenario() { // get customer user Id. string selectedCustomerUserId = this.ObtainCustomerUserId("Enter the ID of the customer user to get details for creating user member"); // get customer Id of the entered customer user. string selectedCustomerId = this.ObtainCustomerId("Enter the ID of the customer whose customer user details should be used for user member"); // get directory role Id. string selectedDirectoryRoleId = this.ObtainDirectoryRoleId("Enter the ID of the directory role"); var partnerOperations = this.Context.UserPartnerOperations; this.Context.ConsoleHelper.StartProgress("Getting Customer User Details"); // getting customer user details var selectedCustomer = partnerOperations.Customers.ById(selectedCustomerId).Users.ById(selectedCustomerUserId).Get(); this.Context.ConsoleHelper.StopProgress(); UserMember userMemberToAdd = new UserMember() { UserPrincipalName = selectedCustomer.UserPrincipalName, DisplayName = selectedCustomer.DisplayName, Id = selectedCustomer.Id }; this.Context.ConsoleHelper.StartProgress("Adding user member to directory roles"); // Add this customer user to the selected directory role. var userMemberAdded = partnerOperations.Customers.ById(selectedCustomerId).DirectoryRoles.ById(selectedDirectoryRoleId).UserMembers.Create(userMemberToAdd); this.Context.ConsoleHelper.StopProgress(); Console.WriteLine("Below Customer user was added to directory role with id: {0}", selectedDirectoryRoleId); this.Context.ConsoleHelper.WriteObject(userMemberAdded, "Added Customer User Member to Directory Role Details"); }
/// <summary> /// Initializes a new instance of the <see cref="ClangLibCpp"/> class. /// </summary> /// <param name="variable">The variable.</param> /// <param name="savedData">Data returned from VerifyCodeType function.</param> public ClangLibCpp(Variable variable, object savedData) { data = (ExtractedData)savedData; address = variable.GetPointerAddress(); ulong stringAddress = data.Process.ReadPointer(address + (uint)data.PointerOffset); bool localData = stringAddress == 0; if (localData) { stringAddress = address + (uint)data.BufferOffset; } bool bigEndian = true; // TODO: if (localData) { length = data.ReadShortDataLength(address); if (bigEndian) { length = length >> 1; } } else { length = data.ReadLongDataLength(address); } if (localData) { reserved = data.BufferLength; } else { reserved = data.ReadCapacity(address); } text = UserMember.Create(() => data.Process.ReadString(stringAddress, data.CharSize, length)); }
/// <summary> /// Initializes a new instance of the <see cref="LibStdCpp6"/> class. /// </summary> /// <param name="variable">The variable.</param> public LibStdCpp6(Variable variable) { length = UserMember.Create(() => (int)variable.GetField("_M_string_length")); text = UserMember.Create(() => variable.GetField("_M_dataplus").GetField("_M_p")); localBuffer = UserMember.Create(() => variable.GetField("_M_local_buf")); capacity = UserMember.Create(() => (int)variable.GetField("_M_allocated_capacity")); }
/// <summary> /// Initializes a new instance of the <see cref="LibStdCpp6"/> class. /// </summary> /// <param name="variable">The variable.</param> public LibStdCpp6(Variable variable) { // Initialize members pointer = UserMember.Create(() => variable.GetField("_M_ptr")); element = UserMember.Create(() => pointer.Value.DereferencePointer().CastAs <T>()); sharedCount = UserMember.Create(() => (int)variable.GetField("_M_refcount").GetField("_M_pi").GetField("_M_use_count")); weakCount = UserMember.Create(() => (int)variable.GetField("_M_refcount").GetField("_M_pi").GetField("_M_weak_count")); isCreatedWithMakeShared = UserMember.Create(() => { CodeType codeType = variable.GetField("_M_refcount").GetField("_M_pi").DowncastInterface().GetCodeType(); if (codeType.Name.StartsWith("std::_Sp_counted_ptr_inplace<")) { return(true); } if (!codeType.Name.StartsWith("std::_Sp_counted_deleter<")) { return(false); } try { codeType = (CodeType)codeType.TemplateArguments[1]; return(codeType.Name.StartsWith("std::__shared_ptr<") && codeType.Name.Contains("::_Deleter<")); } catch { return(false); } }); }
/// <summary> /// Initializes a new instance of the <see cref="item" /> class. /// </summary> /// <param name="variable">The variable.</param> /// <param name="pairCodeType">The key value pair code type.</param> public item(Variable variable, CodeType pairCodeType) { left = UserMember.Create(() => { Variable field = variable.GetField("_M_left"); return(field.IsNullPointer() ? null : new item(field, pairCodeType)); }); right = UserMember.Create(() => { Variable field = variable.GetField("_M_right"); return(field.IsNullPointer() ? null : new item(field, pairCodeType)); }); parent = UserMember.Create(() => { Variable field = variable.GetField("_M_parent"); return(field.IsNullPointer() ? null : new item(field, pairCodeType)); }); pair = UserMember.Create(() => { // Since we cannot get field with address to key value pair, do pointer arithmetic to find address ulong pairAddress = variable.GetPointerAddress() + variable.GetCodeType().ElementType.Size; return(new pair <TKey, TValue>(Variable.Create(pairCodeType, pairAddress))); }); }
/// <summary> /// Initializes a new instance of the <see cref="VisualStudio"/> class. /// </summary> /// <param name="value">The value variable.</param> public VisualStudio(UserMember <Variable> value) { this.value = value; length = UserMember.Create(() => (int)Value.GetField("_Mysize")); reserved = UserMember.Create(() => (int)Value.GetField("_Myres")); text = UserMember.Create(GetText); }
/// <summary> /// Initializes a new instance of the <see cref="LibStdCpp6" /> class. /// </summary> /// <param name="variable">The variable.</param> public LibStdCpp6(Variable variable) { value = UserMember.Create(() => variable.GetField("_M_impl")); first = UserMember.Create(() => Value.GetField("_M_start")); last = UserMember.Create(() => Value.GetField("_M_finish")); end = UserMember.Create(() => Value.GetField("_M_end_of_storage")); }
/// <summary> /// Executes the operations associated with the cmdlet. /// </summary> public override void ExecuteCmdlet() { UserId.AssertNotEmpty(nameof(UserId)); RoleId.AssertNotEmpty(nameof(RoleId)); CustomerUser user = GetUserById(CustomerId, UserId); try { UserMember newMember = new UserMember() { UserPrincipalName = user.UserPrincipalName, DisplayName = user.DisplayName, Id = user.Id }; Partner.Customers[CustomerId].DirectoryRoles[RoleId].UserMembers.Create(newMember); WriteObject(true); } catch (PSPartnerException ex) { throw new PSPartnerException($"Error adding user {UserId} to role {RoleId}", ex); } finally { user = null; } }
/// <summary> /// Initializes a new instance of the <see cref="item"/> class. /// </summary> /// <param name="variable">The variable.</param> public item(Variable variable) { isnil = UserMember.Create(() => (bool)variable.GetField("_Isnil")); left = UserMember.Create(() => new item(variable.GetField("_Left"))); right = UserMember.Create(() => new item(variable.GetField("_Right"))); parent = UserMember.Create(() => new item(variable.GetField("_Parent"))); pair = UserMember.Create(() => new pair <TKey, TValue>(variable.GetField("_Myval"))); }
/// <summary> /// Initializes a new instance of the <see cref="VisualStudio"/> class. /// </summary> /// <param name="variable">The variable.</param> /// <param name="savedData">Data returned from VerifyCodeType function.</param> public VisualStudio(Variable variable, object savedData) { data = (ExtractedData)savedData; address = variable.GetPointerAddress(); length = data.ReadSize(address); reserved = data.ReadReserved(address); text = UserMember.Create(() => GetText()); }
/// <summary> /// Initializes a new instance of the <see cref="ClangLibCpp"/> class. /// </summary> /// <param name="variable">The variable.</param> public ClangLibCpp(Variable variable) { // Initialize members pointer = UserMember.Create(() => variable.GetField("__ptr_")); element = UserMember.Create(() => pointer.Value.DereferencePointer().CastAs <T>()); sharedCount = UserMember.Create(() => (int)variable.GetField("__cntrl_").GetField("__shared_owners_") + 1); weakCount = UserMember.Create(() => (int)variable.GetField("__cntrl_").GetField("__shared_weak_owners_") + 1); isCreatedWithMakeShared = UserMember.Create(() => variable.GetField("__cntrl_").DowncastInterface().GetCodeType().Name.StartsWith("std::__1::__shared_ptr_emplace<")); }
/// <summary> /// Initializes a new instance of the <see cref="SharedPtrBase"/> class. /// </summary> /// <param name="variable">The variable.</param> /// <param name="savedData">Data returned from VerifyCodeType function.</param> public SharedPtrBase(Variable variable, object savedData) { data = (ExtractedData)savedData; ulong address = variable.GetPointerAddress(); pointerAddress = data.Process.ReadPointer(address + (uint)data.PointerOffset); referenceCountAddress = data.Process.ReadPointer(address + (uint)data.ReferenceCountPointerOffset); isCreatedWithMakeShared = UserMember.Create(() => data.TestCreatedWithMakeShared(Variable.Create(data.ReferenceCountCodeType, referenceCountAddress).DowncastInterface().GetCodeType())); }
/// <summary> /// Initializes a new instance of the <see cref="VisualStudio"/> class. /// </summary> /// <param name="variable">The variable.</param> public LibStdCpp6(Variable variable) { // Initialize members pointer = UserMember.Create(() => variable.GetField("_M_ptr")); element = UserMember.Create(() => pointer.Value.DereferencePointer().CastAs <T>()); sharedCount = UserMember.Create(() => (int)variable.GetField("_M_refcount").GetField("_M_pi").GetField("_M_use_count")); weakCount = UserMember.Create(() => (int)variable.GetField("_M_refcount").GetField("_M_pi").GetField("_M_weak_count")); isCreatedWithMakeShared = UserMember.Create(() => variable.GetField("_M_refcount").GetField("_M_pi").DowncastInterface().GetCodeType().Name.StartsWith("std::_Sp_counted_ptr_inplace<")); }
/// <summary> /// Initializes a new instance of the <see cref="VisualStudio"/> class. /// </summary> /// <param name="variable">The variable.</param> public VisualStudio(Variable variable) { // Initialize members pointer = UserMember.Create(() => variable.GetField("_Ptr")); element = UserMember.Create(() => pointer.Value.DereferencePointer().CastAs <T>()); sharedCount = UserMember.Create(() => (int)variable.GetField("_Rep").GetField("_Uses")); weakCount = UserMember.Create(() => (int)variable.GetField("_Rep").GetField("_Weaks")); isCreatedWithMakeShared = UserMember.Create(() => variable.GetField("_Rep").DowncastInterface().GetCodeType().Name.StartsWith("std::_Ref_count_obj<")); }
/// <summary> /// Initializes a new instance of the <see cref="LibStdCpp6"/> class. /// </summary> /// <param name="variable">The variable.</param> public LibStdCpp6(Variable variable) { CodeType codeType = variable.GetCodeType(); CodeType templateCodeType = (CodeType)codeType.TemplateArguments[0]; CodeType intCodeType = (CodeType)codeType.GetFieldType("_M_impl").GetFieldType("_M_node").GetFieldType("_M_storage").TemplateArguments[0]; count = UserMember.Create(() => new list <int> .LibStdCpp6.item(variable.GetField("_M_impl").GetField("_M_node"), intCodeType).Value); head = UserMember.Create(() => new item(variable.GetField("_M_impl").GetField("_M_node"), templateCodeType).Next); }
protected void grdUsers_DataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow && e.Row.DataItem != null) { UserMember u = e.Row.DataItem as UserMember; e.Row.Cells[2].Text = u.UserProfile.FirstName; e.Row.Cells[3].Text = u.UserProfile.LastName; } }
/// <summary> /// Initializes a new instance of the <see cref="LibStdCpp6_NoAbi"/> class. /// </summary> /// <param name="variable">The variable.</param> /// <param name="savedData">Data returned from VerifyCodeType function.</param> public LibStdCpp6_NoAbi(Variable variable, object savedData) { data = (ExtractedData)savedData; address = variable.GetPointerAddress(); ulong stringAddress = data.Process.ReadPointer(address + (uint)data.PointerOffset); length = data.ReadLength(stringAddress); reserved = data.ReadCapacity(stringAddress); text = UserMember.Create(() => data.Process.ReadString(stringAddress, data.CharSize, length)); }
/// <summary> /// Initializes a new instance of the <see cref="LibStdCpp6_NoAbi"/> class. /// </summary> /// <param name="variable">The variable.</param> public LibStdCpp6_NoAbi(Variable variable) { CodeType codeType = variable.GetCodeType(); CodeType _Rep = CodeType.Create($"{codeType.Name}::_Rep", codeType.Module); header = UserMember.Create(() => text.Value.AdjustPointer(-(int)_Rep.Size).CastAs(_Rep)); length = UserMember.Create(() => (int)header.Value.GetField("_M_length")); text = UserMember.Create(() => variable.GetField("_M_dataplus").GetField("_M_p")); capacity = UserMember.Create(() => (int)header.Value.GetField("_M_capacity")); }
/// <summary> /// Initializes a new instance of the <see cref="LibStdCpp6"/> class. /// </summary> /// <param name="variable">The variable.</param> public LibStdCpp6(Variable variable) { value = UserMember.Create(() => { Variable t = variable.GetField("_M_t"); pairCodeType = (CodeType)t.GetCodeType().TemplateArguments[1]; return(t.GetField("_M_impl")); }); size = UserMember.Create(() => (int)Value.GetField("_M_node_count")); root = UserMember.Create(() => new item(Value.GetField("_M_header"), pairCodeType).Parent); }
/// <summary> /// Initializes a new instance of the <see cref="pair{TFirst, TSecond}"/> class. /// </summary> /// <param name="variable">The variable.</param> /// <exception cref="WrongCodeTypeException">std::pair</exception> public pair(Variable variable) { // Verify code type if (!VerifyCodeType(variable.GetCodeType())) { throw new WrongCodeTypeException(variable, nameof(variable), "std::pair"); } // Initialize members first = UserMember.Create(() => variable.GetField("first").CastAs <TFirst>()); second = UserMember.Create(() => variable.GetField("second").CastAs <TSecond>()); }
/// <summary> /// Initializes a new instance of the <see cref="list{T}"/> class. /// </summary> /// <param name="variable">The variable.</param> public list(Variable variable) { // Verify code type if (!VerifyCodeType(variable.GetCodeType())) { throw new Exception("Wrong code type of passed variable " + variable.GetCodeType().Name); } // Initialize members value = UserMember.Create(() => variable.GetField("_Mypair").GetField("_Myval2")); length = UserMember.Create(() => (int)Value.GetField("_Mysize")); head = UserMember.Create(() => new item(Value.GetField("_Myhead"))); }
/// <summary> /// Initializes a new instance of the <see cref="basic_string"/> class. /// </summary> /// <param name="variable">The variable.</param> public basic_string(Variable variable) { // Verify code type if (!VerifyCodeType(variable.GetCodeType())) { throw new Exception("Wrong code type of passed variable " + variable.GetCodeType().Name); } // Initialize members value = UserMember.Create(() => variable.GetField("_Mypair").GetField("_Myval2")); length = UserMember.Create(() => (int)Value.GetField("_Mysize")); reserved = UserMember.Create(() => (int)Value.GetField("_Myres")); text = UserMember.Create(GetText); }
/// <summary> /// Initializes a new instance of the <see cref="vector{T}"/> class. /// </summary> /// <param name="variable">The variable.</param> public vector(Variable variable) { // Verify code type if (!VerifyCodeType(variable.GetCodeType())) { throw new Exception("Wrong code type of passed variable " + variable.GetCodeType().Name); } // Initialize members value = UserMember.Create(() => variable.GetField("_Mypair").GetField("_Myval2")); first = UserMember.Create(() => Value.GetField("_Myfirst")); last = UserMember.Create(() => Value.GetField("_Mylast")); end = UserMember.Create(() => Value.GetField("_Myend")); }
/// <summary> /// Gets the value that is associated with the specified key. /// </summary> /// <param name="key">The key to locate.</param> /// <param name="value">When this method returns, the value associated with the specified key, if the key is found; otherwise, the default value for the type of the <paramref name="value" /> parameter. This parameter is passed uninitialized.</param> /// <returns> /// true if the object that implements the <see cref="T:System.Collections.Generic.IReadOnlyDictionary`2" /> interface contains an element that has the specified key; otherwise, false. /// </returns> public bool TryGetValue(TKey key, out TValue value) { // As we don't have comparer (for sorted tree), we will need to scan all items foreach (KeyValuePair <TKey, TValue> kvp in Enumerate()) { if (kvp.Key.Equals(key)) { value = kvp.Value; return(true); } } value = default(TValue); return(false); }
/// <summary> /// Initializes a new instance of the <see cref="shared_ptr{T}"/> class. /// </summary> /// <param name="variable">The variable.</param> public shared_ptr(Variable variable) { // Verify code type if (!VerifyCodeType(variable.GetCodeType())) { throw new WrongCodeTypeException(variable, nameof(variable), "std::shared_ptr"); } // Initialize members pointer = UserMember.Create(() => variable.GetField("_Ptr")); element = UserMember.Create(() => pointer.Value.DereferencePointer().CastAs <T>()); sharedCount = UserMember.Create(() => (int)variable.GetField("_Rep").GetField("_Uses")); weakCount = UserMember.Create(() => (int)variable.GetField("_Rep").GetField("_Weaks")); isCreatedWithMakeShared = UserMember.Create(() => variable.GetField("_Rep").DowncastInterface().GetCodeType().Name.StartsWith("std::_Ref_count_obj<")); }
/// <summary> /// Adds customer user to a directory role. /// </summary> /// <param name="newEntity">The user to add.</param> /// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param> /// <returns>The customer directory role user member.</returns> public async Task <UserMember> CreateAsync(UserMember newEntity, CancellationToken cancellationToken = default) { newEntity.AssertNotNull(nameof(newEntity)); return(await Partner.ServiceClient.PostAsync <UserMember, UserMember>( new Uri( string.Format( CultureInfo.InvariantCulture, $"/{PartnerService.Instance.ApiVersion}/{PartnerService.Instance.Configuration.Apis.AddUserToCustomerDirectoryRole.Path}", Context.Item1, Context.Item2), UriKind.Relative), newEntity, cancellationToken).ConfigureAwait(false)); }
/// <summary> /// Executes the operations associated with the cmdlet. /// </summary> public override void ExecuteCmdlet() { UserId.AssertNotEmpty(nameof(UserId)); RoleId.AssertNotEmpty(nameof(RoleId)); CustomerUser user = GetUserById(CustomerId, UserId); UserMember newMember = new UserMember() { UserPrincipalName = user.UserPrincipalName, DisplayName = user.DisplayName, Id = user.Id }; Partner.Customers[CustomerId].DirectoryRoles[RoleId].UserMembers.CreateAsync(newMember).GetAwaiter().GetResult(); WriteObject(true); }
/// <summary> /// Initializes a new instance of the <see cref="VisualStudio"/> class. /// </summary> /// <param name="value">The value variable.</param> public VisualStudio(UserMember<Variable> value) { this.value = value; length = UserMember.Create(() => (int)Value.GetField("_Mysize")); reserved = UserMember.Create(() => (int)Value.GetField("_Myres")); text = UserMember.Create(GetText); }