/// <summary> /// Initializes a new instance of the <see cref = "CacheKey" /> class. /// </summary> /// <param name = "target">Target element. This is either target type or target method for invocation types.</param> /// <param name = "type">The type of the proxy. This is base type for invocation types.</param> /// <param name = "interfaces">The interfaces.</param> /// <param name = "options">The options.</param> private CacheKey(MemberWrapper target, Type type, Type[] interfaces, ProxyGenerationOptions options) { this.target = target; this.type = type; this.interfaces = interfaces ?? TypeExtender.EmptyTypes; this.options = options; }
public void SaveExpandedRows(ref RowTree rows) { CurrencyManager source = grid.CurrencyManager; if (source == null) { return; // No data source. } if (rows == null) { rows = new RowTree(null, null); } RowTree parent = rows; int currentLevel = 0; for (int index = 0; index < source.List.Count; index++) { MemberWrapper wrapper = (MemberWrapper)source.List[index]; Debug.Assert(wrapper != null, "wrapper != null"); CellEditorData cellData = (CellEditorData)wrapper.Tag; Debug.Assert(cellData != null, "cellData != null"); while (cellData.Level < currentLevel) { Debug.Assert(parent.Parent != null, "parent.Parent != null"); parent = parent.Parent; currentLevel--; } if (cellData.IsExpanded) { RowTree current = parent[wrapper.Name]; if (current == null) { current = new RowTree(wrapper.Name, parent); parent.Add(current); } parent = current; currentLevel++; } else if (parent[wrapper.Name] != null) { parent.Remove(wrapper.Name); } } }
/// <summary> /// Returns the ReflectedVariable for the given type. /// </summary> /// <param name="memberInfo">The MemberWrapper to use in the ReflectedVariable.</param> /// <param name="instance">The instance to use in the ReflectedVariable.</param> /// <returns>The matching ReflectedVariable or null if no mapping exists.</returns> public static ReflectedVariable createVariable(MemberWrapper memberInfo, Object instance) { Type inType = memberInfo.getWrappedType(); if (typeMapping.ContainsKey(inType)) { return(typeMapping[inType](memberInfo, instance)); } else if (inType.IsEnum()) { return(new EnumReflectedVariable(memberInfo, instance)); } else { return(null); } }
/// <summary> /// /// </summary> /// <typeparam name="T"></typeparam> /// <param name="type"></param> /// <param name="includeNonPublicAccessor"></param> /// <returns>A List Of Advance Members Of T</returns> public static List <MemberWrapper> GetMemberWrappers(Type type, bool includeNonPublicAccessor) { type.IsNullThrow(nameof(type)); // ReSharper disable once AssignNullToNotNullAttribute var key = $"{type.FullName}{includeNonPublicAccessor}"; lock (Lock) { // https://stackoverflow.com/questions/9382681/what-is-more-efficient-dictionary-trygetvalue-or-containskeyitem var membersAlreadyExist = Lookup.TryGetValue(key, out var cachedMembers); if (membersAlreadyExist) { return(cachedMembers); } var list = new List <MemberWrapper>() { }; if (UseRuntimeReflection) { type.GetProperties().ForEach(delegate(PropertyInfo property) { var advance = new MemberWrapper(property) { }; list.Add(advance); }); } else { var accessor = TypeAccessor.Create(type, includeNonPublicAccessor); var set = accessor.GetMembers(); for (var index = 0; index < set.Count; index++) { var member = set[index]; var advance = new MemberWrapper(member) { }; list.Add(advance); } } Lookup.Add(key, list); return(list); } }
/// <summary> /// /// </summary> /// <typeparam name="T"></typeparam> /// <returns>A List Of Advance Members Of T</returns> public static List <MemberWrapper> GetMemberWrappers <T>(T dynamicObject) where T : IDynamicMetaObjectProvider { var list = new List <MemberWrapper>() { }; var dynamicObjectHelper = new DynamicObjectHelper(); dynamicObjectHelper.GetDynamicMemberNameAndValues(dynamicObject).ForEach( delegate(KeyValuePair <string, object> pair) { var advance = new MemberWrapper(pair.Key, pair.Value == null ? typeof(object) : pair.Value.GetType()) { }; list.Add(advance); }); return(list); }
public IHttpActionResult ProfilePhoto() { string url = ""; DateTime?modifiedOn; bool gender; using (bkContext context = new bkContext()) { Member member = context.Members.FirstOrDefault(x => x.MemberID == LoggedInMemberId); if (member != null) { gender = member.Gender; modifiedOn = member.ModifiedOn; url = MemberWrapper.ProfilePhoto(LoggedInMemberId, gender, modifiedOn); } } return(Ok(url)); }
/// <summary> /// Copy source into destination. /// </summary> /// <param name="source">The source dictionary.</param> /// <param name="destination">The destination dictionary.</param> /// <param name="info">The member wrapper to set data.</param> internal override void copyValue(object source, object destination, MemberWrapper info, CopyFilter filter) { IDictionary <Key, Value> sourceDictionary = (IDictionary <Key, Value>)info.getValue(source, null); if (sourceDictionary != null) { Type dictionaryType = sourceDictionary.GetType(); IDictionary <Key, Value> destDictionary = (IDictionary <Key, Value>)System.Activator.CreateInstance(dictionaryType); Type[] keyValueTypes = dictionaryType.GetGenericArguments(); MemberCopier keyCopier = MemberCopier.getCopyClass(keyValueTypes[0]); MemberCopier valueCopier = MemberCopier.getCopyClass(keyValueTypes[1]); foreach (Key key in sourceDictionary.Keys) { Key copiedKey = (Key)keyCopier.createCopy(key, filter); Value copiedValue = (Value)valueCopier.createCopy(sourceDictionary[key], filter); destDictionary.Add(copiedKey, copiedValue); } info.setValue(destination, destDictionary, null); } }
private bool ShouldShowButton(MemberWrapper member, Rectangle bounds, Graphics graphics) { // Show the edit button if we have an editor for this type and it's not the default editor // (the default editor is most likely this one, so ignore it, just as GetEditorType() does). System.Type editorType = ((CellEditorData)member.Tag).GetEditorType(EditorManager); if (editorType == null || editorType == EditorManager.DefaultEditor) { return(false); } if (member.IsString) { return(!CanDisplayWholeStringInCell(member, bounds, graphics)); } else { return(true); // We have an editor. } }
public override void InitFromOriginalObejct(System.Object src) { if (src is SyncEntitySnapshot) { var syncGO = src as SyncEntitySnapshot; this.timeStamp = syncGO.timeStamp; this.sceneUID = syncGO.sceneUID; this.mirrorObjectID = syncGO.mirrorObjectID; foreach (var state in syncGO.syncStates) { var wrapper = new MemberWrapper("SyncStateSnapshot", JsonUtility.ToJson(state, false)); encodedMembers.Add(JsonUtility.ToJson(wrapper, false)); } } else { throw new System.Exception("type convert fail"); } }
private async void OnLoginExecute() { try { var temp = await _memberRepository.GetByOfficeIdAsync(LoginOfficeId); LoggedMember = new MemberWrapper(temp); if (LoggedMember.IpNumber == GetIpNumber()) { Settings.Default.currentUserOfficeId = LoginOfficeId; Settings.Default.Save(); } } catch { _messageDialogService.ShowInfoDialog("로그인 실패"); return; } }
/// <summary> /// This function will copy all the values from source into object. /// </summary> /// <param name="source">The source object.</param> /// <param name="destination">The destination object.</param> /// <param name="info">The member wrapper that allows the values to be set.</param> internal override void copyValue(object source, object destination, MemberWrapper info, CopyFilter filter) { Object deepCopySource; Object deepCopyDestination; //Find the source and destination objects if no info is provided use the given objects if (info != null) { deepCopySource = info.getValue(source, null); deepCopyDestination = info.getValue(destination, null); } else { deepCopySource = source; deepCopyDestination = destination; } //Validate that there is a source. if (deepCopySource != null) { performCopy(destination, info, deepCopySource, deepCopyDestination, filter); } }
/// <summary> /// Helper function, actually does the copy. /// </summary> /// <param name="destination"></param> /// <param name="info"></param> /// <param name="deepCopySource"></param> /// <param name="deepCopyDestination"></param> internal void performCopy(object destination, MemberWrapper info, Object deepCopySource, Object deepCopyDestination, CopyFilter filter) { Type type = deepCopySource.GetType(); //Make sure the destination exists, if it does not create it if (deepCopyDestination == null) { deepCopyDestination = System.Activator.CreateInstance(type); info.setValue(destination, deepCopyDestination, null); } //Scan and copy all properties. IEnumerable <MemberWrapper> members = CopyMemberScanner.Scanner.getMatchingMembers(type); foreach (MemberWrapper member in members) { if (filter == null || filter.allowCopy(member)) { MemberCopier copier = MemberCopier.getCopyClass(member.getWrappedType()); copier.copyValue(deepCopySource, deepCopyDestination, member, filter); } } }
/// <summary> /// /// </summary> /// <typeparam name="T"></typeparam> /// <param name="includeNonPublicAccessor"></param> /// <returns>A List Of Advance Members Of T</returns> /// <exception cref="InvalidOperationException"> This method doesn't support dynamic types. Please use</exception> public static List <MemberWrapper> GetMemberWrappers <T>(bool includeNonPublicAccessor) where T : class { if (typeof(T).IsTypeDynamic()) { throw new InvalidOperationException("Method : GetAdvanceMembers doesn't support dynamic objects please use GetDynamicAdvanceMembers instead."); } var type = typeof(T); // ReSharper disable once AssignNullToNotNullAttribute var key = $"{type.FullName}{includeNonPublicAccessor}"; lock (Lock) { //if (Lookup.TryGetValue(key, out var cachedMembers)) var membersAlreadyExist = Lookup.TryGetValue(key, out var cachedMembers); if (membersAlreadyExist) { return(cachedMembers); } var list = new List <MemberWrapper>() { }; var accessor = TypeAccessor.Create(type, includeNonPublicAccessor); var set = accessor.GetMembers(); for (var index = 0; index < set.Count; index++) { var member = set[index]; var advance = new MemberWrapper(member) { }; list.Add(advance); } Lookup.Add(key, list); return(list); } }
public IHttpActionResult Get(int memberId) { using (bkContext context = new bkContext()) { Matrimonial mat = context.Matrimonials.FirstOrDefault(x => x.MemberID == memberId); Member member = context.Members.FirstOrDefault(x => x.MemberID == memberId); if (mat == null) { return(BadRequest("Matrimony profile cannot be loaded")); } MatrimonyViewModel model = new MatrimonyViewModel(); model.Alcohol = mat.Alcohol; model.BirthTime = mat.BirthTime; model.BodyTypeId = mat.BodyTypeID; model.ComplexionTypeId = mat.ComplexionTypeID; model.Disability = mat.Disability; model.Height = mat.Height; model.Language = mat.Language; model.Mangal = mat.Mangal; model.MaritalStatusId = mat.MaritalStatusID; model.MaternalNukhId = mat.MaternalNukhID; model.MemberId = mat.MemberID; model.MonthlyIncome = mat.MonthlyIncome; model.OwnHome = mat.OwnHome; model.ProfileText = mat.ProfileText; model.Smoke = mat.Smoke; model.Tobacco = mat.Tobacco; model.Vegetarian = mat.Vegetarian; model.Weight = mat.Weight; model.Photo1Url = MemberWrapper.MatrimonyPhoto(mat.MemberID, mat.Member.Gender, 1, mat.ModifiedOn); model.Photo2Url = MemberWrapper.MatrimonyPhoto(mat.MemberID, mat.Member.Gender, 2, mat.ModifiedOn); model.Photo3Url = MemberWrapper.MatrimonyPhoto(mat.MemberID, mat.Member.Gender, 3, mat.ModifiedOn); return(Ok(model)); } }
private bool CanDisplayWholeStringInCell(MemberWrapper member, Rectangle bounds, Graphics graphics) { string valueAsString = member.ValueAsString as string; if (string.IsNullOrEmpty(valueAsString)) { return(true); } if (valueAsString.IndexOfAny(System.Environment.NewLine.ToCharArray()) != -1) { return(false); // Contains newlines, so can't be displayed even if it's small. } if (graphics == null) { graphics = DataGridTableStyle.DataGrid.CreateGraphics(); } SizeF requiredSize = graphics.MeasureString(valueAsString, DataGridTableStyle.DataGrid.Font); return(requiredSize.Width < bounds.Width); }
/// <summary> /// Converts to database value. If value is null convert it to DBNull.Value or if property is decorated with a serializable attribute /// then convert the value to its serialize self /// </summary> /// <param name="member">The member.</param> /// <param name="value">The value.</param> /// <param name="csvSerializer"></param> /// <param name="xmlSerializer"></param> /// <returns>System.Object.</returns> public object ConvertToDatabaseValue(MemberWrapper member, object value, Func <object, string> xmlSerializer, Func <object, string> jsonSerializer, Func <object, string> csvSerializer) { if (value == null) { return(DBNull.Value); } //if (member.Type == typeof(DateTime) && (DateTime)value == DateTime.MinValue || member.Type == typeof(DateTime?) && (DateTime)value == DateTime.MinValue) //{ // if(DatabaseType == DataBaseType.SqlServer) // return new DateTime(1753, 01, 01); //} if (member.GetCustomAttribute <SqlColumnAttribute>()?.SerializableType != SerializableType.None) { switch (member.GetCustomAttribute <SqlColumnAttribute>()?.SerializableType) { case SerializableType.Xml: xmlSerializer.IsNullThrow(nameof(xmlSerializer), new ArgumentNullException(nameof(xmlSerializer), $"{ExceptionHelper.NullSerializer(member, SerializableType.Xml)}")); return(xmlSerializer.Invoke(value)); case SerializableType.Json: jsonSerializer.IsNullThrow(nameof(jsonSerializer), new ArgumentNullException(nameof(jsonSerializer), $"{ExceptionHelper.NullSerializer(member, SerializableType.Json)}")); return(jsonSerializer.Invoke(value)); case SerializableType.Csv: csvSerializer.IsNullThrow(nameof(csvSerializer), new ArgumentNullException(nameof(csvSerializer), $"{ExceptionHelper.NullSerializer(member, SerializableType.Csv)}")); return(csvSerializer.Invoke(value)); case SerializableType.None: case null: break; default: throw new ArgumentOutOfRangeException(); } } return(value); }
public IHttpActionResult DeletePhoto(int photoNumber, int memberId) { if (!CanEditMember(memberId)) { return(BadRequest("You do not have permission to edit this member")); } if (photoNumber < 1 || photoNumber > 3) { return(BadRequest("Invalid photo number")); } string filePath = System.Web.Hosting.HostingEnvironment.MapPath(string.Format(@"~/Images/Matrimonials/{0}_{1}.jpg", memberId, photoNumber)); if (File.Exists(filePath)) { File.Delete(filePath); } string response = string.Empty; using (bkContext context = new bkContext()) { Matrimonial mat = context.Matrimonials.FirstOrDefault(x => x.MemberID == memberId); if (mat != null) { mat.ModifiedBy = LoggedInMemberId; mat.ModifiedOn = DateTime.Now; context.SaveChanges(); } response = MemberWrapper.MatrimonyPhoto(memberId, mat.Member.Gender, photoNumber, mat.ModifiedOn); } return(Ok(response)); }
public async Task LoadAsync() { AllMembers.Clear(); var members = await _memberRepository.GetAllAsync(); foreach (var member in members) { var modelWrapper = new MemberWrapper(member); AllMembers.Add(modelWrapper); } MoviesWatched.Clear(); var movies = await _movieLookupService.GetMovieLookupAsync(); foreach (var movie in movies) { MoviesWatched.Add(new MovieWatchedViewModel { Id = movie.Id, Name = movie.DisplayMember, MovieWatchedDate = DateTime.Now }); } SelectedMovieWatched = MoviesWatched.FirstOrDefault(); }
private string GetPropertySetterStatement( MemberWrapper mw, string masterWrapperVariableName) { var prop = (IProperty)mw.Member; if (!prop.CanSet || prop.Setter.IsPrivate) { return(string.Empty); } if (mw.ImplementationDetails.ImplementInTargetAsAbstract) { return("set;"); } if (mw.ImplementationDetails.ImplementExplicitly) { return(string.Format( "set{{ (({0}){1}){2} = value; }}", mw.ImplementationDetails.ExplicitInterfaceImplementationType .GetOriginalFullNameWithGlobal(), masterWrapperVariableName, prop.IsIndexer ? "[" + prop.Parameters.First().Name + "]" : "." + prop.Name)); } return(string.Format( "set{{ {0}{1} = value; }}", masterWrapperVariableName, prop.IsIndexer ? "[" + prop.Parameters.First().Name + "]" : "." + prop.Name)); }
protected override void Edit(CurrencyManager source, int rowNum, Rectangle bounds, bool readOnly, string instantText, bool cellIsVisible) { m_currentValue = GetProperty(source, rowNum); // Calculate the total witdth of the expand box (with indentation) and align the text. int totalWidth; Rectangle expandBoxBounds = GetBoxBoundsForCellBounds(bounds, m_currentValue, out totalWidth); if (CanExpandProperty(m_currentValue)) { // The actual expand box is visible - store it's bounds, so we can detect when the user clicks it. m_expandBoxBounds = expandBoxBounds; } else { m_expandBoxBounds = Rectangle.Empty; } base.Edit(source, rowNum, new Rectangle(bounds.X + totalWidth, bounds.Y, bounds.Width - totalWidth, bounds.Height), readOnly, instantText, cellIsVisible); }
protected CouchDocumentWrapper() { rev = GetFunc("_rev") ?? GetFunc("rev"); id = GetFunc("_id") ?? GetFunc("id"); }
private static void SetModifiers(MemberName self, MemberWrapper mw) { self._flags(self._flags() | (int)mw.Modifiers); }
public ViewBrowserEditableProperty(String name, MemberWrapper propertyInfo, Object instance) : base(name, propertyInfo, instance) { }
public override EditableProperty createEditableProperty(MemberWrapper memberWrapper, object target) { return(new ActionBrowserEditableProperty(memberWrapper.getWrappedName(), memberWrapper, target)); }
/// <summary> /// Constructor. /// </summary> /// <param name="propInfo">The MemberWrapper to use.</param> /// <param name="instance">The object this variable belongs to.</param> public IntNullableReflectedVariable(MemberWrapper propInfo, Object instance) : base(propInfo, instance) { }
private static bool IsLambdaMetafactory(MemberWrapper mw) { return(mw.Name == "metafactory" && mw.Signature == "(Ljava.lang.invoke.MethodHandles$Lookup;Ljava.lang.String;Ljava.lang.invoke.MethodType;Ljava.lang.invoke.MethodType;Ljava.lang.invoke.MethodHandle;Ljava.lang.invoke.MethodType;)Ljava.lang.invoke.CallSite;" && mw.DeclaringType.Name == "java.lang.invoke.LambdaMetafactory"); }
public LayerStateEditableProperty(Object owner, MemberWrapper memberWrapper) { this.owner = owner; this.memberWrapper = memberWrapper; }
/// <summary> /// This is the test function. It will return true if the member should /// be accepted. /// </summary> /// <param name="wrapper">The MemberWrapper with info about the field/property being scanned.</param> /// <returns>True if the member should be included in the results. False to omit it.</returns> public bool allowMember(MemberWrapper wrapper) { return(wrapper.getCustomAttributes(typeof(JsonPropertyAttribute), true).Any()); }
/// <summary> /// This will copy source into destination. /// </summary> /// <param name="source">The source object.</param> /// <param name="destination">The destination object.</param> /// <param name="info">The info to use to set the value.</param> /// <param name="filter">The filter to use when copying. Can be null.</param> internal abstract void copyValue(Object source, Object destination, MemberWrapper info, CopyFilter filter);
/// <summary> /// Constructor. /// </summary> /// <param name="propInfo">The MemberWrapper to use.</param> /// <param name="instance">The object this variable belongs to.</param> public ULongReflectedVariable(MemberWrapper propInfo, Object instance) : base(propInfo, instance) { }
/// <summary> /// Constructor. /// </summary> /// <param name="name">The name of the variable.</param> /// <param name="propInfo">The MemberWrapper to use.</param> /// <param name="instance">The object this variable belongs to.</param> /// <param name="visibility">The visibility of the variable.</param> public ReflectedVariable(MemberWrapper propInfo, Object instance) { this.propertyInfo = propInfo; this.instance = instance; }